fix(terraform-ls): return current buffer dir when missing .terraform (#5103)
Some checks are pending
CI / build_image (push) Waiting to run
CI / test_ale (--linters-only) (push) Blocked by required conditions
CI / test_ale (--lua-only) (push) Blocked by required conditions
CI / test_ale (--neovim-07-only) (push) Blocked by required conditions
CI / test_ale (--neovim-08-only) (push) Blocked by required conditions
CI / test_ale (--vim-80-only) (push) Blocked by required conditions
CI / test_ale (--vim-90-only) (push) Blocked by required conditions

while working in some larger repos, the .terraform dir might be missing
for one reason or another, terraform-ls will fail to start and return:
```
Failed to find project root, language server won't start
```
check if tf_dir is empty, if so, just return the dir of the file in
buffer.
This commit is contained in:
Andreas Åkesson
2026-04-11 14:46:10 +02:00
committed by GitHub
parent 6ba798d2e7
commit 051d12c72d

View File

@@ -25,6 +25,10 @@ endfunction
function! ale_linters#terraform#terraform_ls#GetProjectRoot(buffer) abort
let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform')
if empty(l:tf_dir)
let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.')
endif
return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : ''
endfunction