Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

feat: support source actions #116

Merged
merged 1 commit into from
Apr 4, 2022
Merged

feat: support source actions #116

merged 1 commit into from
Apr 4, 2022

Conversation

jose-elias-alvarez
Copy link
Owner

@jose-elias-alvarez jose-elias-alvarez commented Mar 15, 2022

Will close #100.

I dug through the typescript-language-server code and figured out how to get these to work in Neovim. This is just a preliminary POC. since I want to implement a few more things (commands, sync actions) before merging.

It should be safe to replace the existing organizeImports command with this one, and removeUnused and fixAll are nice additions. The question is what to do with addMissingImports. Our implementation has some nice improvements like priority, but it's quite brittle compared to simply requesting and applying results from a language server. The new one should emulate VS Code behavior, which I think is good enough.

Generally, removing bespoke functionality and shifting it over to the server is a good idea. This may pave the way for a version 2 of this plugin that focuses on easily setting up typescript-language-server and adding commands for convenience.

@jose-elias-alvarez
Copy link
Owner Author

Since this technically already works, I'm going to go ahead and merge it as-is. I don't want to add more commands, since there's a lot of overlap between these new source actions and existing commands. Anyone interested can set up their own commands by importing the relevant method from require("nvim-lsp-ts-utils.source_actions").

If you only need the functionality from these actions (which covers a lot of what VS Code can do, interestingly) and want things to work out-of-the-box, you can try typescript.nvim, a new project I'm working on.

@jose-elias-alvarez jose-elias-alvarez merged commit 821fd95 into main Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Support typescript-language-server source code actions
1 participant