diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 72d37f6088..ef5b16ff42 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -391,4 +391,10 @@ highlighting. So do these: You can find the details in $VIMRUNTIME/syntax/help.vim +FILETYPE COMPLETION *ft-help-omni* + +To get completion for help tags when writing a tag reference, you can use the +|i_CTRL-X_CTRL-O| command. + + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index d67c78adb5..02c0c7e95a 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -118,6 +118,7 @@ DIAGNOSTICS EDITOR • |:iput| works like |:put| but adjusts indent. +• |omnicompletion| in `help` buffer. |ft-help-omni| EVENTS diff --git a/runtime/ftplugin/help.vim b/runtime/ftplugin/help.vim index 833baf5d8f..0109c1752c 100644 --- a/runtime/ftplugin/help.vim +++ b/runtime/ftplugin/help.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file " Language: Vim help file " Previous Maintainer: Nikolai Weibull -" Latest Revision: 2018-12-29 +" Last Change: 2025 Apr 08 +" 2025 Apr 08 by Vim project (set 'omnifunc' and 'iskeyword', #17073) if exists("b:did_ftplugin") finish @@ -11,15 +12,33 @@ let b:did_ftplugin = 1 let s:cpo_save = &cpo set cpo&vim -let b:undo_ftplugin = "setl fo< tw< cole< cocu< keywordprg<" +let b:undo_ftplugin = "setl isk< fo< tw< cole< cocu< keywordprg< omnifunc<" -setlocal formatoptions+=tcroql textwidth=78 +setlocal formatoptions+=tcroql textwidth=78 keywordprg=:help omnifunc=s:HelpComplete +let &l:iskeyword='!-~,^*,^|,^",192-255' if has("conceal") setlocal cole=2 cocu=nc endif -" Prefer Vim help instead of manpages. -setlocal keywordprg=:help +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