1
0
Fork 0
mirror of synced 2024-11-25 10:15:35 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/puppet/languageserver.vim

38 lines
1.2 KiB
VimL
Raw Normal View History

2018-07-19 08:52:53 -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
" 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')
2018-09-24 20:40:17 -04:00
2018-07-19 08:52:53 -04:00
if !empty(l:root_path)
return fnamemodify(l:root_path, ':h')
endif
for l:test_path in [
\ 'manifests',
\ 'templates',
\]
let l:root_path = ale#path#FindNearestDirectory(a:buffer, l:test_path)
2018-09-24 20:40:17 -04:00
2018-07-19 08:52:53 -04:00
if !empty(l:root_path)
return fnamemodify(l:root_path, ':h:h')
endif
endfor
return ''
endfunction
call ale#linter#Define('puppet', {
\ 'name': 'languageserver',
\ 'lsp': 'stdio',
2019-03-08 06:04:56 -05:00
\ 'executable': {b -> ale#Var(b, 'puppet_languageserver_executable')},
2018-08-25 12:13:42 -04:00
\ 'command': '%e --stdio',
2018-07-19 08:52:53 -04:00
\ 'language': 'puppet',
2019-03-08 06:04:56 -05:00
\ 'project_root': function('ale_linters#puppet#languageserver#GetProjectRoot'),
2018-07-19 08:52:53 -04:00
\})