aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
Commit message (Collapse)AuthorAge
...
* refactor(lsp): stateful data abstraction, vim.lsp.Capability #34639Yi Ming2025-07-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Closes #31453 Solution: Introduce `vim.lsp.Capability`, which may serve as the base class for all LSP features that require caching data. it - was created if there is at least one client that supports the specific method; - was destroyed if all clients that support the method were detached. - Apply the refactor for `folding_range.lua` and `semantic_tokens.lua`. - Show active features in :checkhealth. Future: I found that these features that are expected to be refactored by `vim.lsp.Capability` have one characteristic in common: they all send LSP requests once the document is modified. The following code is different, but they are all for this purpose. - semantic tokens: https://github.com/neovim/neovim/blob/fb8dba413f2bcaa61c15d1854b28112e3e91a035/runtime/lua/vim/lsp/semantic_tokens.lua#L192-L198 - inlay hints, folding ranges, document color https://github.com/neovim/neovim/blob/fb8dba413f2bcaa61c15d1854b28112e3e91a035/runtime/lua/vim/lsp/inlay_hint.lua#L250-L266 I think I can sum up this characteristic as the need to keep certain data synchronized with the latest version computed by the server. I believe we can handle this at the `vim.lsp.Capability` level, and I think it will be very useful. Therefore, my next step is to implement LSP request sending and data synchronization on `vim.lsp.Capability`, rather than limiting it to the current create/destroy data approach.
* fix(lsp): convert the encoded position to line byte (#34824)Yi Ming2025-07-06
|
* feat(options): per-buffer 'busy' status #34493Shadman2025-07-06
| | | | | | | | Problem: Plugins cannot mark a buffer as "busy". Solution: - Add a buffer-local 'busy' option. - Show a busy indicator in the default 'statusline'.
* vim-patch:9.1.1518: getcompletiontype() may crash (#34819)zeertzjq2025-07-06
| | | | | | | | | | Problem: getcompletiontype() crashes when no completion is available (after v9.1.1509). Solution: Don't call set_expand_context() (zeertzjq) fixes: vim/vim#17681 closes: vim/vim#17684 https://github.com/vim/vim/commit/e2c0f81dd014b03a40af6b2c42463b7a0d92f5d6
* refactor(lsp): narrower `hierarchy` argument type (#34799)Maria José Solano2025-07-06
|
* fix(treesitter): inconsistent highlight of multiline combined injection #32619Artem2025-07-06
| | | | | | | Problem: Combined injections not entirely highlighted. Solution: Reapply layer highlights on each line.
* fix(vim.pack): add() stops unexpectedly on package load error #34787Phạm Bình An2025-07-06
| | | | | | | | | | | Problem: Error when adding a plugin will make all following plugins not `:packadd`ed Solution: - add() should handle errors from :packadd with pcall() Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* feat(lsp): handle deprecated document symbols (#34751)Maria José Solano2025-07-06
|
* refactor(lsp): consistent usage of vim.notify #34802Maria José Solano2025-07-06
|
* vim-patch:9.1.1509: patch 9.1.1505 was not goodzeertzjq2025-07-06
| | | | | | | | | | | | | | | | | Problem: Patch 9.1.1505 was not good Solution: Revert "patch 9.1.1505: not possible to return completion type for :ex command" and instead add the getcompletiontype() function (Hirohito Higashi). related: vim/vim#17606 closes: vim/vim#17662 https://github.com/vim/vim/commit/96b3ef23896ce70b2fdf3425ba2c013ce2840db6 Cherry-pick Test_multibyte_expression() from Vim, as it passes. Co-authored-by: Hirohito Higashi <h.east.727@gmail.com> Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
* vim-patch:9.1.1505: not possible to return completion type for :ex commandzeertzjq2025-07-06
| | | | | | | | | | | | | Problem: not possible to return command-line completion type for :ex command Solution: make getcmdcompltype() accept an optional and return the command-line completion for that arg (Shougo Matsushita). closes: vim/vim#17606 https://github.com/vim/vim/commit/5d2354fc07b642f8835bef27e6dd46ee705726b5 Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
* vim-patch:9.1.1512: completion: can only complete from keyword characters ↵zeertzjq2025-07-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#34798) Problem: completion: can only complete from keyword characters Solution: remove this restriction, allow completion functions when called from i_CTRL-N/i_CTRL-P to be triggered from non-keyword characters (Girish Palya) Previously, functions specified in the `'complete'` option were restricted to starting completion only from keyword characters (as introduced in PR 17065). This change removes that restriction. With this change, user-defined functions (e.g., `omnifunc`, `userfunc`) used in `'complete'` can now initiate completion even when triggered from non-keyword characters. This makes it easier to reuse existing functions alongside other sources without having to consider whether the cursor is on a keyword or non-keyword character, or worry about where the replacement should begin (i.e., the `findstart=1` return value). The logic for both the “collection” and “filtering” phases now fully respects each source’s specified start column. This also extends to fuzzy matching, making completions more predictable. Internally, this builds on previously merged infrastructure that tracks per-source metadata. This PR focuses on applying that metadata to compute the leader string and insertion text appropriately for each match. Also, a memory corruption has been fixed in prepare_cpt_compl_funcs(). closes: vim/vim#17651 https://github.com/vim/vim/commit/ba11e78f1d5342786faed0ebd5b09ffee7f7ff86 Co-authored-by: Girish Palya <girishji@gmail.com>
* vim-patch:9.1.1490: 'wildchar' does not work in search contextszeertzjq2025-07-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: 'wildchar' does not work in search contexts Solution: implement search completion when 'wildchar' is typed (Girish Palya). This change enhances Vim's command-line completion by extending 'wildmode' behavior to search pattern contexts, including: - '/' and '?' search commands - ':s', ':g', ':v', and ':vim' commands Completions preserve the exact regex pattern typed by the user, appending the completed word directly to the original input. This ensures that all regex elements — such as '<', '^', grouping brackets '()', wildcards '\*', '.', and other special characters — remain intact and in their original positions. --- **Use Case** While searching (using `/` or `?`) for lines containing a pattern like `"foobar"`, you can now type a partial pattern (e.g., `/f`) followed by a trigger key (`wildchar`) to open a **popup completion menu** showing all matching words. This offers two key benefits: 1. **Precision**: Select the exact word you're looking for without typing it fully. 2. **Memory aid**: When you can’t recall a full function or variable name, typing a few letters helps you visually identify and complete the correct symbol. --- **What’s New** Completion is now supported in the following contexts: - `/` and `?` search commands - `:s`, `:g`, `:v`, and `:vimgrep` ex-commands --- **Design Notes** - While `'wildchar'` (usually `<Tab>`) triggers completion, you'll have to use `<CTRL-V><Tab>` or "\t" to search for a literal tab. - **Responsiveness**: Search remains responsive because it checks for user input frequently. --- **Try It Out** Basic setup using the default `<Tab>` as the completion trigger: ```vim set wim=noselect,full wop=pum wmnu ``` Now type: ``` /foo<Tab> ``` This opens a completion popup for matches containing "foo". For matches beginning with "foo" type `/\<foo<Tab>`. --- **Optional: Autocompletion** For automatic popup menu completion as you type in search or `:` commands, include this in your `.vimrc`: ```vim vim9script set wim=noselect:lastused,full wop=pum wcm=<C-@> wmnu autocmd CmdlineChanged [:/?] CmdComplete() def CmdComplete() var [cmdline, curpos, cmdmode] = [getcmdline(), getcmdpos(), expand('<afile>') == ':'] var trigger_char = '\%(\w\|[*/:.-]\)$' var not_trigger_char = '^\%(\d\|,\|+\|-\)\+$' # Exclude numeric range if getchar(1, {number: true}) == 0 # Typehead is empty, no more pasted input && !wildmenumode() && curpos == cmdline->len() + 1 && (!cmdmode || (cmdline =~ trigger_char && cmdline !~ not_trigger_char)) SkipCmdlineChanged() feedkeys("\<C-@>", "t") timer_start(0, (_) => getcmdline()->substitute('\%x00', '', 'ge')->setcmdline()) # Remove <C-@> endif enddef def SkipCmdlineChanged(key = ''): string set ei+=CmdlineChanged timer_start(0, (_) => execute('set ei-=CmdlineChanged')) return key == '' ? '' : ((wildmenumode() ? "\<C-E>" : '') .. key) enddef **Optional: Preserve history recall behavior** cnoremap <expr> <Up> SkipCmdlineChanged("\<Up>") cnoremap <expr> <Down> SkipCmdlineChanged("\<Down>") **Optional: Customize popup height** autocmd CmdlineEnter : set bo+=error | exec $'set ph={max([10, winheight(0) - 4])}' autocmd CmdlineEnter [/?] set bo+=error | set ph=8 autocmd CmdlineLeave [:/?] set bo-=error ph& ``` closes: vim/vim#17570 https://github.com/vim/vim/commit/6b49fba8c8b97b178ddf81a9ca0c6f36c66f942f Co-authored-by: Girish Palya <girishji@gmail.com>
* vim-patch:9.1.1477: no easy way to deduplicate textzeertzjq2025-07-05
| | | | | | | | | | | | Problem: no easy way to deduplicate text Solution: add the :uniq ex command (Hirohito Higashi) closes: vim/vim#17538 https://github.com/vim/vim/commit/74f0a77bb9a170a25b03cacf640aa4e1b1d222b2 Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
* fix(lsp): consistent use of `vim.notify`/logging with unsupported methodsMaria José Solano2025-07-04
|
* fix(lsp): remove extra notify on empty hoverMaria José Solano2025-07-04
|
* fix(diagnostic): fix flaky errorLewis Russell2025-07-04
|
* feat(pack): add built-in plugin manager `vim.pack`Evgeni Chasnovski2025-07-04
| | | | | | | | Problem: No built-in plugin manager Solution: Add built-in plugin manager Co-authored-by: Lewis Russell <lewis6991@gmail.com>
* feat(async): add `vim._async`Lewis Russell2025-07-04
| | | | | | Problem: no easy built-in way to do async Solution: add `vim._async`
* vim-patch:9.1.1507: symlinks are resolved on :cd commands (#34758)glepnir2025-07-04
| | | | | | | | | | | | | Problem: File paths change from symlink to target path after :cd command when editing files through symbolic links Solution: Add "~" flag to 'cpoptions' to control symlink resolution. When not included (default), symlinks are resolved maintaining backward compatibility. When included, symlinks are preserved providing the improved behavior. (glepnir) related: neovim/neovim#15695 closes: vim/vim#17628 https://github.com/vim/vim/commit/4ade668fb62ebf3f8be537fe451caed6bd1eba9a
* feat(runtime): accept predicates in take and skip (#34657)Mart-Mihkel Aun2025-07-03
| | | | | | Make `vim.iter():take()` and `vim.iter():skip()` optionally accept predicates to enable takewhile and skipwhile patterns used in functional programming.
* vim-patch:9.1.1504: filetype: numbat files are not recognizedChristian Clason2025-07-03
| | | | | | | | | | | | | | | Problem: filetype: numbat files are not recognized Solution: detect *.nbt files as numbat filetype (0xadk) References: - https://github.com/sharkdp/numbat - https://github.com/sharkdp/numbat/tree/master/numbat/modules closes: vim/vim#17643 https://github.com/vim/vim/commit/20eb68a8f29008fe9041e60b920246f64ee29335 Co-authored-by: 0xadk <0xadk@users.noreply.github.com>
* vim-patch:9.1.1503: filetype: haxe files are not recognizedChristian Clason2025-07-03
| | | | | | | | | | | | | | | Problem: filetype: haxe files are not recognized Solution: detect *.hx files as haxe filetype (0xadk) References: - https://haxe.org/ - https://code.haxe.org/category/beginner/hello-world.html closes: vim/vim#17644 https://github.com/vim/vim/commit/b46e3aa0fa08a9007c3f7115cb7a46d7389616b2 Co-authored-by: 0xadk <0xadk@users.noreply.github.com>
* vim-patch:9.1.1502: filetype: quickbms files are not recognizedChristian Clason2025-07-03
| | | | | | | | | | | | | | | Problem: filetype: quickbms files are not recognized Solution: detect *.bms files as quickbms filetype (0xadk) Reference: - https://aluigi.altervista.org/quickbms.htm closes: vim/vim#17645 https://github.com/vim/vim/commit/fdcdded4d58523a5e9565a562466f062fb072109 Co-authored-by: 0xadk <0xadk@users.noreply.github.com>
* vim-patch:9.1.1501: filetype: flix files are not recognizedChristian Clason2025-07-03
| | | | | | | | | | | | | | | | Problem: filetype: flix files are not recognized Solution: detect *.flix files as flix filetype (0xadk) References: - https://flix.dev/ - https://doc.flix.dev/introduction.html closes: vim/vim#17646 https://github.com/vim/vim/commit/b211916e0ae818e0653ae23ae71565b24ccba307 Co-authored-by: 0xadk <0xadk@users.noreply.github.com>
* fix(treesitter): ensure TSLuaTree is always immutableRodrigodd2025-07-02
| | | | | | | | | | | | | | | | Problem: The previous fix in #34314 relies on copying the tree in `tree_root` to ensure the `TSNode`'s tree cannot be mutated. But that causes the problem where two calls to `tree_root` return nodes from different copies of a tree, which do not compare as equal. This has broken at least one plugin. Solution: Make all `TSTree`s on the Lua side always immutable, avoiding the need to copy the tree in `tree_root`, and make the only mutation point, `tree_edit`, copy the tree instead.
* fix(vim.system): env=nil passes env=nil to uv.spawnLewis Russell2025-07-02
| | | | | | | | | | | | 731e616a79 made it so passing `{env = nil, clear_env = true }` would pass `{env = {}}` to `vim.uv.spawn`. However this is not what `clear_env` is (arguably) supposed to do. If `env=nil` then that implies the uses wants `vim.uv.spawn()` to use the default environment. Adding `clear_env = true` simply prevents `NVIM` (the base environment) from being added. Fixes #34730
* fix(lsp): use `vim.notify` with action-less `showMessage` requests (#34720)Maria José Solano2025-07-01
|
* fix: type of nvim_echoLewis Russell2025-07-01
|
* Merge #34715 vim.version improvementsJustin M. Keyes2025-07-01
|\
| * feat(vim.version): add `vim.version.intersect()`Evgeni Chasnovski2025-06-30
| | | | | | | | | | | | | | | | Problem: No way to compute intersection of two version ranges, which is useful when computing version range that fits inside several reference ranges. Solution: Add `vim.version.intersect()`.
| * fix(vim.version): improve construction of '<=a.b.c' and '>a.b.c' rangesEvgeni Chasnovski2025-06-30
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: `vim.version.range('<=a.b.c')` is not precise when it comes to its right hand side. This is due to version ranges using exclusive right hand side. While `vim.version.range('>a.b.c')` is not precise when it comes to its left hand side because left hand sides are inclusive. Solution: For '>=a.b.c' increase `to` from 'a.b.c' to the smallest reasonable version that is bigger than 'a.b.c'. For '<a.b.c' do the same for `from`. More proper solution is an explicit control over inclusivity of version range sides, but it has more side effects and requires design decisions.
| * feat(vim.version): make `tostring()` return human-readable version rangeEvgeni Chasnovski2025-06-30
| | | | | | | | | | | | | | Problem: `tostring()` applied to version range doesn't return human-readable text with information about the range. Solution: Add `__tostring()` method.
| * docs(vim.version): document `vim.VersionRange` as a dedicated classEvgeni Chasnovski2025-06-30
| |
* | doc(vim.version): options formatting #34716James Trew2025-06-30
| |
* | fix(exrc): exrc knows its own location (#34638)Yochem van Rosmalen2025-06-29
| | | | | | | | | | | | | | | | | | | | | | fix(exrc): lua exrc files know their location Problem: 'exrc' files are inherently bound to their location / workspace and therefore require to "know" their location on the filesystem. However, currently using `debug.getinfo(1, 'S')` returns `"<nvim>"`. Solution: Include the filepath as chunkname in `loadstring()` and `nlua_exec()`.
* | refactor(health): use vim.system():wait() #34702Tom Ampuero2025-06-29
|/ | | | | | | Problem: - The ripgrep probe still used the legacy `vim.fn.system()` Solution: - Replace `vim.fn.system()` with `vim.system({rg_path, '-V'}):wait()`
* fix(lsp): fix workspace diagnostic request to follow spec (#34674)Zie Mcdowell2025-06-27
| | | | | * fix(lsp): fix workspace diagnostic request to follow spec * refactor(lsp): add type annotation
* feat(extui): don't enter pager for routed message #34679luukvbaal2025-06-27
| | | | | | | | Problem: Messages routed to the pager to be shown in full, enter the pager automatically, yielding another "press-q-prompt". Solution: Only enter the pager when requested explicitly. Otherwise, close the pager on the next typed mapping, unless that mapping entered the pager.
* perf(extui): delay creating windows, buffers and parser (#34665)luukvbaal2025-06-27
| | | | | | | | | | Problem: vim._extui unconditionally creates windows, buffers and the Vimscript cmdline highlighter when it is first loaded. Solution: Schedule first creation of the window so that first redraw happens sooner (still need to create at least the cmdline window asap as it can have a different highlight through hl-MsgArea; thus further delaying until the first event that needs a particular target seems redundant). Load the cmdline highlighter on the first cmdline_show event.
* feat(ui): emit "msg_clear" event after clearing the screen (#34035)luukvbaal2025-06-26
| | | | | | | | Problem: ext_messages cannot tell when the screen was cleared, which is needed to clear visible messages. An empty message is also never emitted, but clears messages from the message grid. Solution: Repurpose the "msg_clear" event to be emitted when the screen was cleared. Emit an empty message with the `empty` kind to hint to a UI to clear the cmdline area.
* fix(lsp): include context for each client in multi-handler results (#34669)Maria José Solano2025-06-26
|
* fix(lsp/health): always use vim.inspect to show root_markers (#34667)Gregory Anders2025-06-26
| | | | | | | | | | | In https://github.com/neovim/neovim/pull/34092 we changed the healthcheck to display root markers as a concatenated list if the first item in root_markers is a string (not a table). However, this does not solve the general case, because root_markers can contain a string as the first element, but a table as the 2nd element. Because root_markers has a more complex structure we should always just display it using vim.inspect, rather than adding a special case for when all items are a string.
* feat(defaults): map "grt" to LSP type_definition #34642Caleb White2025-06-26
|
* docs(api): document types using LuaCATS typesLewis Russell2025-06-26
| | | | | | | | | | | | | | | | | | | | - Render Lua types in api.txt. - Added `DictAs(name)` API type which acts the same as `Dict` (no parens) when generating the dispatchers, but acts the same as `Dict(name)` when generating docs. - Added `Tuple(...)` API type which is the treated the as `Array` for generating the dispatchers, but is used to document richer types. - Added `Enum(...)` API type to better document enums - Improve typing of some API functions. - Improve c_grammar to properly parse API types and replace string pattern logic in the parsers. - Removed all the hardcoded type overrides in gen_eval_files.lua
* fix(lsp): add `RequestFailed` error code constant #34645Maria José Solano2025-06-26
| | | | Also remove `serverErrorStart/End` as [the spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#errorCodes) says that they're deprecated and don't even represent a real error code.
* fix(vim.system): clear_env=true gives an invalid env to uv.spawn #33955Birdee2025-06-25
| | | | | | | | | Problem: In setup_env, some needed logic is bypassed when clear_env=true. Solution: Drop the early return in setup_env(). Co-authored-by: BirdeeHub <birdee@localhost>
* fix: map wincmd instead of remap #34635phanium2025-06-25
| | | Same issue: a59b052857ca43997b9e8be0a1d5c870ce172807
* feat(prompt): prompt_getinput() gets current input #34491Shadman2025-06-24
| | | | | | | | | | Problem: Not easy to get user-input in prompt-buffer before the user submits the input. Under the current system user/plugin needs to read the buffer contents, figure out where the prompt is, then extract the text. Solution: - Add prompt_getinput(). - Extract prompt text extraction logic to a separate function
* refactor(lsp): use `vim.lsp.buf_request_all` internally (#34604)Maria José Solano2025-06-23
|