Skip to content

Commit fc3de1b

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 70df8b3 + 706b6f5 commit fc3de1b

36 files changed

+1580
-1408
lines changed

Filelist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ SRC_ALL = \
8282
src/findfile.c \
8383
src/float.c \
8484
src/fold.c \
85+
src/fuzzy.c \
8586
src/getchar.c \
8687
src/gc.c \
8788
src/globals.h \
@@ -291,6 +292,7 @@ SRC_ALL = \
291292
src/proto/findfile.pro \
292293
src/proto/float.pro \
293294
src/proto/fold.pro \
295+
src/proto/fuzzy.pro \
294296
src/proto/getchar.pro \
295297
src/proto/gc.pro \
296298
src/proto/gui.pro \

runtime/autoload/vim.vim renamed to runtime/autoload/vimgoto.vim

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
vim9script
22

3+
# Language: Vim9 script
4+
# Contributers: @lacygoill
5+
# Shane-XB-Qian
6+
# Last Change: 2025 Aug 13
7+
#
8+
# Vim Script to handle
9+
# :import, :packadd and :colorscheme
10+
# lines and allows to easily jump to it using gf
11+
#
12+
# see runtime/ftplugin/vim.vim
13+
314
# Interface {{{1
415
export def Find(editcmd: string) #{{{2
516
var curline: string = getline('.')
@@ -9,6 +20,11 @@ export def Find(editcmd: string) #{{{2
920
return
1021
endif
1122

23+
if curline =~ '^\s*\%(:\s*\)\=colo\%[rscheme]\s'
24+
HandleColoLine(editcmd, curline)
25+
return
26+
endif
27+
1228
if curline =~ '^\s*\%(:\s*\)\=import\s'
1329
HandleImportLine(editcmd, curline)
1430
return
@@ -23,7 +39,7 @@ enddef
2339
#}}}1
2440
# Core {{{1
2541
def HandlePackaddLine(editcmd: string, curline: string) #{{{2
26-
var pat: string = '^\s*packadd!\=\s\+\zs\S\+$'
42+
var pat: string = '\s*\%(:\s*\)\=packadd!\=\s\+\zs\S\+\>\ze'
2743
var plugin: string = curline
2844
->matchstr(pat)
2945
->substitute('^vim-\|\.vim$', '', 'g')
@@ -37,12 +53,9 @@ def HandlePackaddLine(editcmd: string, curline: string) #{{{2
3753
endtry
3854
else
3955
var split: string = editcmd[0] == 'g' ? 'edit' : editcmd[1] == 'g' ? 'tabedit' : 'split'
40-
# In the past, we passed `runtime` to `getcompletion()`, instead of
41-
# `cmdline`. But the output was tricky to use, because it contained
42-
# paths relative to inconsistent root directories.
43-
var files: list<string> = getcompletion($'edit **/plugin/{plugin}.vim', 'cmdline')
56+
var files: list<string> = getcompletion($'plugin/{plugin}', 'runtime')
57+
->map((_, fname: string) => fname->findfile(&rtp)->fnamemodify(':p'))
4458
->filter((_, path: string): bool => filereadable(path))
45-
->map((_, fname: string) => fname->fnamemodify(':p'))
4659
if empty(files)
4760
echo 'Could not find any plugin file for ' .. string(plugin)
4861
return
@@ -51,9 +64,33 @@ def HandlePackaddLine(editcmd: string, curline: string) #{{{2
5164
endif
5265
enddef
5366

