Merge pull request #1252 from nthapaliya/fish-shell-linter
Fish shell linter
This commit is contained in:
commit
80342b119a
@ -98,6 +98,7 @@ formatting.
|
|||||||
| Elm | [elm-format](https://github.com/avh4/elm-format), [elm-make](https://github.com/elm-lang/elm-make) |
|
| Elm | [elm-format](https://github.com/avh4/elm-format), [elm-make](https://github.com/elm-lang/elm-make) |
|
||||||
| Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
|
| Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
|
||||||
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
|
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
|
||||||
|
| Fish | fish [-n flag](https://linux.die.net/man/1/fish)
|
||||||
| Fortran | [gcc](https://gcc.gnu.org/) |
|
| Fortran | [gcc](https://gcc.gnu.org/) |
|
||||||
| Fountain | [proselint](http://proselint.com/) |
|
| Fountain | [proselint](http://proselint.com/) |
|
||||||
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
|
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
|
||||||
|
36
ale_linters/fish/fish.vim
Normal file
36
ale_linters/fish/fish.vim
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
" Author: Niraj Thapaliya - https://github.com/nthapaliya
|
||||||
|
" Description: Lints fish files using fish -n
|
||||||
|
|
||||||
|
function! ale_linters#fish#fish#Handle(buffer, lines) abort
|
||||||
|
" Matches patterns such as:
|
||||||
|
"
|
||||||
|
" home/.config/fish/functions/foo.fish (line 1): Missing end to balance this function definition
|
||||||
|
" function foo
|
||||||
|
" ^
|
||||||
|
" <W> fish: Error while reading file .config/fish/functions/foo.fish
|
||||||
|
let l:pattern = '^.* (line \(\d\+\)): \(.*\)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
let l:i = 0
|
||||||
|
while l:i < len(a:lines)
|
||||||
|
let l:match = matchlist(a:lines[l:i], l:pattern)
|
||||||
|
if len(l:match) && len(l:match[2])
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'col': len(a:lines[l:i + 2]),
|
||||||
|
\ 'lnum': str2nr(l:match[1]),
|
||||||
|
\ 'text': l:match[2],
|
||||||
|
\})
|
||||||
|
endif
|
||||||
|
let l:i += 1
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('fish', {
|
||||||
|
\ 'name': 'fish',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'executable': 'fish',
|
||||||
|
\ 'command': 'fish -n %t',
|
||||||
|
\ 'callback': 'ale_linters#fish#fish#Handle',
|
||||||
|
\})
|
14
doc/ale-fish.txt
Normal file
14
doc/ale-fish.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE Fish Integration *ale-fish-options*
|
||||||
|
|
||||||
|
Lints fish files using `fish -n`.
|
||||||
|
|
||||||
|
Note that `fish -n` is not foolproof: it sometimes gives false positives or
|
||||||
|
errors that are difficult to parse without more context. This integration skips
|
||||||
|
displaying errors if an error message is not found.
|
||||||
|
|
||||||
|
If ALE is not showing any errors but your file does not run as expected, run
|
||||||
|
`fish -n <file.fish>` from the command line.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
@ -64,6 +64,7 @@ CONTENTS *ale-contents*
|
|||||||
erlc................................|ale-erlang-erlc|
|
erlc................................|ale-erlang-erlc|
|
||||||
syntaxerl...........................|ale-erlang-syntaxerl|
|
syntaxerl...........................|ale-erlang-syntaxerl|
|
||||||
eruby.................................|ale-eruby-options|
|
eruby.................................|ale-eruby-options|
|
||||||
|
fish..................................|ale-fish-options|
|
||||||
fortran...............................|ale-fortran-options|
|
fortran...............................|ale-fortran-options|
|
||||||
gcc.................................|ale-fortran-gcc|
|
gcc.................................|ale-fortran-gcc|
|
||||||
fountain..............................|ale-fountain-options|
|
fountain..............................|ale-fountain-options|
|
||||||
@ -301,6 +302,7 @@ Notes:
|
|||||||
* Elm: `elm-format, elm-make`
|
* Elm: `elm-format, elm-make`
|
||||||
* Erb: `erb`, `erubis`
|
* Erb: `erb`, `erubis`
|
||||||
* Erlang: `erlc`, `SyntaxErl`
|
* Erlang: `erlc`, `SyntaxErl`
|
||||||
|
* Fish: `fish` (-n flag)
|
||||||
* Fortran: `gcc`
|
* Fortran: `gcc`
|
||||||
* Fountain: `proselint`
|
* Fountain: `proselint`
|
||||||
* FusionScript: `fusion-lint`
|
* FusionScript: `fusion-lint`
|
||||||
|
39
test/handler/test_fish_handler.vader
Normal file
39
test/handler/test_fish_handler.vader
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
Before:
|
||||||
|
runtime ale_linters/fish/fish.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(The fish handler should handle basic warnings and syntax errors):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 20,
|
||||||
|
\ 'col': 23,
|
||||||
|
\ 'text': "Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.",
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 26,
|
||||||
|
\ 'col': 7,
|
||||||
|
\ 'text': "Illegal command name '(prompt_pwd)'",
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 36,
|
||||||
|
\ 'col': 1,
|
||||||
|
\ 'text': "'end' outside of a block",
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#fish#fish#Handle(1, [
|
||||||
|
\ "fish_prompt.fish (line 20): Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.",
|
||||||
|
\ 'if set -q SSH_CLIENT || set -q SSH_TTY',
|
||||||
|
\ ' ^',
|
||||||
|
\ "fish_prompt.fish (line 26): Illegal command name '(prompt_pwd)'",
|
||||||
|
\ ' (prompt_pwd) \',
|
||||||
|
\ ' ^',
|
||||||
|
\ "fish_prompt.fish (line 36): 'end' outside of a block",
|
||||||
|
\ 'end',
|
||||||
|
\ '^',
|
||||||
|
\ 'config.fish (line 45):',
|
||||||
|
\ "abbr --add p 'cd ~/Projects'",
|
||||||
|
\ '^',
|
||||||
|
\ ])
|
Loading…
Reference in New Issue
Block a user