diff options
author | Alexander Olofsson <alexander.olofsson@liu.se> | 2018-07-05 21:35:30 +0200 |
---|---|---|
committer | Alexander Olofsson <alexander.olofsson@liu.se> | 2018-07-05 21:35:51 +0200 |
commit | f78db619d45e54949a8d5d667dffef6ea1e6adb3 (patch) | |
tree | 536db6e8d1c606267907cbd525d2af01eed1aeab /ale_linters/puppet | |
parent | 9ca133feb0a97785aa5a3a2aa27763e385d6b47c (diff) | |
download | ale-f78db619d45e54949a8d5d667dffef6ea1e6adb3.zip |
Clean up root detection for puppet languageserver
Diffstat (limited to 'ale_linters/puppet')
-rw-r--r-- | ale_linters/puppet/languageserver.vim | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/ale_linters/puppet/languageserver.vim b/ale_linters/puppet/languageserver.vim index feff1d53..52880f32 100644 --- a/ale_linters/puppet/languageserver.vim +++ b/ale_linters/puppet/languageserver.vim @@ -14,15 +14,25 @@ function! ale_linters#puppet#languageserver#GetCommand(buffer) abort endfunction function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort - " Note: while manifest.json is a strong recommendation, the only - " *required* path for a Puppet module is the manifests folder. + " Note: The metadata.json file is recommended for Puppet 4+ modules, but + " there's no requirement to have it, so fall back to the other possible + " Puppet module directories let l:root_path = ale#path#FindNearestFile(a:buffer, 'metadata.json') - - if empty(l:root_path) - let l:root_path = ale#path#FindNearestDirectory(a:buffer, 'manifests') + if !empty(l:root_path) + return fnamemodify(l:root_path, ':h') endif - return !empty(l:root_path) ? fnamemodify(l:root_path, ':h') : '' + for l:test_path in [ + \ 'manifests', + \ 'templates', + \] + let l:root_path = ale#path#FindNearestDirectory(a:buffer, l:test_path) + if !empty(l:root_path) + return fnamemodify(l:root_path, ':h:h') + endif + endfor + + return '' endfunction call ale#linter#Define('puppet', { |