Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gleam: Support for gleam language server #4696

Merged
merged 1 commit into from Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.