diff options
author | Christian Höltje <docwhat@gerf.org> | 2018-06-07 13:55:43 -0400 |
---|---|---|
committer | Christian Höltje <docwhat@gerf.org> | 2018-06-25 11:21:53 -0400 |
commit | 49d995a521c7f0fa4cd9524fa139cfdaba6e0677 (patch) | |
tree | 3ff2be7cec46e488fa2af123f5433fd1f87a7ac0 | |
parent | 620951b6d3420ca69754f3e1068167729d8c651b (diff) | |
download | ale-49d995a521c7f0fa4cd9524fa139cfdaba6e0677.zip |
sh: add bash-language-server linter
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | ale_linters/sh/language_server.vim | 33 | ||||
-rw-r--r-- | doc/ale-sh.txt | 19 | ||||
-rw-r--r-- | doc/ale.txt | 3 |
4 files changed, 55 insertions, 2 deletions
@@ -94,7 +94,7 @@ formatting. | API Blueprint | [drafter](https://github.com/apiaryio/drafter) | | AsciiDoc | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [write-good](https://github.com/btford/write-good) | | Awk | [gawk](https://www.gnu.org/software/gawk/)| -| Bash | shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/), [shfmt](https://github.com/mvdan/sh) | +| Bash | [language-server](https://github.com/mads-hartmann/bash-language-server), shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/), [shfmt](https://github.com/mvdan/sh) | | Bourne Shell | shell [-n flag](http://linux.die.net/man/1/sh), [shellcheck](https://www.shellcheck.net/), [shfmt](https://github.com/mvdan/sh) | | C | [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint), [clang](http://clang.llvm.org/), [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/) | | C++ (filetype cpp) | [clang](http://clang.llvm.org/), [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) !!, [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) !!, [cquery](https://github.com/cquery-project/cquery), [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/) | diff --git a/ale_linters/sh/language_server.vim b/ale_linters/sh/language_server.vim new file mode 100644 index 00000000..2f66e27b --- /dev/null +++ b/ale_linters/sh/language_server.vim @@ -0,0 +1,33 @@ +" Author: Christian Höltje (https://docwhat.org/) +" Description: BASH Language server integration for ALE +scriptencoding utf-8 + +call ale#Set('sh_language_server_executable', 'bash-language-server') +call ale#Set('sh_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#sh#language_server#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'sh_language_server', [ + \ 'node_modules/.bin/bash-language-server', + \]) +endfunction + +function! ale_linters#sh#language_server#GetCommand(buffer) abort + let l:exe = ale#Escape(ale_linters#sh#language_server#GetExecutable(a:buffer)) + + return l:exe . ' start' +endfunction + +function! ale_linters#sh#language_server#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('sh', { +\ 'name': 'language_server', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#sh#language_server#GetExecutable', +\ 'command_callback': 'ale_linters#sh#language_server#GetCommand', +\ 'language': 'sh', +\ 'project_root_callback': 'ale_linters#sh#language_server#GetProjectRoot', +\}) diff --git a/doc/ale-sh.txt b/doc/ale-sh.txt index 941dc59b..7557e522 100644 --- a/doc/ale-sh.txt +++ b/doc/ale-sh.txt @@ -3,6 +3,25 @@ ALE Shell Integration *ale-sh-options* =============================================================================== +sh-language-server *ale-sh-language-server* + +g:ale_sh_language_server_executable *g:ale_sh_language_server_executable* + *b:ale_sh_language_server_executable* + Type: |String| + Default: `'bash-language-server'` + + See |ale-integrations-local-executables| + + +g:ale_sh_language_server_use_global *g:ale_sh_language_server_use_global* + *b:ale_sh_language_server_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== shell *ale-sh-shell* g:ale_sh_shell_default_shell *g:ale_sh_shell_default_shell* diff --git a/doc/ale.txt b/doc/ale.txt index 2f91c6d1..6c0b3ccf 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -228,6 +228,7 @@ CONTENTS *ale-contents* prettier............................|ale-scss-prettier| stylelint...........................|ale-scss-stylelint| sh....................................|ale-sh-options| + sh-language-server..................|ale-sh-language-server| shell...............................|ale-sh-shell| shellcheck..........................|ale-sh-shellcheck| shfmt...............................|ale-sh-shfmt| @@ -319,7 +320,7 @@ Notes: * API Blueprint: `drafter` * AsciiDoc: `alex`!!, `proselint`, `redpen`, `write-good` * Awk: `gawk` -* Bash: `shell` (-n flag), `shellcheck`, `shfmt` +* Bash: `language-server`, `shell` (-n flag), `shellcheck`, `shfmt` * Bourne Shell: `shell` (-n flag), `shellcheck`, `shfmt` * C: `cppcheck`, `cpplint`!!, `clang`, `clangtidy`!!, `clang-format`, `flawfinder`, `gcc` * C++ (filetype cpp): `clang`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc` |