aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Ã…kesson2026-04-11 14:46:10 +0200
committerGitHub2026-04-11 21:46:10 +0900
commit051d12c72d3a2ecfc61b0a52c8f6fd89307e5b6c (patch)
treec0c8de6822af1761df569df13dbf97406504485b
parent6ba798d2e773905feb609bf530e681acbdaea22c (diff)
downloadale-051d12c72d3a2ecfc61b0a52c8f6fd89307e5b6c.tar.gz

fix(terraform-ls): return current buffer dir when missing .terraform (#5103)

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.

-rw-r--r--ale_linters/terraform/terraform_ls.vim4
1 files changed, 4 insertions, 0 deletions
diff --git a/ale_linters/terraform/terraform_ls.vim b/ale_linters/terraform/terraform_ls.vim
index 7dc77941d..f442dd073 100644
--- a/ale_linters/terraform/terraform_ls.vim
+++ b/ale_linters/terraform/terraform_ls.vim
@@ -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