Skip to content

Commit

Permalink
Adding support for Odin language server (ols). (#4679)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamindblock authored Feb 22, 2024
1 parent 38c3130 commit 8b8ddea
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ale_linters/odin/ols.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
" Author: Benjamin Block <https://github.com/benjamindblock>
" Description: A language server for Odin.

function! ale_linters#odin#ols#GetProjectRoot(buffer) abort
return fnamemodify('', ':h')
endfunction

call ale#Set('odin_ols_executable', 'ols')
call ale#Set('odin_ols_config', {})

call ale#linter#Define('odin', {
\ 'name': 'ols',
\ 'lsp': 'stdio',
\ 'language': 'odin',
\ 'lsp_config': {b -> ale#Var(b, 'odin_ols_config')},
\ 'executable': {b -> ale#Var(b, 'odin_ols_executable')},
\ 'command': '%e',
\ 'project_root': function('ale_linters#odin#ols#GetProjectRoot'),
\})
29 changes: 29 additions & 0 deletions doc/ale-odin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
===============================================================================
ALE Odin Integration *ale-odin-options*
*ale-integration-odin*

===============================================================================
Integration Information

Currently, the only supported linter for Odin is ols.

===============================================================================
ols *ale-odin-ols*

g:ale_odin_ols_executable *g:ale_odin_ols_executable*
*b:ale_odin_ols_executable*
Type: |String|
Default: `'ols'`

This variable can be modified to change the executable path for `ols`.


g:ale_odin_ols_config *g:ale_odin_ols_config*
*b:ale_odin_ols_config*
Type: |Dictionary|
Default: `{}`

Dictionary with configuration settings for ols.

===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
2 changes: 2 additions & 0 deletions doc/ale-supported-languages-and-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ Notes:
* `ocamllsp`
* `ocp-indent`
* `ols`
* Odin
* `ols`
* OpenApi
* `ibm_validator`
* `prettier`
Expand Down
2 changes: 2 additions & 0 deletions doc/ale.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3224,6 +3224,8 @@ documented in additional help files.
ols...................................|ale-ocaml-ols|
ocamlformat...........................|ale-ocaml-ocamlformat|
ocp-indent............................|ale-ocaml-ocp-indent|
odin....................................|ale-odin-options|
ols...................................|ale-odin-ols|
openapi.................................|ale-openapi-options|
ibm_validator.........................|ale-openapi-ibm-validator|
prettier..............................|ale-openapi-prettier|
Expand Down
2 changes: 2 additions & 0 deletions supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ formatting.
* [ocamllsp](https://github.com/ocaml/ocaml-lsp)
* [ocp-indent](https://github.com/OCamlPro/ocp-indent)
* [ols](https://github.com/freebroccolo/ocaml-language-server)
* Odin
* [ols](https://github.com/DanielGavin/ols)
* OpenApi
* [ibm_validator](https://github.com/IBM/openapi-validator)
* [prettier](https://github.com/prettier/prettier)
Expand Down
16 changes: 16 additions & 0 deletions test/linter/test_odin_ols.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Before:
call ale#assert#SetUpLinterTest('odin', 'ols')

After:
call ale#assert#TearDownLinterTest()

Execute(The default executable path should be correct):
AssertLinter 'ols', ale#Escape('ols')

Execute(The LSP values should be set correctly):
call ale#test#SetFilename('../test-files/odin/main.odin')

AssertLSPLanguage 'odin'
AssertLSPOptions {}
AssertLSPConfig {}
AssertLSPProject '.'
Empty file added test/test-files/odin/main.odin
Empty file.

0 comments on commit 8b8ddea

Please sign in to comment.