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

Add function to save and update references #48

Closed jose-elias-alvarez closed 2 years ago

jose-elias-alvarez commented 3 years ago

@non25 suggests a refactoring workflow where you could:

  1. save a list of references to a hovered const/function somewhere
  2. move it to the other file by hand
  3. update imports from that list using some mechanism like :TSLspImportAll

I think this would work well with #46 and #47.

non25 commented 3 years ago

I like this because it is explicit.

Here's more refined version:

  1. Hover on const/function
  2. Run :TSLspMovePrepare, it will save references
  3. Move const/function to the other file, save it and hover on it
  4. Run :TSLspMoveDone, it will open all buffers with references and run import code action on references, if there is more than one import option - it will use one which matches current file path

What do you think? :thinking:

jose-elias-alvarez commented 3 years ago

I like it. If we require the user to specifically hover over the relevant const / function and declare that they are done, we could save multiple sets of references in state to allow moving multiple exports at the same time, too.

non25 commented 3 years ago

Which one you like better, this one or #46 ? :slightly_smiling_face:

I did this workflow manually for a few times this week. Opened reference list as a quickfix, moved function and fixed them one by one. Silly me. :grin:

jose-elias-alvarez commented 3 years ago

I think we should implement them both, since I imagine we'd want this functionality to build on a more general "fix broken imports" function. Will hopefully have time to work on it this week.

jose-elias-alvarez commented 2 years ago

Like the other issues I've been closing, this is a cool idea but should be implemented at the language server level. The whole point of the LSP specification is to make things like this editor-independent, so even though we could implement a Neovim-specific version, I'd rather put that effort into adding something that everyone can benefit from.