diff options
author | Alexander Olofsson <alexander.olofsson@liu.se> | 2018-07-04 13:36:50 +0200 |
---|---|---|
committer | Alexander Olofsson <alexander.olofsson@liu.se> | 2018-07-04 15:08:25 +0200 |
commit | 42ae06a288e3775261847081a6934bc991abd106 (patch) | |
tree | 6b1668f2ca30ed65ea52efcd2dd16250c7337369 /ale_linters/puppet | |
parent | 00a385930476a8244f7099345448d0afcac0ac31 (diff) | |
download | ale-42ae06a288e3775261847081a6934bc991abd106.zip |
puppet: Add puppet-languageserver linter
Diffstat (limited to 'ale_linters/puppet')
-rw-r--r-- | ale_linters/puppet/languageserver.vim | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ale_linters/puppet/languageserver.vim b/ale_linters/puppet/languageserver.vim new file mode 100644 index 00000000..feff1d53 --- /dev/null +++ b/ale_linters/puppet/languageserver.vim @@ -0,0 +1,35 @@ +" 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#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'puppet_languageserver_executable') +endfunction + +function! ale_linters#puppet#languageserver#GetCommand(buffer) abort + let l:exe = ale#Escape(ale_linters#puppet#languageserver#GetExecutable(a:buffer)) + + return l:exe . ' --stdio' +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. + 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') + endif + + return !empty(l:root_path) ? fnamemodify(l:root_path, ':h') : '' +endfunction + +call ale#linter#Define('puppet', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#puppet#languageserver#GetExecutable', +\ 'command_callback': 'ale_linters#puppet#languageserver#GetCommand', +\ 'language': 'puppet', +\ 'project_root_callback': 'ale_linters#puppet#languageserver#GetProjectRoot', +\}) |