runtime(vim): cannot jump to :colorscheme files
Commit:
https://github.com/vim/vim/commit/487dd1716a028efd0cc1bc1b4bfdc53b82688641
Author: Shane-XB-Qian <[email protected]>
Date: Tue Aug 12 21:14:58 2025 +0200
runtime(vim): cannot jump to :colorscheme files
Problem: cannot jump to :colorscheme files
Solution: Let runtime/autoload/vim.vim handle :colorscheme lines
closes: #17971
Signed-off-by: Shane-XB-Qian <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/autoload/vim.vim b/runtime/autoload/vim.vim
index 8dc14c476..c517b756f 100644
--- a/runtime/autoload/vim.vim
+++ b/runtime/autoload/vim.vim
@@ -1,5 +1,16 @@
vim9script
+# Language: Vim9 script
+# Contributers: @lacygoill
+# Shane-XB-Qian
+# Last Change: 2025 Aug 12
+#
+# Vim Script to handle
+# :import, :packadd and :colorscheme
+# lines and allows to easily jump to it using gf
+#
+# see runtime/ftplugin/vim.vim
+
# Interface {{{1
export def Find(editcmd: string) #{{{2
var curline: string = getline('.')
@@ -9,6 +20,11 @@ export def Find(editcmd: string) #{{{2
return
endif
+ if curline =~ '^\s*\%(:\s*\)\=colo\%[rscheme]\s'
+ HandleColoLine(editcmd, curline)
+ return
+ endif
+
if curline =~ '^\s*\%(:\s*\)\=import\s'
HandleImportLine(editcmd, curline)
return
@@ -51,6 +67,30 @@ def HandlePackaddLine(editcmd: string, curline: string) #{{{2
endif
enddef
+def HandleColoLine(editcmd: string, curline: string) #{{{2
+ var pat: string = '^\s*colo\%[rscheme]\s\+\zs\S\+$'
+ var colo: string = curline->matchstr(pat)
+
+ if colo == ''
+ try
+ execute 'normal! ' .. editcmd .. 'zv'
+ catch
+ Error(v:exception)
+ return
+ endtry
+ else
+ var split: string = editcmd[0] == 'g' ? 'edit' : editcmd[1] == 'g' ?
'tabedit' : 'split'
+ var files: list<string> = getcompletion($'colors/{colo}', 'runtime')
+ ->map((_, fname: string) =>
fname->findfile(&rtp)->fnamemodify(':p'))
+ ->filter((_, path: string): bool => filereadable(path))
+ if empty(files)
+ echo 'Could not find any colorscheme file for ' .. string(colo)
+ return
+ endif
+ files->Open(split)
+ endif
+enddef
+
def HandleImportLine(editcmd: string, curline: string) #{{{2
var fname: string
var import_cmd: string = '^\s*import\s\+\%(autoload\s\+\)\='
@@ -132,3 +172,5 @@ def Error(msg: string) #{{{2
echomsg msg
echohl NONE
enddef
+
+# vim: sw=4 et
--
--
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/E1uluh9-00B14u-WC%40256bit.org.