Skip to content

Commit 525e2b4

Browse files
committed
syntax checking using vim's compiler architecture
1 parent ad16f71 commit 525e2b4

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Features aplenty
1717
* Searching for definitions including sourced files using commands like `[i`.
1818
* Keyword lookup that includes pages for fish builtins using the `K` command.
1919
* Completions from fish using the `^X^O` command.
20+
* Syntax checking with quickfix using the `:make` command.
2021
* Improved `funced` experience to instantly start typing commands in the
2122
function body.
2223
* Mimics `funced` when manually creating new functions.
@@ -29,6 +30,9 @@ some Vim features turned on:
2930
syntax enable
3031
filetype plugin indent on
3132
33+
" Set up :make to use fish for syntax checking.
34+
compiler! fish
35+
3236
" Set this to have long lines wrap inside comments.
3337
set textwidth=79
3438

autoload/fish.vim

+4
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ function! fish#Complete(findstart, base)
6060
return l:results
6161
endif
6262
endfunction
63+
64+
function! fish#errorformat()
65+
return '%Afish: %m,%-Z%f (line %l):%s'
66+
endfunction

compiler/fish.vim

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if exists('current_compiler')
2+
finish
3+
endif
4+
let current_compiler = 'fish'
5+
6+
CompilerSet makeprg=fish\ --no-execute\ %
7+
execute 'CompilerSet errorformat='.escape(fish#errorformat(), ' ')

syntax_checkers/fish/fish.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function! SyntaxCheckers_fish_fish_GetLocList()
1111
let l:makeprg = syntastic#makeprg#build({'exe': 'fish',
1212
\'args': '--no-execute',
1313
\'subchecker': 'fish'})
14-
let l:errorformat = '%Afish: %m,%-Z%f (line %l):%s'
15-
return SyntasticMake({'makeprg': l:makeprg, 'errorformat': l:errorformat})
14+
return SyntasticMake({'makeprg': l:makeprg,
15+
\'errorformat': fish#errorformat()})
1616
endfunction
1717

1818
call g:SyntasticRegistry.CreateAndRegisterChecker({'filetype': 'fish',

0 commit comments

Comments
 (0)