diff options
author | Axel Clark <axel.clark@pm.me> | 2023-09-11 05:48:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-11 13:48:11 +0100 |
commit | ac615e7f656fb379cfe7cd205842b0f089a060d6 (patch) | |
tree | 9363c3295776dda51848c4cf3efd84eb48ea46fb | |
parent | 1bf445c6d5c805db0e0733846538fa4bfd5d8a68 (diff) | |
download | ale-ac615e7f656fb379cfe7cd205842b0f089a060d6.zip |
Add lexical for linting elixir projects (#4580)
-rw-r--r-- | ale_linters/elixir/lexical.vim | 19 | ||||
-rw-r--r-- | doc/ale-elixir.txt | 18 | ||||
-rw-r--r-- | doc/ale-supported-languages-and-tools.txt | 1 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | supported-tools.md | 1 | ||||
-rw-r--r-- | test/linter/test_lexical.vader | 28 |
6 files changed, 68 insertions, 0 deletions
diff --git a/ale_linters/elixir/lexical.vim b/ale_linters/elixir/lexical.vim new file mode 100644 index 00000000..ea13142e --- /dev/null +++ b/ale_linters/elixir/lexical.vim @@ -0,0 +1,19 @@ +" Author: Axel Clark <axelclark@pm.me> +" Description: Lexical integration (https://github.com/lexical-lsp/lexical) + +call ale#Set('elixir_lexical_release', 'lexical') + +function! ale_linters#elixir#lexical#GetExecutable(buffer) abort + let l:dir = ale#path#Simplify(ale#Var(a:buffer, 'elixir_lexical_release')) + let l:cmd = has('win32') ? '\start_lexical.bat' : '/start_lexical.sh' + + return l:dir . l:cmd +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'lexical', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#elixir#lexical#GetExecutable'), +\ 'command': function('ale_linters#elixir#lexical#GetExecutable'), +\ 'project_root': function('ale#handlers#elixir#FindMixUmbrellaRoot'), +\}) diff --git a/doc/ale-elixir.txt b/doc/ale-elixir.txt index 693db5aa..351b442a 100644 --- a/doc/ale-elixir.txt +++ b/doc/ale-elixir.txt @@ -105,4 +105,22 @@ See |ale-cspell-options| =============================================================================== +lexical *ale-elixir-lexical* + +Lexical (https://github.com/lexical-lsp/lexical) + +g:ale_elixir_lexical_release *g:ale_elixir_lexical_release* + *b:ale_elixir_lexical_release* + Type: |String| + Default: `'lexical'` + + Location of the lexical release directory. This directory must contain + the language server scripts (start_lexical.sh and start_lexical.bat). + + For example, set release to: `/home/projects/lexical/_build/dev/rel/lexical` + + There are currnetly no configuration options for lexical. + + +=============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 07ad0a62..ff5a914f 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -168,6 +168,7 @@ Notes: * `dialyxir` * `dogma`!! * `elixir-ls` + * `lexical` * `mix`!! * Elm * `elm-format` diff --git a/doc/ale.txt b/doc/ale.txt index 0263c8cc..ded91aa3 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2993,6 +2993,7 @@ documented in additional help files. elixir-ls.............................|ale-elixir-elixir-ls| credo.................................|ale-elixir-credo| cspell................................|ale-elixir-cspell| + lexical...............................|ale-elixir-lexical| elm.....................................|ale-elm-options| elm-format............................|ale-elm-elm-format| elm-ls................................|ale-elm-elm-ls| diff --git a/supported-tools.md b/supported-tools.md index 66914464..637e771d 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -177,6 +177,7 @@ formatting. * [dialyxir](https://github.com/jeremyjh/dialyxir) * [dogma](https://github.com/lpil/dogma) :floppy_disk: * [elixir-ls](https://github.com/elixir-lsp/elixir-ls) :warning: + * [lexical](https://github.com/lexical-lsp/lexical) :warning: * [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk: * Elm * [elm-format](https://github.com/avh4/elm-format) diff --git a/test/linter/test_lexical.vader b/test/linter/test_lexical.vader new file mode 100644 index 00000000..a5ca2f9e --- /dev/null +++ b/test/linter/test_lexical.vader @@ -0,0 +1,28 @@ +Before: + call ale#assert#SetUpLinterTest('elixir', 'lexical') + +After: + call ale#assert#TearDownLinterTest() + +Execute(should set correct defaults): + if has('win32') + AssertLinter 'lexical\start_lexical.bat', 'lexical\start_lexical.bat' + else + AssertLinter 'lexical/start_lexical.sh', 'lexical/start_lexical.sh' + endif + +Execute(should configure lexical release location): + let b:ale_elixir_lexical_release = 'boo' + + if has('win32') + AssertLinter 'boo\start_lexical.bat', 'boo\start_lexical.bat' + else + AssertLinter 'boo/start_lexical.sh', 'boo/start_lexical.sh' + endif + +Execute(should set correct LSP values): + call ale#test#SetFilename('../test-files/elixir/umbrella_project/apps/app1/lib/app.ex') + + AssertLSPLanguage 'elixir' + AssertLSPOptions {} + AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/elixir/umbrella_project') |