1
0
Fork 0
mirror of synced 2024-11-27 11:15:35 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/elm/ls.vim

42 lines
1.5 KiB
VimL
Raw Permalink Normal View History

2019-08-22 11:36:17 -04:00
" Author: antew - https://github.com/antew
" Description: elm-language-server integration for elm (diagnostics, formatting, and more)
call ale#Set('elm_ls_executable', 'elm-language-server')
call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1))
2019-11-16 10:28:42 -05:00
" elm-language-server will search for local and global binaries, if empty
call ale#Set('elm_ls_elm_path', '')
call ale#Set('elm_ls_elm_format_path', '')
call ale#Set('elm_ls_elm_test_path', '')
call ale#Set('elm_ls_elm_analyse_trigger', 'change')
2019-08-22 11:36:17 -04:00
2024-01-07 10:14:20 -05:00
function! ale_linters#elm#ls#GetProjectRoot(buffer) abort
2019-08-22 11:36:17 -04:00
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : ''
endfunction
2024-10-06 04:25:50 -04:00
function! ale_linters#elm#ls#GetInitializationOptions(buffer) abort
2019-08-22 11:36:17 -04:00
return {
\ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'),
\ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'),
\ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'),
2019-11-16 10:28:42 -05:00
\ 'elmAnalyseTrigger': ale#Var(a:buffer, 'elm_ls_elm_analyse_trigger'),
2019-08-22 11:36:17 -04:00
\}
endfunction
call ale#linter#Define('elm', {
2024-01-07 10:14:20 -05:00
\ 'name': 'ls',
\ 'aliases': ['elm_ls'],
2019-08-22 11:36:17 -04:00
\ 'lsp': 'stdio',
2021-05-31 16:30:26 -04:00
\ 'executable': {b -> ale#path#FindExecutable(b, 'elm_ls', [
2019-08-22 11:36:17 -04:00
\ 'node_modules/.bin/elm-language-server',
\ 'node_modules/.bin/elm-lsp',
\ 'elm-lsp'
\ ])},
\ 'command': '%e --stdio',
2024-01-07 10:14:20 -05:00
\ 'project_root': function('ale_linters#elm#ls#GetProjectRoot'),
2019-08-22 11:36:17 -04:00
\ 'language': 'elm',
2024-10-06 04:25:50 -04:00
\ 'initialization_options': function('ale_linters#elm#ls#GetInitializationOptions')
2019-08-22 11:36:17 -04:00
\})