Document and test reason-language-server

This commit is contained in:
w0rp 2019-06-09 00:12:11 +01:00
parent 92d515c211
commit 507f164a09
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
7 changed files with 49 additions and 17 deletions

View File

@ -1,7 +1,9 @@
" Author: David Buchan-Swanson <github@deecewan.com> " Author: David Buchan-Swanson <github@deecewan.com>
" Description: Integrate ALE with reason-language-server. " 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') let l:reason_config = ale#path#FindNearestFile(a:buffer, 'bsconfig.json')
if !empty(l:reason_config) if !empty(l:reason_config)
@ -16,6 +18,6 @@ call ale#linter#Define('reason', {
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {buffer -> ale#Var(buffer, 'reason_ls_executable')}, \ 'executable': {buffer -> ale#Var(buffer, 'reason_ls_executable')},
\ 'command': '%e', \ 'command': '%e',
\ 'project_root': function('ale_linters#reason#reason_ls#FindProjectRoot'), \ 'project_root': function('ale_linters#reason#ls#FindProjectRoot'),
\ 'language': 'reason', \ 'language': 'reason',
\}) \})

View File

@ -5,10 +5,10 @@ ALE ReasonML Integration *ale-reasonml-options*
=============================================================================== ===============================================================================
merlin *ale-reasonml-merlin* merlin *ale-reasonml-merlin*
To use merlin linter for ReasonML source code you need to make sure Merlin To use merlin linter for ReasonML source code you need to make sure Merlin for
for Vim is correctly configured. See the corresponding Merlin wiki page for Vim is correctly configured. See the corresponding Merlin wiki page for
detailed instructions detailed instructions:
(https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch). https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch
=============================================================================== ===============================================================================
ols *ale-reasonml-ols* ols *ale-reasonml-ols*
@ -18,6 +18,7 @@ ols *ale-reasonml-ols*
instructions: instructions:
https://github.com/freebroccolo/ocaml-language-server#installation https://github.com/freebroccolo/ocaml-language-server#installation
g:ale_reason_ols_executable *g:ale_reason_ols_executable* g:ale_reason_ols_executable *g:ale_reason_ols_executable*
*b:ale_reason_ols_executable* *b:ale_reason_ols_executable*
Type: |String| Type: |String|
@ -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`. This variable can be set to change the executable path for `ols`.
g:ale_reason_ols_use_global *g:ale_reason_ols_use_global* g:ale_reason_ols_use_global *g:ale_reason_ols_use_global*
*b:ale_reason_ols_use_global* *b:ale_reason_ols_use_global*
Type: |String| Type: |String|
@ -33,6 +35,7 @@ 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 This variable can be set to `1` to always use the globally installed
executable. See also |ale-integrations-local-executables|. executable. See also |ale-integrations-local-executables|.
=============================================================================== ===============================================================================
reason-language-server *ale-reasonml-language-server* reason-language-server *ale-reasonml-language-server*
@ -41,6 +44,7 @@ reason-language-server *ale-reasonml-language-server*
latest release. You can place it anywhere, but ensure you set the executable latest release. You can place it anywhere, but ensure you set the executable
path. path.
g:ale_reason_ls_executable *g:ale_reason_ls_executable* g:ale_reason_ls_executable *g:ale_reason_ls_executable*
*b:ale_reason_ls_executable* *b:ale_reason_ls_executable*
Type: |String| Type: |String|
@ -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. This variable can be set to pass the path of the refmt fixer.
g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options* g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options*
*b:ale_reasonml_refmt_options* *b:ale_reasonml_refmt_options*
Type: |String| 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. 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: vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -366,6 +366,7 @@ Notes:
* ReasonML * ReasonML
* `merlin` * `merlin`
* `ols` * `ols`
* `reason-language-server`
* `refmt` * `refmt`
* reStructuredText * reStructuredText
* `alex`!! * `alex`!!

View File

@ -2196,6 +2196,7 @@ documented in additional help files.
reasonml................................|ale-reasonml-options| reasonml................................|ale-reasonml-options|
merlin................................|ale-reasonml-merlin| merlin................................|ale-reasonml-merlin|
ols...................................|ale-reasonml-ols| ols...................................|ale-reasonml-ols|
reason-language-server................|ale-reasonml-language-server|
refmt.................................|ale-reasonml-refmt| refmt.................................|ale-reasonml-refmt|
restructuredtext........................|ale-restructuredtext-options| restructuredtext........................|ale-restructuredtext-options|
textlint..............................|ale-restructuredtext-textlint| textlint..............................|ale-restructuredtext-textlint|

View File

@ -375,6 +375,7 @@ formatting.
* ReasonML * ReasonML
* [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions
* [ols](https://github.com/freebroccolo/ocaml-language-server) * [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) * [refmt](https://github.com/reasonml/reason-cli)
* reStructuredText * reStructuredText
* [alex](https://github.com/wooorm/alex) :floppy_disk: * [alex](https://github.com/wooorm/alex) :floppy_disk:

View File

@ -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')