Skip to content

Commit 051d12c

Browse files
authored
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.
1 parent 6ba798d commit 051d12c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

ale_linters/terraform/terraform_ls.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ endfunction
2525
function! ale_linters#terraform#terraform_ls#GetProjectRoot(buffer) abort
2626
let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform')
2727

28+
if empty(l:tf_dir)
29+
let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.')
30+
endif
31+
2832
return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : ''
2933
endfunction
3034

0 commit comments

Comments
 (0)