You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Being able to format the document using the "code-action-on-save" editor feature. That feature is not really part of the spec. More an editor feature that is currently implemented by VSCode, LSP for Sublime Text, and probably others.
It works by user defining a setting like this one in the editor:
and the client requesting and applying such code actions from the server before saving.
Introducing a code action like source.format.terraform would allow to granularly enable "format-on-save" for that particular server rather than having to globally enable format-on-save (that utilizes formatting provider).
Attempted Solutions
It's currently possible to enable format-on-save in various editors by using its built-in format-on-save functionality that utilizes the server's documentFormattingProvider capabilities. The problem with that approach is that enabling that feature enables it for all servers and the user when running multiple servers, doesn't always want to enable it for all of them.
Proposal
Related LSP methods
The feature would utilize Code Action Request. The client makes a code action request with context.only set to source.format.terraform (for example), receives it back from the server and applies before saving the file. The code action could return a command to run (requires extra round trip) or ideally provide the edits directly.
The server capability codeActionProvider.codeActionKinds is also relevant and should be set by the server to include the source.format.terraform code action. That makes the code action available for both code-action-on-save and some context menus that editors might expose for the document.
References
The text was updated successfully, but these errors were encountered:
This enables in the language server to perform one or more code actions on a range of text or a full document.
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting or when a request has `source.formatAll` or `source.formatAll.terraform-ls`. This can either be a global setting or one specific to the terraform language.
This enables in the language server to perform one or more code actions on a range of text or a full document.
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting or when a request has `source.formatAll` or `source.formatAll.terraform-ls`. This can either be a global setting or one specific to the terraform language.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Current Version
Use-cases
Being able to format the document using the "code-action-on-save" editor feature. That feature is not really part of the spec. More an editor feature that is currently implemented by VSCode, LSP for Sublime Text, and probably others.
It works by user defining a setting like this one in the editor:
and the client requesting and applying such code actions from the server before saving.
Introducing a code action like
source.format.terraform
would allow to granularly enable "format-on-save" for that particular server rather than having to globally enable format-on-save (that utilizes formatting provider).Attempted Solutions
It's currently possible to enable format-on-save in various editors by using its built-in format-on-save functionality that utilizes the server's
documentFormattingProvider
capabilities. The problem with that approach is that enabling that feature enables it for all servers and the user when running multiple servers, doesn't always want to enable it for all of them.Proposal
Related LSP methods
The feature would utilize Code Action Request. The client makes a code action request with
context.only
set tosource.format.terraform
(for example), receives it back from the server and applies before saving the file. The code action could return a command to run (requires extra round trip) or ideally provide the edits directly.The server capability
codeActionProvider.codeActionKinds
is also relevant and should be set by the server to include thesource.format.terraform
code action. That makes the code action available for both code-action-on-save and some context menus that editors might expose for the document.References
The text was updated successfully, but these errors were encountered: