From ac615e7f656fb379cfe7cd205842b0f089a060d6 Mon Sep 17 00:00:00 2001 From: Axel Clark Date: Mon, 11 Sep 2023 05:48:11 -0700 Subject: Add lexical for linting elixir projects (#4580) --- ale_linters/elixir/lexical.vim | 19 +++++++++++++++++++ doc/ale-elixir.txt | 18 ++++++++++++++++++ doc/ale-supported-languages-and-tools.txt | 1 + doc/ale.txt | 1 + supported-tools.md | 1 + test/linter/test_lexical.vader | 28 ++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+) create mode 100644 ale_linters/elixir/lexical.vim create mode 100644 test/linter/test_lexical.vader 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 +" 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 @@ -104,5 +104,23 @@ cspell *ale-elixir-cspell* 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') -- cgit v1.2.3