diff --git a/autoload/fish.vim b/autoload/fish.vim index 0a0a5a8..a51a8a8 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -26,6 +26,8 @@ function! fish#Format() let l:command = v:lnum.','.(v:lnum+v:count-1).'!fish_indent' echo l:command execute l:command + " Fix indentation and replace tabs with spaces if necessary. + normal! '[='] endif endfunction diff --git a/ftdetect/fish.vim b/ftdetect/fish.vim index cbb7d0d..9a462de 100644 --- a/ftdetect/fish.vim +++ b/ftdetect/fish.vim @@ -1,23 +1,13 @@ autocmd BufRead,BufNewFile *.fish setfiletype fish +" Set filetype when using funced. +autocmd BufRead fish_funced.* setfiletype fish + +" Fish histories are YAML documents. +autocmd BufRead,BufNewFile ~/.config/fish/fish_{read_,}history setfiletype yaml + " Detect fish scripts by the shebang line. autocmd BufRead * \ if getline(1) =~# '\v^#!%(\f*/|/usr/bin/env\s*<)fish>' | \ setlocal filetype=fish | \ endif - -" Move cursor to first empty line when using funced. -autocmd BufRead fish_funced_*_*.fish call search('^$') - -" Fish histories are YAML documents. -autocmd BufRead,BufNewFile ~/.config/fish/fish_{read_,}history setfiletype yaml - -" Universal variable storages should not be hand edited. -autocmd BufRead,BufNewFile ~/.config/fish/fishd.* setlocal readonly - -" Mimic `funced` when manually creating functions. -autocmd BufNewFile ~/.config/fish/functions/*.fish - \ call append(0, ['function '.expand('%:t:r'), - \'', - \'end']) | - \ 2 diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index 7c2ddf3..48ac3a2 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -31,8 +31,16 @@ endif " argument to fish instead of man. execute 'setlocal keywordprg=fish\ '.expand(':p:h:h').'/bin/man.fish' +let b:match_ignorecase = 0 +if has('patch-7.3.1037') + let s:if = '\%(else\s\+\)\@15:', '<>%|)') + \ '\<\%(begin\|function\|'.s:if.'\|switch\|while\|for\)\>' + \.':\<\%(else\%(\s*if\)\?\|case\)\>:\' let b:endwise_addition = 'end' let b:endwise_words = 'begin,function,if,switch,while,for' diff --git a/plugin/fish.vim b/plugin/fish.vim new file mode 100644 index 0000000..743be15 --- /dev/null +++ b/plugin/fish.vim @@ -0,0 +1,17 @@ +if get(g:, 'loaded_fish', 0) + finish +endif +let loaded_fish = 1 + +" Universal variable storages should not be hand edited. +autocmd BufRead,BufNewFile ~/.config/fish/fishd.* setlocal readonly +" +" Move cursor to first empty line when using funced. +autocmd BufRead fish_funced.* exec "normal! gg=G" | call search('^\s*\zs$') + +" Mimic `funced` when manually creating functions. +autocmd BufNewFile ~/.config/fish/functions/*.fish + \ call setline(1, ['function '.expand('%:t:r'), + \'', + \'end']) | + \ 2 diff --git a/syntax/fish.vim b/syntax/fish.vim index 3d0a2b6..53b72b6 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -2,6 +2,9 @@ if exists('b:current_syntax') finish endif +syntax sync clear +syntax sync fromstart + syntax case match syntax keyword fishKeyword begin function end