2018-07-04 07:36:50 -04:00
|
|
|
" Author: Alexander Olofsson <alexander.olofsson@liu.se>
|
|
|
|
" Description: Puppet Language Server integration for ALE
|
|
|
|
|
|
|
|
call ale#Set('puppet_languageserver_executable', 'puppet-languageserver')
|
|
|
|
|
|
|
|
function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort
|
2018-07-05 15:35:30 -04:00
|
|
|
" 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
|
2018-07-04 07:36:50 -04:00
|
|
|
let l:root_path = ale#path#FindNearestFile(a:buffer, 'metadata.json')
|
2018-07-05 15:35:30 -04:00
|
|
|
if !empty(l:root_path)
|
|
|
|
return fnamemodify(l:root_path, ':h')
|
2018-07-04 07:36:50 -04:00
|
|
|
endif
|
|
|
|
|
2018-07-05 15:35:30 -04:00
|
|
|
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 ''
|
2018-07-04 07:36:50 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('puppet', {
|
|
|
|
\ 'name': 'languageserver',
|
|
|
|
\ 'lsp': 'stdio',
|
2018-08-02 18:44:12 -04:00
|
|
|
\ 'executable_callback': ale#VarFunc('puppet_languageserver_executable'),
|
|
|
|
\ 'command': '%e --stdio',
|
2018-07-04 07:36:50 -04:00
|
|
|
\ 'language': 'puppet',
|
|
|
|
\ 'project_root_callback': 'ale_linters#puppet#languageserver#GetProjectRoot',
|
|
|
|
\})
|