36b50058bb
* 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>
25 lines
998 B
VimL
25 lines
998 B
VimL
" 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',
|
|
\})
|