From c0172e63e430cfa70fd5a8e7c4aaf730b7212731 Mon Sep 17 00:00:00 2001 From: Greg Anders Date: Fri, 13 Sep 2019 11:28:50 -0600 Subject: [PATCH 01/33] Filter blank completions --- autoload/fish.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/fish.vim b/autoload/fish.vim index 2c4d894..37a5738 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -52,7 +52,7 @@ function! fish#Complete(findstart, base) let l:completions = \ system('fish -c "complete -C'.shellescape(a:base).'"') let l:cmd = substitute(a:base, '\v\S+$', '', '') - for l:line in split(l:completions, '\n') + for l:line in filter(split(l:completions, '\n'), 'len(v:val)') let l:tokens = split(l:line, '\t') call add(l:results, {'word': l:cmd.l:tokens[0], \'abbr': l:tokens[0], From 129fee7ed3b49afe7a07817192701500b3673ae8 Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sat, 4 Jan 2020 14:36:33 -0500 Subject: [PATCH 02/33] Handle escaped quotes in the fishString syntax definition. cc: dag/vim-fish#47 --- syntax/fish.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index 18eccce..ad0661b 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -12,8 +12,8 @@ syntax keyword fishLabel case syntax match fishComment /#.*/ syntax match fishSpecial /\\$/ syntax match fishIdentifier /\$[[:alnum:]_]\+/ -syntax region fishString start=/'/ skip=/\\'/ end=/'/ -syntax region fishString start=/"/ skip=/\\"/ end=/"/ contains=fishIdentifier +syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ +syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishIdentifier syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/ syntax match fishStatement /\v;\s*\zs\k+>/ syntax match fishCommandSub /\v\(\s*\zs\k+>/ From 3a9399296f756b160cfae5331095d23a6319282a Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sun, 5 Jan 2020 11:38:10 -0500 Subject: [PATCH 03/33] When mimicking funced for new fish files in the ~/.config/fish/functions directory don't leave a blank line at the end of the file. --- ftdetect/fish.vim | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ftdetect/fish.vim b/ftdetect/fish.vim index cbb7d0d..775e75c 100644 --- a/ftdetect/fish.vim +++ b/ftdetect/fish.vim @@ -17,7 +17,4 @@ 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 + \ call setline(1, ['function '.expand('%:t:r'), '', 'end']) | 2 From d09755bec0bfae132062d2d044826bd7aeeb7574 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Mon, 14 Jul 2014 00:42:12 -0700 Subject: [PATCH 04/33] Define b:undo_ftplugin and fix b:match_words Clean up the ftplugin a bit. Use the save_cpo pattern to ensure cpo is set appropriately, and define a b:undo_ftplugin. Change the b:match_words definition to match else/else if. --- ftplugin/fish.vim | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index 85873eb..5430f93 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -1,3 +1,11 @@ +if exists('b:did_ftplugin') + finish +end +let b:did_ftplugin = 1 + +let s:save_cpo = &cpo +set cpo&vim + setlocal comments=:# setlocal commentstring=#%s setlocal define=\\v^\\s*function> @@ -31,9 +39,20 @@ endif " argument to fish instead of man. execute 'setlocal keywordprg=fish\ '.fnameescape(expand(':p:h:h').'/bin/man.fish') -let b:match_words = - \ escape('<%(begin|function|if|switch|while|for)>:', '<>%|)') +let b:match_words = escape( + \'<%(begin|function|%(else\s\+)\@:::' + \, '<>%|)') let b:endwise_addition = 'end' let b:endwise_words = 'begin,function,if,switch,while,for' let b:endwise_syngroups = 'fishKeyword,fishConditional,fishRepeat' + +let b:undo_ftplugin = " + \ setlocal comments< commentstring< define< foldexpr< formatoptions< + \|setlocal include< iskeyword< suffixesadd< + \|setlocal formatexpr< omnifunc< path< keywordprg< + \|unlet! b:match_words b:endwise_addition b:endwise_words b:endwise_syngroups + \" + +let &cpo = s:save_cpo +unlet s:save_cpo From 5af7761e8920c35e77e712d03d633af046dda6e1 Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Fri, 12 Jun 2015 13:28:58 -0400 Subject: [PATCH 05/33] Improve fish#Indent() - Fix: multiline strings should not be modified. - Fix: "end" is always decreased by one. - Fix: "case" and "else" are always decreased by one. - Fix: continued lines are not treated differently. - Fix: "if", "while", etc followed by "begin" should increment next line by two instead of by one. - Fix: "case" should be one more than "switch". - Fix: multiline strings and continued lines are considered in the calculations for the next line. --- autoload/fish.vim | 114 ++++++++++++++++++++++++++++++++++++++++------ indent/fish.vim | 1 + 2 files changed, 101 insertions(+), 14 deletions(-) diff --git a/autoload/fish.vim b/autoload/fish.vim index 37a5738..2c4847e 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -1,23 +1,109 @@ +function! s:IsString(lnum, col) + " Returns "true" if syntax item at the given position is part of fishString. + let l:stack = map(synstack(a:lnum, a:col), 'synIDattr(v:val, "name")') + return len(filter(l:stack, 'v:val ==# "fishString"')) +endfunction + +function! s:IsContinuedLine(lnum) + " Returns "true" if the given line is a continued line. + return getline(a:lnum - 1) =~ '\v\\$' +endfunction + +function! s:FindPrevLnum(lnum) + " Starting on the given line, search backwards for a line that is not + " empty, not part of a string and not a continued line. + if a:lnum < 1 || a:lnum > line('$') + " First line or wrong value, follow prevnonblank() behaviour and + " return zero. + return 0 + endif + let l:lnum = prevnonblank(a:lnum) + while l:lnum > 0 && ( s:IsContinuedLine(l:lnum) || s:IsString(l:lnum, 1) ) + let l:lnum = prevnonblank(l:lnum - 1) + endwhile + return l:lnum +endfunction + +function! s:IsSwitch(lnum) + " Returns "true" if the given line is part of a switch block. + let l:lnum = a:lnum + let l:line = getline(l:lnum) + let l:in_block = 0 + let l:stop_pat = '\v^\s*%(if|else|while|for|begin)>' + let l:block_start_pat = '\v^\s*%(if|while|for|switch|begin)>' + while l:lnum > 0 + let l:lnum = prevnonblank(l:lnum - 1) + let l:line = getline(l:lnum) + if l:line =~# '\v^\s*end>' + let l:in_block += 1 + elseif l:in_block && l:line =~# l:block_start_pat + let l:in_block -= 1 + elseif !l:in_block && l:line =~# l:stop_pat + return 0 + elseif !l:in_block && l:line =~# '\v^\s*switch>' + return 1 + endif + endwhile + return 0 +endfunction + function! fish#Indent() - let l:shiftwidth = shiftwidth() - let l:prevlnum = prevnonblank(v:lnum - 1) - if l:prevlnum ==# 0 + let l:line = getline(v:lnum) + if s:IsString(v:lnum, 1) + return indent(v:lnum) + endif + " shiftwidth can be misleading in recent versions, use shiftwidth() if + " it is available. + if exists('*shiftwidth') + let l:shiftwidth = shiftwidth() + else + let l:shiftwidth = &shiftwidth + endif + let l:prevlnum = s:FindPrevLnum(v:lnum - 1) + if l:prevlnum == 0 return 0 endif - let l:indent = 0 + let l:shift = 0 let l:prevline = getline(l:prevlnum) - if l:prevline =~# '\v^\s*switch>' - let l:indent = l:shiftwidth * 2 - elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>' - let l:indent = l:shiftwidth + let l:previndent = indent(l:prevlnum) + if s:IsContinuedLine(v:lnum) + " It is customary to increment indentation of continued lines by three + " or a custom value defined by the user if available. + let l:previndent = indent(v:lnum - 1) + if s:IsContinuedLine(v:lnum - 1) + return l:previndent + elseif exists('g:fish_indent_cont') + return l:previndent + g:fish_indent_cont + elseif exists('g:indent_cont') + return l:previndent + g:indent_cont + else + return l:previndent + 3 + endif endif - let l:line = getline(v:lnum) - if l:line =~# '\v^\s*end>' - return indent(v:lnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent) - elseif l:line =~# '\v^\s*%(case|else)>' - return indent(v:lnum) - l:shiftwidth + if l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case|switch)>' + " First line inside a block, increase by one. + let l:shift += 1 + endif + if l:line =~# '\v^\s*%(end|case|else)>' + " "end", "case" or "else", decrease by one. + let l:shift -= 1 + endif + if l:line =~# '\v^\s*' && l:prevline =~# '\v' + " "case" following "switch", increase by one. + let l:shift += 1 + endif + if l:line =~# '\v\s*end>' && s:IsSwitch(v:lnum) + " "end" ends switch block, decrease by one more so it matches + " the indentation of "switch". + let l:shift -= 1 + endif + if l:prevline =~# '\v^\s*%(if|while|for|else|switch|end)>.*' + " "begin" after start of block, increase by one. + let l:shift += 1 endif - return indent(l:prevlnum) + l:indent + let l:indent = l:previndent + l:shift * l:shiftwidth + " Only return zero or positive numbers. + return l:indent < 0 ? 0 : l:indent endfunction function! fish#Format() diff --git a/indent/fish.vim b/indent/fish.vim index d1ef6be..5e780b7 100644 --- a/indent/fish.vim +++ b/indent/fish.vim @@ -1,2 +1,3 @@ setlocal indentexpr=fish#Indent() +setlocal indentkeys=!^F,o,O setlocal indentkeys+==end,=else,=case From b005e8c7c250dcbf7e6753bd9c8dfcbf78e8472e Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Thu, 18 Jun 2015 22:11:40 -0400 Subject: [PATCH 06/33] Small improvements. - funced and fish_indent always uses tabs for indentation, use fish#Indent() to fix it. Works better with the improved fish#Indent(). - ftdetect should contain filetype detection code. Move autocmds to plugin/fish.vim. - Match new funced temp file name. - Add "else", "else if" and "case" to b:match_words to follow what's used by Vim's ftplugins. blankname: - dropped the syntax changes (cc: dag/vim-fish#28) Co-authored-by: blankname <> --- autoload/fish.vim | 2 ++ ftdetect/fish.vim | 19 ++++++------------- ftplugin/fish.vim | 9 ++++++++- plugin/fish.vim | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 plugin/fish.vim diff --git a/autoload/fish.vim b/autoload/fish.vim index 2c4847e..790c20f 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -113,6 +113,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 775e75c..9a462de 100644 --- a/ftdetect/fish.vim +++ b/ftdetect/fish.vim @@ -1,20 +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 setline(1, ['function '.expand('%:t:r'), '', 'end']) | 2 diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index 5430f93..f206429 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -39,8 +39,15 @@ endif " argument to fish instead of man. execute 'setlocal keywordprg=fish\ '.fnameescape(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)>:::' \, '<>%|)') let b:endwise_addition = 'end' diff --git a/plugin/fish.vim b/plugin/fish.vim new file mode 100644 index 0000000..2feb5f3 --- /dev/null +++ b/plugin/fish.vim @@ -0,0 +1,14 @@ +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 From 32530582bc15e1ba4160bb1d3126216d3881f4f7 Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sun, 5 Jan 2020 15:28:49 -0500 Subject: [PATCH 07/33] Add comment explaining our funced BufRead autocommand. --- plugin/fish.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/fish.vim b/plugin/fish.vim index 2feb5f3..987f6cd 100644 --- a/plugin/fish.vim +++ b/plugin/fish.vim @@ -6,8 +6,12 @@ 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$') +" When using funced: +" - Reindent (because funced adds a tab on the first empty line and the user may +" have set expandtab). +" - Move the cursor to the first empty line. +autocmd BufRead fish_funced.* + \ exe 'normal! gg=G' | call search('^\s*\zs$') " Mimic `funced` when manually creating functions. autocmd BufNewFile ~/.config/fish/functions/*.fish From 0dfeda7466a821891c5d3911e7bbe1ff5bcbf419 Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sun, 5 Jan 2020 15:32:10 -0500 Subject: [PATCH 08/33] Handle new and old file names for both the fish univeral env var file and funced files. --- plugin/fish.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/fish.vim b/plugin/fish.vim index 987f6cd..df2e3af 100644 --- a/plugin/fish.vim +++ b/plugin/fish.vim @@ -4,7 +4,8 @@ endif let loaded_fish = 1 " Universal variable storages should not be hand edited. -autocmd BufRead,BufNewFile ~/.config/fish/fishd.* setlocal readonly +autocmd BufRead,BufNewFile ~/.config/fish/fishd.*,~/.config/fish/fish_variables + \ setlocal readonly " When using funced: " - Reindent (because funced adds a tab on the first empty line and the user may @@ -14,5 +15,5 @@ autocmd BufRead fish_funced.* \ exe 'normal! gg=G' | call search('^\s*\zs$') " Mimic `funced` when manually creating functions. -autocmd BufNewFile ~/.config/fish/functions/*.fish +autocmd BufRead fish_funced.*,fish_funced_*_*.fish,/tmp/fish.*/*.fish \ call setline(1, ['function '.expand('%:t:r'), '', 'end']) | 2 From 8c034e81134cf920c4cc02dfceecd165989ddd06 Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sun, 5 Jan 2020 16:20:43 -0500 Subject: [PATCH 09/33] For funced just retab instead of doing a full format (eventually want to change this to only replace the tab if we're editing a new/blank function). --- plugin/fish.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/fish.vim b/plugin/fish.vim index df2e3af..03b9184 100644 --- a/plugin/fish.vim +++ b/plugin/fish.vim @@ -12,7 +12,7 @@ autocmd BufRead,BufNewFile ~/.config/fish/fishd.*,~/.config/fish/fish_variables " have set expandtab). " - Move the cursor to the first empty line. autocmd BufRead fish_funced.* - \ exe 'normal! gg=G' | call search('^\s*\zs$') + \ exe retab | call search('^\s*\zs$') " Mimic `funced` when manually creating functions. autocmd BufRead fish_funced.*,fish_funced_*_*.fish,/tmp/fish.*/*.fish From fc758c6da7d73ccddc2120df451f97e2abf61c5c Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sat, 8 Feb 2020 11:46:11 -0500 Subject: [PATCH 10/33] Fix funced handling and funced emulation. The wrong autocommand was changed in 0dfeda7. Also use BufNewFile instead of BufRead. --- plugin/fish.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/fish.vim b/plugin/fish.vim index 03b9184..5efe6c4 100644 --- a/plugin/fish.vim +++ b/plugin/fish.vim @@ -11,9 +11,9 @@ autocmd BufRead,BufNewFile ~/.config/fish/fishd.*,~/.config/fish/fish_variables " - Reindent (because funced adds a tab on the first empty line and the user may " have set expandtab). " - Move the cursor to the first empty line. -autocmd BufRead fish_funced.* - \ exe retab | call search('^\s*\zs$') +autocmd BufRead fish_funced.*,fish_funced_*_*.fish,/tmp/fish.*/*.fish + \ retab | call search('^\s*\zs$') " Mimic `funced` when manually creating functions. -autocmd BufRead fish_funced.*,fish_funced_*_*.fish,/tmp/fish.*/*.fish +autocmd BufNewFile ~/.config/fish/functions/*.fish \ call setline(1, ['function '.expand('%:t:r'), '', 'end']) | 2 From 8b20c1768913c7c4610a0b42c3705849c80f9195 Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sun, 22 Mar 2020 13:15:13 -0400 Subject: [PATCH 11/33] Remove '/' from iskeyword so that 'w' doesn't skip over entire paths. I didn't remove the iskeyword definition entirely because I believe including '_' and '.' is still useful. Use 'syntax iskeyword @,48-57,-,_,.,/' in the syntax definitions so that '/' is still matched by syntax patterns that use '\k'. cc: dag/vim-fish#44 --- ftplugin/fish.vim | 2 +- syntax/fish.vim | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index f206429..195fdbc 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -13,7 +13,7 @@ setlocal foldexpr=fish#Fold() setlocal formatoptions+=ron1 setlocal formatoptions-=t setlocal include=\\v^\\s*\\.> -setlocal iskeyword=@,48-57,-,_,.,/ +setlocal iskeyword=@,48-57,-,_,. setlocal suffixesadd^=.fish " Use the 'j' format option when available. diff --git a/syntax/fish.vim b/syntax/fish.vim index ad0661b..c2a0b80 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -3,6 +3,7 @@ if exists('b:current_syntax') endif syntax case match +syntax iskeyword @,48-57,-,_,.,/ syntax keyword fishKeyword begin function end syntax keyword fishConditional if else switch From 5155be4b1e3962187442a977a211a62ecf863ec0 Mon Sep 17 00:00:00 2001 From: Mitchell Kember Date: Sat, 27 Nov 2021 11:42:09 -0800 Subject: [PATCH 12/33] Indent continued lines by shiftwidth, not 3 spaces --- autoload/fish.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/autoload/fish.vim b/autoload/fish.vim index 790c20f..5ef2909 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -67,8 +67,6 @@ function! fish#Indent() let l:prevline = getline(l:prevlnum) let l:previndent = indent(l:prevlnum) if s:IsContinuedLine(v:lnum) - " It is customary to increment indentation of continued lines by three - " or a custom value defined by the user if available. let l:previndent = indent(v:lnum - 1) if s:IsContinuedLine(v:lnum - 1) return l:previndent @@ -77,7 +75,7 @@ function! fish#Indent() elseif exists('g:indent_cont') return l:previndent + g:indent_cont else - return l:previndent + 3 + return l:previndent + l:shiftwidth endif endif if l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case|switch)>' From 04285bc045ad51904c7af8a0969879e658304d8e Mon Sep 17 00:00:00 2001 From: blank_name <> Date: Sun, 12 Mar 2023 17:36:41 -0400 Subject: [PATCH 13/33] Attempt to fix errorformat. --- autoload/fish.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/fish.vim b/autoload/fish.vim index 5ef2909..7e10966 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -149,5 +149,5 @@ function! fish#Complete(findstart, base) endfunction function! fish#errorformat() - return '%Afish: %m,%-G%*\\ ^,%-Z%f (line %l):%s' + return '%E%f (line %l):%m,%C%p^%.%#,%-C%.%#' endfunction From 8b0b5a409189686fcb9ccfff3f3d817ee7fcda34 Mon Sep 17 00:00:00 2001 From: Nova Date: Sun, 8 Mar 2020 03:31:46 +0700 Subject: [PATCH 14/33] Filter man through `col` to remove ^H characters --- bin/man.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/man.fish b/bin/man.fish index f8cbdfd..eede386 100755 --- a/bin/man.fish +++ b/bin/man.fish @@ -1 +1 @@ -man $argv +man $argv | col -bf From a1a7aabf54c72695c30360f86a75a4f232d95154 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 16 Mar 2020 06:01:13 +0700 Subject: [PATCH 15/33] Better syntax highlighting --- ftplugin/fish.vim | 2 +- syntax/fish.vim | 49 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index 195fdbc..f9f4d89 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -52,7 +52,7 @@ let b:match_words = escape( let b:endwise_addition = 'end' let b:endwise_words = 'begin,function,if,switch,while,for' -let b:endwise_syngroups = 'fishKeyword,fishConditional,fishRepeat' +let b:endwise_syngroups = 'fishBlock,fishFunction,fishConditional,fishRepeat' let b:undo_ftplugin = " \ setlocal comments< commentstring< define< foldexpr< formatoptions< diff --git a/syntax/fish.vim b/syntax/fish.vim index c2a0b80..cfd9227 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -5,34 +5,55 @@ endif syntax case match syntax iskeyword @,48-57,-,_,.,/ -syntax keyword fishKeyword begin function end +syntax keyword fishBlock begin end syntax keyword fishConditional if else switch syntax keyword fishRepeat while for in syntax keyword fishLabel case +syntax keyword fishControl return break continue exit +syntax keyword fishOperator and or not +syntax keyword fishBoolean true false +syntax keyword fishFunction function nextgroup=fishFunctionName skipwhite +syntax match fishFunctionName /\k\+/ contained + +" http://fishshell.com/docs/current/commands.html +syntax keyword fishCommand abbr alias argparse bg bind block breakpoint + \ builtin cd cdh command commandline complete count dirh dirs disown echo + \ emit eval exec fg fish funced funcsave functions help history isatty jobs + \ math nextd open popd prevd printf prompt_pwd psub pushd pwd random read + \ realpath set set_color source status suspend test time trap type + \ ulimit umask vared wait contains[] +syntax match fishCommand /\v/ + +syntax match fishOperator '\V=\|*\|%\|&\||\|<\|>\|!\|+\|-' syntax match fishComment /#.*/ -syntax match fishSpecial /\\$/ -syntax match fishIdentifier /\$[[:alnum:]_]\+/ -syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ -syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishIdentifier -syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/ -syntax match fishStatement /\v;\s*\zs\k+>/ -syntax match fishCommandSub /\v\(\s*\zs\k+>/ +syntax match fishSpecial /\\\|;\|(\|)/ +syntax match fishArgument /\v(<-+|\s\zs\+)\k*>/ +syntax match fishNumber /\<\d\+\>#\=/ +syntax match fishNumber /\<-\=\.\=\d\+\>#\=/ -syntax region fishLineContinuation matchgroup=fishStatement - \ start='\v^\s*\zs\k+>' skip='\\$' end='$' - \ contains=fishSpecial,fishIdentifier,fishString,fishCharacter,fishStatement,fishCommandSub,fishComment +syntax match fishDeref /\$[[:alnum:]_]\+/ +syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ +syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDeref,fishCharacter +syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]|\\e[a-zA-Z0-9]/ highlight default link fishKeyword Keyword +highlight default link fishBlock fishKeyword +highlight default link fishFunction fishKeyword highlight default link fishConditional Conditional highlight default link fishRepeat Repeat highlight default link fishLabel Label +highlight default link fishCommand Keyword +highlight default link fishFunctionName Function highlight default link fishComment Comment +highlight default link fishOperator Operator highlight default link fishSpecial Special -highlight default link fishIdentifier Identifier +highlight default link fishDeref PreProc highlight default link fishString String +highlight default link fishNumber Number highlight default link fishCharacter Character -highlight default link fishStatement Statement -highlight default link fishCommandSub fishStatement +highlight default link fishArgument Constant +highlight default link fishBoolean Boolean +highlight default link fishControl Exception let b:current_syntax = 'fish' From b7a79658701b20be16643fc9a2feed63725daaa8 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 16 Mar 2020 06:10:41 +0700 Subject: [PATCH 16/33] Fix 'switch' with endwise causing added 'end' to be unindented --- autoload/fish.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/fish.vim b/autoload/fish.vim index 7e10966..fc9cfbd 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -90,9 +90,9 @@ function! fish#Indent() " "case" following "switch", increase by one. let l:shift += 1 endif - if l:line =~# '\v\s*end>' && s:IsSwitch(v:lnum) - " "end" ends switch block, decrease by one more so it matches - " the indentation of "switch". + if l:line =~# '\v\s*end>' && l:prevline !~# '\v' && s:IsSwitch(v:lnum) + " "end" ends switch block, but not immediately following "switch" + " decrease by one more so it matches the indentation of "switch". let l:shift -= 1 endif if l:prevline =~# '\v^\s*%(if|while|for|else|switch|end)>.*' From 6f4725dd21616ff38ec17e0fa078d2ae34d01be1 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 16 Mar 2020 07:16:52 +0700 Subject: [PATCH 17/33] Better syntax highlighting (2) --- syntax/fish.vim | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index cfd9227..b206985 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -5,6 +5,8 @@ endif syntax case match syntax iskeyword @,48-57,-,_,.,/ +syntax cluster fishKeyword contains=fishBlock,fishFunction,fishConditional, + \ fishRepeat,fishLabel,fishControl,fishOperator,fishBoolean,fishCommand syntax keyword fishBlock begin end syntax keyword fishConditional if else switch syntax keyword fishRepeat while for in @@ -23,14 +25,15 @@ syntax keyword fishCommand abbr alias argparse bg bind block breakpoint \ math nextd open popd prevd printf prompt_pwd psub pushd pwd random read \ realpath set set_color source status suspend test time trap type \ ulimit umask vared wait contains[] -syntax match fishCommand /\v/ +syntax match fishCommand /\v/ -syntax match fishOperator '\V=\|*\|%\|&\||\|<\|>\|!\|+\|-' +syntax match fishOperator '[\[\]=*%&|<>!+-]' syntax match fishComment /#.*/ -syntax match fishSpecial /\\\|;\|(\|)/ -syntax match fishArgument /\v(<-+|\s\zs\+)\k*>/ -syntax match fishNumber /\<\d\+\>#\=/ -syntax match fishNumber /\<-\=\.\=\d\+\>#\=/ +syntax match fishSpecial /[\();]/ +syntax match fishSpecial /\zs\$\ze\$/ +syntax match fishArgument /\v<[+-]+\k+>/ +syntax match fishNumber /\v<[+-]=(\d+\.)=\d+>/ syntax match fishDeref /\$[[:alnum:]_]\+/ syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ From 42d53c5e95f372a78edeb6314cea49d50d2c1421 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 16 Mar 2020 07:42:05 +0700 Subject: [PATCH 18/33] Add missing fish_ commands --- syntax/fish.vim | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index b206985..9734eda 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -20,11 +20,14 @@ syntax match fishFunctionName /\k\+/ contained " http://fishshell.com/docs/current/commands.html syntax keyword fishCommand abbr alias argparse bg bind block breakpoint - \ builtin cd cdh command commandline complete count dirh dirs disown echo - \ emit eval exec fg fish funced funcsave functions help history isatty jobs - \ math nextd open popd prevd printf prompt_pwd psub pushd pwd random read - \ realpath set set_color source status suspend test time trap type - \ ulimit umask vared wait contains[] + \ builtin cd cdh command commandline complete contains[] count dirh dirs + \ disown echo emit eval exec fg fish fish_breakpoint_prompt fish_config + \ fish_git_prompt fish_hg_prompt fish_indent fish_key_reader + \ fish_mode_prompt fish_opt fish_prompt fish_right_prompt + \ fish_svn_prompt fish_update_completions fish_vcs_prompt funced funcsave + \ functions help history isatty jobs math nextd open popd prevd printf + \ prompt_pwd psub pushd pwd random read realpath set set_color source + \ status suspend test time trap type ulimit umask vared wait syntax match fishCommand /\v/ From 8b34a65e392514cedbf7e352e28ae15ef864d1b2 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 16 Mar 2020 19:01:26 +0700 Subject: [PATCH 19/33] Add UNIX commands --- syntax/fish.vim | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index 9734eda..01f2d55 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -5,6 +5,21 @@ endif syntax case match syntax iskeyword @,48-57,-,_,.,/ +" https://en.wikipedia.org/wiki/List_of_Unix_commands +syntax keyword fishUnixCommand admin alias ar asa at awk basename batch bc bg + \ cc c99 cal cat cd cflow chgrp chmod chown cksum cmp comm command compress + \ cp crontab csplit ctags cut cxref date dd delta df diff dirname du echo + \ ed env ex expand expr false fc fg file find fold fort77 fuser gencat get + \ getconf getopts grep hash head iconv id ipcrm ipcs jobs join kill lex + \ less link ln locale localedef logger logname lp ls m4 mailx make man mesg + \ mkdir mkfifo more mv newgrp nice nl nm nohup od paste patch pathchk pax + \ pr printf prs ps pwd qalter qdel qhold qmove qmsg qrerun qrls qselect + \ qsig qstat qsub read renice rm rmdel rmdir sact sccs sed sh sleep sort + \ split strings strip stty tabs tail talk tee test time touch tput tr true + \ tsort tty type ulimit umask unalias uname uncompress unexpand unget uniq + \ unlink uucp uudecode uuencode uustat uux val vi wait wc what who + \ write xargs yacc zcat + syntax cluster fishKeyword contains=fishBlock,fishFunction,fishConditional, \ fishRepeat,fishLabel,fishControl,fishOperator,fishBoolean,fishCommand syntax keyword fishBlock begin end @@ -15,9 +30,6 @@ syntax keyword fishControl return break continue exit syntax keyword fishOperator and or not syntax keyword fishBoolean true false -syntax keyword fishFunction function nextgroup=fishFunctionName skipwhite -syntax match fishFunctionName /\k\+/ contained - " http://fishshell.com/docs/current/commands.html syntax keyword fishCommand abbr alias argparse bg bind block breakpoint \ builtin cd cdh command commandline complete contains[] count dirh dirs @@ -31,6 +43,9 @@ syntax keyword fishCommand abbr alias argparse bg bind block breakpoint syntax match fishCommand /\v/ +syntax keyword fishFunction function nextgroup=fishFunctionName skipwhite +syntax match fishFunctionName /\k\+/ contained + syntax match fishOperator '[\[\]=*%&|<>!+-]' syntax match fishComment /#.*/ syntax match fishSpecial /[\();]/ @@ -50,6 +65,7 @@ highlight default link fishConditional Conditional highlight default link fishRepeat Repeat highlight default link fishLabel Label highlight default link fishCommand Keyword +highlight default link fishUnixCommand Keyword highlight default link fishFunctionName Function highlight default link fishComment Comment highlight default link fishOperator Operator From 583d778c95b32ea4ea983693a281a621e799d7f0 Mon Sep 17 00:00:00 2001 From: Nova Date: Tue, 17 Mar 2020 04:55:20 +0700 Subject: [PATCH 20/33] Complete now matches prefix --- autoload/fish.vim | 25 +++++++++++++++++++------ syntax/fish.vim | 4 ++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/autoload/fish.vim b/autoload/fish.vim index fc9cfbd..20184bc 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -136,13 +136,26 @@ function! fish#Complete(findstart, base) endif let l:results = [] let l:completions = - \ system('fish -c "complete -C'.shellescape(a:base).'"') - let l:cmd = substitute(a:base, '\v\S+$', '', '') - for l:line in filter(split(l:completions, '\n'), 'len(v:val)') + \ system('fish -c "complete -C'.shellescape(a:base).'"') + let l:sufpos = match(a:base, '\v\S+$') + if l:sufpos >= 0 + let l:cmd = a:base[:l:sufpos-1] + let l:arg = a:base[l:sufpos:] + else + let l:cmd = a:base + let l:arg = '' + endif + for l:line in filter(split(l:completions, '\n'), '!empty(v:val)') let l:tokens = split(l:line, '\t') - call add(l:results, {'word': l:cmd.l:tokens[0], - \'abbr': l:tokens[0], - \'menu': get(l:tokens, 1, '')}) + let l:term = l:tokens[0] + if l:term =~? '^\V'.l:arg + call add(l:results, { + \ 'word': l:cmd.l:term, + \ 'abbr': l:term, + \ 'menu': get(l:tokens, 1, ''), + \ 'dup': 1 + \ }) + endif endfor return l:results endif diff --git a/syntax/fish.vim b/syntax/fish.vim index 01f2d55..ac5d66e 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -50,7 +50,7 @@ syntax match fishOperator '[\[\]=*%&|<>!+-]' syntax match fishComment /#.*/ syntax match fishSpecial /[\();]/ syntax match fishSpecial /\zs\$\ze\$/ -syntax match fishArgument /\v<[+-]+\k+>/ +syntax match fishOption /\v<[+-]+\k+>/ syntax match fishNumber /\v<[+-]=(\d+\.)=\d+>/ syntax match fishDeref /\$[[:alnum:]_]\+/ @@ -74,7 +74,7 @@ highlight default link fishDeref PreProc highlight default link fishString String highlight default link fishNumber Number highlight default link fishCharacter Character -highlight default link fishArgument Constant +highlight default link fishOption Constant highlight default link fishBoolean Boolean highlight default link fishControl Exception From ea7cfae563c00c859a787121e4186b435876f660 Mon Sep 17 00:00:00 2001 From: Nova Date: Wed, 18 Mar 2020 17:54:50 +0700 Subject: [PATCH 21/33] Support range operator --- syntax/fish.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index ac5d66e..21a06db 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -44,13 +44,19 @@ syntax match fishCommand /\v/ syntax keyword fishFunction function nextgroup=fishFunctionName skipwhite -syntax match fishFunctionName /\k\+/ contained +syntax match fishFunctionName '[^[:space:]/-][^[:space:]/]*' contained + +syntax match fishOperator '[\[\]=*~%&|<>!+-]' +syntax match fishOperator '\.\.' +syntax region fishOperator matchgroup=fishNumber + \ start=/\v<[+-]=(\d+\.)=\d+/ end=/\v[+-](\d+\.)=\d+>/ +syntax region fishOperator matchgroup=fishNumber + \ start=/\v<[+-]=(\d+\.)=\d+/ end=/\v(\d+\.)=\d+>/ -syntax match fishOperator '[\[\]=*%&|<>!+-]' syntax match fishComment /#.*/ syntax match fishSpecial /[\();]/ syntax match fishSpecial /\zs\$\ze\$/ -syntax match fishOption /\v<[+-]+\k+>/ +syntax match fishOption /\v<[+-][[:alnum:]-_]+>/ syntax match fishNumber /\v<[+-]=(\d+\.)=\d+>/ syntax match fishDeref /\$[[:alnum:]_]\+/ From 9fd00b7a0d7b0c2e429e75ab2265532dd1b985b0 Mon Sep 17 00:00:00 2001 From: Nova Date: Thu, 19 Mar 2020 02:49:44 +0700 Subject: [PATCH 22/33] Update b:match_skip for matchit.vim --- ftplugin/fish.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index f9f4d89..c6230a6 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -49,6 +49,7 @@ endif let b:match_words = escape( \'<%(begin|function|'.s:if.'|switch|while|for)>:::' \, '<>%|)') +let b:match_skip = 's:comment\|string\|deref' let b:endwise_addition = 'end' let b:endwise_words = 'begin,function,if,switch,while,for' From 8e443d487b434f1d1e6bbc4a31b9c68f391a9449 Mon Sep 17 00:00:00 2001 From: Nova Date: Thu, 19 Mar 2020 07:17:28 +0700 Subject: [PATCH 23/33] Use :Man for showing man pages on K --- autoload/fish.vim | 32 ++++++++++++++++++++++++++++++++ ftplugin/fish.vim | 3 ++- plugin/fish.vim | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/autoload/fish.vim b/autoload/fish.vim index 20184bc..dcf15f8 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -164,3 +164,35 @@ endfunction function! fish#errorformat() return '%E%f (line %l):%m,%C%p^%.%#,%-C%.%#' endfunction + +function! fish#Help(ref) abort + let l:ref = a:ref + if empty(a:ref) + " let l:ref = &filetype ==# 'man' ? expand('') : expand('') + let l:ref = expand('') + if empty(l:ref) + call s:fish_help_error('no identifier under cursor') + return + endif + endif + let l:output = systemlist('fish -c "man -w ' . shellescape(l:ref) . '"') + if v:shell_error + call s:fish_help_error(printf('command exited with code %d: %s', v:shell_error, join(l:output))) + return + endif + aug ft_man_fish + au FileType man + \ setlocal nobuflisted + \ | setlocal keywordprg=:FishHelp' + \ | nnoremap K :FishHelp + \ | nnoremap :FishHelp + aug END + execute 'Man ' . l:output[0] + silent aug! ft_man_fish +endfunction + +function! s:fish_help_error(message) + echohl ErrorMsg + echon 'FishHelp: ' a:message + echohl NONE +endfunction diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index c6230a6..8674b89 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -37,7 +37,8 @@ endif " Use the 'man' wrapper function in fish to include fish's man pages. " Have to use a script for this; 'fish -c man' would make the the man page an " argument to fish instead of man. -execute 'setlocal keywordprg=fish\ '.fnameescape(expand(':p:h:h').'/bin/man.fish') +" execute 'setlocal keywordprg=fish\ '.fnameescape(expand(':p:h:h').'/bin/man.fish') +setlocal keywordprg=:FishHelp let b:match_ignorecase = 0 if has('patch-7.3.1037') diff --git a/plugin/fish.vim b/plugin/fish.vim index 5efe6c4..4283117 100644 --- a/plugin/fish.vim +++ b/plugin/fish.vim @@ -17,3 +17,5 @@ autocmd BufRead fish_funced.*,fish_funced_*_*.fish,/tmp/fish.*/*.fish " Mimic `funced` when manually creating functions. autocmd BufNewFile ~/.config/fish/functions/*.fish \ call setline(1, ['function '.expand('%:t:r'), '', 'end']) | 2 + +command! -nargs=? FishHelp call fish#Help() From 230759b29a05639ebfb8b14a9a92a25ab93a58ec Mon Sep 17 00:00:00 2001 From: Nova Date: Thu, 19 Mar 2020 08:10:00 +0700 Subject: [PATCH 24/33] Remove '/' from iskeyword --- ftplugin/fish.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index 8674b89..1ade3f6 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -13,7 +13,7 @@ setlocal foldexpr=fish#Fold() setlocal formatoptions+=ron1 setlocal formatoptions-=t setlocal include=\\v^\\s*\\.> -setlocal iskeyword=@,48-57,-,_,. +setlocal iskeyword=@,48-57,+,-,_,. setlocal suffixesadd^=.fish " Use the 'j' format option when available. From f360c91bb65ba0abc0dae49a68d22ee54ceee47b Mon Sep 17 00:00:00 2001 From: Nova Date: Thu, 19 Mar 2020 23:10:31 +0700 Subject: [PATCH 25/33] Drop range operator --- syntax/fish.vim | 5 ----- 1 file changed, 5 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index 21a06db..a05670c 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -47,11 +47,6 @@ syntax keyword fishFunction function nextgroup=fishFunctionName skipwhite syntax match fishFunctionName '[^[:space:]/-][^[:space:]/]*' contained syntax match fishOperator '[\[\]=*~%&|<>!+-]' -syntax match fishOperator '\.\.' -syntax region fishOperator matchgroup=fishNumber - \ start=/\v<[+-]=(\d+\.)=\d+/ end=/\v[+-](\d+\.)=\d+>/ -syntax region fishOperator matchgroup=fishNumber - \ start=/\v<[+-]=(\d+\.)=\d+/ end=/\v(\d+\.)=\d+>/ syntax match fishComment /#.*/ syntax match fishSpecial /[\();]/ From d099a3c07f3a4b0d8f0c4557e3dc516d7d21aa58 Mon Sep 17 00:00:00 2001 From: Nova Date: Sun, 22 Mar 2020 18:44:09 +0700 Subject: [PATCH 26/33] Multiple dereferencing --- syntax/fish.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index a05670c..81c5417 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -50,11 +50,10 @@ syntax match fishOperator '[\[\]=*~%&|<>!+-]' syntax match fishComment /#.*/ syntax match fishSpecial /[\();]/ -syntax match fishSpecial /\zs\$\ze\$/ syntax match fishOption /\v<[+-][[:alnum:]-_]+>/ syntax match fishNumber /\v<[+-]=(\d+\.)=\d+>/ -syntax match fishDeref /\$[[:alnum:]_]\+/ +syntax match fishDeref /\$\+[[:alnum:]_]\+/ syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDeref,fishCharacter syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]|\\e[a-zA-Z0-9]/ From 1a97744fbd3692e7061651acde4b712f46427ed1 Mon Sep 17 00:00:00 2001 From: Nova Date: Tue, 17 Mar 2020 07:02:31 +0700 Subject: [PATCH 27/33] (comment) errorformat Author: Nova Date: Wed Mar 25 17:33:36 2020 +0700 --- autoload/fish.vim | 1 + compiler/fish.vim | 1 + 2 files changed, 2 insertions(+) diff --git a/autoload/fish.vim b/autoload/fish.vim index dcf15f8..e8731f9 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -163,6 +163,7 @@ endfunction function! fish#errorformat() return '%E%f (line %l):%m,%C%p^%.%#,%-C%.%#' + " return '%A<%t> fish: %m,%Efish: %m,%E%f (line %l): %m,%E%f (line %l):%.%#,%-Z%p^,%Ein %m,%Z called on line %l of file %f,%Ein %m,%C%s,%-G%.%#' endfunction function! fish#Help(ref) abort diff --git a/compiler/fish.vim b/compiler/fish.vim index 21fad71..59f00b7 100644 --- a/compiler/fish.vim +++ b/compiler/fish.vim @@ -5,3 +5,4 @@ let current_compiler = 'fish' CompilerSet makeprg=fish\ --no-execute\ % execute 'CompilerSet errorformat='.escape(fish#errorformat(), ' ') +" execute 'CompilerSet errorformat='.escape(fish#errorformat(), ' ') From 1c62bcd89bbba9b16bfabfe876071112f269f478 Mon Sep 17 00:00:00 2001 From: Nova Date: Fri, 27 Mar 2020 04:21:04 +0700 Subject: [PATCH 28/33] Syntax: Dereferencing extension --- syntax/fish.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index 81c5417..853130b 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -44,18 +44,23 @@ syntax match fishCommand /\v/ syntax keyword fishFunction function nextgroup=fishFunctionName skipwhite -syntax match fishFunctionName '[^[:space:]/-][^[:space:]/]*' contained +syntax match fishFunctionName '[^[:space:]/()-][^[:space:]/()]*' contained + \ contains=fishString,fishDeref syntax match fishOperator '[\[\]=*~%&|<>!+-]' +syntax match fishOperator '\.\.' syntax match fishComment /#.*/ syntax match fishSpecial /[\();]/ +syntax match fishSpecial /"/ syntax match fishOption /\v<[+-][[:alnum:]-_]+>/ syntax match fishNumber /\v<[+-]=(\d+\.)=\d+>/ -syntax match fishDeref /\$\+[[:alnum:]_]\+/ +syntax match fishDeref /\$\+[[:alnum:]_]\+/ nextgroup=fishDerefExtension +syntax region fishDerefExtension matchgroup=fishOperator start=/\[/ end=/\]/ contains=fishDeref,fishNumber,fishOperator contained + syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ -syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDeref,fishCharacter +syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDeref,fishDerefExtension,fishCharacter syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]|\\e[a-zA-Z0-9]/ highlight default link fishKeyword Keyword From 5d1396353474114456abdc5e828b8ac8e4459e4d Mon Sep 17 00:00:00 2001 From: Nova Date: Thu, 2 Apr 2020 20:31:52 +0700 Subject: [PATCH 29/33] Add string escape highlight --- syntax/fish.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index 853130b..d82aa45 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -59,8 +59,12 @@ syntax match fishNumber /\v<[+-]=(\d+\.)=\d+>/ syntax match fishDeref /\$\+[[:alnum:]_]\+/ nextgroup=fishDerefExtension syntax region fishDerefExtension matchgroup=fishOperator start=/\[/ end=/\]/ contains=fishDeref,fishNumber,fishOperator contained -syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ -syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDeref,fishDerefExtension,fishCharacter +syntax match fishSingleQuoteEscape /\\[\\']/ contained +syntax match fishDoubleQuoteEscape /\\[\\"$\n]/ contained +syntax cluster fishStringEscape contains=fishSingleQuoteEscape,fishDoubleQuoteEscape + +syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ contains=fishSingleQuoteEscape +syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDoubleQuoteEscape,fishDeref,fishDerefExtension,fishCharacter syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]|\\e[a-zA-Z0-9]/ highlight default link fishKeyword Keyword @@ -77,6 +81,8 @@ highlight default link fishOperator Operator highlight default link fishSpecial Special highlight default link fishDeref PreProc highlight default link fishString String +highlight default link fishSingleQuoteEscape Special +highlight default link fishDoubleQuoteEscape Special highlight default link fishNumber Number highlight default link fishCharacter Character highlight default link fishOption Constant From 34b27be694bd04c59500379017711b2bae4f75d0 Mon Sep 17 00:00:00 2001 From: Nova Date: Sun, 5 Apr 2020 05:06:22 +0700 Subject: [PATCH 30/33] Fix syntax for fish \e character --- syntax/fish.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index d82aa45..52b0bb4 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -65,7 +65,8 @@ syntax cluster fishStringEscape contains=fishSingleQuoteEscape,fishDoubleQuoteEs syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ contains=fishSingleQuoteEscape syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDoubleQuoteEscape,fishDeref,fishDerefExtension,fishCharacter -syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]|\\e[a-zA-Z0-9]/ +syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/ +syntax match fishCharacter /\v\\e[a-zA-Z0-9]/ highlight default link fishKeyword Keyword highlight default link fishBlock fishKeyword From b0b8195de8daf0e3917e8ee0a619fc4d6f5eb9d1 Mon Sep 17 00:00:00 2001 From: Nova Date: Sun, 5 Apr 2020 21:06:49 +0700 Subject: [PATCH 31/33] Add \0 to fishCharacteR --- syntax/fish.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index 52b0bb4..a91ba50 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -65,7 +65,7 @@ syntax cluster fishStringEscape contains=fishSingleQuoteEscape,fishDoubleQuoteEs syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ contains=fishSingleQuoteEscape syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDoubleQuoteEscape,fishDeref,fishDerefExtension,fishCharacter -syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/ +syntax match fishCharacter /\v\\[0abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/ syntax match fishCharacter /\v\\e[a-zA-Z0-9]/ highlight default link fishKeyword Keyword From 7bae3f7265bd0a6ae09c9ff632a4c21f89c37278 Mon Sep 17 00:00:00 2001 From: Nova Date: Tue, 7 Apr 2020 18:06:45 +0700 Subject: [PATCH 32/33] Indent command substitution --- autoload/fish.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/autoload/fish.vim b/autoload/fish.vim index e8731f9..4b1ea21 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -9,6 +9,11 @@ function! s:IsContinuedLine(lnum) return getline(a:lnum - 1) =~ '\v\\$' endfunction +function! s:IsInSubstitution(lnum) + " Returns "true" if the given line is a continued line. + return getline(a:lnum - 1) =~ '\v\($' +endfunction + function! s:FindPrevLnum(lnum) " Starting on the given line, search backwards for a line that is not " empty, not part of a string and not a continued line. @@ -78,6 +83,14 @@ function! fish#Indent() return l:previndent + l:shiftwidth endif endif + if l:prevline =~ '(\s*$' + " Inside a substitution + let l:shift += 1 + endif + if l:line =~ '^\s*)' + " Outside a substitution + let l:shift -= 1 + endif if l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case|switch)>' " First line inside a block, increase by one. let l:shift += 1 From 4ad8980c84fbcfa66cb6171e1be51c0c03a566e7 Mon Sep 17 00:00:00 2001 From: Nova Date: Thu, 9 Apr 2020 04:03:25 +0700 Subject: [PATCH 33/33] Fix fish escaping $ --- syntax/fish.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/fish.vim b/syntax/fish.vim index a91ba50..c36a4c4 100644 --- a/syntax/fish.vim +++ b/syntax/fish.vim @@ -52,7 +52,7 @@ syntax match fishOperator '\.\.' syntax match fishComment /#.*/ syntax match fishSpecial /[\();]/ -syntax match fishSpecial /"/ +syntax match fishSpecial /\\\$/ syntax match fishOption /\v<[+-][[:alnum:]-_]+>/ syntax match fishNumber /\v<[+-]=(\d+\.)=\d+>/ @@ -64,7 +64,7 @@ syntax match fishDoubleQuoteEscape /\\[\\"$\n]/ contained syntax cluster fishStringEscape contains=fishSingleQuoteEscape,fishDoubleQuoteEscape syntax region fishString start=/'/ skip=/\v(\\{2})|(\\)'/ end=/'/ contains=fishSingleQuoteEscape -syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDoubleQuoteEscape,fishDeref,fishDerefExtension,fishCharacter +syntax region fishString start=/"/ skip=/\v(\\{2})|(\\)"/ end=/"/ contains=fishDoubleQuoteEscape,fishDeref,fishDerefExtension syntax match fishCharacter /\v\\[0abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/ syntax match fishCharacter /\v\\e[a-zA-Z0-9]/