This commit is contained in:
Khaveesh N (MBP) 2021-09-28 20:38:55 +05:30
parent cf759d1ac4
commit d80e11fbbc
No known key found for this signature in database
GPG key ID: CB82DEC6404CD52E
4 changed files with 10 additions and 55 deletions

View file

@ -12,7 +12,9 @@ you can use any plugin manager you like.
- Syntax highlighting and filetype detection, of course.
- Code formatting with `fish_indent`.
- Fold expressions for automatic folding.
- Omni-complete from fish using the `^X^O` command.
- Comment strings & matchit patterns.
For everything above to work you need to have fish installed in `$PATH`
and some Vim features turned on. First, tell Vim to use the syntax and
@ -30,7 +32,7 @@ The above commands are required only for Vim and not for NeoVim.
Vim needs a more POSIX compatible shell than fish for certain
functionality to work, such as `:%!`, compressed help pages and many
third-party addons. If you use fish as your login shell or launch Vim
from fish, you need to set `shell` to something else in your `~/.vimrc`,
from fish, you need to set `shell` to something else in your `vimrc`,
for example:
``` {.vim}

View file

@ -42,35 +42,3 @@ function! fish#Complete(findstart, base) abort
return l:results
endif
endfunction
function! fish#Help(ref) abort
let l:ref = a:ref
if empty(a:ref)
" let l:ref = &filetype ==# 'man' ? expand('<cWORD>') : expand('<cword>')
let l:ref = expand('<cword>')
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 <silent> <buffer> K :FishHelp<cr>
\ | nnoremap <silent> <buffer> <C-]> :FishHelp<cr>
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

View file

@ -1,4 +1,4 @@
au BufNewFile,BufRead *.fish setfiletype fish
autocmd BufNewFile,BufRead *.fish setfiletype fish
" Detect fish scripts by the shebang line.
autocmd BufNewFile,BufRead,StdinReadPost *

View file

@ -10,43 +10,28 @@ setlocal comments=:#
setlocal commentstring=#%s
setlocal define=\\v^\\s*function>
setlocal foldexpr=fish#Fold()
setlocal formatoptions+=n1
setlocal formatoptions+=jn1
setlocal formatoptions-=t
setlocal include=\\v^\\s*\\.>
setlocal iskeyword=@,48-57,+,-,_,.
setlocal suffixesadd^=.fish
" Use the 'j' format option when available.
if v:version ># 703 || v:version ==# 703 && has('patch541')
setlocal formatoptions+=j
endif
if executable('fish')
setlocal omnifunc=fish#Complete
setlocal formatprg=fish_indent
endif
command! -nargs=? FishHelp call fish#Help(<q-args>)
setlocal keywordprg=:FishHelp
let b:match_ignorecase = 0
if has('patch-7.3.1037')
let s:if = '%(else\s\+)\@15<!if'
else
let s:if = '%(else\s\+)\@<!if'
endif
let b:match_words = escape(
\'<%(begin|function|'.s:if.'|switch|while|for)>:<else\s\+if|case>:<else>:<end>'
\, '<>%|)')
\ '<%(begin|function|%(else\s\+)\@15<!if|switch|while|for)>'
\ . ':<else\s\+if|case>:<else>:<end>',
\ '<>%|)')
let b:match_skip = 's:comment\|string\|deref'
let b:undo_ftplugin = "
\ setlocal comments< commentstring< define< foldexpr< formatoptions<
\|setlocal include< iskeyword< suffixesadd<
\|setlocal formatexpr< omnifunc< formatprg< path< keywordprg<
\|unlet! b:match_words
\ | setlocal include< iskeyword< suffixesadd< omnifunc< formatprg<
\ | unlet! b:match_words b:match_skip b:match_ignorecase
\"
let &cpo = s:save_cpo