aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
Commit message (Collapse)AuthorAge
...
* feat(ui): ext_cmdline/messages for the TUI #27855luukvbaal2025-05-02
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: We have an unmaintained Vimscript parser and cmdline highlighting mechanism, with which it is hard to leverage the treesitter highlighter. Long messages result in a hit-enter-prompt. Solution: Implement a vim.ui_attach() UI, that replaces the message grid (orphaning some 3000+ LOC core C code). Introduce an experimental vim._extui module, because removing the message grid at the same time is too risky. The new UI leverages the bundled treesitter highlighter and parser for Vimscript, as well as the matchparen plugin, to highlight the cmdline. Messages are truncated in the cmdline area, or placed in a floating message box in the bottom right corner. Special ("list_cmd") messages and the message history are shown in a, "more prompt" (now a fully interactive regular window). Various default UI elements ('showcmd', 'ruler') are also placed in the cmdline area, as virtual text. `require('vim._extui').enable({})` enables the experimental UI. `{ msg.pos = 'box' }` or `:set cmdheight=0` enables the message box variant. Followup: - Come to a consensus for how best to represent messages (by default). - Start removing message grid when this is deemed a successful replacement. When that is finished, make this new UI the default and update a lot of tests.
* fix(lsp): handle `nil` buffer state in `documentColor` clear (#33746)Maria José Solano2025-05-01
|
* fix(diagnostic): allow virtual_{lines,text} cursor exclusivity #33517Michael Clayton2025-05-01
| | | | | | | | | | | | | | | | | | | | Problem: virtual_text diagnostics are great when skimming a file, and virtual_lines are great when "zooming in" on a particular problem. Having both enabled results in duplicate diagnostics on-screen. Solution: This PR expands the behavior of `current_line` for virtual_text and virtual_lines by making `virtual_text.current_line = false` distinct from `nil`. If you set: vim.diagnostic.config({ virtual_text = { current_line = false }, virtual_lines = { current_line = true }, }) With this configuration, virtual_text will be used to display diagnostics until the cursor reaches the same line, at which point they will be hidden and virtual_lines will take its place.
* Merge pull request #33738 from zeertzjq/vim-fa8b7dbzeertzjq2025-05-01
|\ | | | | vim-patch: doc updates
| * vim-patch:fb08192: runtime(doc): clarify the use of 'tagfunc', update a ↵zeertzjq2025-05-01
| | | | | | | | | | | | | | | | | | | | comment in tags.c related: vim/vim#17228 https://github.com/vim/vim/commit/fb08192ca75344d6467f9e7f9b9e6d4509df308a Co-authored-by: Christian Brabandt <cb@256bit.org>
| * vim-patch:partial:fa8b7db: runtime(doc): tweak documentation style in ↵zeertzjq2025-05-01
| | | | | | | | | | | | | | | | | | | | options.txt closes: vim/vim#17229 https://github.com/vim/vim/commit/fa8b7db99afad9074e4e1f89b49046836ac61d5b Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
* | feat(lsp): start/stop LSPs as necessary during vim.lsp.enable() #33702Jeremy Fleischman2025-04-30
|/ | | | | | | | | | Problem: enable() could be more flexible, so that it works even if called "late". Solution: - enable(true) calls `doautoall nvim.lsp.enable FileType`. - enable(false) calls `client:stop()` on matching clients. This will be useful for e.g. :LspStop/:LspStart also.
* feat(terminal): parse current buffer contents in nvim_open_term() (#33720)Gregory Anders2025-04-30
| | | | When nvim_open_term() is called with a non-empty buffer, the buffer contents are piped into the PTY.
* feat(lsp): `root_markers` can control priority #33485Lorenzo Bellina2025-04-30
| | | | | | | | | | | | | | | | | | Problem: root_markers cannot specify "equal priority filenames. Solution: Support nesting: { ... root_markers = { { ".stylua.toml", ".luarc.json" }, { ".git "} } ... } Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: Gregory Anders <github@gpanders.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(trust): support for trusting directories #33617Jeremy Fleischman2025-04-30
| | | | | | | | | | | | | | | | | | | | | Problem: Directories that are "trusted" by `vim.secure.read()`, are not detectable later (they will prompt again). https://github.com/neovim/neovim/discussions/33587#discussioncomment-12925887 Solution: `vim.secure.read()` returns `true` if the user trusts a directory. Also fix other bugs: - If `f:read('*a')` returns `nil`, we treat that as a successful read of the file, and hash it. `f:read` returns `nil` for directories, but it's also documented as returning `nil` "if it cannot read data with the specified format". I reworked the implementation so we explicitly treat directories differently. Rather than hashing `nil` to put in the trust database, we now put "directory" in there explicitly*. - `vim.secure.trust` (used by `:trust`) didn't actually work for directories, as it would blindly read the contents of a netrw buffer and hash it. Now it uses the same codepath as `vim.secure.read`, and as a result, works correctly for directories.
* feat(ui): use builtin completion popupmenu with ext_cmdline (#31269)luukvbaal2025-04-29
| | | | | | | | Problem: UIs implementing ext_cmdline/message must also implement ext_popupmenu in order to get cmdline completion with wildoptions+=pum. Solution: Allow marking a window as the ext_cmdline window through nvim_open_win(), including prompt offset. Anchor the cmdline- completion popupmenu to this window.
* Merge pull request #33667 from glepnir/vim-9.1.1341zeertzjq2025-04-29
|\ | | | | vim-patch: 9.1.{1341,1344}
| * vim-patch:ffc89e4 runtime(doc): clarify complete_match() and 'isexpand' optionglepnir2025-04-29
| | | | | | | | | | | | | | | | | | | | 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 https://github.com/vim/vim/commit/ffc89e47d014178bcd0a681ff2c8e18470cc972b
| * vim-patch:9.1.1341: cannot define completion triggersglepnir2025-04-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 https://github.com/vim/vim/commit/bcd5995b40a1c26e735bc326feb2e3ac4b05426b Co-authored-by: glepnir <glephunter@gmail.com>
* | Merge #33542 shada improvementsJustin M. Keyes2025-04-27
|\ \ | | | | | | | | | | | | | | | * feat(shada): don't store jumplist if '0 in 'shada' * fix(shada): don't store search and sub patterns if /0 in 'shada' * fix(shada): don't store empty replacement string * fix(shada): don't add '0' mark if f0 in 'shada'
| * | feat(shada): don't store jumplist if '0 in 'shada'Andre Toerien2025-04-27
| | |
* | | docs: lsp, lua #33682Justin M. Keyes2025-04-27
| | | | | | | | | | | | | | | | | | - sort fields alphabetically. - in the `vim.lsp.Client` docs, reference `vim.lsp.ClientConfig` instead of duplicating its docs. - cleanup lots of redundant-yet-drifted field docs.
* | | docs: lsp, emoji, startup #33446Justin M. Keyes2025-04-27
| | | | | | | | | Co-authored-by: Maria José Solano <majosolano99@gmail.com>
* | | fix(lsp): fallback to empty `capability_path` in `supports_registration`Maria José Solano2025-04-27
| | |
* | | fix(lsp): remove unused `ns` fieldMaria José Solano2025-04-27
| | |
* | | feat(checkhealth): trigger FileType event after showing report #33677Justin M. Keyes2025-04-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: `FileType` event is fired before checkhealth report is finished, so user can't override report settings or contents. https://github.com/neovim/neovim/pull/33172#issuecomment-2833513916 Solution: - Trigger FileType event later. - Document how to remove emojis.
* | | fix(lsp): properly handle `documentColor` from multiple servers #33656Maria José Solano2025-04-27
| | |
* | | fix(lsp): access correct client capability path in `supports_registration`Maria José Solano2025-04-26
| | |
* | | feat(lsp): generate method to client capability mapMaria José Solano2025-04-26
|/ /
* | fix(health): checkhealth float opens extra empty buffer #33648Andre Toerien2025-04-26
| |
* | perf(lsp): include `previousResultId` in `DocumentDiagnosticParams` #32887Yi Ming2025-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Users of the Roslyn (C#) LSP have encountered significant delays when retrieving pull diagnostics in large documents while using Neovim. For instance, diagnostics in a 2000-line .cs file can take over 20 seconds to display after edits in Neovim, whereas in VS Code, diagnostics for the same file are displayed almost instantly. As [mparq noted](https://github.com/seblj/roslyn.nvim/issues/93#issuecomment-2508940330) in https://github.com/seblj/roslyn.nvim/issues/93, VS Code leverages additional parameters specified in the [LSP documentation for textDocument/diagnostic](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentDiagnosticParams), specifically: - previousResultId - identifier Solution: When requesting diagnostics, Neovim should include the `previousResultId` and `identifier` parameters as part of the request. These parameters enable the server to utilize caching and return incremental results. Support for maintaining state is already present in the [textDocument/semanticTokens implementation](https://github.com/neovim/neovim/blob/8f84167c30692555d3332565605e8a625aebc43c/runtime/lua/vim/lsp/semantic_tokens.lua#L289). A similar mechanism can be implemented in `textDocument/diagnostic` handler.
* | fix(lsp): detect if Client:request resolved synchronously #33624Bartłomiej Maryńczak2025-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: In cases when the (in-process) LSP server responds to the request immediately and calls `notify_reply_callback` the request will still be marked as pending, because the code assumes that the response will occur asynchronously. Then the request will be pending forever, because it was already set as "completed" before we even set it as "pending". A workaround is to wrap `notify_replay_callback` in `vim.shedule` ([like so](https://github.com/neovim/neovim/pull/24338#issuecomment-2809568617)] but that seems counterintuitive. Solution: Handle this case in Client:request().
* | fix(lsp): cycling signatures with the default `config.focusable`Yi Ming2025-04-26
| |
* | fix(lsp): prioritize showing active signatureYi Ming2025-04-26
| |
* | vim-patch:9.1.1343: filetype: IPython files are not recognizedChristian Clason2025-04-25
| | | | | | | | | | | | | | | | | | | | | | | | Problem: filetype: IPython files are not recognized (user202729) Solution: detect *.ipy files as python filetype fixes: vim/vim#17163 https://github.com/vim/vim/commit/e380b5cbba23869b07e17cfc7f4602e2fe681945 Co-authored-by: Christian Brabandt <cb@256bit.org>
* | fix(docs) fix syntax error in Lua snippet for `vim.lsp.document_color` #33612Stephan Seitz2025-04-24
| | | | | | | | 9ff1239634 added support for 'textDocument/documentColor' but the text snippet in the Lua docs seem to contain a syntax error.
* | fix(lsp): don't create an `'LspAttach'` `document_color` autocommandMaria José Solano2025-04-24
| |
* | fix(lsp): ensure `bufstate` when calling `vim.lsp.document_color.is_enabled`Maria José Solano2025-04-24
| |
* | feat(lsp): support `textDocument/documentColor`Maria José Solano2025-04-24
| | | | | | | | test(lsp): add tests form `vim.lsp.document_color`
* | refactor(lsp): add `handler` to `vim.lsp.util._refresh` optionsMaria José Solano2025-04-24
|/
* vim-patch:9.1.1340: cannot complete :filetype arguments (#33602)zeertzjq2025-04-24
| | | | | | | | | | | | 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 https://github.com/vim/vim/commit/a3422aa3170d49a7c3d1e6cd4242b86e42ef3945 Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:9.1.1329: cannot get information about command line completionzeertzjq2025-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 https://github.com/vim/vim/commit/92f68e26ec36f2c263db5bea4f39d8503e0b741c Co-authored-by: Girish Palya <girishji@gmail.com>
* fix(float): cursor visible in "hidden" floating window #30866glepnir2025-04-23
| | | | | | | | 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.
* feat: render tuple types for API methodsLewis Russell2025-04-23
|
* fix(snippet): use <cmd>call cursor() for visual rangeLuuk van Baal2025-04-23
| | | | | | | | 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.
* perf(snippet): use "[count]|" to move cursor #33571luukvbaal2025-04-22
| | | | | | | Problem: Flicker when using vim.snippet.jump(). Solution: Pass count instead of multiple <right> keys.
* fix(api): wrong return value with reverse range + overlap #32956luukvbaal2025-04-21
| | | | | | | | | | | | | | 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.
* feat(options): default statusline expression #33036Shadman2025-04-21
| | | | | | | | | | 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.
* feat(ui): avoid setting 'cmdheight' with vim.ui_attach()Luuk van Baal2025-04-21
| | | | | | | | | | 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.
* feat(api): add "max_height" argument to nvim_win_text_height (#32835)luukvbaal2025-04-21
| | | | | 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").
* vim-patch:9.1.1327: filetype: nroff detection can be improvedzeertzjq2025-04-21
| | | | | | | | |