terraform-ls: Prefill required fields and ability to validate on save (#3976)

* Implement additional features supporting latest terraform-ls

* docs: Prefill required fields

* Update changelog
pull/3977/head
Sibi Prabakaran 2023-02-27 12:50:55 +05:30 committed by GitHub
parent b45dea4f60
commit 6184254891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 1 deletions

View File

@ -1,5 +1,6 @@
* Changelog
** Unreleased 8.0.1
* terraform-ls now supports prefill requied fields and the ability to validate on save.
* ~lsp-bash~ now supports ~bash-ts-mode~
* ~lsp-ruby-syntax-tree~, ~lsp-solargraph~, ~lsp-sorbet~, ~lsp-steep~, and ~lsp-typeprof~ now support ~ruby-ts-mode~
* Drop support for emacs 26.1 and 26.2

View File

@ -32,7 +32,7 @@
;; terraform-lsp
(defgroup lsp-terraform nil
"LSP support for Terraform, using terraform-lsp"
"LSP support for Terraform, using terraform-lsp."
:group 'lsp-mode
:link '(url-link "https://github.com/juliosueiras/terraform-lsp")
:package-version `(lsp-mode . "6.2"))
@ -96,6 +96,24 @@ language server."
:type 'boolean
:package-version '(lsp-mode . "8.0.1"))
(defcustom lsp-terraform-ls-validate-on-save nil
"Enable validating the current open file on save.
This is an experimental feature provided by the language server."
:group 'lsp-terraform-ls
:type 'boolean
:package-version '(lsp-mode . "8.0.1"))
(defcustom lsp-terraform-ls-prefill-required-fields nil
"Enable completion of required fields.
Enable autocompletion for required fields when completing
Terraform blocks. This is an experimental feature provided by the
language server."
:group 'lsp-terraform-ls
:type 'boolean
:package-version '(lsp-mode . "8.0.1"))
(defcustom lsp-terraform-ls-providers-position-params nil
"The optional providers tree position params.
Defaults to side following treemacs default."
@ -128,6 +146,11 @@ Defaults to side following treemacs default."
(when lsp-terraform-ls-enable-show-reference
'((experimental . ((showReferencesCommandId . "client.showReferences"))))))
(defun lsp-terraform-ls--init-options ()
"Construct initialization options for the lanague server."
`((experimentalFeatures . ((validateOnSave . ,(lsp-json-bool lsp-terraform-ls-validate-on-save))
(prefillRequiredFields . ,(lsp-json-bool lsp-terraform-ls-prefill-required-fields))))))
(defcustom lsp-terraform-semantic-token-faces
'(("namespace" . lsp-face-semhl-namespace)
("type" . lsp-face-semhl-type)
@ -209,6 +232,7 @@ Defaults to side following treemacs default."
:discard-default-types t
:modifiers ,lsp-terraform-semantic-token-modifier-faces
:types ,lsp-terraform-semantic-token-faces)
:initialization-options (lsp-terraform-ls--init-options)
:custom-capabilities (lsp-terraform-ls--custom-capabilities)))
(defun lsp-terraform-ls-validate ()

View File

@ -106,6 +106,19 @@ There are two ways to open the link:
- Key binding: Alt + Enter
- Clicking the middle button of your mouse
### Prefill required fields
This is an experimental feature which can be enabled via the option
`lsp-terraform-ls-prefill-required-fields`:
``` emacs-lisp
(setq lsp-terraform-ls-prefill-required-fields t)
```
This gif demonstrates how this feature is used:
![](../examples/terraform-ls-prefill.gif)
### Treeview controls
For this feature to work, make sure that you have [lsp-treemacs](https://github.com/emacs-lsp/lsp-treemacs)

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB