forked from dense-analysis/ale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for nimlsp (dense-analysis#2815)
* Add support for nimlsp.vim * Add test and docs for nimlsp * Add nimlsp to supported-tools.md * Add nimlsp to doc/ale-supported-languages-and-tools.txt
- Loading branch information
1 parent
bf19557
commit 583de67
Showing
8 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
" Author: jeremija <https://github.com/jeremija> | ||
" Description: Support for nimlsp (language server for nim) | ||
|
||
call ale#Set('nim_nimlsp_nim_sources', '') | ||
|
||
function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort | ||
let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') | ||
|
||
if !empty(l:project_root) | ||
return fnamemodify(l:project_root, ':h:h') | ||
endif | ||
|
||
return '' | ||
endfunction | ||
|
||
function! ale_linters#nim#nimlsp#GetCommand(buffer) abort | ||
let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources') | ||
|
||
if !empty(l:nim_sources) | ||
let l:nim_sources = ale#Escape(l:nim_sources) | ||
endif | ||
|
||
return '%e' . ale#Pad(l:nim_sources) | ||
endfunction | ||
|
||
call ale#linter#Define('nim', { | ||
\ 'name': 'nimlsp', | ||
\ 'lsp': 'stdio', | ||
\ 'executable': 'nimlsp', | ||
\ 'command': function('ale_linters#nim#nimlsp#GetCommand'), | ||
\ 'language': 'nim', | ||
\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'), | ||
\}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=============================================================================== | ||
ALE Nim Integration *ale-nim-options* | ||
|
||
|
||
=============================================================================== | ||
nimcheck *ale-nim-nimcheck* | ||
|
||
ALE does not provide additional configuration options for `nimcheck` at this | ||
point. | ||
|
||
|
||
=============================================================================== | ||
nimlsp *ale-nim-nimlsp* | ||
|
||
g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources* | ||
|
||
Type: |String| | ||
Default: `''` | ||
|
||
Sets the path to Nim source repository as the first argument to `nimlsp` | ||
command. | ||
|
||
|
||
=============================================================================== | ||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,6 +283,7 @@ Notes: | |
* `nasm`!! | ||
* Nim | ||
* `nim check`!! | ||
* `nimlsp` | ||
* nix | ||
* `nix-instantiate` | ||
* `nixpkgs-fmt` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Before: | ||
call ale#assert#SetUpLinterTest('nim', 'nimlsp') | ||
|
||
After: | ||
call ale#assert#TearDownLinterTest() | ||
|
||
Execute(It does not set nim sources by default): | ||
AssertLinter 'nimlsp', ale#Escape('nimlsp') | ||
|
||
Execute(Sets nimlsp and escapes sources from g:ale_nim_nimlsp_nim_sources): | ||
let g:ale_nim_nimlsp_nim_sources = '/path/to /Nim' | ||
AssertLinter 'nimlsp', ale#Escape('nimlsp') . ' ' . ale#Escape('/path/to /Nim') |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Before: | ||
runtime ale_linters/nim/nimlsp.vim | ||
call ale#test#SetDirectory('/testplugin/test') | ||
|
||
After: | ||
if isdirectory(g:dir . '/.git') | ||
call delete(g:dir . '/.git', 'd') | ||
endif | ||
|
||
call ale#test#RestoreDirectory() | ||
call ale#linter#Reset() | ||
|
||
|
||
Execute(Detect root of nim project with .git/ correctly): | ||
call ale#test#SetFilename('nim-test-files/with-git/src/source.nim') | ||
call mkdir(g:dir . '/.git') | ||
AssertEqual | ||
\ ale#path#Simplify(g:dir), | ||
\ ale_linters#nim#nimlsp#GetProjectRoot(bufnr('')) |