smjonas / inc-rename.nvim

Incremental LSP renaming based on Neovim's command-preview feature.
MIT License
637 stars 8 forks source link

Better examples: Use multiple files or non-single word symbols #15

Closed matu3ba closed 2 years ago

matu3ba commented 2 years ago

Single word instances can be, although breaking for :: delimiters, replaced (faster) with

map('n', ',', [["_diwP]], opts) -- keep pasting over the same thing, old map: C-p
map('n', '*', [[m`:keepjumps normal! *``<CR>]], opts) -- word boundary search, no autojump
map('n', 'g*', [[m`:keepjumps normal! g*``<CR>]], opts) -- no word boundary search no autojump

Additional usage of map('n', '<leader>sh', ':ClangdSwitchSourceHeader<CR>', opts) -- switch header_source or harpoon/buffer navigation allows also to workaround many cases (though with lower editing speed):

map('n', '<leader>ff', [[<cmd>lua require('telescope.builtin').find_files()<CR>]], opts) -- find files
-- C-q
-- 1.
-- :cfdo :badd %
-- and :b buffername or :bBufNr with :ls ie as combined command
-- 2.
-- :cfdo lua require("harpoon.mark").add_file()
map('n', '<leader>cj', [[<cmd>lua require("harpoon.term").gotoTerminal(1)<CR>]], opts)
map('n', '<leader>j', [[<cmd>lua require("harpoon.ui").nav_file(1)<CR>]], opts)

It would be nice to mention those things with their advantages + shortcomings, as they are going into the same direction of fast + simple editings. For example inc-rename is less appropriate for editings, which involve intentionally breaking things on changes.

Additional plus would be to mention the treesitter plugin one can use (with advantages + shortcomings).

smjonas commented 2 years ago

Thanks for your suggestions!

It would be nice to mention those things with their advantages + shortcomings, as they are going into the same direction of fast + simple editings. For example inc-rename is less appropriate for editings, which involve intentionally breaking things on changes.

To be honest, I think this is out of scope of this plugin. I am just providing a wrapper around vim.lsp.buf.rename, not much more than that really. So this seems to be more of a question about a general Vim workflow (not sure where the best place to answer such questions would be actually).