Add support for elm-lsp
This commit is contained in:
parent
80ef7ea2d0
commit
8ec9615400
6 changed files with 73 additions and 0 deletions
22
ale_linters/elm/elm_lsp.vim
Normal file
22
ale_linters/elm/elm_lsp.vim
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
" 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'
|
||||||
|
\})
|
|
@ -28,6 +28,24 @@ g:ale_elm_format_options *g:ale_elm_format_options*
|
||||||
|
|
||||||
This variable can be set to pass additional options to elm-format.
|
This variable can be set to pass additional options to elm-format.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
elm-lsp *ale-elm-elm-lsp*
|
||||||
|
|
||||||
|
g:ale_elm_lsp_executable *g:ale_elm_lsp_executable*
|
||||||
|
*b:ale_elm_lsp_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'elm-lsp'`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_elm_lsp_use_global *g:ale_elm_lsp_use_global*
|
||||||
|
*b:ale_elm_lsp_use_global*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
elm-make *ale-elm-elm-make*
|
elm-make *ale-elm-elm-make*
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@ Notes:
|
||||||
* `mix`!!
|
* `mix`!!
|
||||||
* Elm
|
* Elm
|
||||||
* `elm-format`
|
* `elm-format`
|
||||||
|
* `elm-lsp`
|
||||||
* `elm-make`
|
* `elm-make`
|
||||||
* Erb
|
* Erb
|
||||||
* `erb`
|
* `erb`
|
||||||
|
|
|
@ -122,6 +122,7 @@ ALE supports the following key features for linting:
|
||||||
credo...............................|ale-elixir-credo|
|
credo...............................|ale-elixir-credo|
|
||||||
elm...................................|ale-elm-options|
|
elm...................................|ale-elm-options|
|
||||||
elm-format..........................|ale-elm-elm-format|
|
elm-format..........................|ale-elm-elm-format|
|
||||||
|
elm-lsp.............................|ale-elm-elm-lsp|
|
||||||
elm-make............................|ale-elm-elm-make|
|
elm-make............................|ale-elm-elm-make|
|
||||||
erlang................................|ale-erlang-options|
|
erlang................................|ale-erlang-options|
|
||||||
erlc................................|ale-erlang-erlc|
|
erlc................................|ale-erlang-erlc|
|
||||||
|
@ -2260,6 +2261,7 @@ documented in additional help files.
|
||||||
credo.................................|ale-elixir-credo|
|
credo.................................|ale-elixir-credo|
|
||||||
elm.....................................|ale-elm-options|
|
elm.....................................|ale-elm-options|
|
||||||
elm-format............................|ale-elm-elm-format|
|
elm-format............................|ale-elm-elm-format|
|
||||||
|
elm-lsp...............................|ale-elm-elm-lsp|
|
||||||
elm-make..............................|ale-elm-elm-make|
|
elm-make..............................|ale-elm-elm-make|
|
||||||
erlang..................................|ale-erlang-options|
|
erlang..................................|ale-erlang-options|
|
||||||
erlc..................................|ale-erlang-erlc|
|
erlc..................................|ale-erlang-erlc|
|
||||||
|
|
|
@ -127,6 +127,7 @@ formatting.
|
||||||
* [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk:
|
* [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk:
|
||||||
* Elm
|
* Elm
|
||||||
* [elm-format](https://github.com/avh4/elm-format)
|
* [elm-format](https://github.com/avh4/elm-format)
|
||||||
|
* [elm-lsp](https://github.com/antew/elm-lsp)
|
||||||
* [elm-make](https://github.com/elm-lang/elm-make)
|
* [elm-make](https://github.com/elm-lang/elm-make)
|
||||||
* Erb
|
* Erb
|
||||||
* [erb](https://apidock.com/ruby/ERB)
|
* [erb](https://apidock.com/ruby/ERB)
|
||||||
|
|
29
test/command_callback/test_elm_lsp_command_callbacks.vader
Normal file
29
test/command_callback/test_elm_lsp_command_callbacks.vader
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
Before:
|
||||||
|
call ale#assert#SetUpLinterTest('elm', 'elm_lsp')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
Execute(The project root should be detected correctly):
|
||||||
|
AssertLSPProject ''
|
||||||
|
|
||||||
|
call ale#test#SetFilename('../elm-test-files/newapp/src/Main.elm')
|
||||||
|
|
||||||
|
AssertLSPProject ale#path#Simplify(g:dir . '/../elm-test-files/newapp')
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
AssertLinter '/path/to/custom/elm-lsp',
|
||||||
|
\ ale#Escape('/path/to/custom/elm-lsp') . ' --stdio'
|
||||||
|
|
||||||
|
Execute(The language should be correct):
|
||||||
|
AssertLSPLanguage 'elm'
|
Reference in a new issue