]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/puppet/languageserver.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / ale_linters / puppet / languageserver.vim
1 " Author: Alexander Olofsson <alexander.olofsson@liu.se>
2 " Description: Puppet Language Server integration for ALE
3
4 call ale#Set('puppet_languageserver_executable', 'puppet-languageserver')
5
6 function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort
7     " Note: The metadata.json file is recommended for Puppet 4+ modules, but
8     " there's no requirement to have it, so fall back to the other possible
9     " Puppet module directories
10     let l:root_path = ale#path#FindNearestFile(a:buffer, 'metadata.json')
11
12     if !empty(l:root_path)
13         return fnamemodify(l:root_path, ':h')
14     endif
15
16     for l:test_path in [
17     \   'manifests',
18     \   'templates',
19     \]
20         let l:root_path = ale#path#FindNearestDirectory(a:buffer, l:test_path)
21
22         if !empty(l:root_path)
23             return fnamemodify(l:root_path, ':h:h')
24         endif
25     endfor
26
27     return ''
28 endfunction
29
30 call ale#linter#Define('puppet', {
31 \   'name': 'languageserver',
32 \   'aliases': ['puppet_languageserver'],
33 \   'lsp': 'stdio',
34 \   'executable': {b -> ale#Var(b, 'puppet_languageserver_executable')},
35 \   'command': '%e --stdio',
36 \   'language': 'puppet',
37 \   'project_root': function('ale_linters#puppet#languageserver#GetProjectRoot'),
38 \})