-
Notifications
You must be signed in to change notification settings - Fork 137
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
Format on save code action #625
Conversation
52902b5
to
45a349b
Compare
45a349b
to
161328c
Compare
514ef3b
to
25d7038
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave it spin and it worked nicely in both VS Code and Sublime Text. 👍🏻
Aside from my inline comments:
We should also add an RPC-level test for this new handler, similar to the one we have in
func TestLangServer_formatting_basic(t *testing.T) { |
and perhaps one for tfvars
func TestLangServer_formatting_variables(t *testing.T) { |
I'd probably omit the version check as it's already heavily tested in multiple places, including
terraform-exec
itself.
Lastly it would be great to get this new feature documented. The best way to do so is probably adding Code Actions
section similar to Code Lens we have here https://github.com/hashicorp/terraform-ls/blob/main/docs/language-clients.md#code-lens and also briefly explaining the expected use case for the two kinds (source.formatAll
and source.formatAll.terraform-ls
) - one serving the needs of a client which has languageID-based configuration and the other one client which has global configuration (such as Sublime Text).
a9a71d4
to
378f4a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left you just some very minor inline suggestions, but the PR looks pretty good in general and ready for merging.
8f9941e
to
2a359ff
Compare
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.
2a359ff
to
a21c3ee
Compare
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
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.Fixes #327