diff options
author | Oliver Ford <dev.github@ojford.com> | 2020-04-20 15:02:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 16:02:31 +0100 |
commit | 36b50058bb6b37c5a336c01cf3d9a61f16f323c7 (patch) | |
tree | de771c6bfdb3a7a34e4ac75559b032487e741eaa /ale_linters/terraform | |
parent | 3281321d5ccf2eeee235156503b5fe4a7c268caa (diff) | |
download | ale-36b50058bb6b37c5a336c01cf3d9a61f16f323c7.zip |
Add terraform-lsp integration (#2758)
* Add terraform-lsp integration
https://github.com/juliosueiras/terraform-lsp
* Add tests & docs for terraform-lsp integration
terraform_langserver_options setting added to send custom flags to
terraform-lsp.
Vader tests have been added to test custom executable, custom flags, and
finding the project root. All tests pass.
Initial documentation has been added for the above.
Resolves dense-analysis/ale#2758, juliosueiras#57
* Fix tag alignment
Co-authored-by: = <Aubrey.S.Lavigne@gmail.com>
Co-authored-by: w0rp <w0rp@users.noreply.github.com>
Diffstat (limited to 'ale_linters/terraform')
-rw-r--r-- | ale_linters/terraform/terraform_lsp.vim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ale_linters/terraform/terraform_lsp.vim b/ale_linters/terraform/terraform_lsp.vim new file mode 100644 index 00000000..e2408c15 --- /dev/null +++ b/ale_linters/terraform/terraform_lsp.vim @@ -0,0 +1,25 @@ +" Author: OJFord <dev@ojford.com> +" Description: terraform-lsp integration for ALE (cf. https://github.com/juliosueiras/terraform-lsp) + +call ale#Set('terraform_langserver_executable', 'terraform-lsp') +call ale#Set('terraform_langserver_options', '') + +function! ale_linters#terraform#terraform_lsp#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'terraform_langserver_options')) +endfunction + +function! ale_linters#terraform#terraform_lsp#GetProjectRoot(buffer) abort + let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform') + + return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform_lsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_langserver_executable')}, +\ 'command': function('ale_linters#terraform#terraform_lsp#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_lsp#GetProjectRoot'), +\ 'language': 'terraform', +\}) |