Problem: no way of getting all highlight group definitions in a namespace.
Solution: add `nvim_get_hl()`, deprecate `nvim_get_hl_by_name()` and `nvim_get_hl_by_id()`.
Problem:
semver specifies that digit sequences in a prerelease string should be
compared as numbers, not lexically: https://semver.org/#spec-item-11
> Precedence for two pre-release versions with the same major, minor,
> and patch version MUST be determined by comparing each dot separated
> identifier from left to right until a difference is found as follows:
> 1. Identifiers consisting of only digits are compared numerically.
> 2. Identifiers with letters or hyphens are compared lexically in ASCII sort order.
> 3. Numeric identifiers always have lower precedence than non-numeric identifiers.
> 4. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
Example:
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
Solution:
cmp_prerel() treats all digit sequences in a prerelease string as
numbers. This doesn't _exactly_ match the spec, which specifies that
only dot-delimited digit sequences should be treated as numbers...
Problem:
- vim.split has more features than vim.gsplit.
- Cannot inspect the "separator" segments of vim.split or vim.gsplit.
Solution:
- Move common implementation from vim.split into vim.gsplit.
- TODO: deprecate vim.split in favor of vim.totable(vim.gsplit())?
- Introduce `keepsep` parameter.
Related: 84f66909e4
existing behavior of
:=
and
:[range]=
are unchanged. `|` is still allowed with this usage.
However,
:=p
and similar are changed in a way which could be construed as a breaking
change. Allowing |ex-flags| for := in the first place was a mistake as
any form of := DOES NOT MOVE THE CURSOR. So it would print one line number
and then print a completely different line contents after that.
Problem:
"tmux 3.2a" (output from "tmux -V") is not parsed easily.
Solution:
With `strict=false`, discard everything before the first digit.
- rename Semver => Version
- rename vim.version.version() => vim.version._version()
- rename matches() => has()
- remove `opts` from cmp()
Problem:
On Windows, :make does not display the output of the program it runs.
The cause is the default 'shellpipe'. On Linux, nvim uses `tee` to redirect the
output to both stdout and the error file. In Windows, for both cmd.exe and
powershell, the output is only redirected to the error file.
Solution:
- On Windows, change the 'shellpipe' default to "2>&1| tee".
- Nvim includes `tee` in its Windows package.
- Document recommended defaults for powershell.
Fixes#12910
Problem:
On Windows, pasting multiple lines on a terminal buffer cause all the
lines to appear on the same line, i.e., the line breaks are lost.
Cause:
Windows shells expect "\r\n" as line break but "terminal_paste" function
uses "\n".
Solution:
Use "\r\n" as line break for pasting in terminal buffer on Windows.
Note:
Although this issue was reported with powershell set as 'shell', it
occurs in cmd too.
Fixes#14621
Problem: Clamp for height in floating windows enforced no more than
editor height - 1, disallowing full editor height floating windows when
using cmdheight=0
Solution: Clamp to full height, removing the -1. Tested to give the
intended results with cmdheight=0, 1, or more than 1. This also
inadvertently fixes a rendering error with cmdheight >1 where the
bottom border would be overlapped by the cmdline.
* fix(column): rebuild status column when sign column is invalidated
Problem: When implementing a custom sign column through
`'statuscolumn'`, the status column is not properly rebuilt
when the sign column width changes.
Solution: Force a rebuild of the status column when the sign column
width is invalidated.
* test(column): 'statuscolumn' has correct width when (un)placing signs
Problem: Cursor displayed in wrong position after removing text prop. (Ben
Jackson)
Solution: Invalidate the cursor position. (closesvim/vim#10898)
326c5d36e7
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem:
vim.deprecate() shows ":help deprecated" for third-party plugins. ":help
deprecated" only describes deprecations in Nvim, and is unrelated to any
3rd party deprecations.
Solution:
If `plugin` is specified, don't show ":help deprecated".
fix#22235
Problem:
When LSP client renames a directory, opened buffers in the edfitor are not
renamed or closed. Then `:wall` shows errors.
https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/util.lua#L776
works correctly if you try to rename a single file, but doesn't delete old
buffers with `old_fname` is a dir.
Solution:
Update the logic in runtime/lua/vim/lsp/util.lua:rename()
Fixes#22617
Semi-regression. The "ruler" behavior for a floating window
was never really specified but in practice followed the users
cursor movements in normal mode in a focused float, which seems
like a reasonable behavior to now specify.
The builtin cat was removed in 4bc9229ecb
as it is not used during runtime but only for tests. However, it is a
very small and useful utility program that we need for a lot of our
tests, so there's no harm in bundling it, and it helps us avoid
complicating our build system by having two versions of neovim (neovim
for users and neovim for testing).
Also skip tests if "grep" or "sleep" isn't available.
we cannot remove 'paste'. It is very common in plugins and configs.
'pastetoggle' can and should be removed though, it's a total waste of everyone's time because it generates bug reports and doesn't work well, and is useless because bracketed-paste works better.
Problem:
The function name `vim.pretty_print`:
1. is verbose, which partially defeats its purpose as sugar
2. does not draw from existing precedent or any sort of convention
(except external projects like penlight or python?), which reduces
discoverability, and degrades signaling about best practices.
Solution:
- Rename to `vim.print`.
- Change the behavior so that
1. strings are printed without quotes
2. each arg is printed on its own line
3. tables are indented with 2 instead of 4 spaces
- Example:
:lua ='a', 'b', 42, {a=3}
a
b
42
{
a = 3
}
Comparison of alternatives:
- `vim.print`:
- pro: consistent with Lua's `print()`
- pro: aligns with potential `nvim_print` API function which will
replace nvim_echo, nvim_notify, etc.
- con: behaves differently than Lua's `print()`, slightly misleading?
- `vim.echo`:
- pro: `:echo` has similar "pretty print" behavior.
- con: inconsistent with Lua idioms.
- `vim.p`:
- pro: very short, fits with `vim.o`, etc.
- con: not as discoverable as "echo"
- con: less opportunity for `local p = vim.p` because of potential shadowing.
scroll_delta contains how much the top line of a window moved since the
last time win_viewport was emitted. It is expected to be used to
implement smooth scrolling. For this purpose it only counts "virtual" or
"displayed" so folds should count as one line. Because of this it
adds extra information that cannot be computed from the topline
parameter.
Fixes#19227
Although using `buffer://` for unsaved file buffers fixes issues with
language servers like eclipse.jdt.ls or ansible-language-server, it
breaks completion and signature help for clangd.
A regression is worse than a fix for something else, so this reverts
commit 896d672736.
The spec change is also still in dicussion, see
https://github.com/microsoft/language-server-protocol/pull/1679#discussion_r1130704886
Problem: Highlight for popupmenu kind and extra cannot be set.
Solution: Add PmenuKind, PmenuKindSel, PmenuExtra and PmenuExtraSel
highlight groups and use them. (Gianmaria Bajo, closesvim/vim#12114)
6a7c774920
Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
Sets `NVIM_APPNAME` for the lsp server instances and also for the
`exec_lua` environment to ensure local user config doesn't interfere
with the test cases.
My local `ftplugin/xml.lua` broke the LSP test cases about setting
`omnifunc` defaults.
Problem:
Some built-in ftplugins set omnifunc/tagfunc/formatexpr which causes
lsp.lua:set_defaults() to skip setup of defaults for those filetypes.
For example the C++ ftplugin has:
omnifunc=ccomplete#Complete
Last set from /usr/share/nvim/runtime/ftplugin/c.vim line 30
so the changes done in #95c65a6b221fe6e1cf91e8322e7d7571dc511a71
will always be skipped for C++ files.
Solution:
Overwrite omnifunc/tagfunc/formatexpr options that were set by stock
ftplugin.
Fixes#21001
Problem:
If vim_tempdir mysteriously goes missing (typically by "antivirus" on
Windows), any plugins using tempname() will be broken for the rest of
the session. #1432#9833https://groups.google.com/g/vim_use/c/ef55jNm5czI
Steps:
mkdir foo
TMPDIR=./foo nvim
:echo tempname()
!rm -r foo
:echo tempname()
tempname() still uses the foo path even though it was deleted.
Solution:
- Don't assume that vim_tempdir exists.
- If it goes missing once, retry vim_mktempdir and log (silently) an error.
- If it goes missing again, retry vim_mktempdir and show an error.
Rejected in Vim for performance reasons:
https://groups.google.com/g/vim_use/c/qgRob9SWDv8/m/FAOFVVcDTv0Jhttps://groups.google.com/g/vim_dev/c/cogp-Vye4oo/m/d_SVFXBbnnoJ
But, logging shows that `vim_gettempdir` is not called frequently.
Fixes#1432Fixes#9833Fixes#11250
Related: stdpath("run") f50135a32e
When a buffer update callback is called, textlock is active so buffer
text cannot be changed, but cursor can still be moved. This can cause
problems when the buffer update is in the middle of an operator, like
the one mentioned in #16729. The solution is to save cursor position and
restore it afterwards, like how cursor is saved and restored when
evaluating an <expr> mapping.
Problem:
:Man command errors if given more than two arguments. Thus, it is
impossible to open man pages that contain spaces in their names.
Solution:
Adjust :Man so that it tries variants with spaces and underscores, and
uses the first found.
Problem: 'statuscolumn' width can be incorrect when toggling 'number'
or setting 'statuscolumn'.
Solution: Make sure the width is reset and re-estimated when
'statuscolumn' and 'number' are set. (When 'relativenumber'
is set this already happens because it always changes
"nrwidth_line_count".)
also make implicit submodules "uri" and "_inspector" work with completion
this is needed for `:lua=vim.uri_<tab>` wildmenu completion
to work even before uri or _inspector functions are used.
feat(lsp)!: change semantic token highlighting
Change the default highlights used, and add more highlights per token.
Add an LspTokenUpdate event and a highlight_token function.
:Inspect now shows any highlights applied by token highlighting rules,
default or user-defined.
BREAKING CHANGE: change the default highlight groups used by semantic
token highlighting.
Problem:
If major<major but minor>minor, cmp_version_core returns 1
Solution:
- Fix logic in cmp_version_core
- Delete most eq()/gt()/lt() tests, they are redundant.
- version.cmp(): assert valid version
- add test for loading vim.version (the other tests use shared.lua in
the test runner)
- reduce test scopes, reword test descriptions
Searching the entire repo for a directory named "contrib" causes failure
if there happens to be another subdirectory with the name "contrib".
Instead, point directly to the correct contrib directory.
Problem:
No easy way to find files under certain directories (ex: grab all files under
`test/`) or exclude the content of certain paths (ex. `build/`, `.git/`)
Solution:
Pass the full `path` as an arg to the predicate.
Problem:
In a success-failure-success situation, if minimal timeout is reached
between the failure and the second success, the session is stopped
without waiting for the second success, causing the test to fail.
Solution:
Wait for another success if a failure is seen after a success.
Ref #22155#22464
Problem:
If shell-test finishes before the next RPC call, TermClose has already
been triggered, so the test fails.
Solution:
Add INTERACT argument so that shell-test keeps running.
redraw! redraws the entire screen instead of just the windows with
the buffer which were actually changed.
I considered trying to calculating the range for the delta
but it looks tricky. Could a follow-up.
Problem:
has('gui_running') is still common in the wild and our answer has
changed over time, causing frustration.
95a6ccbe9f
Solution:
Use stdin_tty/stdout_tty to decide if a UI is (not) a GUI.
Problem:
Treesitter injections are slow because all injected trees are invalidated on every change.
Solution:
Implement smarter invalidation to avoid reparsing injected regions.
- In on_bytes, try and update self._regions as best we can. This PR just offsets any regions after the change.
- Add valid flags for each region in self._regions.
- Call on_bytes recursively for all children.
- We still need to run the query every time for the top level tree. I don't know how to avoid this. However, if the new injection ranges don't change, then we re-use the old trees and avoid reparsing children.
This should result in roughly a 2-3x reduction in tree parsing when the comment injections are enabled.
When combining attributes use the one that takes priority.
For :highlight command use the last one specified.
For API use a hard-coded order same as the order in docs.
Problem:
vim.treesitter does not know how to map a specific filetype to a parser.
This creates problems since in a few places (including in vim.treesitter itself), the filetype is incorrectly used in place of lang.
Solution:
Add an API to enable this:
- Add vim.treesitter.language.add() as a replacement for vim.treesitter.language.require_language().
- Optional arguments are now passed via an opts table.
- Also takes a filetype (or list of filetypes) so we can keep track of what filetypes are associated with which langs.
- Deprecated vim.treesitter.language.require_language().
- Add vim.treesitter.language.get_lang() which returns the associated lang for a given filetype.
- Add vim.treesitter.language.register() to associate filetypes to a lang without loading the parser.
Problem:
The Lua-API bridge allows Dict params to be empty Lua (list) tables at
the function-signature level. But not for _nested_ Dicts, because they
are not modeled:
fae7540732/src/nvim/api/keysets.lua (L184)
Some API functions like nvim_cmd check for kObjectTypeDictionary and
don't handle the case of empty Lua tables (treated as "Array").
Solution:
Introduce VALIDATE_T_DICT and use it in places where
kObjectTypeDictionary was being checked directly.
fixes#21005
This commit implements the ability to control all of the XDG paths
Neovim should use. This is done by setting an environment variable named
NVIM_APPNAME. For example, setting $NVIM_APPNAME makes Neovim look for
its configuration directory in $XDG_CONFIG_HOME/$NVIM_APPNAME instead of
$XDG_CONFIG_HOME/nvim.
If NVIM_APPNAME is not set or is an empty string, "nvim" will be used as
default.
The usecase for this feature is to enable an easy way to switch from
configuration to configuration. One might argue that the various $XDG
environment variables can already be used for this usecase. However,
setting $XDG environment variables also affects tools spawned by Neovim.
For example, while setting $XDG_CONFIG_HOME will enable Neovim to use a
different configuration directory, it will also prevent Git from finding
its "default" configuration.
Closes https://github.com/neovim/neovim/issues/21691
Problem: Scrolling two lines with even line count and 'scrolloff' set.
Solution: Adjust how the topline is computed. (closesvim/vim#10545)
1d6539cf36
Cherry-pick test_scroll_opt.vim changes from patch 8.2.1432.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem:
The sleep before collecting the initial screen state is confusing and
may lead to unexpected success if it comes after a blocking RPC call.
Solution:
Remove that sleep and add an "intermediate" argument.
Problem:
Validation messages are not consistently formatted.
- Parameter names sometimes are NOT quoted.
- Descriptive names (non-parameters) sometimes ARE quoted.
Solution:
Always quote the `name` value passed to a VALIDATE macro _unless_ the
value has whitespace.
Problem:
- API validation involves too much boilerplate.
- API validation errors are not consistently worded.
Solution:
Introduce some macros. Currently these are clumsy, but they at least
help with consistency and avoid some nesting.
Problem: The cursorline highlight logic checks for `w_cursor.lnum`
which may be different from the line number passed to
`win_line()` even when the cursor is actually on that line.
Solution: Update cursor line highlight logic to check for the line
number of the start of a closed fold if necessary.
If nothing matched in match_from_hashbang, also check the file extension table.
For a hashbang like '#!/bin/env foo', this will set the filetype to 'fooscript'
assuming the filetype for the 'foo' extension is 'fooscript' in the extension
table.
Problem:
When not inside an Ex command, screen_resize() calls update_screen(),
which calls screenclear() and set the screen as valid. However, when
inside an Ex command, redrawing is postponed so update_screen() screen
doesn't do anything, and the screen is still invalid after the resize,
causing ui_comp_raw_line() to be no-op until update_screen() is called
on the main loop.
Solution:
Restore the call to screenclear() inside screen_resize() so that the
screen is invalid after screen_resize(). Since screenclear() changes
redraw type from UPD_CLEAR to UPD_NOT_VALID, it is called at most once
for each resize, so this shouldn't change how much code is run in the
common (not inside an Ex command) case.
The original motivation for this change came from developping
https://github.com/neovim/neovim/pull/22159, which will require adding
more autocommand creation to Neovim's startup sequence.
This change requires lightly editing a test that expected no autocommand
to have been created from lua.
Problem: Inserting a register on the command line does not trigger
incsearch or update hlsearch.
Solution: Have cmdline_insert_reg() return CMDLINE_CHANGED when appropriate
and handle it correctly. (Ken Takata, closesvim/vim#11960)
c4b7dec382
Co-authored-by: K.Takata <kentkt@csc.jp>
Eliminates lua-client and non-static libluv as test time dependencies
Note: the API for a public lua-client is not yet finished.
The interface needs to be adjusted to work in the embedded loop
of a nvim instance (to use it to talk between instances)
Previously, if the autocommands are not triggered, the tests may still
pass because no assertion is done. Add an assertion so that the tests
will fail if the autocommands aren't triggered.
Problem: Display shows lines scrolled down erroneously. (Yishai Lerner)
Solution: Do not change "wl_lnum" at index zero. (closesvim/vim#11938)
61fdbfa1e3
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: The fold and sign column is built and stored regardless of
whether the corresponding item is present in 'statuscolumn'.
Solution: Since the 'statuscolumn' parses itself, we can defer
building the columns until the corresponding item is
actually encountered.
Problem: The 'statuscolumn' width is being estimated without the
proper context. In particular, this resulted in the fact
that a custom fold column could be included in the estimated
`number_width()`, and doubly added when actually drawing the
statuscolumn due to `win_col_off()` also adding the
`'foldcolumn'` width. Resulting in a status column that is
`'foldcolumn'` cells wider than necessary.
Solution: Estimate 'statuscolumn' width in `get_statuscol_str()` when
a buffer's line count has changed.
Problem: Some injections (like markdown) allow specifying arbitrary
language names for code blocks, which may be lead to errors when
looking for a corresponding parser in runtime path.
Solution: Validate that the language name only contains alphanumeric
characters and `_` (e.g., for `c_sharp`) and error otherwise.
test(exepath): test if exepath returns correct path with multiple
Windows shells
This test covers the changes from #21175 where exepath() is set to
prefer file extensions in powershell.exe aswell as in cmd.exe.
In both shells, the file with a valid extension should be returned
instead of the extensionless file.
`vim.lsp.buf.format()` silently did nothing if no servers supported
`textDocument/rangeFormatting` when formatting with a range.
Issue found by `@hwrd:matrix.org` in the Matrix chat.
Problem:
The "force" flag of win_close() complicates the code and adds edge cases
where it is not clear what the correct behavior should be.
The "free_buf" flag of win_close() is passed on to float windows when
closing the last window of a tabpage, which doesn't make much sense.
Solution:
Remove the "force" flag and always close float windows as if :close! is
used when closing the last window of a tabpage, and set the "free_buf"
flag for a float window based on whether its buffer can be freed.
As 'hidden' is on by default, this change shouldn't affect many people.
Problem:
Build is not reproducible, because generated source files (.c/.h/) are not
deterministic, mostly because Lua pairs() is unordered by design (for security).
https://github.com/LuaJIT/LuaJIT/issues/626#issuecomment-707005671https://www.lua.org/manual/5.1/manual.html#pdf-next
> The order in which the indices are enumerated is not specified [...]
>
>> The hardening of the VM deliberately randomizes string hashes. This in
>> turn randomizes the iteration order of tables with string keys.
Solution:
- Update the code generation scripts to be deterministic.
- That is only a partial solution: the exported function
(funcs_metadata.generated.h) and ui event
(ui_events_metadata.generated.h) metadata have some mpack'ed
tables, which are not serialized deterministically.
- As a workaround, introduce `PRG_GEN_LUA` cmake setting, so you can
inject a modified build of luajit (with LUAJIT_SECURITY_PRN=0)
that preserves table order.
- Longer-term we should change the mpack'ed data structure so it no
longer uses tables keyed by strings.
Closes#20124
Co-Authored-By: dundargoc <gocdundar@gmail.com>
Co-Authored-By: Arnout Engelen <arnout@bzzt.net>
Problem: When a folded line has virtual lines attached, the following
problems occur:
- The virtual lines are drawn empty.
- The 'foldtext' line is drawn empty.
- The cursor is drawn incorrectly.
Solution: Check whether virtual lines belong to a folded line.
Fix#17027Fix#19557Fix#21837
Co-authored-by: zeertzjq <zeertzjq@outlook.com>