mirror of https://github.com/dense-analysis/ale
Add support for nimlsp (#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
This commit is contained in:
parent
f4070f6c43
commit
e5a4c82917
|
@ -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'),
|
||||
\})
|
|
@ -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:
|
|
@ -282,6 +282,7 @@ Notes:
|
|||
* `nasm`!!
|
||||
* Nim
|
||||
* `nim check`!!
|
||||
* `nimlsp`
|
||||
* nix
|
||||
* `nix-instantiate`
|
||||
* `nixpkgs-fmt`
|
||||
|
|
|
@ -2307,6 +2307,9 @@ documented in additional help files.
|
|||
mmc...................................|ale-mercury-mmc|
|
||||
nasm....................................|ale-nasm-options|
|
||||
nasm..................................|ale-nasm-nasm|
|
||||
nim.....................................|ale-nim-options|
|
||||
nimcheck..............................|ale-nim-nimcheck|
|
||||
nimlsp................................|ale-nim-nimlsp|
|
||||
nix.....................................|ale-nix-options|
|
||||
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
|
||||
nroff...................................|ale-nroff-options|
|
||||
|
|
|
@ -291,6 +291,7 @@ formatting.
|
|||
* [nasm](https://www.nasm.us/) :floppy_disk:
|
||||
* Nim
|
||||
* [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk:
|
||||
* [nimlsp](https://github.com/PMunch/nimlsp)
|
||||
* nix
|
||||
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
|
||||
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
|
||||
|
|
|
@ -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')
|
|
@ -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(''))
|
Loading…
Reference in New Issue