aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
Commit message (Collapse)AuthorAge
...
* 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
|
* fix(lsp): avoid `foldclose()` after current window-buffer changed #33901Yi Ming2025-05-22
| | | | | | | Problem: Because the buffer in the window may change before the request is completed, foldclose() might be executed on the wrong buffer. Solution: Avoid that.
* feat(outline): smaller indentation #34005altermo2025-05-22
|
* feat(glob): new Glob implementation based on Peglob #33605Brynne Taylor2025-05-22
| | | | | | | |vim.glob.to_lpeg()| uses a new LPeg-based implementation (Peglob) that provides ~50% speedup for complex patterns. The implementation restores support for nested braces and follows LSP 3.17 specification with additional constraints for improved correctness and resistance to backtracking edge cases.
* fix(extui): reset message state after "search_cmd" message (#34119)luukvbaal2025-05-21
| | | | | | Problem: A "search_cmd" message alters the message state (since 8e8f4523), unnecessarily affecting logic for messages that follow. Solution: Reset the appropriate variables after a "search_cmd" message. Don't show "search_cmd" message with zero 'cmdheight'.
* fix(diagnostic): accept multiple namespace in `open_float()` (#34073)Maria José Solano2025-05-21
|
* fix(diagnostics): fixed virtual_text cursormoved autocmd error (#34017)Rijul Kapoor2025-05-21
|
* Merge pull request #34090 from yochem/exrc-search-parentGregory Anders2025-05-20
|\ | | | | feat(exrc): unset 'exrc' to stop searching parent directories
| * feat(exrc): stop searching in parent directories by unsetting 'exrc'Yochem van Rosmalen2025-05-20
| | | | | | | | | | | | | | | | | | | | Problem: No way for a user to limit 'exrc' search in parent directories (compare editorconfig.root). Solution: A configuration file can unset 'exrc', disabling the search for its parent directories.
| * fix(defaults): start exrc search from parent directoryYochem van Rosmalen2025-05-19
| | | | | | | | | | | | | | | | | | | | Problem: The exrc file in the current directory is executed twice, here and in `do_exrc_initalization()`. Solution: Start search from parent directory. Let core handle exrc in current directory.
* | fix(lsp/health): ensure valid table before concatenating (#34092)Gregory Anders2025-05-20
| | | | | | | | | | | | | | | | The root_markers field can now contain a table of tables (as of https://github.com/neovim/neovim/pull/33485) and :checkhealth will show an error in that case since Lua cannot concatenate a table of tables. Ensure that tables contain strings before concatenating and if not, fall back to using vim.inspect().
* | fix(diagnostic): deprecate `float` in `vim.diagnostic.Opts.Jump` (#34037)v1nh1shungry2025-05-19
|/
* feat(logs): show full paths in lsp logs (#33886)Anakin Childerhose2025-05-17
| | | | | | | | | | feat(logs): show full path of short_src in lsp logs Problem: - Cannot gf to info.short_src printed in the logs since only the last 16 characters are printed Solution: - Print full info.short_src and remove ...
* fix(extui): translate <Tab> in cmdline text (#34055)luukvbaal2025-05-17
| | | | | | | Problem: <Tab> is not translated on the cmdline, and exposes a wrong assumption in search messages that may contain multiple chunks. Solution: Translate unprintable characters in the cmdline content. Extract the 'search_count' from the last chunk and route 'search_cmd' to cmdline to handle multiple chunks.
* vim-patch:9.1.1396: 'grepformat' is a global option (#34060)zeertzjq2025-05-17
| | | | | | | | | | | | | | | Problem: The 'grepformat' option is global option, but it would be useful to have it buffer-local, similar to 'errorformat' and other quickfix related options (Dani Dickstein) Solution: Add the necessary code to support global-local 'grepformat', allowing different buffers to parse different grep output formats (glepnir) fixes: vim/vim#17316 closes: vim/vim#17315 https://github.com/vim/vim/commit/7b9eb6389d693dafcd502cda2ffc62564a2dbba9 Co-authored-by: glepnir <glephunter@gmail.com>
* fix(extui): better message highlighting after carriage return (#34034)luukvbaal2025-05-15
| | | | | | Problem: Incorrect message highlighting for highlighted message chunks containing carriage returns. Solution: Add a highlight for each substring ending in a newline or carriage return separately.