Commit Graph

382 Commits

Author SHA1 Message Date
3b6084ddf4 fix: type fixes
Type fixes caught by emmylua
2025-06-06 15:36:48 +01:00
f577bb024e docs: getreg() type #34215
```lua
---@type string
local _a = vim.fn.getreg('a', 1)

---@type string[]
local _b = vim.fn.getreg('a', 1, 1)
```
2025-06-04 09:26:56 -07:00
aa4fa24963 vim-patch:bfeefc4: runtime(doc): clarify the effect of exclusive single char selections (#34289)
closes: vim/vim#17410

bfeefc474a

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-06-02 23:54:29 +00:00
981d4ba45e fix(eval): winnr('$') counts non-current hidden/unfocusable windows #34207
Problem:  Non-visible/focusable windows are assigned a window number,
          whereas commands that use this window number skip over them.

Solution: Skip over non-visible/focusable windows when computing
          the window number, unless it is made the current window
          through the API in which case an identifiable window number
          is still useful. This also ensures it matches the window
          number of the window entered by `<winnr>wincmd w` since
          403fcacf.
2025-06-01 15:12:12 -07:00
6c4ddf607f vim-patch:9.1.1417: missing info about register completion in complete_info() (#34219)
Problem:  missing info about register completion in complete_info()
          (after v9.1.1408)
Solution: update documentation and mention that register is used as
          source, add a test (glepnir)

closes: vim/vim#17389

49864aecd0

Co-authored-by: glepnir <glephunter@gmail.com>
2025-05-29 07:09:50 +08:00
c9d8468020 feat(search): increase MAX_COUNT to 999
Problem: "99 searchcount ought to be enough for anyone."

Solution: Increase `SEARCH_STAT_DEF_MAX_COUNT` to 999, which I'm sure
will suffice for the next twenty years.

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2025-05-24 10:55:43 +02:00
cb12c8fa47 vim-patch:9973b39: runtime(doc): remove duplicate sentence in builtin.txt
9973b39a17

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-05-10 07:29:41 +08:00
1bfb8dd338 vim-patch:17ad852: runtime(doc): update return types for builtin functions
fixes: vim/vim#17273

credit: Github user @msoyka2024

17ad852a62

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-05-10 07:29:37 +08:00
902b689c4d docs(lua): typing for vim.fn.winlayout #33817
Problem:
`any[]` means nothing, and the return value is not the same as what's
documented in the comment (eg, Lua returns `{ "row", { { "leaf", 1000 },
{ "leaf", 1001 } } }`, not `{ "row", { "leaf", 1000, "leaf", 1001 } }`)

Solution:
Create two classes (vim.fn.winlayout.leaf and vim.fn.winlayout.branch)
and one alias that links the two together.

Also: Due to LuaLS limitations, there is an empty class,
vim.fn.winlayout.empty

Signed-Off-By: VoxelPrismatic <voxelprismatic@pm.me>
2025-05-03 11:34:25 -07:00
862e676efc docs: add missing change to getcharstr() signature (#33797) 2025-05-03 08:10:13 +08:00
e7e665b489 vim-patch:ffc89e4 runtime(doc): clarify complete_match() and 'isexpand' option
clarify complete_match() documentation to better explain its backward
search behavior, argument handling, and return value format and add an
example of isexpand

closes: https://github.com/vim/vim/pull/17212

ffc89e47d0
2025-04-29 14:11:55 +08:00
fcabbc2283 vim-patch:9.1.1341: cannot define completion triggers
Problem:  Cannot define completion triggers and act upon it
Solution: add the new option 'isexpand' and add the complete_match()
          function to return the completion matches according to the
          'isexpand' setting (glepnir)

Currently, completion trigger position is determined solely by the
'iskeyword' pattern (\k\+$), which causes issues when users need
different completion behaviors - such as triggering after '/' for
comments or '.' for methods. Modifying 'iskeyword' to include these
characters has undesirable side effects on other Vim functionality that
relies on keyword definitions.

Introduce a new buffer-local option 'isexpand' that allows specifying
different completion triggers and add the complete_match() function that
finds the appropriate start column for completion based on these
triggers, scanning backwards from cursor position.

This separation of concerns allows customized completion behavior
without affecting iskeyword-dependent features. The option's
buffer-local nature enables per-filetype completion triggers.

closes: vim/vim#16716

bcd5995b40

Co-authored-by: glepnir <glephunter@gmail.com>
2025-04-27 15:00:31 +08:00
ac8ae1596c vim-patch:9.1.1340: cannot complete :filetype arguments (#33602)
Problem:  cannot complete :filetype arguments (Phạm Bình An)
Solution: add :filetype ex command completion, add "filetypecmd"
          completion type for getcompletion()

fixes: vim/vim#17165
closes: vim/vim#17167

a3422aa317

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-04-24 00:50:33 +00:00
07d60e8f19 vim-patch:9.1.1331: Leaking memory with cmdcomplete()
Problem:  Leaking memory with cmdcomplete()
          (zeertzjq, after v9.1.1329)
Solution: free the memory (Girish Palya)

closes: vim/vim#17190

5c3d1e3258

Co-authored-by: Girish Palya <girishji@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
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
57d99a515f docs: clipboard, eval #33223 2025-04-05 06:01:40 -07:00
ec6670080a docs(eval): fix dict param type of mapset
Match maparg's return type.
2025-04-01 10:55:39 +01:00
4a36f234ac docs(eval): fix lnum type for functions using tv_get_lnum
These occurrences also accept string, which is used like in getline.

Also make the lnum field of vim.fn.sign_placelist.list.item optional, as it can
be omitted like vim.fn.sign_place.dict's.
2025-04-01 10:55:39 +01:00
797195e0ea vim-patch:9.1.1219: Strange error with wrong type for matchfuzzy() "camelcase"
Problem:  Strange error with type for matchfuzzy() "camelcase".
Solution: Show the error "Invalid value for argument camelcase" instead
          of "Invalid argument: camelcase" (zeertzjq).

Note that using tv_get_string() will lead to confusion, as when the
value cannot be converted to a string tv_get_string() will also give an
error about that, but "camelcase" takes a boolean, not a string.  Also
don't use tv_get_string() for the "limit" argument above.

closes: vim/vim#16926

c4815c157b
2025-03-27 08:25:12 +08:00
162edf7b30 vim-patch:9.1.1214: matchfuzzy() can be improved for camel case matches
Problem:  When searching for "Cur", CamelCase matches like "lCursor" score
          higher than exact prefix matches like Cursor, which is
          counter-intuitive (Maxim Kim).
Solution: Add a 'camelcase' option to matchfuzzy() that lets users disable
          CamelCase bonuses when needed, making prefix matches rank higher.
          (glepnir)

fixes: vim/vim#16504
closes: vim/vim#16797

28e40a7b55

Co-authored-by: glepnir <glephunter@gmail.com>
2025-03-27 08:19:25 +08:00
8a7e1b19b9 docs: news, lsp autocomplete #33047 2025-03-26 05:49:48 -07:00
026cfa28d0 docs: misc
Co-authored-by: Au. <acehinnnqru@gmail.com>
Co-authored-by: Daniel Rainer <daniel.rainer@localhost>
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Co-authored-by: Pierre Barbin <pierre@heitzsystem.com>
Co-authored-by: Riley Bruins <ribru17@hotmail.com>
Co-authored-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Co-authored-by: phanium <91544758+phanen@users.noreply.github.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-03-15 15:00:44 +01:00
785e620700 vim-patch:c1c3b5d: runtime(doc): remove unnecessary "an" (#32865)
"umask" is pronounce like "youmask", so having an "an" before it is a
bit strange.  In other places in the help, "umask" is not preceded by
either "a" or "an", and sometimes preceded by "the".

Also, "Note" is usually followed either by ":" or "that" in builtin.txt,
so add a ":" after "Note".

closes: 16860

c1c3b5d6a0
2025-03-13 07:15:19 +08:00
bcafbc3f7b vim-patch:0a336cc: runtime(doc): clarify that a umask is applied to mkdir() (#32845)
fixes: vim/vim#16849

0a336ccb57

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-03-11 22:46:45 +00:00
c4a0c1d3b0 docs: misc #31996 2025-03-02 14:27:52 -08:00
4a2a54f993 vim-patch:5647c91: runtime(doc): add reference to extendnew() at extend() (#32500)
related: vim/vim#16607

5647c91355

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-02-17 22:59:34 +00:00
a75b09019f docs: stdpath() type #32480 2025-02-16 13:33:56 -08:00
7c43f1128d vim-patch:9.1.1081: has('bsd') is true for GNU/Hurd
Problem:  has('bsd') is true for GNU/Hurd
Solution: exclude GNU/Hurd from BSD feature flag
          (Zhaoming Luo)

GNU/Hurd, like Mac OS X, is a BSD-based system. It should exclude
has('bsd') feature just like what Mac OS X does. The __GNU__ pre-defined
macro indicates it's compiled for GNU/Hurd.

closes: vim/vim#16580

a41dfcd55b

Co-authored-by: Zhaoming Luo <zhmingluo@163.com>
2025-02-07 06:30:11 +08:00
af069c5c05 vim-patch:9.1.1070: Cannot control cursor positioning of getchar() (#32303)
Problem:  Cannot control cursor positioning of getchar().
Solution: Add "cursor" flag to {opts}, with possible values "hide",
          "keep" and "msg".

related: vim/vim#10603
closes: vim/vim#16569

edf0f7db28
2025-02-03 00:09:03 +00:00
4bdabf9b1a vim-patch:9.1.1068: getchar() can't distinguish between C-I and Tab (#32295)
Problem:  getchar() can't distinguish between C-I and Tab.
Solution: Add {opts} to pass extra flags to getchar() and getcharstr(),
          with "number" and "simplify" keys.

related: vim/vim#10603
closes: vim/vim#16554

e0a2ab397f

Cherry-pick tv_dict_has_key() from patch 8.2.4683.
2025-02-02 09:32:51 +00:00
0d3a8e8c1a vim-patch:9.1.1020: no way to get current selected item in a async context (#32056)
Problem:  no way to get current selected item in a async context
Solution: add completed flag to show the entries of currently selected
          index item (glepnir)

closes: vim/vim#16451

037b028a22

Co-authored-by: glepnir <glephunter@gmail.com>
2025-01-17 08:38:58 +08:00
6a425e7045 docs: misc
Co-authored-by: Axel <axelhjq@gmail.com>
Co-authored-by: Colin Kennedy <colinvfx@gmail.com>
Co-authored-by: Daiki Noda <sys9kdr@users.noreply.github.com>
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: Jean-Jacq du Plessis <1030058+jj-du-plessis@users.noreply.github.com>
Co-authored-by: Juan Giordana <juangiordana@gmail.com>
Co-authored-by: Lincoln Wallace <locnnil0@gmail.com>
Co-authored-by: Matti Hellström <hellstrom@scm.com>
Co-authored-by: Steven Locorotondo <steven.locorotondo@justeattakeaway.com>
Co-authored-by: Yochem van Rosmalen <git@yochem.nl>
Co-authored-by: glepnir <glephunter@gmail.com>
Co-authored-by: ifish <fishioon@live.com>
2025-01-11 10:34:12 +01:00
8fa4306eb9 vim-patch:9.1.0991: v:stacktrace has wrong type in Vim9 script
Problem:  v:stacktrace has wrong type in Vim9 script.
Solution: Change the type to t_list_dict_any.  Fix grammar in docs.
          (zeertzjq)

closes: vim/vim#16390

6655bef330
2025-01-07 09:15:10 +08:00
d5308637bf vim-patch:9.1.0984: exception handling can be improved
Problem:  exception handling can be improved
Solution: add v:stacktrace and getstacktrace()

closes: vim/vim#16360

663d18d610

Co-authored-by: ichizok <gclient.gaap@gmail.com>
Co-authored-by: Naruhiko Nishino <naru123456789@gmail.com>
2025-01-07 09:15:10 +08:00
bdc0b5f505 vim-patch:9.1.0983: not able to get the displayed items in complete_i… (#31796)
vim-patch:9.1.0983: not able to get the displayed items in complete_info()

Problem:  not able to get the displayed items in complete_info()
          (Evgeni Chasnovski)
Solution: return the visible items via the "matches" key for
          complete_info() (glepnir)

fixes: vim/vim#10007
closes: vim/vim#16307

d4088edae2
2024-12-31 19:12:50 +08:00
8ef41f5902 feat(jobs): jobstart(…,{term=true}), deprecate termopen() #31343
Problem:
`termopen` has long been a superficial wrapper around `jobstart`, and
has no real purpose. Also, `vim.system` and `nvim_open_term` presumably
will replace all features of `jobstart` and `termopen`, so centralizing
the logic will help with that.

Solution:
- Introduce `eval/deprecated.c`, where all deprecated eval funcs will live.
- Introduce "term" flag of `jobstart`.
- Deprecate `termopen`.
2024-12-19 07:07:04 -08:00
f9dd682621 docs(annotations): added ---@generic support 2024-12-13 17:05:38 +00:00
492ae57aa6 docs(annotation): return types for Vimscript functions #31546 2024-12-11 03:27:08 -08:00
ae93c7f369 docs: misc, help tags for neovim.io searches #31428
Problem:
Various keywords are commonly searched-for on https://neovim.io, but
don't have help tags.

Solution:
Add help tags.

fix #31327
2024-12-03 09:44:28 -08:00
66bb1e577c vim-patch:9.1.0888: leftcol property not available in getwininfo() (#31349)
Problem:  leftcol property not available in getwininfo()
Solution: add leftcol property property (glepnir)

closes: vim/vim#16119

0a850673e3

Co-authored-by: glepnir <glephunter@gmail.com>
2024-11-26 07:53:07 +08:00
5a27d02584 docs: misc (#30914)
Co-authored-by: Ernie Rael <errael@raelity.com>
Co-authored-by: Famiu Haque <famiuhaque@proton.me>
Co-authored-by: Jade <spacey-sooty@proton.me>
Co-authored-by: glepnir <glephunter@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-11-09 08:10:56 +08:00
ad3472e291 fix(vim.system): resolve executable paths on windows
Fixes #31107
2024-11-08 16:29:44 +00:00
7bf3a616e1 vim-patch:b5e7da1: runtime(doc): mention 'iskeyword' at :h charclass() (#31026)
fixes: vim/vim#15965

b5e7da1f27

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-11-01 18:22:08 +08:00
42fa3d080e refactor: sort various Lua tables in src/ alphabetically (#30977) 2024-10-29 07:57:25 +08:00
3a86b60032 docs: misc
Co-authored-by: David Pedersen <limero@me.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Leo Schlosser <Leo.Schlosser@Student.HTW-Berlin.de>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-10-23 14:13:42 +02:00
c8e47f6480 fix(meta): do not use hyphens in param names
Fixes #30882
2024-10-21 12:09:33 +01:00
fa6ab0d909 Merge pull request #30825 from lewis6991/refactor/lsputil 2024-10-17 13:35:02 +01:00
21151144c6 feat(meta): add type for quickfix entries 2024-10-17 10:54:19 +01:00
c89150241d vim-patch:6c2fc37: runtime(help): Update help syntax
This commit makaes the following changes to the vim help syntax:

- fix excessive URL detection in help, because `file:{filename}` in
  doc/options.txt is determined to be a URL.
- update highlighting N for :resize in help
- split Italian-specific syntax into separate help script
- highlight `Note` in parentheses in help
- update 'titlestring' behaviour in documentation for invalid '%' format

closes: vim/vim#15883

6c2fc377bf

Co-authored-by: Milly <milly.ca@gmail.com>
2024-10-17 07:55:55 +08:00