mirror of
https://github.com/vim/vim.git
synced 2025-07-24 10:45:12 -04:00
runtime(vim): Update ftplugin, fix option variable 'keywordprg' matching
- Match &option, and &[lg]:option variables. - Match commands after :bar. - Fix matching of pre and post context text. - Style - use '..' for string concatenation. Fixes issue #17567.  Signed-off-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
parent
523f9f5898
commit
cde093c2b9
@ -1,9 +1,9 @@
|
|||||||
" Vim filetype plugin
|
" Vim filetype plugin
|
||||||
" Language: Vim
|
" Language: Vim
|
||||||
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||||
" Last Change: 2025 Mar 05
|
" Last Change: 2025 Jul 03
|
||||||
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Contributors: Riley Bruins <ribru17@gmail.com> ('commentstring'),
|
" Contributors: Riley Bruins <ribru17@gmail.com> ('commentstring')
|
||||||
" @Konfekt
|
" @Konfekt
|
||||||
" @tpope (s:Help())
|
" @tpope (s:Help())
|
||||||
|
|
||||||
@ -56,41 +56,42 @@ if !exists("*" .. expand("<SID>") .. "Help")
|
|||||||
function s:Help(topic) abort
|
function s:Help(topic) abort
|
||||||
let topic = a:topic
|
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)
|
if get(g:, 'syntax_on', 0)
|
||||||
let syn = synIDattr(synID(line('.'), col('.'), 1), 'name')
|
let syn = synIDattr(synID(line('.'), col('.'), 1), 'name')
|
||||||
if syn ==# 'vimFuncName'
|
if syn ==# 'vimFuncName'
|
||||||
return topic.'()'
|
return topic .. '()'
|
||||||
elseif syn ==# 'vimOption'
|
elseif syn ==# 'vimOption' || syn ==# 'vimOptionVarName'
|
||||||
return "'".topic."'"
|
return "'" .. topic .. "'"
|
||||||
elseif syn ==# 'vimUserAttrbKey'
|
elseif syn ==# 'vimUserCmdAttrKey'
|
||||||
return ':command-'.topic
|
return ':command-' .. topic
|
||||||
elseif syn =~# 'vimCommand'
|
elseif syn ==# 'vimCommand'
|
||||||
return ':'.topic
|
return ':' .. topic
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let col = col('.') - 1
|
if pre =~# '^\s*:\=$' || pre =~# '\%(\\\||\)\@<!|\s*:\=$'
|
||||||
while col && getline('.')[col] =~# '\k'
|
return ':' .. topic
|
||||||
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
|
|
||||||
elseif pre =~# '\<v:$'
|
elseif pre =~# '\<v:$'
|
||||||
return 'v:'.topic
|
return 'v:' .. topic
|
||||||
elseif pre =~# '<$'
|
elseif pre =~# '<$'
|
||||||
return '<'.topic.'>'
|
return '<' .. topic .. '>'
|
||||||
elseif pre =~# '\\$'
|
elseif pre =~# '\\$'
|
||||||
return '/\'.topic
|
return '/\' .. topic
|
||||||
elseif topic ==# 'v' && post =~# ':\w\+'
|
elseif topic ==# 'v' && post =~# ':\w\+'
|
||||||
return 'v'.matchstr(post, ':\w\+')
|
return 'v' .. matchstr(post, ':\w\+')
|
||||||
|
elseif pre =~# '&\%([lg]:\)\='
|
||||||
|
return "'" .. topic "'"
|
||||||
else
|
else
|
||||||
return topic
|
return topic
|
||||||
endif
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user