Files
vim/runtime/ftplugin/help.vim
T
zeertzjq c23bfd7922 runtime(help): fix wrong check for existing HelpComplete function
To check for an existing HelpComplete function, exists('*HelpComplete')
should be used, as exists('HelpComplete') still returns 0 after sourcing
the ftplugin.

closes: #20073

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2026-04-26 14:36:23 +00:00

49 lines
1.4 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)
" 2025 Aug 08 by Vim project (unset comment options, #17889)
" 2026 Apr 26 by Vim project (make HelpComplete global, #20024)
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< comments< cms<"
setl comments= cms=
setlocal formatoptions+=tcroql textwidth=78 keywordprg=:help omnifunc=HelpComplete
let &l:iskeyword='!-~,^*,^|,^",192-255'
if has("conceal")
setlocal cole=2 cocu=nc
endif
if !exists('*HelpComplete')
func 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