Skip to content

Conversation

guillaumebrunerie
Copy link

This adds support for the "Move to file" code action for the JavaScript/TypeScript language server, fixing #4649.
Note that this pull request depends on typescript-language-server/typescript-language-server#987 being merged first.

This pull request does the following:

  • sets the new supportsMoveToFileCodeAction initialization option of typescript-language-server to t,
  • uses action-filter to intercept the "Move to file" code action, ask the user for a file, and add the appropriate arguments to the command.

Note that "Move to file" doesn’t seem to work if the destination file exists but isn’t open in Emacs, not sure if that’s how it behaves in VSCode as well or if there is a way to work around that?

@guillaumebrunerie
Copy link
Author

typescript-language-server/typescript-language-server#987 has been merged now, so this pull request is ready to be merged to add support for "Move to file" in Emacs.

Copy link

@dzhu dzhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! I'm not affiliated with the project, but I was excited to see this PR open, and I tried it out myself. I had to make a change to get it to work, though: there is the lsp-use-plists option, which changes the internal objects from hashes to plists, so you should use the lsp-get and lsp-put wrapper functions as shown in the inline suggestion. That will let the code work whichever way the option is set.

Thanks for putting the pieces together to make this feature work!

Co-authored-by: Danny Zhu <[email protected]>
@guillaumebrunerie
Copy link
Author

@dzhu Thank you for the suggestion! I didn’t know about lsp-get and lsp-put and it did feel wrong to use gethash and puthash directly, it’s much better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client One or more of lsp-mode language clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants