mirror of
https://github.com/vim/vim
synced 2025-04-29 21:07:49 +02:00
Problem: - Help tags provide a good way to navigate the Vim documentation, but many help documents don't use them effectively. I think one of the reasons is that help writers have to look up help tags manually with `:help` command, which is not very convenient. - 'iskeyword' is only set for help buffers opened by `:help` command. That means if I'm editing a help file, I cannot jump to tag in same file using `Ctrl-]` unless I manually set it, which is annoying. Solution: - Add omni completion for Vim help tags. - Set 'iskeyword' for `ft-help` closes: #17073 Co-authored-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Phạm Bình An <phambinhanctb2004@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
44 lines
1.2 KiB
VimL
44 lines
1.2 KiB
VimL
" Vim filetype plugin file
|
|
" Language: Vim help file
|
|
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
|
" Last Change: 2025 Apr 08
|
|
" 2025 Apr 08 by Vim project (set 'omnifunc' and 'iskeyword', #17073)
|
|
|
|
if exists("b:did_ftplugin")
|
|
finish
|
|
endif
|
|
let b:did_ftplugin = 1
|
|
|
|
let s:cpo_save = &cpo
|
|
set cpo&vim
|
|
|
|
let b:undo_ftplugin = "setl isk< fo< tw< cole< cocu< keywordprg< omnifunc<"
|
|
|
|
setlocal formatoptions+=tcroql textwidth=78 keywordprg=:help omnifunc=s:HelpComplete
|
|
let &l:iskeyword='!-~,^*,^|,^",192-255'
|
|
if has("conceal")
|
|
setlocal cole=2 cocu=nc
|
|
endif
|
|
|
|
if !exists('*s:HelpComplete')
|
|
func s:HelpComplete(findstart, base)
|
|
if a:findstart
|
|
let colnr = col('.') - 1 " Get the column number before the cursor
|
|
let line = getline('.')
|
|
for i in range(colnr - 1, 0, -1)
|
|
if line[i] ==# '|'
|
|
return i + 1 " Don't include the `|` in base
|
|
elseif line[i] ==# "'"
|
|
return i " Include the `'` in base
|
|
endif
|
|
endfor
|
|
else
|
|
return taglist('^' .. a:base)
|
|
\ ->map({_, item -> #{word: item->get('name'), kind: item->get('kind')}})
|
|
\ ->extend(getcompletion(a:base, 'help'))
|
|
endif
|
|
endfunc
|
|
endif
|
|
|
|
let &cpo = s:cpo_save
|
|
unlet s:cpo_save
|