Update elm-ls
* elm_lsp is now elm_ls * The binary published by @elm-tooling is elm-language-server Updates tests, docs and adds more options to the plugin.
This commit is contained in:
parent
65ba4b85ec
commit
0843efc7a5
5 changed files with 73 additions and 36 deletions
35
ale_linters/elm/elm_ls.vim
Normal file
35
ale_linters/elm/elm_ls.vim
Normal file
|
@ -0,0 +1,35 @@
|
|||
" 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))
|
||||
call ale#Set('elm_ls_elm_path', 'elm')
|
||||
call ale#Set('elm_ls_elm_format_path', 'elm-format')
|
||||
call ale#Set('elm_ls_elm_test_path', 'elm-test')
|
||||
|
||||
function! elm_ls#GetRootDir(buffer) abort
|
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
|
||||
|
||||
return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : ''
|
||||
endfunction
|
||||
|
||||
function! elm_ls#GetOptions(buffer) abort
|
||||
return {
|
||||
\ 'runtime': 'node',
|
||||
\ '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'),
|
||||
\}
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elm', {
|
||||
\ 'name': 'elm_ls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_ls', [
|
||||
\ 'node_modules/.bin/elm-language-server'
|
||||
\ ])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('elm_ls#GetRootDir'),
|
||||
\ 'language': 'elm',
|
||||
\ 'initialization_options': function('elm_ls#GetOptions')
|
||||
\})
|
|
@ -1,22 +0,0 @@
|
|||
" Author: antew - https://github.com/antew
|
||||
" Description: LSP integration for elm, currently supports diagnostics (linting)
|
||||
|
||||
call ale#Set('elm_lsp_executable', 'elm-lsp')
|
||||
call ale#Set('elm_lsp_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! elm_lsp#GetRootDir(buffer) abort
|
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
|
||||
|
||||
return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elm', {
|
||||
\ 'name': 'elm_lsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_lsp', [
|
||||
\ 'node_modules/.bin/elm-lsp',
|
||||
\ ])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('elm_lsp#GetRootDir'),
|
||||
\ 'language': 'elm'
|
||||
\})
|
|
@ -29,20 +29,44 @@ g:ale_elm_format_options *g:ale_elm_format_options*
|
|||
This variable can be set to pass additional options to elm-format.
|
||||
|
||||
===============================================================================
|
||||
elm-lsp *ale-elm-elm-lsp*
|
||||
elm-ls *ale-elm-elm-ls*
|
||||
|
||||
g:ale_elm_lsp_executable *g:ale_elm_lsp_executable*
|
||||
*b:ale_elm_lsp_executable*
|
||||
g:ale_elm_ls_executable *g:ale_elm_ls_executable*
|
||||
*b:ale_elm_ls_executable*
|
||||
Type: |String|
|
||||
Default: `'elm-lsp'`
|
||||
Default: `'elm-language-server'`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_elm_lsp_use_global *g:ale_elm_lsp_use_global*
|
||||
*b:ale_elm_lsp_use_global*
|
||||
g:ale_elm_ls_use_global *g:ale_elm_ls_use_global*
|
||||
*b:ale_elm_ls_use_global*
|
||||
Type: |Number|
|
||||
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||
Default: `get(g:, 'ale_use_global_executables', 1)`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path*
|
||||
*b:ale_elm_ls_elm_path*
|
||||
Type: |String|
|
||||
Default: `'elm'`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path*
|
||||
*b:ale_elm_ls_elm_format_path*
|
||||
Type: |String|
|
||||
Default: `'elm-format'`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_elm_ls_elm_test_path *g:ale_elm_ls_elm_test_path*
|
||||
*b:ale_elm_ls_elm_test_path*
|
||||
Type: |String|
|
||||
Default: `'elm-test'`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
|
|
@ -2002,7 +2002,7 @@ documented in additional help files.
|
|||
credo.................................|ale-elixir-credo|
|
||||
elm.....................................|ale-elm-options|
|
||||
elm-format............................|ale-elm-elm-format|
|
||||
elm-lsp...............................|ale-elm-elm-lsp|
|
||||
elm-ls................................|ale-elm-elm-ls|
|
||||
elm-make..............................|ale-elm-elm-make|
|
||||
erlang..................................|ale-erlang-options|
|
||||
dialyzer..............................|ale-erlang-dialyzer|
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('elm', 'elm_lsp')
|
||||
call ale#assert#SetUpLinterTest('elm', 'elm_ls')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
@ -7,7 +7,7 @@ After:
|
|||
Execute(The default executable path should be correct):
|
||||
call ale#test#SetFilename('../elm-test-files/newapp/src/Main.elm')
|
||||
|
||||
AssertLinter 'elm-lsp', ale#Escape('elm-lsp') . ' --stdio'
|
||||
AssertLinter 'elm-language-server', ale#Escape('elm-language-server') . ' --stdio'
|
||||
|
||||
Execute(The project root should be detected correctly):
|
||||
AssertLSPProject ''
|
||||
|
@ -19,11 +19,11 @@ Execute(The project root should be detected correctly):
|
|||
Execute(Should let users configure a global executable and override local paths):
|
||||
call ale#test#SetFilename('../elm-test-files/newapp/src/Main.elm')
|
||||
|
||||
let g:ale_elm_lsp_executable = '/path/to/custom/elm-lsp'
|
||||
let g:ale_elm_lsp_use_global = 1
|
||||
let g:ale_elm_ls_executable = '/path/to/custom/elm-language-server'
|
||||
let g:ale_elm_ls_use_global = 1
|
||||
|
||||
AssertLinter '/path/to/custom/elm-lsp',
|
||||
\ ale#Escape('/path/to/custom/elm-lsp') . ' --stdio'
|
||||
AssertLinter '/path/to/custom/elm-language-server',
|
||||
\ ale#Escape('/path/to/custom/elm-language-server') . ' --stdio'
|
||||
|
||||
Execute(The language should be correct):
|
||||
AssertLSPLanguage 'elm'
|
Reference in a new issue