From 1c6e4486cf5c13f67fb737e34b34f9ed2a6714a0 Mon Sep 17 00:00:00 2001 From: Peter Sheehan <145384599+peter-bread@users.noreply.github.com> Date: Fri, 16 Jan 2026 02:22:13 +0000 Subject: [PATCH 1/7] feat: replace `peter.util.list.uniq` with `vim.list.unique` --- lua/peter/plugins/core/treesitter.lua | 3 +-- lua/peter/plugins/lsp/mason.lua | 3 +-- lua/peter/util/list.lua | 27 ++++++++++++--------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/lua/peter/plugins/core/treesitter.lua b/lua/peter/plugins/core/treesitter.lua index 52cda3f0..221803c9 100644 --- a/lua/peter/plugins/core/treesitter.lua +++ b/lua/peter/plugins/core/treesitter.lua @@ -39,12 +39,11 @@ return { ---@param opts peter.treesitter.Config config = function(_, opts) local nts = require("nvim-treesitter") - local list = require("peter.util.list") local autocmds = require("peter.util.autocmds") nts.setup(opts --[[@as TSConfig]]) - local ensure_installed = list.uniq(opts.ensure_installed or {}) + local ensure_installed = vim.list.unique(opts.ensure_installed or {}) local already_installed = nts.get_installed() diff --git a/lua/peter/plugins/lsp/mason.lua b/lua/peter/plugins/lsp/mason.lua index 7cf9282f..445b2aaa 100644 --- a/lua/peter/plugins/lsp/mason.lua +++ b/lua/peter/plugins/lsp/mason.lua @@ -41,8 +41,7 @@ return { ---@param opts peter.mason.Opts config = function(_, opts) - local list = require("peter.util.list") - opts.ensure_installed = list.uniq(opts.ensure_installed or {}) + opts.ensure_installed = vim.list.unique(opts.ensure_installed or {}) require("mason").setup(opts --[[@as MasonSettings]]) diff --git a/lua/peter/util/list.lua b/lua/peter/util/list.lua index 698768f6..76f3607d 100644 --- a/lua/peter/util/list.lua +++ b/lua/peter/util/list.lua @@ -7,21 +7,18 @@ local M = {} -- --[[ ---------------------------------------------------------------------- ]] ----Remove duplicate elements from a list. ----@param list any[] List to remove duplicates from. ----@return any[] new_list List with duplicates removed. -function M.uniq(list) - local hash = {} - local ret = {} - - for _, v in ipairs(list) do - if not hash[v] then - ret[#ret + 1] = v - hash[v] = true - end - end - - return ret +---Removes duplicate values from a list-like table without modifying the original +---table. +--- +---The input table is not modified. A new table is created by this function. +--- +---For in-place deduplication, see `:h vim.list.unique`. +--- +---@generic T +---@param t T[] +---@return T[] t A new, deduplicated list. +function M.uniq_copy(t) + return vim.list.unique(vim.deepcopy(t)) end return M From 16b5bb1350544541cc34bfb4bd2ced3c9a351bc9 Mon Sep 17 00:00:00 2001 From: Peter Sheehan <145384599+peter-bread@users.noreply.github.com> Date: Sat, 22 Aug 2026 00:40:30 +0100 Subject: [PATCH 2/7] refactor(lsp): use new codelens API --- lua/peter/config/lsp.lua | 2 +- lua/peter/util/lsp.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/peter/config/lsp.lua b/lua/peter/config/lsp.lua index f5dc8a39..f9e9782f 100644 --- a/lua/peter/config/lsp.lua +++ b/lua/peter/config/lsp.lua @@ -69,7 +69,7 @@ do -- No more progress; the LSP is idle. active_tokens_by_client[client_id] = nil - vim.lsp.codelens.refresh() + vim.lsp.codelens.enable(true) end end, }) diff --git a/lua/peter/util/lsp.lua b/lua/peter/util/lsp.lua index ef9fb053..0161be65 100644 --- a/lua/peter/util/lsp.lua +++ b/lua/peter/util/lsp.lua @@ -74,7 +74,9 @@ function M.try_enable_codelens(client, bufnr) group = autocmds.augroup("RefreshCodeLens"), desc = "Refresh CodeLens", buffer = bufnr, - callback = vim.lsp.codelens.refresh, + callback = function() + vim.lsp.codelens.enable(true) + end, }) end end @@ -296,7 +298,7 @@ function M.set_default_keymaps(client, bufnr) has = "textDocument/codeLens", }) - map("cC", vim.lsp.codelens.refresh, { + map("cC", function() vim.lsp.codelens.enable(true) end, { desc = "Refresh Codelens", has = "textDocument/codeLens", }) From e5d4ea54e807ef40e34d05762165c55fd532b9e5 Mon Sep 17 00:00:00 2001 From: Peter Sheehan <145384599+peter-bread@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:07:53 +0100 Subject: [PATCH 3/7] fix(lsp): disable default codelens mapping Refs: #142 --- lua/peter/util/lsp.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/peter/util/lsp.lua b/lua/peter/util/lsp.lua index 0161be65..019fcce0 100644 --- a/lua/peter/util/lsp.lua +++ b/lua/peter/util/lsp.lua @@ -91,6 +91,7 @@ function M.delete_global_defaults() del("n", "grn") -- Rename. del("n", "grr") -- References. del("n", "grt") -- Type definition. + del("n", "grx") -- Run codelens. del("n", "gO") -- Document symbols. del("i", "") -- Signature help. From 70ed03be7e0e99a7a745b10f1cc0f3b3240002ef Mon Sep 17 00:00:00 2001 From: Peter Sheehan <145384599+peter-bread@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:08:14 +0100 Subject: [PATCH 4/7] feat: require nvim 0.12+ Refs: #142 --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 73937204..1f1a70f0 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ -if vim.fn.has("nvim-0.11") ~= 1 then +if vim.fn.has("nvim-0.12") ~= 1 then vim.notify_once( - "peter.nvim requires Neovim 0.11 or above. " + "peter.nvim requires Neovim 0.12 or above. " .. "Current version: " .. require("peter.util.version").string() .. ". " From 17b9423dffe685c506af2d89b5b66dc05b133b4c Mon Sep 17 00:00:00 2001 From: Peter Sheehan <145384599+peter-bread@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:18:44 +0100 Subject: [PATCH 5/7] feat(ui): enable ui2 Refs: #142 --- init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.lua b/init.lua index 1f1a70f0..fcf0ee1c 100644 --- a/init.lua +++ b/init.lua @@ -13,3 +13,5 @@ if vim.fn.has("nvim-0.12") ~= 1 then end require("peter.config") + +require("vim._core.ui2").enable() From 78babe0ac2bdd3fb3e5c082da94052e02314f727 Mon Sep 17 00:00:00 2001 From: Peter Sheehan <145384599+peter-bread@users.noreply.github.com> Date: Sun, 23 Aug 2026 22:16:38 +0100 Subject: [PATCH 6/7] refactor(diagnostic): use severities instead of strings --- lua/peter/config/keymaps.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/peter/config/keymaps.lua b/lua/peter/config/keymaps.lua index f5eebeba..a620b2a6 100644 --- a/lua/peter/config/keymaps.lua +++ b/lua/peter/config/keymaps.lua @@ -68,13 +68,15 @@ set("n", "cd", vim.diagnostic.open_float, { desc = "Line diagnostics" }) do local diagnostic = require("peter.util.diagnostic") local next, prev = diagnostic.next, diagnostic.prev + local ERROR = vim.diagnostic.severity.ERROR + local WARN = vim.diagnostic.severity.ERROR -- stylua: ignore start set("n", "]d", next, { desc = "Next Diagnostic" }) set("n", "[d", prev, { desc = "Prev Diagnostic" }) - set("n", "]e", function() next({ severity = "ERROR" }) end, { desc = "Next Error" }) - set("n", "[e", function() prev({ severity = "ERROR" }) end, { desc = "Prev Error" }) - set("n", "]w", function() next({ severity = "WARN" }) end, { desc = "Next Warning" }) - set("n", "[w", function() prev({ severity = "WARN" }) end, { desc = "Prev Warning" }) + set("n", "]e", function() next({ severity = ERROR }) end, { desc = "Next Error" }) + set("n", "[e", function() prev({ severity = ERROR }) end, { desc = "Prev Error" }) + set("n", "]w", function() next({ severity = WARN }) end, { desc = "Next Warning" }) + set("n", "[w", function() prev({ severity = WARN }) end, { desc = "Prev Warning" }) -- stylua: ignore end end From d98fecd5081e29738733c94d9bc18c0ddf5c9dae Mon Sep 17 00:00:00 2001 From: Peter Sheehan <145384599+peter-bread@users.noreply.github.com> Date: Mon, 24 Aug 2026 22:40:42 +0100 Subject: [PATCH 7/7] feat(codelens): simplify codelens config --- lua/peter/config/lsp.lua | 97 ++++++++++++++++++++-------------------- lua/peter/util/lsp.lua | 12 +---- 2 files changed, 51 insertions(+), 58 deletions(-) diff --git a/lua/peter/config/lsp.lua b/lua/peter/config/lsp.lua index f9e9782f..f5f2bbb6 100644 --- a/lua/peter/config/lsp.lua +++ b/lua/peter/config/lsp.lua @@ -1,5 +1,4 @@ local lsp = require("peter.util.lsp") -local autocmds = require("peter.util.autocmds") -- Enable LSPs *after* 'mason.nvim' install directory has been added to `PATH`. -- @@ -27,50 +26,52 @@ lsp.on_attach(function(client, bufnr) lsp.try_enable_codelens(client, bufnr) end) -do - -- Store active progress tokens for all running clients. - local active_tokens_by_client = {} - - vim.api.nvim_create_autocmd("LspProgress", { - group = autocmds.augroup("LspProgressCodeLens"), - desc = "Refresh CodeLens whenever the LSP becomes idle", - callback = function(ev) - local client_id = ev.data.client_id - local client = vim.lsp.get_client_by_id(client_id) - - if not client or not client:supports_method("textDocument/codeLens") then - return - end - - local value = ev.data.params.value - local token = ev.data.params.token - - if not (value and token) then - return - end - - -- stylua: ignore - active_tokens_by_client[client_id] = active_tokens_by_client[client_id] or {} - - -- Active tokens for the current client. - local active_tokens = active_tokens_by_client[client_id] - - if value.kind == "begin" then - active_tokens[token] = true - elseif value.kind == "end" then - active_tokens[token] = nil - - -- Check if all tokens are done. - for _, active in pairs(active_tokens) do - if active then - return - end - end - - -- No more progress; the LSP is idle. - active_tokens_by_client[client_id] = nil - vim.lsp.codelens.enable(true) - end - end, - }) -end +-- do +-- local autocmds = require("peter.util.autocmds") +-- +-- -- Store active progress tokens for all running clients. +-- local active_tokens_by_client = {} +-- +-- vim.api.nvim_create_autocmd("LspProgress", { +-- group = autocmds.augroup("LspProgressCodeLens"), +-- desc = "Refresh CodeLens whenever the LSP becomes idle", +-- callback = function(ev) +-- local client_id = ev.data.client_id +-- local client = vim.lsp.get_client_by_id(client_id) +-- +-- if not client or not client:supports_method("textDocument/codeLens") then +-- return +-- end +-- +-- local value = ev.data.params.value +-- local token = ev.data.params.token +-- +-- if not (value and token) then +-- return +-- end +-- +-- -- stylua: ignore +-- active_tokens_by_client[client_id] = active_tokens_by_client[client_id] or {} +-- +-- -- Active tokens for the current client. +-- local active_tokens = active_tokens_by_client[client_id] +-- +-- if value.kind == "begin" then +-- active_tokens[token] = true +-- elseif value.kind == "end" then +-- active_tokens[token] = nil +-- +-- -- Check if all tokens are done. +-- for _, active in pairs(active_tokens) do +-- if active then +-- return +-- end +-- end +-- +-- -- No more progress; the LSP is idle. +-- active_tokens_by_client[client_id] = nil +-- vim.lsp.codelens.enable(true) +-- end +-- end, +-- }) +-- end diff --git a/lua/peter/util/lsp.lua b/lua/peter/util/lsp.lua index 019fcce0..6a8bdf32 100644 --- a/lua/peter/util/lsp.lua +++ b/lua/peter/util/lsp.lua @@ -64,20 +64,12 @@ function M.try_enable_inlay_hints(client, bufnr) end ---Enable LSP Codelens for the current buffer if the LSP supports it. ----See `:h vim.lsp.codelens.refresh`. +---See `:h vim.lsp.codelens.enable`. ---@param client vim.lsp.Client ---@param bufnr integer function M.try_enable_codelens(client, bufnr) - local autocmds = require("peter.util.autocmds") if client:supports_method("textDocument/codeLens") then - vim.api.nvim_create_autocmd({ "BufEnter", "InsertLeave", "BufWritePost" }, { - group = autocmds.augroup("RefreshCodeLens"), - desc = "Refresh CodeLens", - buffer = bufnr, - callback = function() - vim.lsp.codelens.enable(true) - end, - }) + vim.lsp.codelens.enable(true, { bufnr = bufnr }) end end