Coc.nvim: Feature request: rename a file => update all references

Created on 31 Aug 2019  路  14Comments  路  Source: neoclide/coc.nvim

I'd like to be able to rename a file and get all references updated, just like in VSCode. Is this possible?

Vim bug

Most helpful comment

Maybe it's needed to send notification to notify language servers. I'll try to fix it.

All 14 comments

Try :CocCommand workspace.renameCurrentFile, which will change current filename to a new name and reload it.

@fannheyward that's working fine (note that I can also change the filename in NERDTree with mm.)

The problem is that the references to the file (all the import statements) are not updated in _other_ files. VSCode has this support, though I'm not sure if it comes with LSP or not.

Maybe it's needed to send notification to notify language servers. I'll try to fix it.

Thanks so much! I'm hitting this with a TypeScript project, if that helps.

By now, you can :CocRestart after rename file. This will restart client-server connection, and will update references.

This did not seem to help. It indeed restarted the connection, but the references did not get udpated. I'll wait for a fix, as this is not really super urgent for me. (I'm keeping VSCode around for debugging at least, and for file renames for now. :)) Thanks for the help!

It works for me. If i change the file name, it will change all files which import that file.

PS. It will not save the change to disk.

@iamcco what language server are you playing with? tsserver?

@muratg I use coc-tsserver

You need watchman installed, read readme of coc-tsserver

@chemzqm thanks, that worked! (Although installing Watchman for the first time was an adventure.)

Thanks again, all!

@chemzqm Hi! Thanks for the work you do! One complaint::CocCommand workspace.renameCurrentFile is a little annoying to use because you have to type out the entire file path each time and mistakes may be made. Could we have it autofill with the current file path so that it is easier to work with?

@geoyws you might be using old version of coc.nvim, it does prompt for change of current file path.

I have the latest coc.nvim (0.0.75) though, running on Vim 8.1.
no-autocomplete-vim-coc-rename-file
As you can see there's nothing prefilled when it prompts for the new path. :(
Also, after typing out the long path name, and saving... my imports are not updated too (Watchman is installed).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marene picture marene  路  3Comments

rkulla picture rkulla  路  3Comments

MacGuffinLife picture MacGuffinLife  路  4Comments

zhou13 picture zhou13  路  3Comments

andys8 picture andys8  路  3Comments