Clean up root detection for puppet languageserver
This commit is contained in:
parent
9ca133feb0
commit
f78db619d4
@ -14,15 +14,25 @@ function! ale_linters#puppet#languageserver#GetCommand(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort
|
function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort
|
||||||
" Note: while manifest.json is a strong recommendation, the only
|
" Note: The metadata.json file is recommended for Puppet 4+ modules, but
|
||||||
" *required* path for a Puppet module is the manifests folder.
|
" 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')
|
let l:root_path = ale#path#FindNearestFile(a:buffer, 'metadata.json')
|
||||||
|
if !empty(l:root_path)
|
||||||
if empty(l:root_path)
|
return fnamemodify(l:root_path, ':h')
|
||||||
let l:root_path = ale#path#FindNearestDirectory(a:buffer, 'manifests')
|
|
||||||
endif
|
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
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('puppet', {
|
call ale#linter#Define('puppet', {
|
||||||
|
Loading…
Reference in New Issue
Block a user