#}}}1
# Core {{{1
def HandlePackaddLine(editcmd: string, curline: string) #{{{2
- var pat: string = '^\s*packadd!\=\s\+\zs\S\+$'
+ var pat: string = '^\s*\%(:\s*\)\=packadd!\=\s\+\zs\S\+$'
var plugin: string = curline
->matchstr(pat)
->substitute('^vim-\|\.vim$', '', 'g')
endtry
else
var split: string = editcmd[0] == 'g' ? 'edit' : editcmd[1] == 'g' ? 'tabedit' : 'split'
- # In the past, we passed `runtime` to `getcompletion()`, instead of
- # `cmdline`. But the output was tricky to use, because it contained
- # paths relative to inconsistent root directories.
- var files: list<string> = getcompletion($'edit **/plugin/{plugin}.vim', 'cmdline')
+ var files: list<string> = getcompletion($'plugin/{plugin}', 'runtime')
+ ->map((_, fname: string) => fname->findfile(&rtp)->fnamemodify(':p'))
->filter((_, path: string): bool => filereadable(path))
- ->map((_, fname: string) => fname->fnamemodify(':p'))
if empty(files)
echo 'Could not find any plugin file for ' .. string(plugin)
return
enddef
def HandleColoLine(editcmd: string, curline: string) #{{{2
- var pat: string = '^\s*colo\%[rscheme]\s\+\zs\S\+$'
+ var pat: string = '^\s*\%(:\s*\)\=colo\%[rscheme]\s\+\zs\S\+$'
var colo: string = curline->matchstr(pat)
if colo == ''
def HandleImportLine(editcmd: string, curline: string) #{{{2
var fname: string
- var import_cmd: string = '^\s*import\s\+\%(autoload\s\+\)\='
+ var import_cmd: string = '^\s*\%(:\s*\)\=import\s\+\%(autoload\s\+\)\='
var import_alias: string = '\%(\s\+as\s\+\w\+\)\=$'
var import_string: string = import_cmd .. '\([''"]\)\zs.*\ze\1' .. import_alias
var import_expr: string = import_cmd .. '\zs.*\ze' .. import_alias
" Last Change: 2025 Aug 07
" 2025 Aug 06 by Vim Project (add gf maps #17881)
" 2025 Aug 08 by Vim Project (add Vim script complete function #17871)
+" 2025 Aug 12 by Vim Project (improve vimgoto script #17970))
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
xnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
- " Purpose: Handle `:import` and `:packadd` lines in a smarter way. {{{
+ " Purpose: Handle :import, :colorscheme and :packadd lines in a smarter way. {{{
"
" `:import` is followed by a filename or filepath. Find it.
"
" buffer.
" }}}
" We use the `F` variants, instead of the `f` ones, because they're smarter.
- nnoremap <silent><buffer> gf :<C-U>call vim#Find('gF')<CR>
- nnoremap <silent><buffer> <C-W>f :<C-U>call vim#Find("\<lt>C-W>F")<CR>
- nnoremap <silent><buffer> <C-W>gf :<C-U>call vim#Find("\<lt>C-W>gF")<CR>
+ " See $VIMRUNTIME/autoload/vimgoto.vim
+ nnoremap <silent><buffer> gf :<C-U>call vimgoto#Find('gF')<CR>
+ nnoremap <silent><buffer> <C-W>f :<C-U>call vimgoto#Find("\<lt>C-W>F")<CR>
+ nnoremap <silent><buffer> <C-W>gf :<C-U>call vimgoto#Find("\<lt>C-W>gF")<CR>
endif
" Let the matchit plugin know what items can be matched.