jose-elias-alvarez / nvim-lsp-ts-utils

Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
The Unlicense
438 stars 18 forks source link

[FEATURE REQUEST] Add new command to move/rename folder #105

Closed fragov closed 2 years ago

fragov commented 2 years ago

Issues

Feature description

We have TSLspRenameFile for file, could we also get TSLspRenameFolder to rename/move a folder, which contains other files? Probably, you could rename the folder and run TSLspRenameFile for each file in that folder and its subfolders.

Help

Yes, but I don't know how to start. I would need guidance

Implementation help

No response

jose-elias-alvarez commented 2 years ago

So this (theoretically) already works–if you enable update_imports_on_move and rename a folder, it should handle everything correctly.

:TSLspRenameFile doesn't currently allow specifying a source (it always uses the current file) but I am planning on updating all of the commands once 0.7.0 is released, since the new nvim_add_user_command API makes defining commands in Lua a lot friendlier. If I have time, I may start working on this earlier, but this feature would only work on 0.7.0.

jose-elias-alvarez commented 2 years ago

I gave this a shot but am actually not sure whether the language server supports this in the first place or whether there's some kind of conflict with how Neovim handles the relevant notification (it seems to require buffers to be loaded in order to apply text edits, but these are folders, so the concept of a buffer doesn't apply).

I don't plan on adding this here, but if someone wants to investigate and give it a shot, I think typescript.nvim is the place for it, since it's using the new command API and is generally much easier to work with.