summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <contact@kyren.codes>2026-06-22 18:59:04 +0300
committerKyren223 <contact@kyren.codes>2026-06-22 18:59:04 +0300
commit9a46455ac09bc007abb45b0fe7ab9b55d24f3cfb (patch)
treec3ce88940d4537076380c6eeab6951a6778418c4
parent798f2e0c8ea4708da4e55bdb2faf8f44d1e91f6e (diff)
Add live-rename plugin which is basically IntelliJ-like rename, don't
need the LSPSaga rename now
-rw-r--r--.config/nvim/lazy-lock.json6
-rw-r--r--.config/nvim/lua/keymaps.lua40
-rw-r--r--.config/nvim/lua/plugins/live-rename.lua65
3 files changed, 106 insertions, 5 deletions
diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json
index 93686bf..5a4cd2b 100644
--- a/.config/nvim/lazy-lock.json
+++ b/.config/nvim/lazy-lock.json
@@ -1,5 +1,5 @@
{
- "Comment.nvim": { "branch": "fix-inline-visual-linewise-comment", "commit": "01019c2889fa6c63a80a223c55c1d28999b5c959" },
+ "Comment.nvim": { "branch": "master", "commit": "01019c2889fa6c63a80a223c55c1d28999b5c959" },
"auto-save.nvim": { "branch": "main", "commit": "37c82fd548e3f5ffc2d9d020a65dac1044584f44" },
"auto-session": { "branch": "main", "commit": "3e145ee9af42eb6764908a1a481f53fe7f0bdbe5" },
"blink-cmp-git": { "branch": "master", "commit": "a820245eb0e5cb44ed0c27c63a41d90635b39e0e" },
@@ -19,6 +19,7 @@
"iswap.nvim": { "branch": "master", "commit": "e02cc91f2a8feb5c5a595767d208c54b6e3258ec" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" },
+ "live-rename.nvim": { "branch": "main", "commit": "2a30bfdc9369c8ffb188e6da715fbdf1aef6f647" },
"lsp-progress.nvim": { "branch": "main", "commit": "f3df1df8f5ea33d082db047b5d2d2b83cc01cd8a" },
"lspsaga.nvim": { "branch": "main", "commit": "95201b41b19baa54eaa9a70caee31ae37791d284" },
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
@@ -29,8 +30,6 @@
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
- "nvim-dap": { "branch": "master", "commit": "9e848e09a697ee95302a3ef2dd43fd6eb709e570" },
- "nvim-java": { "branch": "main", "commit": "f36a376dfebbbb4cf382008ea6e8b70d40049112" },
"nvim-jdtls": { "branch": "master", "commit": "4d77ff02063cf88963d5cf10683ab1fd15d072de" },
"nvim-lint": { "branch": "master", "commit": "7ef127aaede2a4d5ad8df8321e2eb4e567f29594" },
"nvim-notify": { "branch": "master", "commit": "397c7c1184745fca649e5104de659e6392ef5a4d" },
@@ -45,7 +44,6 @@
"render-markdown.nvim": { "branch": "main", "commit": "eec00fbfd7273cdfa0a1154dbef0bb983641eaf8" },
"rustaceanvim": { "branch": "master", "commit": "e9c5aaba16fead831379d5f44617547a90b913c7" },
"snacks.nvim": { "branch": "main", "commit": "b240ddf39c842effeefb7fecab7dbf9ba05e133d" },
- "spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" },
"tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "7dcf8542059fb15c978de845fc8665428ae13a04" },
"todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" },
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua
index a900a50..aae2928 100644
--- a/.config/nvim/lua/keymaps.lua
+++ b/.config/nvim/lua/keymaps.lua
@@ -112,7 +112,45 @@ local keymaps = {
end,
{ desc = 'Show [P]arameters' },
},
- { 'n', 'R', '<cmd>Lspsaga rename<cr>', { desc = '[R]ename' } },
+ -- { 'n', 'R', '<cmd>Lspsaga rename<cr>', { desc = '[R]ename' } },
+ {
+ 'n',
+ 'r',
+ function()
+ -- require('live-rename').rename()
+ -- require('live-rename').rename({ cursorpos = -1 })
+ -- require('live-rename').rename({ insert = true, cursorpos = -1 })
+
+ require('live-rename').rename({ cursorpos = -1 })
+ vim.schedule(function()
+ vim.api.nvim_feedkeys('A', 'n', false)
+ end)
+ end,
+ { desc = '[R]ename' },
+ },
+ {
+ 'n',
+ 'rr',
+ function()
+ -- require('live-rename').rename()
+ -- require('live-rename').rename({ cursorpos = -1 })
+ -- require('live-rename').rename({ insert = true, cursorpos = -1 })
+
+ require('live-rename').rename({ cursorpos = -1 })
+ vim.schedule(function()
+ vim.api.nvim_feedkeys('A', 'n', false)
+ end)
+ end,
+ { desc = '[R]ename' },
+ },
+ {
+ 'n',
+ 'R',
+ function()
+ require('live-rename').rename({ insert = true, text = '' })
+ end,
+ { desc = '[R]ename' },
+ },
{ { 'n', 'i' }, '<M-Enter>', '<cmd>Lspsaga code_action<cr>', { desc = 'Code Actions' } },
-- { 'n', '<leader>e', next_diagnostic(severity.ERROR), { desc = 'Goto [E]rror' } },
-- { 'n', '<leader>E', prev_diagnostic(severity.ERROR), { desc = 'Goto [E]rror (prev)' } },
diff --git a/.config/nvim/lua/plugins/live-rename.lua b/.config/nvim/lua/plugins/live-rename.lua
new file mode 100644
index 0000000..c81ad12
--- /dev/null
+++ b/.config/nvim/lua/plugins/live-rename.lua
@@ -0,0 +1,65 @@
+return {
+ 'saecki/live-rename.nvim',
+ commit = '2a30bfdc9369c8ffb188e6da715fbdf1aef6f647',
+ -- default config
+ keys = { 'r', 'rr', 'R' },
+ opts = {
+ -- Send a `textDocument/prepareRename` request to the server to
+ -- determine the word to be renamed, can be slow on some servers.
+ -- Otherwise fallback to using `<cword>`.
+ prepare_rename = true,
+ --- The timeout for the `textDocument/prepareRename` request and final
+ --- `textDocument/rename` request when submitting.
+ request_timeout = 1500,
+ -- Make an initial `textDocument/rename` request to gather other
+ -- occurences which are edited and use these ranges to preview.
+ -- If disabled only the word under the cursor will have a preview.
+ show_other_ocurrences = true,
+ -- Try to infer patterns from the initial `textDocument/rename` request
+ -- and use these to show hopefully better edit previews.
+ use_patterns = true,
+ -- The register which is used to temporarily record a macro into. This
+ -- macro can then be executed on other symbols using the `macrorepeat`
+ -- rename option.
+ scratch_register = 'l',
+ keys = {
+ submit = {
+ { 'n', '<cr>' },
+ { 'v', '<cr>' },
+ { 'i', '<cr>' },
+ { 'n', '<esc>' },
+ },
+ cancel = {
+ { 'n', '<c-c>' },
+ { 'i', '<c-c>' },
+ { 'n', 'q' },
+ },
+ },
+ hl = {
+ current = 'LiveRenameCurrent',
+ others = 'LiveRenameOthers',
+ },
+ },
+
+ -- -- Start in normal mode and maintain cursor position.
+ -- require("live-rename").rename()
+ --
+ -- -- Start in normal mode and jump to the start of the word.
+ -- require("live-rename").rename({ cursorpos = 0 })
+ --
+ -- -- Start in insert mode and jump to the end of the word
+ -- require("live-rename").rename({ insert = true, cursorpos = -1 })
+ --
+ -- -- Start in insert mode with an empty word
+ -- require("live-rename").rename({ text = "", insert = true })
+ --
+ -- -- The actions that happened in the previous rename window are recorded as a macro.
+ -- -- The rename can be repeated by using `.`, or by manually calling the rename
+ -- -- funciton with the `macrorepeat` parameter.
+ --
+ -- -- The last lsp rename is repeated and commited without any further confirmation.
+ -- require("live-rename").rename({ macrorepeat = true, noconfirm = true })
+ --
+ -- -- Without `noconfirm` additional actions can be appended to the macro.
+ -- require("live-rename").rename({ macrorepeat = true })
+}