Problem:
- `vim.json` exposes various global options which:
- affect all Nvim Lua plugins (especially the LSP client)
- are undocumented and untested
- can cause confusing problems such as: cc76ae3abe
- `vim.json` exposes redundant mechanisms:
- `vim.json.null` is redundant with `vim.NIL`.
- `array_mt` is redundant because Nvim uses a metatable
(`vim.empty_dict()`) for empty dict instead, which `vim.json` is
configured to use by default (see `as_empty_dict`).
Example:
```
:lua vim.print(vim.json.decode('{"bar":[],"foo":{}}'))
--> { bar = {}, foo = vim.empty_dict() }
```
Thus we don't need to also decorate empty arrays with `array_mt`.
Solution:
Remove the functions from the public vim.json interface.
Comment-out the implementation code to minimize drift from upstream.
TODO:
- Expose the options as arguments to `vim.json.new()`
Problem:
Spacing around inlay hints has the same highlight as the hint itself.
The LSP spec for inlay hints specifically mentions the padding should not be
coloured:
/**
Render padding before the hint.
Note: Padding should use the editor's background color, not the
background color of the hint itself. That means padding can be used
to visually align/separate an inlay hint.
*/
paddingLeft?: boolean;
/**
Render padding after the hint.
Note: Padding should use the editor's background color, not the
background color of the hint itself. That means padding can be used
to visually align/separate an inlay hint.
*/
paddingRight?: boolean;
Solution:
Add the space as separate parts of the virtual text, don't add the space to the
text itself.
Add automatic refresh and a public interface on top of #23736
* add on_reload, on_detach handlers in `enable()` buf_attach, and
LspDetach autocommand in case of manual detach
* unify `__buffers` and `hint_cache_by_buf`
* use callback bufnr in `on_lines` callback, bufstate: remove __index override
* move user-facing functions into vim.lsp.buf, unify enable/disable/toggle
Closes#18086
Co-authored by: zeertzjq <zeertzjq@outlook.com>
Co-authored by: Steven Todd McIntyre II <114119064+stmii@users.noreply.github.com>
Co-authored by: nobe4 <nobe4@users.noreply.github.com>
- docs: mention --luadev-mod to run with lua runtime files
When changing a lua file in the ./runtime folder, a new contributor
might expect changes to be applied to the built Neovim binary.
Problem: Current implementation of "remove trailing /" doesn't
account for the case of literal '/' as path.
Solution: Remove trailing / only if it preceded by something else.
Co-authored by: notomo <notomo.motono@gmail.com>
Previously, filtering code actions with the "only" option failed
if the code action kind contained special Lua pattern chars such as "-"
(e.g. the ocaml language server supports a "type-annotate" code action).
Solution: use string comparison instead of string.find
Problem: Having utf16idx() rounding up is inconvenient.
Solution: Make utf16idx() round down. (Yegappan Lakshmanan, closesvim/vim#12523)
95707037af
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
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>