67+
def HandleColoLine(editcmd: string, curline: string) #{{{2
68+
var pat: string = '\s*\%(:\s*\)\=colo\%[rscheme]\s\+\zs\S\+\>\ze'
69+
var colo: string = curline->matchstr(pat)
70+
71+
if colo == ''
72+
try
73+
execute 'normal! ' .. editcmd .. 'zv'
74+
catch
75+
Error(v:exception)
76+
return
77+
endtry
78+
else
79+
var split: string = editcmd[0] == 'g' ? 'edit' : editcmd[1] == 'g' ? 'tabedit' : 'split'
80+
var files: list<string> = getcompletion($'colors/{colo}', 'runtime')
81+
->map((_, fname: string) => fname->findfile(&rtp)->fnamemodify(':p'))
82+
->filter((_, path: string): bool => filereadable(path))
83+
if empty(files)
84+
echo 'Could not find any colorscheme file for ' .. string(colo)
85+
return
86+
endif
87+
files->Open(split)
88+
endif
89+
enddef
90+
5491
def HandleImportLine(editcmd: string, curline: string) #{{{2
5592
var fname: string
56-
var import_cmd: string = '^\s*import\s\+\%(autoload\s\+\)\='
93+
var import_cmd: string = '^\s*\%(:\s*\)\=import\s\+\%(autoload\s\+\)\='
5794
var import_alias: string = '\%(\s\+as\s\+\w\+\)\=$'
5895
var import_string: string = import_cmd .. '\([''"]\)\zs.*\ze\1' .. import_alias
5996
var import_expr: string = import_cmd .. '\zs.*\ze' .. import_alias
@@ -132,3 +169,5 @@ def Error(msg: string) #{{{2
132169
echomsg msg
133170
echohl NONE
134171
enddef
172+
173+
# vim: sw=4 et

runtime/doc/builtin.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*builtin.txt* For Vim version 9.1. Last change: 2025 Aug 10
1+
*builtin.txt* For Vim version 9.1. Last change: 2025 Aug 12
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -7425,9 +7425,6 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
74257425
given sequence.
74267426
limit Maximum number of matches in {list} to be
74277427
returned. Zero means no limit.
7428-
camelcase Use enhanced camel case scoring making results
7429-
better suited for completion related to
7430-
programming languages. Defaults to v:true.
74317428

74327429
If {list} is a list of dictionaries, then the optional {dict}
74337430
argument supports the following additional items:

runtime/doc/pattern.txt

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*pattern.txt* For Vim version 9.1. Last change: 2025 Aug 06
1+
*pattern.txt* For Vim version 9.1. Last change: 2025 Aug 13
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1501,34 +1501,51 @@ Finally, these constructs are unique to Perl:
15011501
==============================================================================
15021502
11. Fuzzy matching *fuzzy-matching*
15031503

1504-
Fuzzy matching refers to matching strings using a non-exact search string.
1505-
Fuzzy matching will match a string, if all the characters in the search string
1506-
are present anywhere in the string in the same order. Case is ignored. In a
1507-
matched string, other characters can be present between two consecutive
1508-
characters in the search string. If the search string has multiple words, then
1509-
each word is matched separately. So the words in the search string can be
1510-
present in any order in a string.
1511-
1512-
Fuzzy matching assigns a score for each matched string based on the following
1513-
criteria:
1514-
- The number of sequentially matching characters.
1515-
- The number of characters (distance) between two consecutive matching
1516-
characters.
1517-
- Matches at the beginning of a word
1518-
- Matches at a camel case character (e.g. Case in CamelCase)
1519-
- Matches after a path separator or a hyphen.
1520-
- The number of unmatched characters in a string.
1521-
- A full/exact match is preferred.
1522-
The matching string with the highest score is returned first.
1523-
1524-
For example, when you search for the "get pat" string using fuzzy matching, it
1525-
will match the strings "GetPattern", "PatternGet", "getPattern", "patGetter",
1526-
"getSomePattern", "MatchpatternGet" etc.
1527-
1528-
The functions |matchfuzzy()| and |matchfuzzypos()| can be used to fuzzy search
1529-
a string in a List of strings. The matchfuzzy() function returns a List of
1530-
matching strings. The matchfuzzypos() functions returns the List of matches,
1531-
the matching positions and the fuzzy match scores.
1504+
Fuzzy matching scores how well a string matches a pattern when the pattern
1505+
characters appear in order but not necessarily contiguously.
1506+
1507+
Example: >
1508+
Pattern: "vim"
1509+
Candidates: "vim" -> perfect
1510+
"vimeo" -> good (v i m)
1511+
"voice mail" -> weaker (v _ i _ _ _ m)
1512+
"vintage" -> no match (no "m")
1513+
<
1514+
If the search string has multiple words, each word is matched separately and
1515+
may appear in any order in the candidate. For example "get pat" matches
1516+
"GetPattern", "PatternGet", "getPattern", "patGetter", "getSomePattern",
1517+
"MatchpatternGet", etc.
1518+
1519+
The 'ignorecase' and 'smartcase' options do not apply, case is ignored if the
1520+
pattern is all lower case.
1521+
1522+
Vim's implementation is based on the algorithm from the fzy project:
1523+
https://github.com/jhawthorn/fzy
1524+
1525+
It uses dynamic programming to compute an optimal score for a given pattern
1526+
and candidate.
1527+
1528+
The algorithm works in two stages:
1529+
1530+
1. Forward pass
1531+
Scan the candidate left to right, tracking the best score for each
1532+
pattern position. Matches score higher when they occur at the start
1533+
of the candidate, the start of a word (space, underscore, dash,
1534+
camelCase), or directly after the previous match.
1535+
1536+
2. Backward pass
1537+
Start from the best-scoring end position and step back to find match
1538+
positions, ensuring the alignment is optimal.
1539+
1540+
Vim extends the original algorithm to support multibyte codepoints, allowing
1541+
correct matching for UTF-8 and other encodings.
1542+
1543+
Time complexity is O(pattern * candidate). Memory usage is proportional
1544+
to the same.
1545+
1546+
The |matchfuzzy()| and |matchfuzzypos()| functions perform fuzzy searching in
1547+
a List of strings. |matchfuzzy()| returns the matching strings, while
1548+
|matchfuzzypos()| returns the matches along with their positions and scores.
15321549

