-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support code-action-on-save for triggering formatting #327
Comments
jpogran
added a commit
that referenced
this issue
Aug 18, 2021
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting. This can either be a global setting or one specific to the terraform language.
jpogran
added a commit
that referenced
this issue
Aug 18, 2021
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting. This can either be a global setting or one specific to the terraform language.
jpogran
added a commit
that referenced
this issue
Aug 18, 2021
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting. This can either be a global setting or one specific to the terraform language.
jpogran
added a commit
that referenced
this issue
Aug 19, 2021
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting. This can either be a global setting or one specific to the terraform language.
jpogran
added a commit
that referenced
this issue
Aug 19, 2021
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting. This can either be a global setting or one specific to the terraform language.
jpogran
added a commit
that referenced
this issue
Aug 19, 2021
This adds a code action to format a file based on the `editor.codeActionsOnSave` setting. This can either be a global setting or one specific to the terraform language.
jpogran
added a commit
that referenced
this issue
Aug 20, 2021
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.
jpogran
added a commit
that referenced
this issue
Aug 23, 2021
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.
jpogran
added a commit
that referenced
this issue
Aug 23, 2021
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.
jpogran
added a commit
that referenced
this issue
Aug 23, 2021
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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: