Update runtime files
10e8ff9b26
Also:
- fix a missing `<` in builtin.txt.
- edit `:function` `{name}` wording to match the change made for the docs above
by Justin in #10619.
- link to `*vimrc*` rather than `*init.vim*` in repeat.txt change (as `init.lua`
may also be used).
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Filetype name t32 is a bit obscure.
Solution: Rename t32 to trace32. (Christoph Sax, closesvim/vim#12512)
740df76c90
Co-authored-by: Christoph Sax <christoph.sax@mailbox.org>
Problem: charidx() and utf16idx() result is not consistent with byteidx().
Solution: When the index is equal to the length of the text return the
lenght of the text instead of -1. (Yegappan Lakshmanan,
closesvim/vim#12503)
577922b917
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
`client.messages` could grow unbounded because the default handler only
added new messages, never removing them.
A user either had to consume the messages by calling
`vim.lsp.util.get_progress_messages` or by manually removing them from
`client.messages.progress`. If they didn't do that, using LSP
effectively leaked memory.
To fix this, this deprecates the `messages` property and instead adds a
`progress` ring buffer that only keeps at most 50 messages. In addition
it deprecates `vim.lsp.util.get_progress_messages` in favour of a new
`vim.lsp.status()` and also promotes the `LspProgressUpdate` user
autocmd to a regular autocmd to allow users to pattern match on the
progress kind.
Also closes https://github.com/neovim/neovim/pull/20327
Problem: Nix files are not recognized from the hashbang line.
Solution: Add a hashbang check. (issue vim/vim#12507)
19548c6a74
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Trace32 files are not recognized.
Solution: Add patterns for the t32 filetype. (Christoph Sax, closesvim/vim#12505)
7fbcee6f92
Co-authored-by: Christoph Sax <christoph.sax@mailbox.org>
Problem: URL shortcut files are not recognized.
Solution: Add a pattern for URL shortcut files. (closesvim/vim#12474)
cdb7b4c508
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
feat(lua): add vim.system()
Problem:
Handling system commands in Lua is tedious and error-prone:
- vim.fn.jobstart() is vimscript and comes with all limitations attached to typval.
- vim.loop.spawn is too low level
Solution:
Add vim.system().
Partly inspired by Python's subprocess module
Does not expose any libuv objects.
The options 'path', 'include', and 'define' all use C-specific default
values. This may have made sense a long time ago when Vim was mostly
used just for writing C, but this is no longer the case, and we have
ample support for filetype specific configuration. Make the default
values of these options empty and move the C-specific values into a
filetype plugin where they belong.
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Problem:
"playground" is new jargon that overlaps with existing concepts:
"dev" (`:help dev`) and "view" (also "scratch" `:help scratch-buffer`) .
Solution:
We should consistently use "dev" as the namespace for where "developer
tools" live. For purposes of a "throwaway sandbox object", we can use
the name "view".
- Rename `TSPlayground` => `TSView`
- Rename `playground.lua` => `dev.lua`
vim.version.range() couldn't parse them correctly.
For example, vim.version.range('<0.9.0'):has('0.9.0') returned `true`.
fix: range:has() accepts vim.version()
So that it's possible to compare a range with:
vim.version.range(spec):has(vim.version())
Problem:
Completion messages such as "scanning tags" are noisy and generally not
useful on most systems. Most users probably aren't aware that this is
configurable.
Solution:
Set `shortmess+=C`.
PROBLEM:
Whenever any text edits are applied to the buffer, the `marks` part of those
lines will be lost. This is mostly problematic for code formatters that format
the whole buffer like `prettier`, `luafmt`, ...
When doing atomic changes inside a vim doc, vim keeps track of those changes and
can update the positions of marks accordingly, but in this case we have a whole
doc that changed. There's no simple way to update the positions of all marks
from the previous document state to the new document state.
SOLUTION:
* save marks right before `nvim_buf_set_lines` is called inside `apply_text_edits`
* check if any marks were lost after doing `nvim_buf_set_lines`
* restore those marks to the previous positions
TEST CASE:
* have a formatter enabled
* open any file
* create a couple of marks
* indent the whole file to the right
* save the file
Before this change: all marks will be removed.
After this change: they will be preserved.
Fixes#14307
Problem: Filetype detection fails for *.conf file without comments.
(Dmitrii Tcyganok)
Solution: Use "conf" filetype as a fallback for an empty .conf file.
(closesvim/vim#12487, closesvim/vim#12483)
664fd12aa2
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
If the server sends the positionEncoding capability in its
initialization response, automatically set the client's offset_encoding
to use the value provided.
BREAKING CHANGE: LspRequest is no longer a User autocmd but is now a
first class citizen.
LspRequest as a User autocmd had limited functionality. Namely, the only
thing you could do was use the notification to do a lookup on all the
clients' requests tables to figure out what changed.
Promoting the autocmd to a full autocmd lets us set the buffer the
request was initiated on (so people can set buffer-local autocmds for
listening to these events).
Additionally, when used from Lua, we can pass additional metadata about
the request along with the notification, including the client ID, the
request ID, and the actual request object stored on the client's
requests table. Users can now listen for these events and act on them
proactively instead of polling all of the requests tables and looking
for changes.
Problem: Some "gomod" files are not recognized.
Solution: Check for "go.mod" file name before checking out the contents.
(Omar El Halabi, closesvim/vim#12462)
c9fbd2560f
Problem: Lua ftplugins in runtime take precedence over Vimscript
ftplugins in user configs (even in `after/`).
Solution: Source ftplugins separately per directory, first Vimscript
then Lua.
- `client.dynamic_capabilities` is an object that tracks client register/unregister
- `client.supports_method` will additionally check if a dynamic capability supports the method, taking document filters into account. But only if the client enabled `dynamicRegistration` for the capability
- updated the default client capabilities to include dynamicRegistration for:
- formatting
- rangeFormatting
- hover
- codeAction
- hover
- rename
Problem: CI: indent test hangs on FreeBSD.
Solution: Set 'nomore' when running the indent tests. (Ozaki Kiichi,
closesvim/vim#12446)
9f3afe7a70
Co-authored-by: ichizok <gclient.gaap@gmail.com>
libvterm v0.3 supports reflow of terminal buffer when Nvim is resized
Since v0.3 is now a required dependency, enable it by default to find
(and fix) possible issues.
Note: Neovim's scrollback buffer does not support reflow (yet), so lines
vanishing into the buffer due to a too small window will be restored
without reflow.
Some LSP servers (tailwindcss, rome) are known to request registration
for `workspace/didChangeWatchedFiles` even when the corresponding client
capability does not advertise support. This change adds an extra check
in the `client/registerCapability` handler not to start a watch unless
the client capability is set appropriately.
- Add bindings to Treesitter ts_parser_set_logger and ts_parser_logger
- Add logfile with path STDPATH('log')/treesitter.c
- Rework existing LanguageTree loggin to use logfile
- Begin implementing log levels for vim.g.__ts_debug
Problem: USD filetype is not recognized.
Solution: Add patterns for USD filetype. (Colin Kennedy, closesvim/vim#12370)
b848ce6b7e
Co-authored-by: Colin Kennedy <colinvfx@gmail.com>
Problem: Some commands for opening a file don't use 'switchbuf'.
Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan,
closesvim/vim#12383, closesvim/vim#12381)
54be5fb382
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Making a mapping work in all modes is complicated.
Solution: Add the <Cmd> special key. (Yegappan Lakshmanan, closesvim/vim#7282,
closes 4784, based on patch by Bjorn Linse)
957cf67d50
Change docs to match Vim if it's wording is better.
Change error numbers to match Vim.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Current behaviour of `:Man` is to only work with "number" sections.
This is caused by wrong assumptions about man sections naming.
Also, there was similar assumption about length of section dirs
in `paths` variable.
fixes#23485
Signed-off-by: Vadim Misbakh-Soloviov <git@mva.name>
This replaces the custom `health{Error,Warning,Success}` highlight
groups with `Diagnostic{Error,Warning,Ok}`, which are defined by
default. Removes the link for `healthHelp`, which was no longer
actually used after #20879.
perf(lsp): load buffer contents once when processing semantic token responses
Using _get_line_byte_from_position() for each token's boundaries was a
pretty huge bottleneck, since that function would load individual buffer
lines via nvim_buf_get_lines() (plus a lot of extra overhead). So each
token caused two calls to nvim_buf_get_lines() (once for the start
position, and once for the end position).
For semantic tokens, we only attach to buffers that have already been
loaded, so we can safely just get all the lines for the entire buffer at
once, and lift the rest of the _get_line_byte_from_position()
implementation directly while bypassing the part that loads the buffer
line.
While I was looking at get_lines (used by _get_line_byte_from_position),
I noticed that we were checking for non-file URIs before we even looked
to see if we already had the buffer loaded. Moving the buffer-loaded
check to be the first thing done in get_lines() more than halved the
average time spent transforming the token list into highlight ranges vs
when it was still using _get_line_byte_from_position. I ended up
improving that loop more by not using get_lines, but figured the
performance improvement it provided was worth leaving in.
Problem: Using inclusive index for slice is not always desired.
Solution: Add the slice() method, which has an exclusive index. (closes
vim/vim#7408)
6601b62943
Cherry-pick a line in docs added later.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Vim9: string indexes are counted in bytes.
Solution: Use character indexes. (closesvim/vim#6574)
e3c37d8ebf
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Not enough characters accepted for 'spellfile'.
Solution: Add vim_is_fname_char() and use it for 'spellfile'.
bc49c5f48f
Cherry-pick related doc update from Vim runtime.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Divide by zero with 'smoothscroll' set and a narrow window.
Solution: Bail out when the window is too narrow.
870219c58c
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cannot scroll by screen line if a line wraps.
Solution: Add the 'smoothscroll' option. Only works for CTRL-E and CTRL-Y
so far.
f6196f4244
vim-patch:9.0.0641: missing part of the new option code
Problem: Missing part of the new option code.
Solution: Add missing WV_SMS.
bbbda8fd81
Co-authored-by: Bram Moolenaar <Bram@vim.org>
When injections are added or removed make sure to:
- invoke 'changedtree' callbacks for when new trees are added.
- invoke 'changedtree' callbacks for when trees are invalidated
- redraw regions when languagetree children are removed
Problem: Heredoc for interfaces does not support "trim".
Solution: Update the script heredoc support to be same as the :let command.
(Yegappan Lakshmanan, closesvim/vim#5916)
6c2b7b8055
Packing and unpacking return values impairs performance considerably.
In an attempt to avoid creating tables as much as possible we can
instead pass return values between functions (which does not require
knowing the number of values a function might return). This makes the
code more complex, but improves benchmark numbers non-trivially.
fix(extmarks): disallow removing extmarks in on_lines callbacks
decor_redraw_start (which runs before decor_providers_invoke_lines) gets
references for the extmarks on a specific line. If these extmarks are
deleted in on_lines callbacks then this results in a heap-use-after-free
error.
Fixes#22801
Problem: no functions for converting from/to UTF-16 index.
Solution: Add UTF-16 flag to existing funtions and add strutf16len() and
utf16idx(). (Yegappan Lakshmanan, closesvim/vim#12216)
67672ef097
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Behavior of exists() in a :def function is unpredictable.
Solution: Add exists_compiled().
267359902c
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cannot get the first screen column of a character.
Solution: Let virtcol() optionally return a list. (closesvim/vim#10482,
closesvim/vim#7964)
0f7a3e1de6
Co-authored-by: LemonBoy <thatlemon@gmail.com>
Problem: Checks for Dictionary argument often give a vague error message.
Solution: Give a useful error message. (Yegappan Lakshmanan, closesvim/vim#11009)
04c4c5746e
Cherry-pick removal of E922 from docs from patch 9.0.1403.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* vim-patch:9.0.1478: filetypes for *.v files not detected properly
Problem: Filetypes for *.v files not detected properly.
Solution: Use the file contents to detect the filetype. (Turiiya,
closesvim/vim#12281)
80406c2618
Co-authored-by: Turiiya <34311583+tobealive@users.noreply.github.com>
Co-authored-by: Jonas Strittmatter <40792180+smjonas@users.noreply.github.com>
Problem: Tee-Object does not create a file if it does not receive input
for example when :grep does not find matches.
and so nvim tries to open a nonexistent errorfile causing an error.
Solution: use tee.exe instead of Tee-Object
This is a more robust method for tagging a packed table as it completely
eliminates the possibility of mistaking an actual table key as the
packed table tag.
This one generates a runtime/ file instead of a source file.
But otherwise it works the same like all other generators.
It has the same prerequisites (shared and mpack modules, etc), and,
importantly, it uses results from the source generators.
The odd location makes it easy to overlook when refactoring generators
(like I did last time, lol)
Problem:
`vim.split('a:::', ':', {trimempty=true})` trims inner empty items.
Regression from 9c49c10470
Solution:
Set `empty_start=false` when first non-empty item is found.
close#23212
fix(treesitter playground): wrong range of a node displayed in playground
The call parameters order of the function `get_range_str` is flipped for the last two arguments compared to the declaration.
This was originally meant as a convenience but prevents possible
functionality. For example:
-- Get the keys of the table with even values
local t = { a = 1, b = 2, c = 3, d = 4 }
vim.iter(t):map(function(k, v)
if v % 2 == 0 then return k end
end):totable()
The example above would not work, because the map() function returns
only a single value, and cannot be converted back into a table (there
are many such examples like this).
Instead, to convert an iterator into a map-like table, users can use
fold():
vim.iter(t):fold({}, function(t, k, v)
t[k] = v
return t
end)
If pack() is called with a single value, it does not create a table; it
simply returns the value it is passed. When unpack is called with a
table argument, it interprets that table as a list of values that were
packed together into a table.
This causes a problem when the single value being packed is _itself_ a
table. pack() will not place it into another table, but unpack() sees
the table argument and tries to unpack it.
To fix this, we add a simple "tag" to packed table values so that
unpack() only attempts to unpack tables that have this tag. Other tables
are left alone. The tag is simply the length of the table.
Problem: Jenkinsfiles are not recognized as groovy.
Solution: Add a pattern for Jenkinsfiles. (closesvim/vim#12236)
142ffb024d
Co-authored-by: dundargoc <gocdundar@gmail.com>
Problem: There is no way to get a list of swap file names.
Solution: Add the swapfilelist() function. Use it in the test script to
clean up. Remove deleting individual swap files.
c216a7a21a
vim-patch:9.0.1005: a failed test may leave a swap file behind
Problem: A failed test may leave a swap file behind.
Solution: Delete the swap file to avoid another test to fail. Use another
file name.
d0f8d39d20
Cherry-pick test_window_cmd.vim changes from patch 8.2.1593.
Remove FUNC_ATTR_UNUSED from eval functions as fptr is always unused.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
vim.iter wraps a table or iterator function into an `Iter` object with
methods such as `filter`, `map`, and `fold` which can be chained to
produce iterator pipelines that do not create new tables at each step.
- vim.diagnostic.config() now accepts a function for the virtual_text.prefix
option, which allows for rendering e.g., diagnostic severities differently.
shell_error is a function, the code missed parentheses
The actual module for perl module version is App::cpanminus::script, not
App::cpanminus::fatscript.
Problem: C++ 20 modules are not recognized.
Solution: Add patterns to recognize C++ 20 modules as "cpp". (Ben Jackson,
closesvim/vim#12261)
732d69e191
Co-authored-by: Ben Jackson <puremourning@gmail.com>