Add support for yang-lsp

This commit is contained in:
David Hotham 2018-08-03 20:59:32 +01:00
parent 209cd54783
commit d0e3302253
5 changed files with 47 additions and 0 deletions

View File

@ -191,6 +191,7 @@ formatting.
| XHTML | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
| XML | [xmllint](http://xmlsoft.org/xmllint.html) |
| YAML | [swaglint](https://github.com/byCedric/swaglint), [yamllint](https://yamllint.readthedocs.io/) |
| YANG | [yang-lsp](https://github.com/theia-ide/yang-lsp) |
<a name="usage"></a>

View File

@ -0,0 +1,14 @@
call ale#Set('yang_lsp_executable', 'yang-language-server')
function! ale_linters#yang#yang_lsp#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'yang.settings')
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
call ale#linter#Define('yang', {
\ 'name': 'yang_lsp',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('yang_lsp_executable'),
\ 'project_root_callback': 'ale_linters#yang#yang_lsp#GetProjectRoot',
\ 'command': '%e',
\})

17
doc/ale-yang.txt Normal file
View File

@ -0,0 +1,17 @@
===============================================================================
ALE YANG Integration *ale-yang-options*
===============================================================================
yang-lsp *ale-yang-lsp*
g:ale_yang_lsp_executable *g:ale_yang_lsp_executable*
*b:ale_yang_lsp_executable*
Type: |String|
Default: `'yang-language-server'`
This variable can be changed to use a different executable for yang-lsp.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -292,6 +292,8 @@ CONTENTS *ale-contents*
yaml..................................|ale-yaml-options|
swaglint............................|ale-yaml-swaglint|
yamllint............................|ale-yaml-yamllint|
yang..................................|ale-yang-options|
yang-lsp............................|ale-yang-lsp|
8. Commands/Keybinds....................|ale-commands|
9. API..................................|ale-api|
10. Special Thanks......................|ale-special-thanks|
@ -435,6 +437,7 @@ Notes:
* XHTML: `alex`!!, `proselint`, `write-good`
* XML: `xmllint`
* YAML: `swaglint`, `yamllint`
* YANG: `yang-lsp`
===============================================================================
3. Linting *ale-lint*

View File

@ -0,0 +1,12 @@
Before:
call ale#assert#SetUpLinterTest('yang', 'yang_lsp')
After:
call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
AssertLinter 'yang-language-server', ale#Escape('yang-language-server')
let b:ale_yang_lsp_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar')