From fd42e8e935e31ac7eef8db821302280d12e6cff0 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Thu, 5 Jul 2018 14:04:20 +0200 Subject: [PATCH] vue: Add the vls language server linter --- README.md | 2 +- ale_linters/vue/vls.vim | 32 ++++++++++++++++++++++++++++++++ doc/ale-vue.txt | 20 ++++++++++++++++++++ doc/ale.txt | 3 ++- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 ale_linters/vue/vls.vim diff --git a/README.md b/README.md index caddc590..584861c0 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ formatting. | Verilog | [iverilog](https://github.com/steveicarus/iverilog), [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) | | Vim | [vint](https://github.com/Kuniwak/vint) | | Vim help^ | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | -| Vue | [prettier](https://github.com/prettier/prettier) | +| Vue | [prettier](https://github.com/prettier/prettier), [vls](https://github.com/vuejs/vetur/tree/master/server) | | 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/) | diff --git a/ale_linters/vue/vls.vim b/ale_linters/vue/vls.vim new file mode 100644 index 00000000..0d4bf9f6 --- /dev/null +++ b/ale_linters/vue/vls.vim @@ -0,0 +1,32 @@ +" Author: Alexander Olofsson +" Description: Vue vls Language Server integration for ALE + +call ale#Set('vue_vls_executable', 'vls') +call ale#Set('vue_vls_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#vue#vls#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'vue_vls', [ + \ 'node_modules/.bin/vls', + \]) +endfunction + +function! ale_linters#vue#vls#GetCommand(buffer) abort + let l:exe = ale#Escape(ale_linters#vue#vls#GetExecutable(a:buffer)) + + return l:exe . ' --stdio' +endfunction + +function! ale_linters#vue#vls#GetProjectRoot(buffer) abort + let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json') + + return !empty(l:package_path) ? fnamemodify(l:package_path, ':h') : '' +endfunction + +call ale#linter#Define('vue', { +\ 'name': 'vls', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#vue#vls#GetExecutable', +\ 'command_callback': 'ale_linters#vue#vls#GetCommand', +\ 'language': 'vue', +\ 'project_root_callback': 'ale_linters#vue#vls#GetProjectRoot', +\}) diff --git a/doc/ale-vue.txt b/doc/ale-vue.txt index 937b603b..a2c2786f 100644 --- a/doc/ale-vue.txt +++ b/doc/ale-vue.txt @@ -7,5 +7,25 @@ prettier *ale-vue-prettier* See |ale-javascript-prettier| for information about the available options. + +=============================================================================== +vls *ale-vue-vls* + +g:ale_vue_vls_executable *g:ale_vue_vls_executable* + *b:ale_vue_vls_executable* + Type: |String| + Default: `'vls'` + + See |ale-integrations-local-executables| + + +g:ale_vue_vls_use_global *g:ale_vue_vls_use_global* + *b:ale_vue_vls_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 9283765f..b500d5d4 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -273,6 +273,7 @@ CONTENTS *ale-contents* write-good..........................|ale-vim-help-write-good| vue...................................|ale-vue-options| prettier............................|ale-vue-prettier| + vls.................................|ale-vue-vls| xhtml.................................|ale-xhtml-options| write-good..........................|ale-xhtml-write-good| xml...................................|ale-xml-options| @@ -418,7 +419,7 @@ Notes: * Verilog: `iverilog`, `verilator` * Vim: `vint` * Vim help^: `alex`!!, `proselint`, `write-good` -* Vue: `prettier` +* Vue: `prettier`, `vls` * XHTML: `alex`!!, `proselint`, `write-good` * XML: `xmllint` * YAML: `swaglint`, `yamllint`