yioneko / vtsls

LSP wrapper for typescript extension of vscode
Other
486 stars 7 forks source link

How to add a global fix to 'remove all unused imports' to code action? #150

Closed chaozwn closed 6 months ago

chaozwn commented 6 months ago

How to add a global fix to 'remove all unused imports' to code actions, like typescript-tools.nvim.

image

yioneko commented 6 months ago

:lua vim.lsp.buf.code_action({ context = { only = { "source" } } })

Or use :lua vim.lsp.buf.code_action({ context = { only = { "source", "refactor", "quickfix" } } }) to see all of the available code actions.

chaozwn commented 6 months ago

:lua vim.lsp.buf.code_action({ context = { only = { "source" } } })

Or use :lua vim.lsp.buf.code_action({ context = { only = { "source", "refactor", "quickfix" } } }) to see all of the available code actions.

Thank you for your response, but I hope that these options are available by default in the buffer using code action, just like Move to a new File.

yioneko commented 6 months ago

Sorry, I prefer not to implement this on server side, as explained in https://github.com/microsoft/language-server-protocol/issues/1554. For compatibility, we should only return standard quickfix actions on request without any provided kinds, and this is also what most of the lsp servers does. User should implement this on client side.