From 0843efc7a5010cd1aa0875a0254b466db9f7fc4a Mon Sep 17 00:00:00 2001 From: andys8 Date: Fri, 21 Jun 2019 20:07:23 +0200 Subject: [PATCH] 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. --- ale_linters/elm/elm_ls.vim | 35 +++++++++++++++++ ale_linters/elm/elm_lsp.vim | 22 ----------- doc/ale-elm.txt | 38 +++++++++++++++---- doc/ale.txt | 2 +- ...er => test_elm_ls_command_callbacks.vader} | 12 +++--- 5 files changed, 73 insertions(+), 36 deletions(-) create mode 100644 ale_linters/elm/elm_ls.vim delete mode 100644 ale_linters/elm/elm_lsp.vim rename test/command_callback/{test_elm_lsp_command_callbacks.vader => test_elm_ls_command_callbacks.vader} (63%) diff --git a/ale_linters/elm/elm_ls.vim b/ale_linters/elm/elm_ls.vim new file mode 100644 index 00000000..4a373822 --- /dev/null +++ b/ale_linters/elm/elm_ls.vim @@ -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') +\}) diff --git a/ale_linters/elm/elm_lsp.vim b/ale_linters/elm/elm_lsp.vim deleted file mode 100644 index 2259286f..00000000 --- a/ale_linters/elm/elm_lsp.vim +++ /dev/null @@ -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' -\}) diff --git a/doc/ale-elm.txt b/doc/ale-elm.txt index bb7a6132..823b53e1 100644 --- a/doc/ale-elm.txt +++ b/doc/ale-elm.txt @@ -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| diff --git a/doc/ale.txt b/doc/ale.txt index eea3d102..d18b98f0 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -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| diff --git a/test/command_callback/test_elm_lsp_command_callbacks.vader b/test/command_callback/test_elm_ls_command_callbacks.vader similarity index 63% rename from test/command_callback/test_elm_lsp_command_callbacks.vader rename to test/command_callback/test_elm_ls_command_callbacks.vader index d06ef134..3e1d5fbf 100644 --- a/test/command_callback/test_elm_lsp_command_callbacks.vader +++ b/test/command_callback/test_elm_ls_command_callbacks.vader @@ -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'