mirror of
https://github.com/dense-analysis/ale
synced 2024-12-24 23:22:29 +00:00
Add support for purescript language server (#2572)
* Add support for purescript language server * Update naming * Add purescript language server tests
This commit is contained in:
parent
701c1e4f17
commit
1c71da5624
49
ale_linters/purescript/ls.vim
Normal file
49
ale_linters/purescript/ls.vim
Normal file
@ -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')},
|
||||
\})
|
33
doc/ale-purescript.txt
Normal file
33
doc/ale-purescript.txt
Normal file
@ -0,0 +1,33 @@
|
||||
===============================================================================
|
||||
ALE PureScript Integration *ale-purescript-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
purescript-language-server *ale-purescript-language-server*
|
||||
|
||||
PureScript Language Server
|
||||
(https://github.com/nwolverson/purescript-language-server)
|
||||
|
||||
g:ale_purescript_ls_executable g:ale_purescript_ls_executable
|
||||
b:ale_purescript_ls_executable
|
||||
Type: |String|
|
||||
Default: `'purescript-language-server'`
|
||||
|
||||
PureScript language server executable.
|
||||
|
||||
g:ale_purescript_ls_config g:ale_purescript_ls_config
|
||||
b:ale_purescript_ls_config
|
||||
Type: |Dictionary|
|
||||
Default: `{}`
|
||||
|
||||
Dictionary containing configuration settings that will be passed to the
|
||||
language server. For example, with a spago project:
|
||||
{
|
||||
\ 'purescript': {
|
||||
\ 'addSpagoSources': v:true,
|
||||
\ 'addNpmPath': v:true,
|
||||
\ 'buildCommand': 'spago build -- --json-errors'
|
||||
\ }
|
||||
\}
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
@ -338,6 +338,8 @@ Notes:
|
||||
* `languageserver`
|
||||
* `puppet`
|
||||
* `puppet-lint`
|
||||
* PureScript
|
||||
* `purescript-language-server`
|
||||
* Python
|
||||
* `autopep8`
|
||||
* `bandit`
|
||||
|
@ -2176,6 +2176,8 @@ documented in additional help files.
|
||||
puppet................................|ale-puppet-puppet|
|
||||
puppetlint............................|ale-puppet-puppetlint|
|
||||
puppet-languageserver.................|ale-puppet-languageserver|
|
||||
purescript..............................|ale-purescript-options|
|
||||
purescript-language-server............|ale-purescript-language-server|
|
||||
pyrex (cython)..........................|ale-pyrex-options|
|
||||
cython................................|ale-pyrex-cython|
|
||||
python..................................|ale-python-options|
|
||||
|
@ -347,6 +347,8 @@ formatting.
|
||||
* [languageserver](https://github.com/lingua-pupuli/puppet-editor-services)
|
||||
* [puppet](https://puppet.com)
|
||||
* [puppet-lint](https://puppet-lint.com)
|
||||
* PureScript
|
||||
* [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
|
||||
* Python
|
||||
* [autopep8](https://github.com/hhatto/autopep8)
|
||||
* [bandit](https://github.com/PyCQA/bandit) :warning:
|
||||
|
@ -0,0 +1,31 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('purescript', 'ls')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(should set correct defaults):
|
||||
AssertLinter 'purescript-language-server', ale#Escape('purescript-language-server') . ' --stdio'
|
||||
|
||||
Execute(should set correct LSP values):
|
||||
call ale#test#SetFilename('purescript_paths/spago/Foo.purs')
|
||||
|
||||
AssertLSPLanguage 'purescript'
|
||||
AssertLSPOptions {}
|
||||
AssertLSPConfig {}
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/purescript_paths/spago')
|
||||
|
||||
Execute(should set correct project for bower):
|
||||
call ale#test#SetFilename('purescript_paths/bower/Foo.purs')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/purescript_paths/bower')
|
||||
|
||||
Execute(should set correct project for psc-package):
|
||||
call ale#test#SetFilename('purescript_paths/psc-package/Foo.purs')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/purescript_paths/psc-package')
|
||||
|
||||
Execute(should accept configuration settings):
|
||||
AssertLSPConfig {}
|
||||
let b:ale_purescript_ls_config = {'purescript': {'addSpagoSources': v:true}}
|
||||
AssertLSPConfig {'purescript': {'addSpagoSources': v:true}}
|
Loading…
Reference in New Issue
Block a user