Skip to content

Commit

Permalink
Support gleamlsp language server for gleam (#4696)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalardy committed Jan 14, 2024
1 parent 32e6fc5 commit ebc6718
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ale_linters/gleam/gleamlsp.vim
@@ -0,0 +1,18 @@
" Author: Jonathan Palardt https://github.com/jpalardy
" Description: Support for Gleam Language Server

call ale#Set('gleam_gleamlsp_executable', 'gleam')

function! ale_linters#gleam#gleamlsp#GetProjectRoot(buffer) abort
let l:gleam_toml = ale#path#FindNearestFile(a:buffer, 'gleam.toml')

return !empty(l:gleam_toml) ? fnamemodify(l:gleam_toml, ':p:h') : ''
endfunction

call ale#linter#Define('gleam', {
\ 'name': 'gleamlsp',
\ 'lsp': 'stdio',
\ 'executable': {buffer -> ale#Var(buffer, 'gleam_gleamlsp_executable')},
\ 'command': '%e lsp',
\ 'project_root': function('ale_linters#gleam#gleamlsp#GetProjectRoot'),
\})
23 changes: 23 additions & 0 deletions doc/ale-gleam.txt
@@ -0,0 +1,23 @@
===============================================================================
ALE Gleam Integration *ale-gleam-options*
*ale-integration-gleam*

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

Currently, the only supported linter for gleam is gleamlsp.


===============================================================================
gleamlsp *ale-gleam-gleamlsp*

g:ale_gleam_gleamlsp_executable *g:ale_gleam_gleamlsp_executable*
*b:ale_gleam_gleamlsp_executable*
Type: |String|
Default: `'gleam'`

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


===============================================================================
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
Expand Up @@ -202,6 +202,8 @@ Notes:
* `fusion-lint`
* Git Commit Messages
* `gitlint`
* Gleam
* `gleamlsp`
* GLSL
* `glslang`
* `glslls`
Expand Down
2 changes: 2 additions & 0 deletions doc/ale.txt
Expand Up @@ -3031,6 +3031,8 @@ documented in additional help files.
fusion-lint...........................|ale-fuse-fusionlint|
git commit..............................|ale-gitcommit-options|
gitlint...............................|ale-gitcommit-gitlint|
gleam...................................|ale-gleam-options|
gleamlsp..............................|ale-gleam-gleamlsp|
glsl....................................|ale-glsl-options|
glslang...............................|ale-glsl-glslang|
glslls................................|ale-glsl-glslls|
Expand Down
2 changes: 2 additions & 0 deletions supported-tools.md
Expand Up @@ -211,6 +211,8 @@ formatting.
* [fusion-lint](https://github.com/RyanSquared/fusionscript)
* Git Commit Messages
* [gitlint](https://github.com/jorisroovers/gitlint)
* Gleam
* [gleamlsp](https://github.com/gleam-lang/gleam)
* GLSL
* [glslang](https://github.com/KhronosGroup/glslang)
* [glslls](https://github.com/svenstaro/glsl-language-server)
Expand Down
15 changes: 15 additions & 0 deletions test/linter/test_gleam_gleamlsp.vader
@@ -0,0 +1,15 @@
Before:
call ale#assert#SetUpLinterTest('gleam', 'gleamlsp')

After:
call ale#assert#TearDownLinterTest()

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

Execute(The project root should be detected correctly):
AssertLSPProject ''

call ale#test#SetFilename('../test-files/gleam/gleam.toml')

AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/gleam')
Empty file.

0 comments on commit ebc6718

Please sign in to comment.