inc-rename.nvim icon indicating copy to clipboard operation
inc-rename.nvim copied to clipboard

Bug: Changing the current word under the cursor broken

Open DMunkei opened this issue 1 year ago • 10 comments

Hey, when I use the snippet provided in the config to rename a variable it works, as long as I don't completely remove the previous variable. Hopefully the video explains it better.

Also an aside question, does this use the AST for renaming?

https://github.com/smjonas/inc-rename.nvim/assets/17084284/3d2250b3-f97e-448e-ab75-a9dc403ed8be

This is how my config looks like right now. I'm using Lazy as my plugin manager

return {
  "smjonas/inc-rename.nvim",
  config = function()
    require("inc_rename").setup()
    vim.keymap.set("n", "<leader>rn", function()
      return ":IncRename " .. vim.fn.expand("<cword>")
    end, { expr = true })
  end,
}

This is the neovim version I'm running

➜ nvim --version
NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

DMunkei avatar Nov 30 '23 18:11 DMunkei

Thanks for reporting, I'll definitely look into this!

Also an aside question, does this use the AST for renaming?

It uses Nvim's builtin LSP functions (vim.lsp.buf.rename and another to get the locations of the variables), so it depends on the concrete LSP server for the current buffer. Although probably every LSP server constructs an AST of some kind.

smjonas avatar Dec 01 '23 23:12 smjonas

Which language server are you using? (output of :LspInfo?)

smjonas avatar Dec 03 '23 12:12 smjonas

I was using Pyright and jedi-language-server.

DMunkei avatar Dec 04 '23 10:12 DMunkei

Hy guys, any date to fix that issue ?? I had the same problem here using the "js/ts language server" at lazyvim

sirwebdev avatar Feb 29 '24 17:02 sirwebdev

I've also had this issue constantly happening inside of TS while writing vuejs code. It somehow just deletes more than it should. Not sure why.

DMunkei avatar Mar 01 '24 12:03 DMunkei

Hy guys, any date to fix that issue ?? I had the same problem here using the "js/ts language server" at lazyvim

@pmartinsdev Thanks for also reporting this issue. Can you please provide me with example code where this is happening? It's hard for me to find out what the problem is without that.

smjonas avatar Mar 02 '24 20:03 smjonas

I mentioned this in #53 too.

Something I noticed and could have the same root problem: 1. Same project, same file 2. line 92 and try renaming ParseContext. 3. Add a couple of characters and have a look at the preview. With every new character added to the rename, the previously added characters should appear again with every new character you add. Hard to describe but the number of characters shown in the preview is the factorial of the number of characters added to the rename. (not sure if you can reproduce it tho because that behavior is a bit less predictable)

You should be able to reproduce this with the second example.

Moerliy avatar May 11 '24 07:05 Moerliy