aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
Commit message (Collapse)AuthorAge
...
* fix(treesitter): scope highlight state per window #34347Riley Bruins2025-06-07
| | | | | | | | | **Problem:** There is a lot of distracting highlight flickering when editing a buffer with multiple open windows. This is because the parsing/highlighting state is shared across all windows. **Solution:** Greatly reduce flicker in window splits by scoping the highlighter state object and the `parsing` state object to each individual window, so there is no cross-window interference.
* docs: lua, UI events #34261Justin M. Keyes2025-06-07
|
* fix: type fixesLewis Russell2025-06-06
| | | | Type fixes caught by emmylua
* refactor(treesitter): avoid unnecessarily copying treeRodrigodd2025-06-06
| | | | | node:tree() now already copies the tree before returning it, for memory safety reasons.
* fix(extui): use visible to determine active "more" (#34327)luukvbaal2025-06-06
| | | | | | | | | | | Problem: Current window is checked to determine whether "more" window is open. Making it the current window is scheduled in case the cmdwin is open so this can be too late. "cmdline_hide" may be emitted when the topline is temporarily invalid (after incsearch->restore_viewstate()). Solution: Use the window visibility to determine an active "more" window instead. Don't nvim__redraw->flush the "cmdline_hide" event (a normal will already happen).
* fix(lsp): only auto-detach lsp.config enabled clients #34325Kai-Hsiang Hsu2025-06-06
| | | | | | | Problem: A custom server (initialized through `vim.lsp.start`) gets unexpectedly detached. Solution: Only auto-detach the clients enabled through `vim.lsp.enable` to prevent unexpected behavior.
* fix(diagnostic): ensure autocmd always is always sent diagnosticsLewis Russell2025-06-05
|
* vim-patch:d6c9ac9: runtime(doc): clarify the effect of 'smarttab'zeertzjq2025-06-05
| | | | | | | | closes: vim/vim#17426 https://github.com/vim/vim/commit/d6c9ac97a009f7099b7d3636548aa3a4fabb5f1a Co-authored-by: Damien Lejay <damien@lejay.be>
* fix(extui): copy window config to new tabpage (#34308)luukvbaal2025-06-04
| | | | | | | | | Problem: When opening a new tabpage, extui windows are initialized with their default config. Window visiblity/dimensions on other tabpages may get out of sync with their buffer content. Solution: Copy the config of the window to the new tabpage. No longer keep track of the various windows on each tabpage. Close windows on inactive tabpages instead (moving them could be more efficient but is currently not supported in the API).
* docs: getreg() type #34215phanium2025-06-04
| | | | | | | | | ```lua ---@type string local _a = vim.fn.getreg('a', 1) ---@type string[] local _b = vim.fn.getreg('a', 1, 1) ```
* fix(vim.diagnostic): improve typingLewis Russell2025-06-03
| | | | | | | | | | | | | | | | | | Problem: `vim.diagnostic.set()` doesn't actually accept a list of `vim.Diagnostic` as internally `vim.diagnostic.set()` normalizes the diagnostics and this normalization is assumed throughout the module. Solution: - Add a new type `vim.Diagnostic.Set` which is the input to `vim.diagnostic.set()` - `col` is now an optional field and defaults to `0` to be consistent with `vim.diagnostic.match()`. - Change `table.insert(t, x)` to `table[#table + 1] = x` for improved type checking.
* fix(diagnostics): diagnostic just after EOL is not highlighted #34085Sergei Slipchenko2025-06-03
| | | | | | | | | | | | | | Fixes #34013 Problem: when diagnostic is set right after EOL, underline handler looks inconsistent compared to other handlers, visually underline is shown starting from the next line. On top of that it's also inconsistent with open_float and jump. Solution: clamp starting column position in underline handler to be right before EOL to make it visible and consistent with other handlers, open_float and jump.
* fix(glob): handling commas in letter pattern #34170Brynne Taylor2025-06-03
|
* vim-patch:bfeefc4: runtime(doc): clarify the effect of exclusive single char ↵zeertzjq2025-06-02
| | | | | | | | | selections (#34289) closes: vim/vim#17410 https://github.com/vim/vim/commit/bfeefc474a3ed25852491a93e1e5610774f4de8c Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:9.1.1409: using f-flag in 'complete' conflicts with Neovimzeertzjq2025-06-03
| | | | | | | | | | | | | | Problem: using f-flag in 'complete' conflicts with Neovims filename completion (glepnir, after v9.1.1301). Solution: use upper-case "F" flag for completion functions (Girish Palya). fixes: vim/vim#17347 closes: vim/vim#17378 https://github.com/vim/vim/commit/14f6da5ba8d602263fc7bf6cb899c8520f4c3060 Co-authored-by: Girish Palya <girishji@gmail.com>
* vim-patch:fa8b7db: runtime(doc): tweak documentation style in options.txtzeertzjq2025-06-03
| | | | | | | | closes: vim/vim#17229 https://github.com/vim/vim/commit/fa8b7db99afad9074e4e1f89b49046836ac61d5b Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
* vim-patch:9.1.1311: completion: not possible to limit number of matcheszeertzjq2025-06-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: completion: not possible to limit number of matches Solution: allow to limit the matches for 'complete' sources by using the "{flag}^{limit}" notation (Girish Palya) This change extends the 'complete' option to support limiting the number of matches returned from individual completion sources. **Rationale:** In large files, certain sources (such as the current buffer) can generate an overwhelming number of matches, which may cause more relevant results from other sources (e.g., LSP or tags) to be pushed out of view. By specifying per-source match limits, the completion menu remains balanced and diverse, improving visibility and relevance of suggestions. A caret (`^`) followed by a number can be appended to a source flag to specify the maximum number of matches for that source. For example: ``` :set complete=.^9,w,u,t^5 ``` In this configuration: - The current buffer (`.`) will return up to 9 matches. - The tag completion (`t`) will return up to 5 matches. - Other sources (`w`, `u`) are not limited. This feature is fully backward-compatible and does not affect behavior when the `^count` suffix is not used. The caret (`^`) was chosen as the delimiter because it is least likely to appear in file names. closes: vim/vim#17087 https://github.com/vim/vim/commit/0ac1eb3555445f4c458c06cef7c411de1c8d1020 Cherry-pick test_options.vim change from patch 9.1.1325. Co-authored-by: Girish Palya <girishji@gmail.com>
* vim-patch:9.1.1301: completion: cannot configure completion functions with ↵zeertzjq2025-06-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'complete' Problem: completion: cannot configure completion functions with 'complete' Solution: add support for setting completion functions using the f and o flag for 'complete' (Girish Palya) This change adds two new values to the `'complete'` (`'cpt'`) option: - `f` – invokes the function specified by the `'completefunc'` option - `f{func}` – invokes a specific function `{func}` (can be a string or `Funcref`) These new flags extend keyword completion behavior (e.g., via `<C-N>` / `<C-P>`) by allowing function-based sources to participate in standard keyword completion. **Key behaviors:** - Multiple `f{func}` values can be specified, and all will be called in order. - Functions should follow the interface defined in `:help complete-functions`. - When using `f{func}`, escaping is required for spaces (with `\`) and commas (with `\\`) in `Funcref` names. - If a function sets `'refresh'` to `'always'`, it will be re-invoked on every change to the input text. Otherwise, Vim will attempt to reuse and filter existing matches as the input changes, which matches the default behavior of other completion sources. - Matches are inserted at the keyword boundary for consistency with other completion methods. - If finding matches is time-consuming, `complete_check()` can be used to maintain responsiveness. - Completion matches are gathered in the sequence defined by the `'cpt'` option, preserving source priority. This feature increases flexibility of standard completion mechanism and may reduce the need for external completion plugins for many users. **Examples:** Complete matches from [LSP](https://github.com/yegappan/lsp) client. Notice the use of `refresh: always` and `function()`. ```vim set cpt+=ffunction("g:LspCompletor"\\,\ [5]). # maxitems = 5 def! g:LspCompletor(maxitems: number, findstart: number, base: string): any if findstart == 1 return g:LspOmniFunc(findstart, base) endif return {words: g:LspOmniFunc(findstart, base)->slice(0, maxitems), refresh: 'always'} enddef autocmd VimEnter * g:LspOptionsSet({ autoComplete: false, omniComplete: true }) ``` Complete matches from `:iabbrev`. ```vim set cpt+=fAbbrevCompletor def! g:AbbrevCompletor(findstart: number, base: string): any if findstart > 0 var prefix = getline('.')->strpart(0, col('.') - 1)->matchstr('\S\+$') if prefix->empty() return -2 endif return col('.') - prefix->len() - 1 endif var lines = execute('ia', 'silent!') if lines =~? gettext('No abbreviation found') return v:none # Suppresses warning message endif var items = [] for line in lines->split("\n") var m = line->matchlist('\v^i\s+\zs(\S+)\s+(.*)$') if m->len() > 2 && m[1]->stridx(base) == 0 items->add({ word: m[1], info: m[2], dup: 1 }) endif endfor return items->empty() ? v:none : items->sort((v1, v2) => v1.word < v2.word ? -1 : v1.word ==# v2.word ? 0 : 1) enddef ``` **Auto-completion:** Vim's standard completion frequently checks for user input while searching for new matches. It is responsive irrespective of file size. This makes it well-suited for smooth auto-completion. You can try with above examples: ```vim set cot=menuone,popup,noselect inf autocmd TextChangedI * InsComplete() def InsComplete() if getcharstr(1) == '' && getline('.')->strpart(0, col('.') - 1) =~ '\k$' SkipTextChangedIEvent() feedkeys("\<c-n>", "n") endif enddef inoremap <silent> <c-e> <c-r>=<SID>SkipTextChangedIEvent()<cr><c-e> def SkipTextChangedIEvent(): string # Suppress next event caused by <c-e> (or <c-n> when no matches found) set eventignore+=TextChangedI timer_start(1, (_) => { set eventignore-=TextChangedI }) return '' enddef ``` closes: vim/vim#17065 https://github.com/vim/vim/commit/cbe53191d01926c045a39198b3a9517e3c5077d2 Temporarily remove bufname completion with #if 0 to make merging easier. Co-authored-by: Girish Palya <girishji@gmail.com> Co-authored-by: Christian Brabandt <cb@256bit.org> Co-authored-by: glepnir <glephunter@gmail.com>
* fix(extui): properly setup "more" window for changed bufferLuuk van Baal2025-06-02
| | | | | | Problem: Buffer setup after moving the message buffer to the "more" window after ff95d7ff is incomplete. Solution: Adjust and invoke tab_check_wins() to do the setup instead.
* fix(extui): reposition "more" window after entering cmdwinLuuk van Baal2025-06-02
| | | | | | | Problem: Closing the "more" window for an entered cmdwin in ff95d7ff9 still requires special casing to properly handle "more" visibility. Solution: Reposition the "more" window instead; anchoring it to the cmdwin.
* vim-patch:95ea0b0: runtime(doc): make 'shiftwidth' setting more precise (#34266)zeertzjq2025-06-02
| | | | | | | closes: vim/vim#17414 https://github.com/vim/vim/commit/95ea0b0f8de4ab6e13bf090f33b8cbfe5b6e5c9f Co-authored-by: Damien Lejay <damien@lejay.be>
* fix(eval): winnr('$') counts non-current hidden/unfocusable windows #34207luukvbaal2025-06-01
| | | | | | | | | | | 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.
* docs: news, intro, lsp, api #33687Justin M. Keyes2025-06-01
|
* fix(extui): adjust "more" window routing (#34251)luukvbaal2025-06-01
| | | | | | | | | | | | | Problem: Message lines from multiple message events that end up spilling 'cmdheight' end up spread out over the cmdline and "more" window. Messages emitted as feedback to a typed :command (rather than its sole purpose like :echo/:=) are routed to the more window. The more window isn't closed when entering the cmdwin, and doesn't allow `vim.hl.on_yank()`. Solution: When first opening the "more" window for spilled messages, move the message buffer to the more window. Restrict routing of typed commands to echo kinds. Ignore all events but WinLeave and TextYankPost.
* Merge pull request #34239 from e-kwsm/vim-9.1.1342zeertzjq2025-06-01
|\ | | | | vim-patch:9.1.{1342,1420}
| * vim-patch:9.1.1342: Shebang filetype detection can be improvedEisuke Kawashima2025-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Shebang filetype detection can be improved Solution: Improve detection logic (Eisuke Kawashima) Vim does not correctly detect filetype from - `#!/usr/bin/env --split-string=awk -f` - `#!/usr/bin/env -S -i awk -f` - `#!/usr/bin/env -S VAR= awk -f` So update the current detection logic to detect those cases. closes: vim/vim#17199 https://github.com/vim/vim/commit/f102f4c2e80f5493a02a7b1130f11615d60b6295 Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
* | feat(lsp)!: pass entire entry to format function (#34166)Maria José Solano2025-05-31
|/ | | | | * feat(lsp)!: pass entire entry to format function * refactor(lsp): deprecate `vim.lsp.log.should_log()`
* vim-patch:9.1.1419: It is difficult to ignore all but some events (#34245)luukvbaal2025-05-31
| | | | | | | | Problem: It is difficult to ignore all but some events. Solution: Add support for a "-" prefix syntax in '(win)eventignore' that subtracts an event from the ignored set if present (Luuk van Baal). https://github.com/vim/vim/commit/8cc6d8b187d53c70c5fdc8fb83d4d3cef35e6d44
* vim-patch:a4a3f71: runtime(doc): clarify tabstop settings and guidancezeertzjq2025-05-31
| | | | | | | | | | closes: vim/vim#17381 https://github.com/vim/vim/commit/a4a3f712e250299bb788a1de9c7557ba0de92f06 Co-authored-by: Damien Lejay <damien@lejay.be> Co-authored-by: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com> Co-authored-by: Christian Brabandt <cb@256bit.org>
* fix(treesitter): parser metadata annotationsChristian Clason2025-05-29
| | | | | | | | Problem: `TSLangInfo` annotation does not reflect the structure returned by `vim.treesitter.language.inspect()`. Solution: Move version information under new (optional since ABI 15 only) `TSLangMetadata` field.
* fix(vim.system): improve error message when cwd does not existLewis Russell2025-05-29
| | | | | | | | | | Problem: vim.uv.spawn will emit ENOENT for either when the cmd or cwd do not exist and does not tell you which. Solution: If an error occurs, check if cwd was supplied and included in the error message if it does not exist.
* vim-patch:9.1.1417: missing info about register completion in ↵zeertzjq2025-05-29
| | | | | | | | | | | | | | 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 https://github.com/vim/vim/commit/49864aecd0d23676e202b30bc8705c78ae52d680 Co-authored-by: glepnir <glephunter@gmail.com>
* vim-patch:9.1.1408: not easily possible to complete from register content ↵glepnir2025-05-28
| | | | | | | | | | | (#34198) Problem: not easily possible to complete from register content Solution: add register-completion submode using i_CTRL-X_CTRL-R (glepnir) closes: vim/vim#17354 https://github.com/vim/vim/commit/0546068aaef2b1a40faa2945ef7eba249739f219
* fix(filetype): error when `vim.filetype.match{buf=fn.bufadd('a.sh')}` #34155phanium2025-05-27
| | | | | Problem: Error when `vim.filetype.match` a buffer with suffix `sh`. Solution: fallback to an empty string as buffer content.
* fix(gO): use non-breaking space #34197altermo2025-05-27
|
* feat(api): set nvim_echo() kind for ext_messages (#33998)luukvbaal2025-05-27
| | | | | Problem: Unable to emit a message with arbitrary kind. Solution: Add a "kind" opts field to nvim_echo(). Use it to set the "list_cmd" kind for vim.show_pos().
* fix(extui): incorrect cmdline cursor position (#34201)luukvbaal2025-05-27
| | | | | | | Problem: Calculated cmdline cursor position can be smaller than 0. Prompt part of the cmdline is translated, while it should support "\t" characters. Solution: Remove prompt part from the stored "cmdbuff" and get rid of dubious +/-1 from cmdline cursor calculation.
* feat(extui): route to "more" window if it is open (#34190)luukvbaal2025-05-27
| | | | | | | | | | | Problem: An already open "more" window is the most convenient place to route messages to with `cfg.msg.pos == 'cmd'`. Instead we route to the cmdline (unless that message also exceeds 'cmdheight'). Solution: Route to "more" window while it is open and scroll to bottom to show the newest message. This is more convenient and more efficient due to not writing to the target buffer first (which is done to calculate the height of the message). (Ensure message highlights are deleted when text is replaced.)
* vim-patch:a6172f8: runtime(doc): Correct allowed characters at :help 'filetype'zeertzjq2025-05-27
| | | | | | | | closes: vim/vim#17366 https://github.com/vim/vim/commit/a6172f8c5ce136d877965bf49881fc6e71ea4edf Co-authored-by: Doug Kearns <dougkearns@gmail.com>
* perf(runtime): vim.trim for long only whitespace stringsmonkoose2025-05-26
|
* fix(extui): write each message chunk pattern separately (#34188)luukvbaal2025-05-26
| | | | | | | | | | Problem: Bulking message lines to write in a single API call is complicated and still not correct w.r.t. overwriting highlights. Solution: Write each chunk pattern separately with it's highlight such that it will be spliced correctly for message chunks that contain a carriage return. Go with correctness over performance until this proves to be too inefficient. Also add an identifying name to the various extui buffers.
* fix(lsp): announce `normalizesLineEndings` capability (#34175)Maria José Solano2025-05-25
|
* refactor(lsp): use `vim.validate` in `vim.lsp.log` (#34165)Maria José Solano2025-05-25
|
* fix(extui): using tracked message column in cleared buffer (#34154)luukvbaal2025-05-24
| | | | | | Problem: Using tracked message column as column in cleared buffer. Solution: Ensure column does not exceed current line length. Further work to ensure carriage return and cmdline block mode work properly.
* fix(treesitter): properly clip nested injectionsRiley Bruins2025-05-24
|
* fix(extui): map wincmd instead of remapped key (#34151)phanium2025-05-24
| | | | Problem: "q" cannot close window when `<c-w>` is mapped. Solution: Map q to `<Cmd>wincmd c<CR>`.
* feat(search): increase `MAX_COUNT` to 999Christian Clason2025-05-24
| | | | | | | | | 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>
* fix(extui): append consecutive :echon messagesLuuk van Baal2025-05-24
| | | | | Problem: Consecutive `:echon` messages are printed on separate lines. Solution: Implement the new msg_show->append parameter.
* fix(lsp): fix error with InsertReplaceEdit events #33973Evan Hahn2025-05-22
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: Some LSPs cause the following completion error (reformatted slightly): Error executing vim.schedule lua callback: .../runtime/lua/vim/lsp/completion.lua:373 attempt to index field 'range' (a nil value) This is because an internal function assumes edits are either missing or of type `TextEdit`, but there's a third [possibility][0] that's not handled: the `InsertReplaceEdit`. This was previously reported in at least two issues: - https://github.com/neovim/neovim/issues/33142 - https://github.com/neovim/neovim/issues/33224 Solution: Don't assume the edit is a `TextEdit`. This implicitly handles `InsertReplaceEdit`s. Also, add a test case for this, which previously caused an error. [0]: https://github.com/neovim/neovim/blob/2c07428966a74c76003e00e2a37bf98eb8802c93/runtime/lua/vim/lsp/_meta/protocol.lua#L1099
* fix: use nvim namespace convention #34010Yochem van Rosmalen2025-05-22
|