runtime(vim): Update ftplugin, fix option variable 'keywordprg' matching
Commit:
https://github.com/vim/vim/commit/c65643cbec4f5a77a2d30232c64c258b5f0f5c09
Author: Doug Kearns <[email protected]>
Date: Sat Aug 9 23:41:21 2025 +0200
runtime(vim): Update ftplugin, fix option variable 'keywordprg' matching
- Match &option, and &[lg]:option variables.
- Match Ex commands after :bar.
- Fix matching of pre and post context text.
- Style - use '..' for string concatenation.
fixes #17567
closes: #17653
Signed-off-by: Doug Kearns <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim
index 5ee3812b4..fa2135eb4 100644
--- a/runtime/ftplugin/vim.vim
+++ b/runtime/ftplugin/vim.vim
@@ -1,8 +1,9 @@
" Vim filetype plugin
" Language: Vim
" Maintainer: Doug Kearns <[email protected]>
+" Last Change: 2025 Aug 07
" Former Maintainer: Bram Moolenaar <[email protected]>
-" Contributors: Riley Bruins <[email protected]> ('commentstring'),
+" Contributors: Riley Bruins <[email protected]> ('commentstring')
" @Konfekt
" @tpope (s:Help())
" @lacygoill
@@ -62,41 +63,42 @@ if !exists("*" .. expand("<SID>") .. "Help")
function s:Help(topic) abort
let topic = a:topic
+ " keyword is not necessarily under the cursor, see :help K
+ let line = getline('.')
+ let i = match(line, '\V' .. escape(topic, '\'), col('.') - len(topic))
+ let pre = strpart(line, 0, i)
+ let post = strpart(line, i + len(topic))
+
+ " local/global option vars
+ if topic =~# '[lg]' && pre ==# '&' && post =~# ':\k\+'
+ let topic = matchstr(post, '\k\+')
+ endif
+
if get(g:, 'syntax_on', 0)
let syn = synIDattr(synID(line('.'), col('.'), 1), 'name')
if syn ==# 'vimFuncName'
- return topic.'()'
- elseif syn ==# 'vimOption'
- return "'".topic."'"
- elseif syn ==# 'vimUserAttrbKey'
- return ':command-'.topic
- elseif syn =~# 'vimCommand'
- return ':'.topic
+ return topic .. '()'
+ elseif syn ==# 'vimOption' || syn ==# 'vimOptionVarName'
+ return "'" .. topic .. "'"
+ elseif syn ==# 'vimUserCmdAttrKey'
+ return ':command-' .. topic
+ elseif syn ==# 'vimCommand'
+ return ':' .. topic
endif
endif
- let col = col('.') - 1
- while col && getline('.')[col] =~# '\k'
- let col -= 1
- endwhile
- let pre = col == 0 ? '' : getline('.')[0 : col]
-
- let col = col('.') - 1
- while col && getline('.')[col] =~# '\k'
- let col += 1
- endwhile
- let post = getline('.')[col : -1]
-
- if pre =~# '^\s*:\=$'
- return ':'.topic
+ if pre =~# '^\s*:\=$' || pre =~# '\%(\\||\)\@<!|\s*:\=$'
+ return ':' .. topic
elseif pre =~# '\<v:$'
- return 'v:'.topic
+ return 'v:' .. topic
elseif pre =~# '<$'
- return '<'.topic.'>'
+ return '<' .. topic .. '>'
elseif pre =~# '\$'
- return '/\'.topic
+ return '/\' .. topic
elseif topic ==# 'v' && post =~# ':\w\+'
- return 'v'.matchstr(post, ':\w\+')
+ return 'v' .. matchstr(post, ':\w\+')
+ elseif pre =~# '&\%([lg]:\)\=$'
+ return "'" .. topic .. "'"
else
return topic
endif
--
--
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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1ukrNF-005BAF-09%40256bit.org.