Problem: Lua callbacks for "msg_show" events with vim.ui_attach() are
executed when it is not safe.
Solution: Disallow non-fast API calls for "msg_show" event callbacks.
Automatically detach callback after excessive errors.
Make sure fast APIs do not modify Nvim state.
Problem: Quitting source buffer for ```:InspectTree``` command raises
```E855``` when source buffer and tree views are the only open buffers.
Solution: Add ```QuitPre``` event to autocmd handling closing/hiding the
source buffer to close all open tree views. This allows nvim to quit
when source and tree buffers are the only open windows.
This changes the type for the sorted pattern table from
`vim.filetype.mapping[]` to `vim.filetype.mapping.sorted[]`
E.g. instead of:
```lua
{
{ ['/debian/changelog$'] = {'debchangelog', { parent = '/debian/' } },
{ ['%.git/'] = { detect.git , { parent = 'git/', priority = -1 } },
}
```
It is now:
```lua
{
{ '/debian/, '/debian/changelog$', 'debchangelog' },
{ 'git/' , '%.git/' , detect.git , -1 },
}
```
Overall this should roughly cut the amount of tables used by 3, and
replaces lots of hash indexes with array indexes.
Problem: filetype: leo files are not recognized
Solution: detect '*.leo' files as leo filetype, include
a filetype plugin (Riley Bruins)
References:
https://github.com/ProvableHQ/leocloses: vim/vim#1598893f65a4ab8
Co-authored-by: Riley Bruins <ribru17@hotmail.com>
Problem:
There are three different ways of marking an option as hidden, `enable_if
= false`, `hidden = true` and `immutable = true`. These also have different
behaviors. Options hidden with `enable_if = false` can't have their value
fetched using Vim script or the API, but options hidden with `hidden = true` or
`immutable = true` can. On the other hand, options with `hidden = true` do not
error when trying to set their value, but options with `immutable = true` do.
Solution:
Remove `enable_if = false`, remove the `hidden` property for options, and use
`immutable = true` to mark an option as hidden instead. Also make hidden option
variable pointers always point to the default value, which allows fetching the
value of every hidden option using Vim script and the API. This does also mean
that trying to set a hidden option will now give an error instead of just being
ignored.
Problem: The window opened :InspectTree or :EditQuery isn't closed when
the source buffer is unloaded, even though it is closed when
the buffer is hidden.
Solution: Also close the window on BufUnload.
Problem: 'findexpr' can't be used for lambads
(Justin Keyes)
Solution: Replace the findexpr option with the findfunc option
(Yegappan Lakshmanan)
related: vim/vim#15905closes: vim/vim#15976a13f3a4f5d
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Long lists of available parsers make it hard to see WASM
status.
Solution: Add separate headings for "treesitter features" (ABI, WASM)
and "treesitter parsers". Also add minimum supported ABI version.
Problem: filetype: sway files are not recognized
Solution: detect '*.sw' files as sway filetype, include
a filetype plugin (Riley Bruins)
References:
https://github.com/FuelLabs/sway.
Comments taken from their syntax documentation. File extension taken
from the same documentation/GitHub's own recognition of these file types
closes: vim/vim#1597384b5b1c660
Co-authored-by: Riley Bruins <ribru17@hotmail.com>
- Partition the handlers in vim.lsp.handlers as:
- client to server response handlers (RCS)
- server to client request handlers (RSC)
- server to client notification handlers (NSC)
Note use string indexes instead of protocol.methods for improved
typing in LuaLS (tip: use hover on RCS, RSC or NSC).
`-NonInteractive` at least somewhat hints to pwsh/powershell, that shell
sessions created from :! are not interactive, though even that is not
foolproof, because powershell is weird.
`$PSStyle.OutputRendering='plaintext'` causes pwsh/powershell
to omit ANSI escape sequences in its output.
Problem: 'findexpr' completion doesn't set v:fname to cmdline argument.
Solution: Set v:fname to the cmdline argument as-is (zeertzjq).
closes: vim/vim#1593420e045f781
feat(diagnostics)!: sort underline with severity_sort
BREAKING CHANGE: underline will be applied with a higher value than `vim.hl.priorities.diagnostics`
The workspace folder name is meant to be a human-readable name which is
only used in the UI. Comparing the name against root_dir is thus not
a valid comparison. Instead, we should compare the workspace folder's
URI against the root dir URI.
* deprecate old signatures
* move to new str_byteindex/str_utfindex signature
* use single-underscore name (double-underscore is reserved for Lua itself)
Problem:
`lsp.buf_request` send the same params to all servers and many
calls to this pass PositionalParams which depends on the clients
offset_encoding. This can result with incorrect params being sent
to a server.
Solution:
`lsp.buf_request` `params` argument can now be passed as a function
which takes the client as the first argument. This is used in
lsp/buf.lua to construct correct params for each client request.
PROBLEM:
There are several limitations to vim.str_byteindex, vim.str_utfindex:
1. They throw given out-of-range indexes. An invalid (often user/lsp-provided)
index doesn't feel exceptional and should be handled by the caller.
`:help dev-error-patterns` suggests that `retval, errmsg` is the preferred
way to handle this kind of failure.
2. They cannot accept an encoding. So LSP needs wrapper functions. #25272
3. The current signatures are not extensible.
* Calling: The function currently uses a fairly opaque boolean value to
indicate to identify the encoding.
* Returns: The fact it can throw requires wrapping in pcall.
4. The current name doesn't follow suggestions in `:h dev-naming` and I think
`get` would be suitable.
SOLUTION:
- Because these are performance-sensitive, don't introduce `opts`.
- Introduce an "overload" that accepts `encoding:string` and
`strict_indexing:bool` params.
```lua
local col = vim.str_utfindex(line, encoding, [index, [no_out_of_range]])
```
Support the old versions by dispatching on the type of argument 2, and
deprecate that form.
```lua
vim.str_utfindex(line) -- (utf-32 length, utf-16 length), deprecated
vim.str_utfindex(line, index) -- (utf-32 index, utf-16 index), deprecated
vim.str_utfindex(line, 'utf-16') -- utf-16 length
vim.str_utfindex(line, 'utf-16', index) -- utf-16 index
vim.str_utfindex(line, 'utf-16', math.huge) -- error: index out of range
vim.str_utfindex(line, 'utf-16', math.huge, false) -- utf-16 length
```
Co-authored-by: David Pedersen <limero@me.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Leo Schlosser <Leo.Schlosser@Student.HTW-Berlin.de>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Problem:
Hidden options are documented despite being no-ops.
Solution:
Remove docs for hidden options.
Move tags for options that we plan to restore, to ":help nvim-missing".
Move tags for permanently removed options, to ":help nvim-removed".
Problem:
`vim.validate()` takes two forms when it only needs one.
Solution:
- Teach the fast form all the features of the spec form.
- Deprecate the spec form.
- General optimizations for both forms.
- Add a `message` argument which can be used alongside or in place
of the `optional` argument.
Problem:
- `vim.highlight` module does not follow `:help dev-name-common`, which
documents the name for "highlight" as "hl".
- Shorter names are usually preferred.
Solution:
Rename `vim.highlight` to `vim.hl`.
This is not a breaking change until 2.0 (or maybe never).
vim-patch:8.2.4744: a terminal window can't use the bell
vim-patch:8.2.4745: using wrong flag for using bell in the terminal
BREAKING CHANGE: Bells from :terminal are now silent by default, unless
'belloff' option doesn't contain "term" or "all".
Problem:
If there are multiple LSP clients, it's not clear which actions are provided by which servers. #30710
Solution:
Show the server name next to each action (only if there are multiple clients).
This commit makaes the following changes to the vim help syntax:
- fix excessive URL detection in help, because `file:{filename}` in
doc/options.txt is determined to be a URL.
- update highlighting N for :resize in help
- split Italian-specific syntax into separate help script
- highlight `Note` in parentheses in help
- update 'titlestring' behaviour in documentation for invalid '%' format
closes: vim/vim#158836c2fc377bf
Co-authored-by: Milly <milly.ca@gmail.com>
Problem:
Previously the index was only checked against the UTF8 length. This
could cause unexpected behaviours for strings containing multibyte chars
Solution:
Check indicies correctly against their max value before returning the
fallback length
Problem: Some runtime files no longer spark joy.
Solution: Kondo the place up.
Still sparks _some_ joy (moved to new `runtime/scripts` folder):
* `macros/less.*`
* `mswin.vim`
* `tools/emoji_list.lua`
No longer sparks joy (removed):
* `macmap.vim` (gvimrc file; not useful in Nvim)
* `tools/check_colors.vim` (no longer useful with new default colorscheme and treesitter)
* `macros/editexisting.vim` (throws error on current Nvim)
* `macros/justify.vim` (obsolete shim for `packadd! justify`)
* `macros/matchit.vim` (same)
* `macros/shellmenu.vim` (same)
* `macros/swapmous.vim` (same)
Problem: cannot preserve error position when setting quickfix lists
Solution: Add the 'u' action for setqflist()/setloclist() and try
to keep the closes target position (Jeremy Fleischman)
fixes: vim/vim#15839closes: vim/vim#1584127fbf6e5e8
Co-authored-by: Jeremy Fleischman <jeremyfleischman@gmail.com>
Problem: The standard statusline example is missing the preview flag
"%w"
Solution: Add the preview flag "%w"
closes: vim/vim#158747b5e52d16f
Co-authored-by: saher <msaher.shair@gmail.com>
Problem: filetype: lf config files are not recognized
Solution: detect lfrc files as lf filetype, include a syntax
script for lf files (Andis Spriņķis).
References:
- https://github.com/gokcehan/lfcloses: vim/vim#158590f146b7925
Co-authored-by: Andis Spriņķis <spr.andis@protonmail.com>
Problem: filetype: Some upstream php files are not recognized
Solution: Detect more config files from the PHP source
distribution as filetype ini (nisbet-hubbard).
closes: vim/vim#15840367499c5c3
Co-authored-by: nisbet-hubbard <87453615+nisbet-hubbard@users.noreply.github.com>
**Problems:**
- `vim.treesitter.language.inspect()` returns duplicate
symbol names, sometimes up to 6 of one kind in the case of `markdown`
- The list-like `symbols` table can have holes and is thus not even a
valid msgpack table anyway, mentioned in a test
**Solution:** Return symbols as a map, rather than a list, where field
names are the names of the symbol. The boolean value associated with the
field encodes whether or not the symbol is named.
Note that anonymous nodes are surrounded with double quotes (`"`) to
prevent potential collisions with named counterparts that have the same
identifier.
This commit also marks `child_containing_descendant()` as deprecated
(per upstream's documentation), and uses `child_with_descendant()` in
its place. Minimum required tree-sitter version will now be `0.24`.
Problem: filetype: some Apache files are not recognized
Solution: Detect more config files from the Apache source
distribution as filetype apache (nisbet-hubbard)
closes: vim/vim#15810e58e9015cc
Co-authored-by: nisbet-hubbard <87453615+nisbet-hubbard@users.noreply.github.com>
Problem: on `CompleteDone` cursor can jump to the end of line instead of
the end of the completed word.
Solution: remove only inserted word for snippet expansion instead of everything
until eol.
Fixes#30656
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Problem: Currently completion attribute hl_group is combined with
all items, which is redundant and confusing with kind_hlgroup
Solution: Renamed to abbr_hlgroup and combine it only with the abbr item
(glepnir).
closes: vim/vim#158180fe17f8ffb
Co-authored-by: glepnir <glephunter@gmail.com>
Problem: current command completion is a bit limited
Solution: Add the shellcmdline completion type and getmdcomplpat()
function (Ruslan Russkikh).
closes: vim/vim#158230407d621bb
Co-authored-by: Ruslan Russkikh <dvrussk@yandex.ru>
Problem:
tagfunc failed in a weird buffer (either a directory or some other
non-file buffer, I don't remember):
E987: Invalid return value from tagfunc
E5108: Error executing lua …/runtime/lua/vim/lsp/util.lua:311: EISDIR: illegal operation on a directory
stack traceback:
at this line:
local data = assert(uv.fs_read(fd, stat.size, 0))
Solution:
Check for directory.
Problem: 'cedit', 'termwinkey' and 'wildchar' may not be parsed
correctly
Solution: improve string_to_key() function in option.c
(Milly)
- Problem: `^@` raises an error.
Solution: Store as `<Nul>`.
- Problem: `<t_xx` does not raise an error.
Solution: Raise an error if closing `>` is missing.
- Problem: Single `<` or `^` raises an error. It is inconvenient for users.
Solution: They are stored as a single character.
closes: vim/vim#15811a9c6f90918
Co-authored-by: Milly <milly.ca@gmail.com>
Problem:
- Some servers like LuaLS add unwanted blank lines after multiline
`@param` description.
- List items do not wrap nicely.
Solution:
- When rendering the LSP doc hover, remove blank lines in each `@param`
or `@return`.
- But ensure exactly one empty line before each.
- Set 'breakindent'.
Problem: `runtime/tools/emoji_list.vim` is a Lua script masquerading as
Vimscript, which is unnecessary now that `:source` works for Lua files.
Solution: Remove Vimscript wrapper.
Some commands don't accept "count" and only work with "range". It's not
clear why. The issue is tracked at [1], but this is a workaround for
now.
[1]: https://github.com/neovim/neovim/issues/30641
Problem: Lua accessors for
- global, local, and special variables (`vim.{g,t,w,b,v}.*`), and
- options (`vim.{o,bo,wo,opt,opt_local,opt_global}.*`),
do not have command-line completion, unlike their vimscript counterparts
(e.g., `g:`, `b:`, `:set`, `:setlocal`, `:call <fn>`, etc.).
Completion for vimscript functions (`vim.fn.*`) is incomplete and does
not list all the available functions.
Solution: Implement completion for vimscript function, variable and
option accessors in `vim._expand_pat` through:
- `getcompletion()` for variable and vimscript function accessors, and
- `nvim_get_all_options_info()` for option accessors.
Note/Remark:
- Short names for options are yet to be implemented.
- Completions for accessors with handles (e.g. `vim.b[0]`, `vim.wo[0]`)
are also yet to be implemented, and are left as future work, which
involves some refactoring of options.
- For performance reasons, we may want to introduce caching for
completing options, but this is not considered at this time since the
number of the available options is not very big (only ~350) and Lua
completion for option accessors appears to be pretty fast.
- Can we have a more "general" framework for customizing completions?
In the future, we may want to improve the implementation by moving the
core logic for generating completion candidates to each accessor (or
its metatable) or through some central interface, rather than writing
all the accessor-specific completion implementations in a single
function: `vim._expand_pat`.
An implication of this current approach is that `NVIM_API_LEVEL` should be
bumped when a new Lua function is added.
TODO(future): add a lint check which requires `@since` on all new functions.
ref #25416
**Problem:** The documentation for `TSNode` and `TSTree` methods is
incomplete from the LSP perspective. This is because they are written
directly to the vimdoc, rather than in Lua and generated to vimdoc.
**Solution:** Migrate the docs to Lua and generate them into the vimdoc.
This requires breaking up the `treesitter/_meta.lua` file into a
directory with a few different modules.
This commit also makes the vimdoc generator slightly more robust with
regard to sections that have multiple help tags (e.g. `*one* *two*`)
Some composite/compound types even as basic as `(string|number)[]` are
not currently supported by the luacats LPEG grammar used by gen_vimdoc.
It would be parsed & rendered as just `string|number`.
Changeset adds better support for these types.
Problem: fixed order of items in insert-mode completion menu
Solution: Introduce the 'completeitemalign' option with default
value "abbr,kind,menu" (glepnir).
Adding an new option `completeitemalign` abbr is `cia` to custom
the complete-item order in popupmenu.
closes: vim/vim#14006closes: vim/vim#157606a89c94a9e
Problem:
The `_watch.watch()` strategy may fail if the given path does not exist:
…/vim/_watch.lua:101: ENOENT: no such file or directory
stack traceback:
[C]: in function 'assert'
…/vim/_watch.lua:101: in function <…/vim/_watch.lua:61>
[string "<nvim>"]:5: in main chunk
- `_watch.watch()` actively asserts any error returned by `handle:start()`.
- whereas `_watch.watchdirs()` just ignores the result of `root_handle:start()`.
Servers may send "client/registerCapability" with "workspace/didChangeWatchedFiles"
item(s) (`baseUri`) which do not actually exist on the filesystem:
https://github.com/neovim/neovim/issues/28058#issuecomment-2189929424
{
method = "client/registerCapability",
params = {
registrations = { {
method = "workspace/didChangeWatchedFiles",
registerOptions = {
watchers = { {
globPattern = {
baseUri = "file:///Users/does/not/exist",
pattern = "**/*.{ts,js,mts,mjs,cjs,cts,json,svelte}"
}
},
...
}
Solution:
- Remove the assert in `_watch.watch()`.
- Show a once-only message for both cases.
- More detailed logging is blocked until we have `nvim_log` / `vim.log`.
fix#28058