smjonas / inc-rename.nvim

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

Incompatible with `custom-elements-languageserver` ("Nothing to rename") #44

Closed Dioswilson closed 11 months ago

Dioswilson commented 11 months ago

Hello, I am having issues making it work on lua files, I've tested it on C,C++ and java and it worked well, but when trying to use it on lua files it doesn't work. I have this sudggeste mapping:

vim.keymap.set("n", "<leader>rn", function()
    return ":IncRename " .. vim.fn.expand("<cword>")
end, { expr = true, desc = "[R]e[n]ame" })

When trying to use it on lua files the dressing window appears for an instant and I get the following error: [inc_rename] Nothing to rename Also if I try to use the command manually the command tries to trigger as soon asi I write :Inc with the E471: Argument required error

I tried with Lspsaga's rename and it works fine. Lsp I use on Lua is stylua

smjonas commented 11 months ago

Hi, thanks for reporting. Can you send me the contents of the Lua file and let me know which symbol your cursor was on as you tried to rename? Thanks.

Dioswilson commented 11 months ago

Sure, it happens on(almost) every lua file so can't rename this on a separate file(cursor is on top of "test"):

local test={"thing"}

test[1]="ABC"

I couldn't determine when It happens though, if I create a test.lua inside home dir it works fine, but on every project I create a lua file I have this issue

Dioswilson commented 11 months ago

Ok, it seems to be working wrong with most of the filetypes when running under a project. When runnning in single file mode it works well . With java(jdtls) it doesn't thow any errors but it doesn't work, with C/C++(clangd) I get the same error and with python(pylsp) it works well

smjonas commented 11 months ago

Could you send me the link to a project where it does not work? Since I can't reproduce it right now (seems to work for both single file mode and within a project).

Dioswilson commented 11 months ago

Here is my nvim- config, doesn't work there

Dioswilson commented 11 months ago

Also just created a new project with only "test.lua" and .git directory, it first worked, then opened my config tried to rename something there, it didn't work, and the went to rename somthing in test.lua and it didn't work anymore

smjonas commented 11 months ago

That's strange, it works for me in your config: image What happens if you run := vim.lsp.buf.rename() instead of :IncRename?

Dioswilson commented 11 months ago

Cannot test right now, but is project root the root directory of the project when you run :LspInfo ? For me issues ocurred when that happened

smjonas commented 11 months ago

Yes, LspInfo shows this:

 Client: lua_ls (id: 2, bufnr: [4])
    filetypes:       lua
    autostart:       true
    root directory:  /home/<me>/Desktop/nvim-config/lua/
    cmd:             /home/<me>/.local/share/nvim/mason/bin/lua-language-server
Dioswilson commented 11 months ago

I will test when I get home with vim.lsp.buf.rename() and try to figure out if ant plugin is getting in the way. Also i did try with lspsaga's rename and it worked well

Dioswilson commented 11 months ago

Update: executing := vim.lsp.buf.rename() works. I will try to figure out if another plugin is getting in the way

Dioswilson commented 11 months ago

I found the issue. It happens whedn the custom-elements-languageserver LSP is intalled. I uninstalled it and it works fine

smjonas commented 11 months ago

Thanks a lot for investigating, I'm glad you figured it out!