Problem:
The default "#" mapping fails on the following example after v$h# with
cursor at start of the first line:
aa?/\bb
aa
aa?/\bb
Solution:
Also escape "?".
Problem:
Lua functions that return multiple results are declared by using
multiple `@return` docstring directives. But the generated docs don't
make it obvious what this represents.
Solution:
- Generate a "Return (multiple)" heading for multiple-value functions.
- Fix `@note` directives randomly placed after `@return`.
Problem: `hl_mode` for inlay hints is `combine`, causing bugs like
inlay hints using highlights from the previous character
(#24152, #24068)
Solution: Don't use hl_mode=combine for inlay hints.
* feat(lua): allow vim.wo to be double indexed
Problem: `vim.wo` does not implement `setlocal`
Solution: Allow `vim.wo` to be double indexed
Co-authored-by: Christian Clason <c.clason@uni-graz.at>
Problem: When using treesitter foldexpr,
* :diffput/get open diff folds, and
* folds are not updated in other windows that contain the updated
buffer.
Solution: Update folds in all windows that contain the updated buffer
and use expr foldmethod.
Problem:
The parent commit added a new vim.get_visual_selection() function to
improve visual star. But that is redundant with vim.region(). Any
current limitations of vim.region() should be fixed instead of adding
a new function.
Solution:
Delete vim.get_visual_selection().
Use vim.region() to get the visual selection.
TODO: fails with visual "block" selections.
Problem:
Visual mode "*", "#" mappings don't work on text with "/", "\", "?", and
newlines.
Solution:
Get the visual selection and escape it as a search pattern.
Add functions vim.get_visual_selection and _search_for_visual_selection.
Fix#21676
Problem:
Sometimes, when nvim sends the `win_viewport` event, for example when scrolling
with visible folds on the screen, it reports the `scroll_delta` value one batch
into "future". So when the client application is trying to show the new viewport
it's not yet updated, resulting in temporary corruption / screen flickering.
For more details see #23609, and starting from [this comment](
https://github.com/neovide/neovide/pull/1790#issuecomment-1518697747) in
https://github.com/neovide/neovide/pull/1790,, where the issue was first
detected. Note that some of the conclusions in those are not fully accurate, but
the general observations are.
Solution:
When there are pending updates to a Window, delay the `win_viewport` UI event
until the updates are sent. This ensures that there's no flush between sending
the viewport and updating of the lines corresponding to the new viewport.
Document the existing viewport behaviour (for cases where there are no
extra flushes), give a hint about how applications can deal with the slightly
surprising behaviour of the viewport event being sent after the updates.
Fixes https://github.com/neovim/neovim/issues/23609
Problem: nvim_buf_set_text(), nvim_open_term() and termopen() all change buffer
text, which is forbidden during textlock. Additionally, nvim_open_term() and
termopen() may be used to convert the cmdwin buffer into a terminal buffer,
which is weird.
Solution: Allow nvim_buf_set_text() and nvim_open_term() in the cmdwin, but
disallow nvim_open_term() from converting the cmdwin buffer into a terminal
buffer. termopen() is not allowed in the cmdwin (as it always operates on
curbuf), so just check text_locked().
Also happens to improve the error in #21055: nvim_buf_set_text() was callable
during textlock, but happened to check textlock indirectly via u_save();
however, this caused the error to be overwritten by an unhelpful "Failed to
save undo information" message when msg_list == NULL (e.g: an `<expr>` mapping
invoked outside of do_cmdline()).
Problem: some API functions that check textlock (usually those that can change
curwin or curbuf) can break the cmdwin.
Solution: make FUNC_API_CHECK_TEXTLOCK call text_locked() instead, which already
checks for textlock, cmdwin and `<expr>` status.
Add FUNC_API_TEXTLOCK_ALLOW_CMDWIN to allow such functions to be usable in the
cmdwin if they can work properly there; the opt-in nature of this attribute
should hopefully help mitigate future bugs.
Also fix a regression in #22634 that made functions checking textlock usable in
`<expr>` mappings, and rename FUNC_API_CHECK_TEXTLOCK to FUNC_API_TEXTLOCK.
Problem:
Showing an error via vim.notify() makes it awkward for callers such as
lsp/handlers.lua to avoid showing redundant errors.
Solution:
Return the message instead of showing it. Let the caller decide whether
and when to show the message.
---
Rejected experiment: move vim.ui.open() to vim.env.open()
Problem:
`vim.ui` is where user-interface "providers" live, which can be
overridden. It would also be useful to have a "providers" namespace for
platform-specific features such as "open", clipboard, python, and the other
providers listed in `:help providers`. We could overload `vim.ui` to
serve that purpose as the single "providers" namespace, but
`vim.ui.nodejs()` for example seems awkward.
Solution:
`vim.env` currently has too narrow of a purpose. Overload it to also be
a namespace for `vim.env.open`.
diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua
index 913f1fe20348..17d05ff37595 100644
--- a/runtime/lua/vim/_meta.lua
+++ b/runtime/lua/vim/_meta.lua
@@ -37,8 +37,28 @@ local options_info = setmetatable({}, {
end,
})
-vim.env = setmetatable({}, {
- __index = function(_, k)
+vim.env = setmetatable({
+ open = setmetatable({}, {
+ __call = function(_, uri)
+ print('xxxxx'..uri)
+ return true
+ end,
+ __tostring = function()
+ local v = vim.fn.getenv('open')
+ if v == vim.NIL then
+ return nil
+ end
+ return v
+ end,
+ })
+ },
+ {
+ __index = function(t, k, ...)
+ if k == 'open' then
+ error()
+ -- vim.print({...})
+ -- return rawget(t, k)
+ end
local v = vim.fn.getenv(k)
if v == vim.NIL then
return nil
Problem: in #24046 the signature of buf.clear_references() changed, which
indirectly breaks callers that were passing "ignored" args.
Solution: because util.buf_clear_references() already defaulted to "current buffer",
the change to buf.clear_references() isn't actually needed, so just revert it.
perf(treesitter): cache vim.treesitter.query.get
Problem:
vim.treesitter.query.get searches and reads query files every time it's
called, if user hasn't overridden the query. So this can incur slowdown
when called frequently.
This can happen when using treesitter foldexpr. For example, when using
`:h :range!` in markdown file to format fenced codeblock, on_changedtree
in _fold.lua is triggered many times despite that the tree doesn't have
syntactic changes (might be a bug in LanguageTree). (Incidentally, the
resulting fold is incorrect due to a bug in `:h range!`.) on_changedtree
calls vim.treesitter.query.get for each tree changes. In addition, it
may request folds queries for injected languages without fold queries,
such as markdown_inline.
Solution:
* Cache the result of vim.treesitter.query.get.
* If query file was not found, fail quickly at later calls.
- fix lint / analysis warnings
- locations_to_items(): get default offset_encoding from active client
- character_offset(): get default offset_encoding from active client
Commit 37079fc moved inlay_hint to vim.lsp() but in the process did
missed converting a call to disable/enable which are now local.
Fixes the below error when trying to toggle inlay hints.
E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:248: attempt to call field 'disable' (a nil value)
stack traceback:
/usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:248: in function 'toggle'
/usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:310: in function 'inlay_hint'
[string ":lua"]:1: in main chunk
Problem:
vim_lsp_inlayhint: Error executing lua: .../lsp/_inlay_hint.lua:249: attempt to index field 'applied' (a nil value)
Solution:
Assign {} to bufstates.applied in on_reload
fixes#24172
Problem: Termdebug: error with more than 99 breakpoints.
Solution: Use a different sign for breakpoint 100 and over. (closesvim/vim#12589,
closesvim/vim#12588)
e7d9ca2b3b
Co-authored-by: skywind3000 <skywind3000@163.com>
Problem: Treesitter fold is not updated if treesitter hightlight is not
active. More precisely, updating folds requires `LanguageTree:parse()`.
Solution: Call `parse()` before computing folds and compute folds when
lines are added/removed.
This doesn't guarantee correctness of the folds, because some changes
that don't add/remove line won't update the folds even if they should
(e.g. adding pair of braces). But it is good enough for most cases,
while not introducing big overhead.
Also, if highlighting is active, it is likely that
`TSHighlighter._on_buf` already ran `parse()` (or vice versa).
Problem: Not all cabal config files are recognized.
Solution: Add a couple of patterns. (Marcin Szamotulski, closesvim/vim#12463)
166cd7b801
Also:
- Do not expand Lua patterns in environment variables used in file patterns.
- Test $XDG_CONFIG_HOME on Windows, as it can be used by Nvim (and the runner
sets it).
Co-authored-by: Marcin Szamotulski <coot@coot.me>
Prepare for https://github.com/neovim/tree-sitter-vimdoc/pull/108 which improves
`{arg}` highlighting in many common cases:
vim.foo({bar})
vim.foo( {bar})
nvim_foo({bar})
nvim_foo({bar},{baz})
nvim_foo({bar}, {baz})
foo[{buf}]
The tradeoff is that things like `"[{"` are flagged as parse errors.
We could avoid if we drop support for `foo[{buf}]`, but that is rather common
(see `builtin.txt`).
Problem: vimdoc parser requires space between column heading and `~`.
Solution: Add space to docs (and mention it). Also edit `luaref.txt`
headings for consistency.
Problem:
In the generated docs HTML there is too much whitespace before/after `<pre>`
blocks.
- In the old layout (fixed-width), all text in `.old-help-para` is formatted as
`white-space:pre`.
- In the new layout, when `<pre>` is at the end of a `<div>`, the margins of
both are redundant, causing too much space.
Solution:
- In the old layout, always remove `<pre>` margin.
- In the new layout, disable `<pre>` margin if it is the last child.