diff options
author | Drew Olson <drew@drewolson.org> | 2019-06-17 06:54:43 -0500 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2019-06-17 12:54:43 +0100 |
commit | 1c71da5624fc46107cda4852add08fe34385dfd9 (patch) | |
tree | 4dc0c856be3798f7bfe1539fb33a2bea5496fca7 /ale_linters/purescript/ls.vim | |
parent | 701c1e4f170a665ec2873a828297bb0afad6719b (diff) | |
download | ale-1c71da5624fc46107cda4852add08fe34385dfd9.zip |
Add support for purescript language server (#2572)
* Add support for purescript language server
* Update naming
* Add purescript language server tests
Diffstat (limited to 'ale_linters/purescript/ls.vim')
-rw-r--r-- | ale_linters/purescript/ls.vim | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ale_linters/purescript/ls.vim b/ale_linters/purescript/ls.vim new file mode 100644 index 00000000..1c5f937f --- /dev/null +++ b/ale_linters/purescript/ls.vim @@ -0,0 +1,49 @@ +" Author: Drew Olson <drew@drewolson.org> +" Description: Integrate ALE with purescript-language-server. + +call ale#Set('purescript_ls_executable', 'purescript-language-server') +call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('purescript_ls_config', {}) + +function! ale_linters#purescript#ls#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'purescript_ls', [ + \ 'node_modules/.bin/purescript-language-server', + \]) +endfunction + +function! ale_linters#purescript#ls#GetCommand(buffer) abort + let l:executable = ale_linters#purescript#ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +function! ale_linters#purescript#ls#FindProjectRoot(buffer) abort + let l:config = ale#path#FindNearestFile(a:buffer, 'bower.json') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + let l:config = ale#path#FindNearestFile(a:buffer, 'psc-package.json') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + let l:config = ale#path#FindNearestFile(a:buffer, 'spago.dhall') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('purescript', { +\ 'name': 'purescript-language-server', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#purescript#ls#GetExecutable'), +\ 'command': function('ale_linters#purescript#ls#GetCommand'), +\ 'project_root': function('ale_linters#purescript#ls#FindProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'purescript_ls_config')}, +\}) |