runtime(help): add omni completion and 'iskeyword' to filetype plugin

Commit: 
https://github.com/vim/vim/commit/0b540c6f381c63c2d80cc0aaef76b0df008b9f86
Author: Phạm Bình An <phambinhanctb2...@gmail.com>
Date:   Tue Apr 8 20:40:12 2025 +0200

    runtime(help): add omni completion and 'iskeyword' to filetype plugin
    
    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 <c...@256bit.org>
    Signed-off-by: Phạm Bình An <phambinhanctb2...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt
index 7b9dd7671..26804d546 100644
--- a/runtime/doc/helphelp.txt
+++ b/runtime/doc/helphelp.txt
@@ -1,4 +1,4 @@
-*helphelp.txt* For Vim version 9.1.  Last change: 2025 Jan 11
+*helphelp.txt* For Vim version 9.1.  Last change: 2025 Apr 08
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -471,8 +471,13 @@ highlighting.  So do these:
 You can find the details in $VIMRUNTIME/syntax/help.vim
 
 
-GENDER NEUTRAL LANGUAGE
+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.
 
+
+GENDER NEUTRAL LANGUAGE
                                                *gender-neutral* *inclusion*
 Vim is for everybody, no matter race, gender or anything.  For new or updated
 help text, gender neutral language is recommended.  Some of the help text is
diff --git a/runtime/doc/tags b/runtime/doc/tags
index e55623dad..e0006da54 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -7394,6 +7394,7 @@ ft-groff-syntax   syntax.txt      /*ft-groff-syntax*
 ft-gsp-syntax  syntax.txt      /*ft-gsp-syntax*
 ft-hare        filetype.txt    /*ft-hare*
 ft-haskell-syntax      syntax.txt      /*ft-haskell-syntax*
+ft-help-omni   helphelp.txt    /*ft-help-omni*
 ft-html-indent indent.txt      /*ft-html-indent*
 ft-html-omni   insert.txt      /*ft-html-omni*
 ft-html-syntax syntax.txt      /*ft-html-syntax*
diff --git a/runtime/ftplugin/help.vim b/runtime/ftplugin/help.vim
index b619a7573..0109c1752 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 <n...@bitwi.se>
-" 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,12 +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 keywordprg=:help
+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

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1u2EB3-008aPQ-32%40256bit.org.

Raspunde prin e-mail lui