summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntew <antewcode@gmail.com>2019-03-21 00:55:05 -0400
committerAntew <antewcode@gmail.com>2019-03-21 02:55:49 -0400
commit8ec96154000031e59d96092efe1ee9fd104ffcd0 (patch)
tree3ff8cb134323c0bfd160e09b362c8c6e29905160
parent80ef7ea2d0b22f0d8de7387a3d5bf6e9e5b72e9d (diff)
downloadale-8ec96154000031e59d96092efe1ee9fd104ffcd0.zip
Add support for elm-lsp
-rw-r--r--ale_linters/elm/elm_lsp.vim22
-rw-r--r--doc/ale-elm.txt18
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md1
-rw-r--r--test/command_callback/test_elm_lsp_command_callbacks.vader29
6 files changed, 73 insertions, 0 deletions
diff --git a/ale_linters/elm/elm_lsp.vim b/ale_linters/elm/elm_lsp.vim
new file mode 100644
index 00000000..2259286f
--- /dev/null
+++ b/ale_linters/elm/elm_lsp.vim
@@ -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'
+\})
diff --git a/doc/ale-elm.txt b/doc/ale-elm.txt
index de7d8939..bb7a6132 100644
--- a/doc/ale-elm.txt
+++ b/doc/ale-elm.txt
@@ -29,6 +29,24 @@ 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*
+
+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*
g:ale_elm_make_executable *g:ale_elm_make_executable*
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index d3409384..9be28f87 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -118,6 +118,7 @@ Notes:
* `mix`!!
* Elm
* `elm-format`
+ * `elm-lsp`
* `elm-make`
* Erb
* `erb`
diff --git a/doc/ale.txt b/doc/ale.txt
index 3812c92d..f3ceacdb 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -122,6 +122,7 @@ ALE supports the following key features for linting:
credo...............................|ale-elixir-credo|
elm...................................|ale-elm-options|
elm-format..........................|ale-elm-elm-format|
+ elm-lsp.............................|ale-elm-elm-lsp|
elm-make............................|ale-elm-elm-make|
erlang................................|ale-erlang-options|
erlc................................|ale-erlang-erlc|
@@ -2260,6 +2261,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-make..............................|ale-elm-elm-make|
erlang..................................|ale-erlang-options|
erlc..................................|ale-erlang-erlc|
diff --git a/supported-tools.md b/supported-tools.md
index 0c3b2ca6..c044d9f3 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -127,6 +127,7 @@ formatting.
* [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk:
* Elm
* [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)
* Erb
* [erb](https://apidock.com/ruby/ERB)
diff --git a/test/command_callback/test_elm_lsp_command_callbacks.vader b/test/command_callback/test_elm_lsp_command_callbacks.vader
new file mode 100644
index 00000000..d06ef134
--- /dev/null
+++ b/test/command_callback/test_elm_lsp_command_callbacks.vader
@@ -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'