From c50018b791a6295fb0f3219fe637209a381db4c4 Mon Sep 17 00:00:00 2001 From: Brian Di Palma <1597820+briandipalma@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:51:36 +0100 Subject: [PATCH] feat(editor): added extra for inc-rename.nvim (#3432) * feat(editor-extra): Add inc-rename * fix: refactor and moved noice integration --------- Co-authored-by: Folke Lemaitre --- .../plugins/extras/editor/inc-rename.lua | 38 +++++++++++++++++++ lua/lazyvim/plugins/lsp/keymaps.lua | 16 +------- lua/lazyvim/plugins/ui.lua | 1 - 3 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 lua/lazyvim/plugins/extras/editor/inc-rename.lua diff --git a/lua/lazyvim/plugins/extras/editor/inc-rename.lua b/lua/lazyvim/plugins/extras/editor/inc-rename.lua new file mode 100644 index 00000000..a7c65243 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/inc-rename.lua @@ -0,0 +1,38 @@ +return { + + -- Rename with cmdpreview + recommended = true, + desc = "Incremental LSP renaming based on Neovim's command-preview feature", + { + "smjonas/inc-rename.nvim", + cmd = "IncRename", + opts = {}, + }, + + -- LSP Keymaps + { + "neovim/nvim-lspconfig", + opts = function() + local keys = require("lazyvim.plugins.lsp.keymaps").get() + keys[#keys + 1] = { + "cr", + function() + local inc_rename = require("inc_rename") + return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") + end, + expr = true, + desc = "Rename (inc-rename.nvim)", + has = "rename", + } + end, + }, + + --- Noice integration + { + "folke/noice.nvim", + optional = true, + opts = { + presets = { inc_rename = true }, + }, + }, +} diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index d56cee08..3f2bd690 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -26,6 +26,7 @@ function M.get() { "cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" }, { "cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" }, { "cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } }, + { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }, { "cA", function() @@ -50,20 +51,7 @@ function M.get() { "", function() LazyVim.lsp.words.jump(-vim.v.count1, true) end, has = "documentHighlight", desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled end }, } - if LazyVim.has("inc-rename.nvim") then - M._keys[#M._keys + 1] = { - "cr", - function() - local inc_rename = require("inc_rename") - return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") - end, - expr = true, - desc = "Rename", - has = "rename", - } - else - M._keys[#M._keys + 1] = { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" } - end + return M._keys end diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index e46faf51..18aa5200 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -299,7 +299,6 @@ return { bottom_search = true, command_palette = true, long_message_to_split = true, - inc_rename = true, }, }, -- stylua: ignore