2019-08-22 11:36:17 -04:00
|
|
|
" 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
|
2021-05-31 16:30:26 -04:00
|
|
|
return ale#path#FindExecutable(a:buffer, 'purescript_ls', [
|
2019-08-22 11:36:17 -04:00
|
|
|
\ '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',
|
2024-01-07 10:14:20 -05:00
|
|
|
\ 'aliases': ['purescriptls'],
|
2019-08-22 11:36:17 -04:00
|
|
|
\ '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')},
|
|
|
|
\})
|