15331550
The "f" flag of `:vimgrep` enables fuzzy matching.
15341551

runtime/doc/version9.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*version9.txt* For Vim version 9.1. Last change: 2025 Aug 08
1+
*version9.txt* For Vim version 9.1. Last change: 2025 Aug 12
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -41723,6 +41723,8 @@ Functions: ~
4172341723
- Add the optional {opts} |Dict| argument to |getchar()| to control: cursor
4172441724
behaviour, return type and whether or not to simplify the returned key
4172541725
- |chdir()| allows to optionally specify a scope argument
41726+
- |matchfuzzy()| and |matchfuzzypos()| use an improved fuzzy matching
41727+
algorithm (same as fzy).
4172641728

4172741729
Others: ~
4172841730
- the regex engines match correctly case-insensitive multi-byte characters
@@ -41736,6 +41738,7 @@ Others: ~
4173641738
- |gv| works in operator pending mode and does not abort
4173741739
- The close button shown in the non-GUI 'tabline' will only be visible if the
4173841740
'mouse' option contains either "a" or any of the flags "n", "v", or "i".
41741+
- |C-indenting| handles compound literals.
4173941742

4174041743
*added-9.2*
4174141744
Added ~

runtime/ftplugin/vim.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
" Last Change: 2025 Aug 07
1010
" 2025 Aug 06 by Vim Project (add gf maps #17881)
1111
" 2025 Aug 08 by Vim Project (add Vim script complete function #17871)
12+
" 2025 Aug 12 by Vim Project (improve vimgoto script #17970))
1213

1314
" Only do this when not done yet for this buffer
1415
if exists("b:did_ftplugin")
@@ -152,7 +153,7 @@ if !exists("no_plugin_maps") && !exists("no_vim_maps")
152153
nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
153154
xnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
154155
155-
" Purpose: Handle `:import` and `:packadd` lines in a smarter way. {{{
156+
" Purpose: Handle :import, :colorscheme and :packadd lines in a smarter way. {{{
156157
"
157158
" `:import` is followed by a filename or filepath. Find it.
158159
"
@@ -171,9 +172,10 @@ if !exists("no_plugin_maps") && !exists("no_vim_maps")
171172
" buffer.
172173
" }}}
173174
" We use the `F` variants, instead of the `f` ones, because they're smarter.
174-
nnoremap <silent><buffer> gf :<C-U>call vim#Find('gF')<CR>
175-
nnoremap <silent><buffer> <C-W>f :<C-U>call vim#Find("\<lt>C-W>F")<CR>
176-
nnoremap <silent><buffer> <C-W>gf :<C-U>call vim#Find("\<lt>C-W>gF")<CR>
175+
" See $VIMRUNTIME/autoload/vimgoto.vim
176+
nnoremap <silent><buffer> gf :<C-U>call vimgoto#Find('gF')<CR>
177+
nnoremap <silent><buffer> <C-W>f :<C-U>call vimgoto#Find("\<lt>C-W>F")<CR>
178+
nnoremap <silent><buffer> <C-W>gf :<C-U>call vimgoto#Find("\<lt>C-W>gF")<CR>
177179
endif
178180

