Commit Graph

32640 Commits

Author SHA1 Message Date
a9f810b203 vim-patch:31b78cc: runtime(doc): update documentation
closes: vim/vim#17180

31b78cce6e

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
2025-04-24 06:53:26 +08:00
f3c4fec43f vim-patch:9.1.1329: cannot get information about command line completion
Problem:  cannot get information about command line completion
Solution: add CmdlineLeavePre autocommand and cmdcomplete_info() Vim
          script function (Girish Palya)

This commit introduces two features to improve introspection and control
over command-line completion in Vim:

- Add CmdlineLeavePre autocmd event:

  A new event triggered just before leaving the command line and before
  CmdlineLeave. It allows capturing completion-related state that is
  otherwise cleared by the time CmdlineLeave fires.

- Add cmdcomplete_info() Vim script function:

  Returns a Dictionary with details about the current command-line
  completion state.

These are similar in spirit to InsertLeavePre and complete_info(),
but focused on command-line mode.

**Use case:**

In [[PR vim/vim#16759](https://github.com/vim/vim/pull/16759)], two examples
demonstrate command-line completion: one for live grep, and another for
fuzzy file finding. However, both examples share two key limitations:

1. **Broken history recall (`<Up>`)**
   When selecting a completion item via `<Tab>` or `<C-n>`, the original
pattern used for searching (e.g., a regex or fuzzy string) is
overwritten in the command-line history. This makes it impossible to
recall the original query later.
   This is especially problematic for interactive grep workflows, where
it’s useful to recall a previous search and simply select a different
match from the menu.

2. **Lack of default selection on `<CR>`**
   Often, it’s helpful to allow `<CR>` (Enter) to accept the first match
in the completion list, even when no item is explicitly selected. This
behavior is particularly useful in fuzzy file finding.

----
Below are the updated examples incorporating these improvements:

**Live grep, fuzzy find file, fuzzy find buffer:**

```vim
command! -nargs=+ -complete=customlist,GrepComplete Grep VisitFile()
def GrepComplete(arglead: string, cmdline: string, cursorpos: number):
list<any>
    return arglead->len() > 1 ? systemlist($'grep -REIHns "{arglead}"' ..
       ' --exclude-dir=.git --exclude=".*" --exclude="tags" --exclude="*.swp"') : []
enddef
def VisitFile()
    if (selected_match != null_string)
        var qfitem = getqflist({lines: [selected_match]}).items[0]
        if qfitem->has_key('bufnr') && qfitem.lnum > 0
            var pos = qfitem.vcol > 0 ? 'setcharpos' : 'setpos'
            exec $':b +call\ {pos}(".",\ [0,\ {qfitem.lnum},\ {qfitem.col},\ 0]) {qfitem.bufnr}'
            setbufvar(qfitem.bufnr, '&buflisted', 1)
        endif
    endif
enddef
nnoremap <leader>g :Grep<space>
nnoremap <leader>G :Grep <c-r>=expand("<cword>")<cr>
command! -nargs=* -complete=customlist,FuzzyFind Find
execute(selected_match != '' ? $'edit {selected_match}' : '')
var allfiles: list<string>
autocmd CmdlineEnter : allfiles = null_list
def FuzzyFind(arglead: string, _: string, _: number): list<string>
    if allfiles == null_list
        allfiles = systemlist($'find {get(g:, "fzfind_root", ".")} \! \(
-path "*/.git" -prune -o -name "*.swp" \) -type f -follow')
    endif
    return arglead == '' ? allfiles : allfiles->matchfuzzy(arglead)
enddef
nnoremap <leader><space> :<c-r>=execute('let
fzfind_root="."')\|''<cr>Find<space><c-@>
nnoremap <leader>fv :<c-r>=execute('let
fzfind_root="$HOME/.vim"')\|''<cr>Find<space><c-@>
nnoremap <leader>fV :<c-r>=execute('let
fzfind_root="$VIMRUNTIME"')\|''<cr>Find<space><c-@>
command! -nargs=* -complete=customlist,FuzzyBuffer Buffer execute('b '
.. selected_match->matchstr('\d\+'))
def FuzzyBuffer(arglead: string, _: string, _: number): list<string>
    var bufs = execute('buffers', 'silent!')->split("\n")
    var altbuf = bufs->indexof((_, v) => v =~ '^\s*\d\+\s\+#')
    if altbuf != -1
        [bufs[0], bufs[altbuf]] = [bufs[altbuf], bufs[0]]
    endif
    return arglead == '' ? bufs : bufs->matchfuzzy(arglead)
enddef
nnoremap <leader><bs> :Buffer <c-@>
var selected_match = null_string
autocmd CmdlineLeavePre : SelectItem()
def SelectItem()
    selected_match = ''
    if getcmdline() =~ '^\s*\%(Grep\|Find\|Buffer\)\s'
        var info = cmdcomplete_info()
        if info != {} && info.pum_visible && !info.matches->empty()
            selected_match = info.selected != -1 ? info.matches[info.selected] : info.matches[0]
            setcmdline(info.cmdline_orig). # Preserve search pattern in history
        endif
    endif
enddef
```

**Auto-completion snippet:**

```vim
set wim=noselect:lastused,full wop=pum wcm=<C-@> wmnu
autocmd CmdlineChanged : CmdComplete()
def CmdComplete()
    var [cmdline, curpos] = [getcmdline(), getcmdpos()]
    if getchar(1, {number: true}) == 0  # Typehead is empty (no more pasted input)
            && !pumvisible() && curpos == cmdline->len() + 1
            && cmdline =~ '\%(\w\|[*/:.-]\)$' && cmdline !~ '^\d\+$'  # Reduce noise
        feedkeys("\<C-@>", "ti")
        SkipCmdlineChanged()  # Suppress redundant completion attempts
        # Remove <C-@> that get inserted when no items are available
        timer_start(0, (_) => getcmdline()->substitute('\%x00', '', 'g')->setcmdline())
    endif
enddef
cnoremap <expr> <up> SkipCmdlineChanged("\<up>")
cnoremap <expr> <down> SkipCmdlineChanged("\<down>")
autocmd CmdlineEnter : set bo+=error
autocmd CmdlineLeave : set bo-=error
def SkipCmdlineChanged(key = ''): string
    set ei+=CmdlineChanged
    timer_start(0, (_) => execute('set ei-=CmdlineChanged'))
    return key != '' ? ((pumvisible() ? "\<c-e>" : '') .. key) : ''
enddef
```

These customizable snippets can serve as *lightweight* and *native*
alternatives to picker plugins like **FZF** or **Telescope** for common,
everyday workflows. Also, live grep snippet can replace **cscope**
without the overhead of building its database.

closes: vim/vim#17115

92f68e26ec

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-04-24 06:53:22 +08:00
Au.
652c3e76c7 fix(api): nvim_parse_cmd "range" when ea.addr_count=0 #33536
Problem:
nvim_parse_cmd returns invalid 'range' field for cmd like `:bdelete`.

Solution:
Add the condtion `ea.add_count > 0` as required to put 'range'
into result.

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-04-23 07:56:17 -07:00
bc814cfb2c fix(winblend): treat braille blank (\u2800) as whitespace #32741
Problem:
'winblend' does not display text behind blank unicode characters other than 0x20 ascii space.

Solution:
In ui_compositor.c -> compose_line() check for either 0x20 or 0x80A0E2 (utf8 \u2800).
2025-04-23 05:27:21 -07:00
d4f2b9050d fix(float): cursor visible in "hidden" floating window #30866
Problem:
Cursor is visible in "hidden" floating window.

Solution:
Hide cursor when curwin is a hidden floating window.
Show cursor after returning to a normal (non-hidden) window.
2025-04-23 05:22:43 -07:00
70d7979439 feat: render tuple types for API methods 2025-04-23 11:58:30 +01:00
019b2050e1 fix(snippet): use <cmd>call cursor() for visual range
Problem:  Change applied in d3e495ce uses a byte-offset where a virtual
          column is expected.
Solution: Set the cursor directly through a <Cmd> mapping, while making
          sure the commands are ordered correctly by adding them to the
          type-ahead buffer.
2025-04-23 10:58:22 +02:00
8d68dbf906 vim-patch:229f79c: runtime(yaml): fix wrong order of undo_ftplugin suboptions
This commit fixes the following error message:
```
Compiler not supported: make inc< sw< sts<
```

1. orginal value: `setl com< cms< et< fo<| compiler make inc< sw< sts<`
2. correct value: `setl com< cms< et< fo< inc< sw< sts< | compiler make`

While at it, let's also document the g:yaml_recommended_style variable.

closes: vim/vim#17179

229f79c168

Co-authored-by: Vincent Law <vlaw@users.noreply.github.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-04-23 08:37:36 +02:00
2ea14c0cf4 vim-patch:7bc9880: runtime(make): do not automatically indent after a special target
prevent indentation if the previous line starts with e.g. `.PHONY:`

closes: vim/vim#17183

7bc988067e

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-04-23 08:37:36 +02:00
1dbede5b93 fix(events): avoid superfluous CursorMovedI on first autocmd (#33588) 2025-04-23 03:20:21 +00:00
803649da11 vim-patch:fa3b104: runtime(vim): Update base-syntax, improve :autocmd highlighting (#33586)
- Match full :autocmd, :doautocmd and :doautoall commands.
- Add filename pattern (wildcard) highlighting.

fa3b1043c6

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-04-23 01:31:08 +00:00
82f08f33c1 fix(tui): ensure all pending escape sequences are processed before exiting #32151
Problem:
Neovim disables a number of terminal modes when it exits, some of which
cause the terminal to send asynchronous events to Neovim. It's possible
that Neovim exits before the terminal has received and processed all of
the sequences to disable these modes, causing the terminal to emit one
of these asynchronous sequences after Neovim has already exited. If this
happens, then the sequence is received by the user's shell (or some
other program that is not Neovim).

Solution:
When Neovim exits, it now emits a Device Attributes request (DA1)
after disabling all of the different modes. When the terminal responds
to this request we know that it has already received all of our other
sequences disabling the other modes. At that point, it should not be
emitting any further asynchronous sequences. This means the process of
exiting Neovim is now asynchronous as well since it depends on receiving
the DA1 response from the terminal.
2025-04-22 05:18:34 -07:00
d3e495ce03 perf(snippet): use "[count]|" to move cursor #33571
Problem:
Flicker when using vim.snippet.jump().

Solution:
Pass count instead of multiple <right> keys.
2025-04-22 04:34:41 -07:00
8c81ed8678 feat(runtime): revert cfilter, ccomplete to legacy Vim
Problem: Transpiled Lua code from vim9script is not amenable to static
analysis, requiring manual cleanup or ignoring parts of our codebase.

Solution: Revert to pre-rewrite version of (low-impact) legacy plugins
and remove the vim9jit shim.
2025-04-22 11:03:05 +02:00
65170e8dad fix(api): wrong return value with reverse range + overlap #32956
Problem:  When iterating in reverse with {start} > {end} in
          `nvim_buf_get_extmarks()`, marks that overlap {start} and are
          greater than {end} are included in the return value twice.
          Marks that overlap {end} and do not overlap {start} are not
          not included in the return value at all. Marks are not
          actually returned in a meaningful "traversal order".

Solution: Rather than actually iterating in reverse, (also possible but
          requires convoluted conditions and would require fetching
          overlapping marks for both the {start} and {end} position,
          while still ending up with non-traversal ordered marks),
          iterate normally and reverse the return value.
2025-04-21 16:18:03 -07:00
28e31f5d3d feat(options): default statusline expression #33036
Problem:
Default 'statusline' is implemented in C and not representable as
a statusline expression. This makes it hard for user configs/plugins to
extend it.

Solution:
- Change the default 'statusline' slightly to a statusline expression.
- Remove the C implementation.
2025-04-21 15:05:34 -07:00
ab72799841 fix(coverity/530026,530028): free resources on early exit in nlua_exec_file #33502
Problem: The stdin reading path does not close `stdin_dup` or free `sb`
upon early exit.

Solution: Free the resources before returning false.
2025-04-21 08:43:38 -07:00
986b92eb07 fix(messages): single msg_show event for multiple :set options #33555
Problem:  :set opt1 opt2... emits a separate event for each option.

Solution: Only set the kind for the first printed option value.
2025-04-21 07:51:47 -07:00
7ba0f623d7 feat(ui): avoid setting 'cmdheight' with vim.ui_attach()
Problem:  We allow setting 'cmdheight' to 0 with ext_messages enabled
          since b72931e7. Enabling ext_messages with vim.ui_attach()
          implicitly sets 'cmdheight' to 0 for BWC. When non-zero
          'cmdheight' is wanted, this behavior make it unnecessarily
          hard to keep track of the user configured value.
Solution: Add set_cmdheight to vim.ui_attach() opts table that can be
          set to false to avoid setting 'cmdheight' to 0.
2025-04-21 15:38:23 +02:00
de7306a250 docs(news): fix incorrect placements (#33566) 2025-04-21 12:20:05 +00:00
7ba043f0f3 feat(api): add "max_height" argument to nvim_win_text_height (#32835)
Useful to e.g. limit the height to the window height, avoiding unnecessary
work. Or to find out how many buffer lines beyond "start_row" take up a
certain number of logical lines (returned in "end_row" and "end_vcol").
2025-04-21 19:48:26 +08:00
98ec3fdf74 vim-patch:9.1.1328: too many strlen() calls in indent.c (#33563)
Problem:  too many strlen() calls in indent.c
Solution: refactor indent.c slightly and remove strlen() calls
          (John Marriott)

closes: vim/vim#17156

eac45c558e

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-04-21 19:16:29 +08:00
e3c3f4730d vim-patch:7938c40: runtime(keymaps): update Brazilian keymaps (#33562)
closes: vim/vim#17161

7938c40b34

Co-authored-by: LuMarquesIlva <luismarques0504@proton.me>
2025-04-21 19:16:17 +08:00
8051092414 Merge pull request #33561 from zeertzjq/vim-9.1.1304
vim-patch:9.1.{1304,1327}: filetype: some man files are not recognized
2025-04-21 19:09:29 +08:00
9fafdcb99c vim-patch:9.1.1327: filetype: nroff detection can be improved
Problem:  filetype: nroff detection can be improved
Solution: improve nroff detection (Eisuke Kawashima)

- explicitly check roff comments and macros typically found in manpages
- do not try to detect alphabetically-sectioned files, except for n, as
  nroff
    - l: > 'l' happens to be a section for historical reasons
         <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391977>
    - n: e.g. /usr/share/man/mann/Tcl.n.gz
    - o: unsure (perhaps fedora-specific)
    - p: unsure (perhaps fedora-specific)

closes: vim/vim#17160

2cb42efc18

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-04-21 18:40:58 +08:00
7da1639a14 vim-patch:9.1.1304: filetype: some man files are not recognized
Problem:  filetype: some man files are not recognized
          (e.g. 1p (POSIX commands))
Solution: update the filetype detection pattern and detect more man
          files as nroff (Eisuke Kawashima)

- sections are revised referring to
    - debian-12:/etc/manpath.config
    - fedora-41:/etc/man_db.conf
- detection logic is improved
- detection test is implemented

closes: vim/vim#17117

babdb0554a

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-04-21 18:40:58 +08:00
1437144740 vim-patch:e125ee4: runtime(pov): deprecate #render and #statistics in syntax script
- 3.1g: active
  https://www.povray.org/ftp/pub/povray/Old-Versions/Official-3.1g/Docs/povuser.pdf#page=172
- 3.5 or later: deprecated
  https://www.povray.org/ftp/pub/povray/Old-Versions/Official-3.5/Linux/povlinux.tgz
  ─ povray-3.50c/html/povdoc_172.html
  - https://www.povray.org/documentation/3.7.0/r3_3.html#r3_3_2_7_1

closes: vim/vim#17177

e125ee4b9f

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-04-21 12:38:27 +02:00
d55330bcd1 refactor(lsp): use method type annotations for parameters 2025-04-21 11:35:29 +02:00
351613bc1f vim-patch:187df69: runtime(doc): cross-link :| meaning :p and explain E749 (#33559)
E749 is given when :print (with any range) is issued on an empty buffer,
like the one you get with :new or :enew. Furthermore, due to Vi
compatibility :| is a synonym.

As a result, mappings intended to include a <bar> separator (esp. in the
case of boolean or "||") between commands can generate E749 on startup
when placed in a vimrc if the bars are not properly encoded or escaped.
[1]. Document this failure mode and synonym near the generated error,
and cross link with :help :bar. Note that one must read or scroll quite
a bit to find the mention of :| behaving like :print!

[1]: https://vi.stackexchange.com/q/46625/10604

closes: vim/vim#17173

187df69fd1

Co-authored-by: D. Ben Knoble <ben.knoble+github@gmail.com>
2025-04-21 08:56:05 +00:00
4b02d1f6f6 fix(gen_vimdoc): unnecessary assert for non-source files
Problem:  The presence of non-source files breaks `make doc`.
Solution: Replace assert with if statement to skip non-matching files.
2025-04-21 10:15:33 +02:00
d3cded796c vim-patch:9.1.1326: invalid cursor position after 'tagfunc' (#33556)
Problem:  invalid cursor position after 'tagfunc'
          (gandalf4a)
Solution: call check_cursor() after executing the 'tagfunc'

9919085491

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-04-20 23:04:02 +00:00
c7d8812ca7 vim-patch:2398460: runtime(doc): clarify 'includeexpr' is not used for <cfile> (#33540)
fixes: vim/vim#17139

2398460232

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-04-19 19:10:43 +08:00
e4516a90b1 vim-patch:54081f0: runtime(nix): set iskeyword and b:match_words in ftplugin (#33541)
closes: vim/vim#17154

54081f0ce0

Co-authored-by: Arnie97 <arnie97@gmail.com>
2025-04-19 10:59:12 +00:00
255bf6e5b1 vim-patch:9.1.1320: filetype: alsoft config files are not recognized
Problem:  filetype: alsoft config files are not recognized
Solution: detect alsoft config files as dosini filetype
          (David Mandelberg)

References:
* code with paths to config: ReadALConfig() in
  https://github.com/kcat/openal-soft/blob/master/alc/alconfig.cpp
* example config:
  https://github.com/kcat/openal-soft/blob/master/alsoftrc.sample

closes: vim/vim#17140

1d96caaa4b

Co-authored-by: David Mandelberg <david@mandelberg.org>
2025-04-19 10:52:12 +02:00
1b0dedb81c vim-patch:9.1.1321: filetype: MS ixx and mpp files are not recognized
Problem:  filetype: MS ixx and mpp files are not recognized
Solution: detect *.mpp and *.ixx files as c++ filetype
          (Hampus Avekvist)

closes: vim/vim#17155

aee34ef23e

Co-authored-by: Hampus Avekvist <hampus.avekvist@hey.com>
2025-04-19 10:52:12 +02:00
df96276b19 test(api/window_spec): check start_vcol on folded line (#33535) 2025-04-19 05:14:34 +00:00
ed5e70465a test(api): nvim_win_text_height with virt_lines around fold (#33529) 2025-04-19 01:00:46 +00:00
7380f8ec71 vim-patch:cb3b752: runtime(doc): clarify "nearest" value for 'completeopt' (#33534)
closes: vim/vim#17146

cb3b752f95

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-04-19 08:42:48 +08:00
dca8b3fede vim-patch:9.1.1322: small delete register cannot paste multi-line correctly (#33531)
Problem:  small delete register cannot paste multi-line correctly
          (after v8.2.2189)
Solution: caused by 032a2d050b82b146d70d6ff714838ee62c07d8ad, so make
          this logic handle charwise only (phanium)

closes: vim/vim#17151

7e93d4c617
2025-04-19 08:01:51 +08:00
c67398d31b vim-patch:9.1.1319: Various typos in the code, issue with test_inst_complete.vim (#33527)
Problem:  Various typos in the code, redundant and strange use of
          :execute in test_ins_complete.vim (after 9.1.1315).
Solution: Fix typos in the code and in the documentation, use the
          executed command directly (zeertzjq).

closes: vim/vim#17143

98800979dc

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2025-04-19 07:23:20 +08:00
9397fdafe1 Merge pull request #33519 from zeertzjq/vim-9.1.1314
vim-patch:9.1.{1314,1318}: max allowed string width too small
2025-04-19 07:22:39 +08:00
Au.
44f1dbee0d fix(spell): save spell files to stdpath('data')/site/spell #33528 2025-04-18 08:56:20 -07:00
0251a25541 vim-patch:9.1.1318: tests: test_format fails
Problem:  tests: test_format fails (after 9.1.1314).
Solution: Increase the string size.  Add missing test_format.res in
          NEW_TESTS_RES (zeertzjq).

closes: vim/vim#17144

e9a27ef373
2025-04-18 17:00:34 +08:00
ccdb37b075 vim-patch:9.1.1314: max allowed string width too small
Problem:  max allowed string width too small
Solution: increased MAX_ALLOWED_STRING_WIDTH from 6400 to 1MiB
          (Hirohito Higashi)

closes: vim/vim#17138

06fdfa11c5

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-04-18 16:58:10 +08:00
34791f7988 Merge pull request #33526 from zeertzjq/vim-3dca512
vim-patch: Vim syntax updates
2025-04-18 15:25:11 +08:00
9045656014 vim-patch:9b171bd: runtime(vim): Update-base-syntax, match full :*grep, :make, :sort and :filter commands
closes: vim/vim#17082

9b171bdfd6

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-04-18 14:59:20 +08:00
67d6f2baa4 vim-patch:520a2c7: runtime(vim): Update base-syntax, improve :command highlighting
- Match multiline :command definitions.
- Match custom completion funcref var names.

fixes: vim/vim#17001
closes: vim/vim#17067

520a2c7852

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-04-18 14:57:09 +08:00
5662bdafc2 vim-patch:2f5a8c0: runtime(vim): Update base-syntax, match full :redir command
closes: vim/vim#17057

2f5a8c0b5b

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-04-18 14:55:45 +08:00
3ee144aa95 vim-patch:2a6be83: runtime(vim): Update base-syntax, improve :set backslash handling
Improve backslash handling in :set option values. There is no special
handling for options supporting Windows path separators yet.

See :help option-backslash.

Remove the vimSetString syntax group. Option string values cannot be
specified with a quoted string, this is a command terminating tail
comment.

fixes: vim/vim#16913
closes: vim/vim#17034

2a6be83512

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-04-18 14:52:50 +08:00
234be4aebc vim-patch:722fbd1: runtime(vim): Update base-syntax, match tuples
Tuples were introduced in commit 9cb865e.  See PR vim/vim#16776.

fixes: vim/vim#16965
closes: vim/vim#16935

722fbd1554

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-04-18 14:50:05 +08:00