All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Horacio Sanson <hsanson@gmail.com>
2 " Description: terraform-ls integration for ALE (cf. https://github.com/hashicorp/terraform-ls)
4 call ale#Set('terraform_terraform_executable', 'terraform')
5 call ale#Set('terraform_ls_executable', 'terraform-ls')
6 call ale#Set('terraform_ls_options', '')
8 function! ale_linters#terraform#terraform_ls#GetTerraformExecutable(buffer) abort
9 let l:terraform_executable = ale#Var(a:buffer, 'terraform_terraform_executable')
11 if(ale#path#IsAbsolute(l:terraform_executable))
12 return '-tf-exec ' . l:terraform_executable
18 function! ale_linters#terraform#terraform_ls#GetCommand(buffer) abort
21 \ . ale#Pad(ale_linters#terraform#terraform_ls#GetTerraformExecutable(a:buffer))
22 \ . ale#Pad(ale#Var(a:buffer, 'terraform_ls_options'))
25 function! ale_linters#terraform#terraform_ls#GetProjectRoot(buffer) abort
26 let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform')
28 return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : ''
31 call ale#linter#Define('terraform', {
32 \ 'name': 'terraform_ls',
33 \ 'aliases': ['terraformls'],
35 \ 'executable': {b -> ale#Var(b, 'terraform_ls_executable')},
36 \ 'command': function('ale_linters#terraform#terraform_ls#GetCommand'),
37 \ 'project_root': function('ale_linters#terraform#terraform_ls#GetProjectRoot'),
38 \ 'language': 'terraform',