From 507f164a09d2cb3c99983424f9d186d6f4081820 Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 9 Jun 2019 00:12:11 +0100 Subject: [PATCH] Document and test reason-language-server --- ale_linters/reason/{reason_ls.vim => ls.vim} | 8 +++-- doc/ale-reasonml.txt | 34 +++++++++++-------- doc/ale-supported-languages-and-tools.txt | 1 + doc/ale.txt | 1 + supported-tools.md | 1 + .../reason_ls_paths/bsconfig.json | 0 .../test_reason_ls_command_callback.vader | 21 ++++++++++++ 7 files changed, 49 insertions(+), 17 deletions(-) rename ale_linters/reason/{reason_ls.vim => ls.vim} (64%) create mode 100644 test/command_callback/reason_ls_paths/bsconfig.json create mode 100644 test/command_callback/test_reason_ls_command_callback.vader diff --git a/ale_linters/reason/reason_ls.vim b/ale_linters/reason/ls.vim similarity index 64% rename from ale_linters/reason/reason_ls.vim rename to ale_linters/reason/ls.vim index 9bf25d3a..fb1114ae 100644 --- a/ale_linters/reason/reason_ls.vim +++ b/ale_linters/reason/ls.vim @@ -1,7 +1,9 @@ " Author: David Buchan-Swanson " Description: Integrate ALE with reason-language-server. -function! ale_linters#reason#reason_ls#FindProjectRoot(buffer) abort +call ale#Set('reason_ls_executable', '') + +function! ale_linters#reason#ls#FindProjectRoot(buffer) abort let l:reason_config = ale#path#FindNearestFile(a:buffer, 'bsconfig.json') if !empty(l:reason_config) @@ -14,8 +16,8 @@ endfunction call ale#linter#Define('reason', { \ 'name': 'reason-language-server', \ 'lsp': 'stdio', -\ 'executable':{buffer -> ale#Var(buffer, 'reason_ls_executable')}, +\ 'executable': {buffer -> ale#Var(buffer, 'reason_ls_executable')}, \ 'command': '%e', -\ 'project_root': function('ale_linters#reason#reason_ls#FindProjectRoot'), +\ 'project_root': function('ale_linters#reason#ls#FindProjectRoot'), \ 'language': 'reason', \}) diff --git a/doc/ale-reasonml.txt b/doc/ale-reasonml.txt index 89231f4f..75eb19ac 100644 --- a/doc/ale-reasonml.txt +++ b/doc/ale-reasonml.txt @@ -5,18 +5,19 @@ ALE ReasonML Integration *ale-reasonml-options* =============================================================================== merlin *ale-reasonml-merlin* - To use merlin linter for ReasonML source code you need to make sure Merlin - for Vim is correctly configured. See the corresponding Merlin wiki page for - detailed instructions - (https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch). +To use merlin linter for ReasonML source code you need to make sure Merlin for +Vim is correctly configured. See the corresponding Merlin wiki page for +detailed instructions: +https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch =============================================================================== ols *ale-reasonml-ols* - The `ocaml-language-server` is the engine that powers OCaml and ReasonML - editor support using the Language Server Protocol. See the installation - instructions: - https://github.com/freebroccolo/ocaml-language-server#installation +The `ocaml-language-server` is the engine that powers OCaml and ReasonML +editor support using the Language Server Protocol. See the installation +instructions: +https://github.com/freebroccolo/ocaml-language-server#installation + g:ale_reason_ols_executable *g:ale_reason_ols_executable* *b:ale_reason_ols_executable* @@ -25,6 +26,7 @@ g:ale_reason_ols_executable *g:ale_reason_ols_executable* This variable can be set to change the executable path for `ols`. + g:ale_reason_ols_use_global *g:ale_reason_ols_use_global* *b:ale_reason_ols_use_global* Type: |String| @@ -33,16 +35,18 @@ g:ale_reason_ols_use_global *g:ale_reason_ols_use_global* This variable can be set to `1` to always use the globally installed executable. See also |ale-integrations-local-executables|. + =============================================================================== reason-language-server *ale-reasonml-language-server* - Note: You *must* set an executable - there is no 'default' install location. - Go to https://github.com/jaredly/reason-language-server and download the - latest release. You can place it anywhere, but ensure you set the executable - path. +Note: You *must* set an executable - there is no 'default' install location. +Go to https://github.com/jaredly/reason-language-server and download the +latest release. You can place it anywhere, but ensure you set the executable +path. -g:ale_reason_ls_executable *g:ale_reason_ls_executable* - *b:ale_reason_ls_executable* + +g:ale_reason_ls_executable *g:ale_reason_ls_executable* + *b:ale_reason_ls_executable* Type: |String| This variable defines the standard location of the language server @@ -59,6 +63,7 @@ g:ale_reasonml_refmt_executable *g:ale_reasonml_refmt_executable* This variable can be set to pass the path of the refmt fixer. + g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options* *b:ale_reasonml_refmt_options* Type: |String| @@ -66,5 +71,6 @@ g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options* This variable can be set to pass additional options to the refmt fixer. + =============================================================================== 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 9487829e..aa7489e9 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -366,6 +366,7 @@ Notes: * ReasonML * `merlin` * `ols` + * `reason-language-server` * `refmt` * reStructuredText * `alex`!! diff --git a/doc/ale.txt b/doc/ale.txt index 5314b5d1..19f2f48b 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2196,6 +2196,7 @@ documented in additional help files. reasonml................................|ale-reasonml-options| merlin................................|ale-reasonml-merlin| ols...................................|ale-reasonml-ols| + reason-language-server................|ale-reasonml-language-server| refmt.................................|ale-reasonml-refmt| restructuredtext........................|ale-restructuredtext-options| textlint..............................|ale-restructuredtext-textlint| diff --git a/supported-tools.md b/supported-tools.md index a34a3f90..6f033645 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -375,6 +375,7 @@ formatting. * ReasonML * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions * [ols](https://github.com/freebroccolo/ocaml-language-server) + * [reason-language-server](https://github.com/jaredly/reason-language-server) * [refmt](https://github.com/reasonml/reason-cli) * reStructuredText * [alex](https://github.com/wooorm/alex) :floppy_disk: diff --git a/test/command_callback/reason_ls_paths/bsconfig.json b/test/command_callback/reason_ls_paths/bsconfig.json new file mode 100644 index 00000000..e69de29b diff --git a/test/command_callback/test_reason_ls_command_callback.vader b/test/command_callback/test_reason_ls_command_callback.vader new file mode 100644 index 00000000..64f672d7 --- /dev/null +++ b/test/command_callback/test_reason_ls_command_callback.vader @@ -0,0 +1,21 @@ +Before: + call ale#assert#SetUpLinterTest('reason', 'ls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The linter should not be run by default): + AssertLinterNotExecuted + +Execute(The executable should be configurable): + let b:ale_reason_ls_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(There should be no default project root): + AssertLSPProject '' + +Execute(The project root should be detected using bsconfig.json): + call ale#test#SetFilename('reason_ls_paths/test.ml') + + AssertLSPProject ale#path#Simplify(g:dir . '/reason_ls_paths')