summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2019-03-25 21:41:33 +0000
committerGitHub <noreply@github.com>2019-03-25 21:41:33 +0000
commit8768a309b8ef1c2e819dcb6f4630f73acab59792 (patch)
tree81161ed835dde269fb94df88ceb7fa40b0f775a2
parentad998211f892cdbfac6df3ab296a4d1b849f4086 (diff)
parent8ec96154000031e59d96092efe1ee9fd104ffcd0 (diff)
downloadale-8768a309b8ef1c2e819dcb6f4630f73acab59792.zip
Merge pull request #2378 from antew/feature/elm-lsp-linter
Elm: 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'