smjonas / inc-rename.nvim

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

Partially Doesn't Work #51

Closed eeriemyxi closed 5 months ago

eeriemyxi commented 6 months ago

https://github.com/smjonas/inc-rename.nvim/assets/86738916/e558107b-5b35-4670-bfa3-93ef7ca8b3bf

It worked when I tried to rename parser but it didn't work when I tried to rename argparse. However, it does rename argparse in the live preview.

 Detected filetype:   python

 2 client(s) attached to this buffer: 

 Client: pyright (id: 1, bufnr: [1])
    filetypes:       python
    autostart:       true
    root directory:  /home/myxi/Documents/coding/python/glowl
    cmd:             /usr/bin/pyright-langserver --stdio

 Client: ruff_lsp (id: 2, bufnr: [1])
    filetypes:       python
    autostart:       true
    root directory:  /home/myxi/Documents/coding/python/glowl
    cmd:             /home/myxi/.local/bin/ruff-lsp

Neovim version: 0.9.5 Python version: 3.12.2

smjonas commented 5 months ago

Thanks for reporting! This is not really an issue of this plugin but it's caused due to the way the pyright LSP server responds to the textDocument/references and textDocument/rename requests. Pyright will report a reference at the import when the symbol under the cursor is the module name at the top, but it won't allow renaming (references which are used for highlights and expected result are different). In contrast, pylsp allows you to rename module names directly (references and expected result match).

So I would advise you to either report this to pyright or switch to pylsp. Alternatively, you can use both LSP servers at the same time (which also tends to give you better linting in my experience). In that case, pylsp allows you rename the import as expected.