179181
" Let the matchit plugin know what items can be matched.

runtime/syntax/python.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim syntax file
22
" Language: Python
33
" Maintainer: Zvezdan Petkovic <[email protected]>
4-
" Last Change: 2025 Aug 11
4+
" Last Change: 2025 Aug 13
55
" Credits: Neil Schemenauer <[email protected]>
66
" Dmitry Vasiliev
77
" Rob B
@@ -113,6 +113,10 @@ syn keyword pythonAsync async await
113113
syn match pythonConditional "^\s*\zscase\%(\s\+.*:.*$\)\@="
114114
syn match pythonConditional "^\s*\zsmatch\%(\s\+.*:\s*\%(#.*\)\=$\)\@="
115115

116+
" These names are special by convention. While they aren't real keywords,
117+
" giving them distinct highlighting provides a nice visual cue.
118+
syn keyword pythonClassVar self cls
119+
116120
" Decorators
117121
" A dot must be allowed because of @MyClass.myfunc decorators.
118122
syn match pythonDecorator "@" display contained
@@ -378,6 +382,7 @@ hi def link pythonOperator Operator
378382
hi def link pythonException Exception
379383
hi def link pythonInclude Include
380384
hi def link pythonAsync Statement
385+
hi def link pythonClassVar Identifier
381386
hi def link pythonDecorator Define
382387
hi def link pythonDecoratorName Function
383388
hi def link pythonClass Structure

src/Make_ami.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ SRC += \
113113
findfile.c \
114114
float.c \
115115
fold.c \
116+
fuzzy.c \
116117
getchar.c \
117118
gc.c \
118119
hardcopy.c \

src/Make_cyg_ming.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ OBJ = \
823823
$(OUTDIR)/findfile.o \
824824
$(OUTDIR)/float.o \
825825
$(OUTDIR)/fold.o \
826+
$(OUTDIR)/fuzzy.o \
826827
$(OUTDIR)/getchar.o \
827828
$(OUTDIR)/gc.o \
828829
$(OUTDIR)/gui_xim.o \

src/Make_mvc.mak

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ OBJ = \
732732
$(OUTDIR)\findfile.obj \
733733
$(OUTDIR)\float.obj \
734734
$(OUTDIR)\fold.obj \
735+
$(OUTDIR)\fuzzy.obj \
735736
$(OUTDIR)\getchar.obj \
736737
$(OUTDIR)\gc.obj \
737738
$(OUTDIR)\gui_xim.obj \
@@ -1616,6 +1617,8 @@ $(OUTDIR)/float.obj: $(OUTDIR) float.c $(INCL)
16161617

16171618
$(OUTDIR)/fold.obj: $(OUTDIR) fold.c $(INCL)
16181619

1620+
$(OUTDIR)/fuzzy.obj: $(OUTDIR) fuzzy.c $(INCL)
1621+
16191622
$(OUTDIR)/getchar.obj: $(OUTDIR) getchar.c $(INCL)
16201623

16211624
$(OUTDIR)/gc.obj: $(OUTDIR) gc.c $(INCL)
@@ -1961,6 +1964,7 @@ proto.h: \
19611964
proto/filepath.pro \
19621965
proto/findfile.pro \
19631966
proto/float.pro \
1967+
proto/fuzzy.pro \
19641968
proto/getchar.pro \
19651969
proto/gc.pro \
19661970
proto/gui_xim.pro \

0 commit comments

Comments
 (0)