diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-06-25 17:03:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-25 17:03:15 +0100 |
commit | 66820ed452839a9e09eb18bbaad538d3a25d33f8 (patch) | |
tree | 3ff2be7cec46e488fa2af123f5433fd1f87a7ac0 /ale_linters | |
parent | 620951b6d3420ca69754f3e1068167729d8c651b (diff) | |
parent | 49d995a521c7f0fa4cd9524fa139cfdaba6e0677 (diff) | |
download | ale-66820ed452839a9e09eb18bbaad538d3a25d33f8.zip |
Merge pull request #1641 from docwhat/pr/add-bash-lsp
sh: add bash-language-server linter
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/sh/language_server.vim | 33 |
1 files changed, 33 insertions, 0 deletions
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', +\}) |