smjonas / inc-rename.nvim

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

Bug: Changing the current word under the cursor broken #45

Open DMunkei opened 9 months ago

DMunkei commented 9 months ago

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
smjonas commented 9 months ago

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 commented 9 months ago

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

DMunkei commented 9 months ago

I was using Pyright and jedi-language-server.

sirwebdev commented 6 months ago

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

DMunkei commented 6 months ago

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.

smjonas commented 6 months ago

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.

Moerliy commented 4 months ago

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.