mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00

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
6b49fba8c8
Co-authored-by: Girish Palya <girishji@gmail.com>
299 lines
9.8 KiB
Plaintext
299 lines
9.8 KiB
Plaintext
*news.txt* Nvim
|
|
|
|
|
|
NVIM REFERENCE MANUAL
|
|
|
|
|
|
Notable changes since Nvim 0.11 *news*
|
|
|
|
For changes in the previous release, see |news-0.11|.
|
|
|
|
Type |gO| to see the table of contents.
|
|
|
|
==============================================================================
|
|
BREAKING CHANGES IN HEAD OR EXPERIMENTAL *news-breaking-dev*
|
|
|
|
====== Remove this section before release. ======
|
|
|
|
The following changes to UNRELEASED features were made during the development
|
|
cycle (Nvim HEAD, the "master" branch).
|
|
|
|
EVENTS
|
|
|
|
• Renamed "nvim.find_exrc" |default-autocmds| group to "nvim.exrc".
|
|
|
|
EXPERIMENTS
|
|
|
|
• todo
|
|
|
|
LSP
|
|
|
|
• |vim.lsp.buf.selection_range()| now accepts an integer which specifies its
|
|
direction, rather than a string `'outer'` or `'inner'`.
|
|
|
|
OPTIONS
|
|
|
|
• todo
|
|
|
|
TREESITTER
|
|
|
|
• todo
|
|
|
|
==============================================================================
|
|
BREAKING CHANGES *news-breaking*
|
|
|
|
These changes may require adaptations in your config or plugins.
|
|
|
|
API
|
|
|
|
• todo
|
|
|
|
BUILD
|
|
|
|
• todo
|
|
|
|
DIAGNOSTICS
|
|
|
|
• |diagnostic-signs| can no longer be configured with |:sign-define| or
|
|
|sign_define()| (deprecated in Nvim 0.10 |deprecated-0.10|).
|
|
• |vim.diagnostic.disable()| and |vim.diagnostic.is_disabled()| (deprecated in
|
|
Nvim 0.10 |deprecated-0.10|) are removed.
|
|
• The legacy signature of |vim.diagnostic.enable()| (deprecated in Nvim 0.10
|
|
|deprecated-0.10|) is no longer supported.
|
|
|
|
EDITOR
|
|
|
|
• todo
|
|
|
|
EVENTS
|
|
|
|
• |ui-messages| no longer emits the `msg_show.return_prompt`, and
|
|
`msg_history_clear` events. The `msg_clear` event was repurposed and is now
|
|
emitted after the screen is cleared. These events arbitrarily assumed a
|
|
message UI that mimicks the legacy message grid. Benefit: reduced UI event
|
|
traffic and more flexibility for UIs.
|
|
• A new `empty` message kind is emitted for an empty (e.g. `:echo ""`) message.
|
|
|
|
HIGHLIGHTS
|
|
|
|
• todo
|
|
|
|
LSP
|
|
|
|
• `root_markers` in |vim.lsp.Config| can now be ordered by priority.
|
|
• The function set with |vim.lsp.log.set_format_func()| is now given all
|
|
arguments corresponding to a log entry instead of the individual arguments.
|
|
|
|
LUA
|
|
|
|
• todo
|
|
|
|
OPTIONS
|
|
|
|
• 'shelltemp' defaults to "false".
|
|
|
|
PLUGINS
|
|
|
|
• todo
|
|
|
|
TREESITTER
|
|
|
|
• |treesitter-directive-offset!| can now be applied to quantified captures. It
|
|
no longer sets `metadata[capture_id].range`; it instead sets
|
|
`metadata[capture_id].offset`. The offset will be applied in
|
|
|vim.treesitter.get_range()|, which should be preferred over reading
|
|
metadata directly for retrieving node ranges.
|
|
|
|
TUI
|
|
|
|
• todo
|
|
|
|
VIMSCRIPT
|
|
|
|
• todo
|
|
|
|
==============================================================================
|
|
NEW FEATURES *news-features*
|
|
|
|
The following new features were added.
|
|
|
|
API
|
|
|
|
• |nvim_win_text_height()| can limit the lines checked when a certain
|
|
`max_height` is reached, and returns the `end_row` and `end_vcol` for which
|
|
`max_height` or the calculated height is reached.
|
|
• |vim.secure.read()| now returns `true` for trusted directories. Previously
|
|
it would return `nil`, which made it impossible to tell if the directory was
|
|
actually trusted.
|
|
• Added |vim.lsp.is_enabled()| to check if a given LSP config has been enabled
|
|
by |vim.lsp.enable()|.
|
|
• |nvim_echo()| can set the |ui-messages| kind with which to emit the message.
|
|
|
|
BUILD
|
|
|
|
• A Zig-based build system has been added as an alternative to CMake. It is
|
|
currently limited in functionality, and CMake remains the recommended option
|
|
for the time being.
|
|
|
|
DEFAULTS
|
|
|
|
• 'statusline' default is exposed as a statusline expression (previously it
|
|
was implemented as an internal C routine).
|
|
• Project-local configuration ('exrc') is also loaded from parent directories.
|
|
Unset 'exrc' to stop further search.
|
|
• Mappings:
|
|
• |grt| in Normal mode maps to |vim.lsp.buf.type_definition()|
|
|
|
|
DIAGNOSTICS
|
|
|
|
• |vim.diagnostic.setloclist()| and |vim.diagnostic.setqflist()| now support a
|
|
`format` function to modify (or filter) diagnostics before being set in the
|
|
location/quickfix list.
|
|
• |vim.diagnostic.get()| now accepts an `enabled` filter to only return
|
|
enabled or disabled diagnostics.
|
|
|
|
EDITOR
|
|
|
|
• |:iput| works like |:put| but adjusts indent.
|
|
• |:uniq| deduplicates text in the current buffer.
|
|
• |omnicompletion| in `help` buffer. |ft-help-omni|
|
|
• Setting "'0" in 'shada' prevents storing the jumplist in the shada file.
|
|
• 'shada' now correctly respects "/0" and "f0".
|
|
• |prompt-buffer| supports multiline input/paste, undo/redo, and o/O normal
|
|
commands.
|
|
• 'wildchar' now enables completion in search contexts using |/|, |?|, |:g|, |:v|
|
|
and |:vimgrep| commands.
|
|
|
|
EVENTS
|
|
|
|
• |CmdlineLeavePre| triggered before preparing to leave the command line.
|
|
• New `append` paremeter for |ui-messages| `msg_show` event.
|
|
|
|
HIGHLIGHTS
|
|
|
|
• |hl-DiffTextAdd| highlights added text within a changed line.
|
|
• |hl-StderrMsg| |hl-StdoutMsg|
|
|
|
|
LSP
|
|
|
|
• |vim.lsp.ClientConfig| gained `workspace_required`.
|
|
• You can control priority of |vim.lsp.Config| `root_markers`.
|
|
• Support for `textDocument/documentColor`: |lsp-document_color|
|
|
https://microsoft.github.io/language-server-protocol/specification/#textDocument_documentColor
|
|
• The `textDocument/diagnostic` request now includes the previous id in its
|
|
parameters.
|
|
• |vim.lsp.enable()| start/stops clients as necessary. And detaches
|
|
non-applicable LSP clients.
|
|
• |vim.lsp.is_enabled()| checks if a LSP config is enabled (without
|
|
"resolving" it).
|
|
• Support for `workspace/diagnostic`: |vim.lsp.buf.workspace_diagnostics()|
|
|
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_dagnostics
|
|
• Incremental selection is now supported via `textDocument/selectionRange`.
|
|
`an` selects outwards and `in` selects inwards.
|
|
• Support for multiline semantic tokens.
|
|
• Support for the `disabled` field on code actions.
|
|
• The function form of `cmd` in a vim.lsp.Config or vim.lsp.ClientConfig
|
|
receives the resolved config as the second arg: `cmd(dispatchers, config)`.
|
|
• Support for annotated text edits.
|
|
|
|
LUA
|
|
|
|
• Lua type annotations for `vim.uv`.
|
|
• |vim.hl.range()| now allows multiple timed highlights.
|
|
• |vim.tbl_extend()| and |vim.tbl_deep_extend()| now accept a function behavior argument.
|
|
• |vim.fs.root()| can define "equal priority" via nested lists.
|
|
• |vim.version.range()| output can be converted to human-readable string with |tostring()|.
|
|
• |vim.version.intersect()| computes intersection of two version ranges.
|
|
• |Iter:take()| and |Iter:skip()| now optionally accept predicates.
|
|
• Built-in plugin manager |vim.pack|
|
|
|
|
OPTIONS
|
|
|
|
• 'autowriteall' writes all buffers upon receiving `SIGHUP`, `SIGQUIT` or `SIGTSTP`.
|
|
• 'chistory' and 'lhistory' set size of the |quickfix-stack|.
|
|
• 'completefuzzycollect' enables fuzzy collection of candidates for (some)
|
|
|ins-completion| modes.
|
|
• 'complete' new flags:
|
|
• "F{func}" complete using given function
|
|
• "F" complete using 'completefunc'
|
|
• "o" complete using 'omnifunc'
|
|
• 'complete' allows limiting matches for sources using "{flag}^<limit>".
|
|
• 'completeopt' flag "nearset" sorts completion results by distance to cursor.
|
|
• 'diffopt' `inline:` configures diff highlighting for changes within a line.
|
|
• 'grepformat' is now a |global-local| option.
|
|
• 'pummaxwidth' sets maximum width for the completion popup menu.
|
|
• 'winborder' "bold" style.
|
|
• |g:clipboard| accepts a string name to force any builtin clipboard tool.
|
|
|
|
PERFORMANCE
|
|
|
|
• |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.
|
|
|
|
PLUGINS
|
|
|
|
• Customize :checkhealth by handling a `FileType checkhealth` event.
|
|
|health-usage|
|
|
|
|
STARTUP
|
|
|
|
• todo
|
|
|
|
TERMINAL
|
|
|
|
• |nvim_open_term()| can be called with a non-empty buffer. The buffer
|
|
contents are piped to the PTY and displayed as terminal output.
|
|
|
|
TREESITTER
|
|
|
|
• todo
|
|
|
|
TUI
|
|
|
|
• |TermResponse| now supports APC query responses.
|
|
|
|
UI
|
|
|
|
• |:restart| restarts Nvim and reattaches the current UI.
|
|
• |:checkhealth| shows a summary in the header for every healthcheck.
|
|
• |ui-multigrid| provides composition information and absolute coordinates.
|
|
• `vim._extui` provides an experimental commandline and message UI intended to
|
|
replace the message grid in the TUI.
|
|
• Error messages are more concise:
|
|
• "Error detected while processing:" changed to "Error in:".
|
|
• "Error executing Lua:" changed to "Lua:".
|
|
|
|
VIMSCRIPT
|
|
|
|
• |cmdcomplete_info()| gets current cmdline completion info.
|
|
• |prompt_getinput()| gets current user-input in prompt-buffer.
|
|
|
|
==============================================================================
|
|
CHANGED FEATURES *news-changed*
|
|
|
|
These existing features changed their behavior.
|
|
|
|
• |gv| works in operator pending mode and does not abort.
|
|
• 'smartcase' applies to completion filtering.
|
|
• 'spellfile' location defaults to `stdpath("data").."/site/spell/"` instead of
|
|
the first writable directory in 'runtimepath'.
|
|
• |vim.version.range()| doesn't exclude `to` if it is equal to `from`.
|
|
• |searchcount()|'s maximal value is raised from 99 to 999.
|
|
|
|
==============================================================================
|
|
REMOVED FEATURES *news-removed*
|
|
|
|
These deprecated features were removed.
|
|
|
|
• todo
|
|
|
|
==============================================================================
|
|
DEPRECATIONS *news-deprecations*
|
|
|
|
See |deprecated-0.12|.
|
|
|
|
vim:tw=78:ts=8:sw=2:et:ft=help:norl:
|