aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md66
-rw-r--r--MAINTAIN.md28
-rw-r--r--runtime/doc/api.txt16
-rw-r--r--runtime/doc/builtin.txt21
-rw-r--r--runtime/doc/channel.txt2
-rw-r--r--runtime/doc/deprecated.txt41
-rw-r--r--runtime/doc/develop.txt19
-rw-r--r--runtime/doc/editing.txt6
-rw-r--r--runtime/doc/insert.txt20
-rw-r--r--runtime/doc/lsp.txt131
-rw-r--r--runtime/doc/lua.txt19
-rw-r--r--runtime/doc/map.txt1
-rw-r--r--runtime/doc/news.txt13
-rw-r--r--runtime/doc/options.txt18
-rw-r--r--runtime/doc/pattern.txt1
-rw-r--r--runtime/doc/russian.txt1
-rw-r--r--runtime/doc/starting.txt25
-rw-r--r--runtime/doc/ui.txt2
-rw-r--r--runtime/doc/usr_11.txt5
-rw-r--r--runtime/doc/usr_45.txt3
-rw-r--r--runtime/doc/various.txt11
-rw-r--r--runtime/doc/vim_diff.txt34
-rw-r--r--runtime/lua/vim/fs.lua4
-rw-r--r--runtime/lua/vim/iter.lua5
-rw-r--r--runtime/lua/vim/lsp.lua72
-rw-r--r--runtime/lua/vim/lsp/_inlay_hint.lua162
-rw-r--r--runtime/lua/vim/lsp/buf.lua33
-rw-r--r--runtime/lua/vim/lsp/codelens.lua24
-rw-r--r--runtime/lua/vim/lsp/handlers.lua3
-rw-r--r--runtime/lua/vim/lsp/types.lua2
-rw-r--r--runtime/lua/vim/treesitter/highlighter.lua4
-rw-r--r--scripts/gen_help_html.lua2
-rwxr-xr-xscripts/gen_vimdoc.py1
-rw-r--r--src/man/nvim.12
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/api/window.c2
-rw-r--r--src/nvim/fileio.c3
-rw-r--r--src/nvim/main.c22
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua3
-rw-r--r--test/functional/lua/fs_spec.lua6
-rw-r--r--test/functional/plugin/lsp/inlay_hint_spec.lua10
-rw-r--r--test/old/testdir/test_startup.vim6
42 files changed, 512 insertions, 339 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4c8387fbd2..91badd4c58 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,7 +33,7 @@ Reporting problems
Developer guidelines
--------------------
-- Read [:help dev](https://neovim.io/doc/user/develop.html#dev) if you are working on Nvim core.
+- Read [:help dev](https://neovim.io/doc/user/develop.html#dev) and [:help dev-doc][dev-doc-guide] if you are working on Nvim core.
- Read [:help dev-ui](https://neovim.io/doc/user/develop.html#dev-ui) if you are developing a UI.
- Read [:help dev-api-client](https://neovim.io/doc/user/develop.html#dev-api-client) if you are developing an API client.
- Install `ninja` for faster builds of Nvim.
@@ -264,40 +264,52 @@ For managing includes in C files, use [include-what-you-use].
See [#549][549] for more details.
+### Lua runtime files
+
+Most of the Lua core [`runtime/`](./runtime) modules are precompiled to
+bytecode, so changes to those files won't get used unless you rebuild Nvim or
+by passing `--luamod-dev` and `$VIMRUNTIME`. For example, try adding a function
+to `runtime/lua/vim/_editor.lua` then:
+
+ VIMRUNTIME=./runtime ./build/bin/nvim --luamod-dev
+
Documenting
-----------
-Many parts of the `:help` documentation are autogenerated from C or Lua docstrings using the `./scripts/gen_vimdoc.py` script.
-You can filter the regeneration based on the target (api, lua, or lsp), or the file you changed, that need a doc refresh using `./scripts/gen_vimdoc.py -t <target>`.
+Read [:help dev-doc][dev-doc-guide] to understand the expected documentation style and conventions.
-## Lua docstrings
+### Generating :help
-Lua documentation uses a subset of [EmmyLua] annotations. A rough outline of a function documentation is
+Many `:help` docs are autogenerated from (C or Lua) docstrings by the `./scripts/gen_vimdoc.py` script.
+For convenience you can filter the regeneration by target (api, lua, lsp) using the `-t` option, for example:
-```lua
---- {Brief}
----
---- {Long explanation}
----
----@param arg1 type {description}
----@param arg2 type {description}
-{...}
----
----@return type {description}
-```
+ ./scripts/gen_vimdoc.py -t lua
-If possible, always add type information (`table`, `string`, `number`, ...). Multiple valid types are separated by a bar (`string|table`). Indicate optional parameters via `type|nil`.
+### Lua docstrings
-If a function in your Lua module should not be documented (e.g. internal function or local function), you should set the doc comment to:
-
-```
----@private
-```
+Lua documentation uses a subset of [EmmyLua] annotations. See [:help dev-doc-lua][dev-doc-lua].
-Mark functions that are deprecated as
-```
----@deprecated
-```
+- The template for function documentation is:
+ ```lua
+ --- {Brief}
+ ---
+ --- {Long explanation}
+ ---
+ ---@param arg1 type {description}
+ ---@param arg2 type {description}
+ --- ...
+ ---
+ ---@return type {description}
+ ```
+- If possible, add type information (`table`, `string`, `number`, ...). Multiple valid types are separated by a bar (`string|table`). Indicate optional parameters via `type|nil`.
+- If a function in your Lua module should _not_ be documented (e.g. internal or local function), set the doc comment to:
+ ```
+ ---@private
+ ```
+- Mark deprecated functions with:
+ ```
+ ---@deprecated
+ ```
Reviewing
---------
@@ -326,6 +338,8 @@ as context, use the `-W` argument as well.
[Merge a Vim patch]: https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-Vim
[complexity:low]: https://github.com/neovim/neovim/issues?q=is%3Aopen+is%3Aissue+label%3Acomplexity%3Alow
[conventional_commits]: https://www.conventionalcommits.org
+[dev-doc-guide]: https://neovim.io/doc/user/develop.html#dev-doc
+[dev-doc-lua]: https://neovim.io/doc/user/develop.html#dev-lua-doc
[EmmyLua]: https://github.com/sumneko/lua-language-server/wiki/Annotations
[gcc-warnings]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
[gh]: https://cli.github.com/
diff --git a/MAINTAIN.md b/MAINTAIN.md
index 2ba764851b..191ef70709 100644
--- a/MAINTAIN.md
+++ b/MAINTAIN.md
@@ -60,6 +60,32 @@ has a major bug:
Neovim automation includes a [backport bot](https://github.com/zeebe-io/backport-action).
Trigger the action by labeling a PR with `backport release-X.Y`. See `.github/workflows/backport.yml`.
+Deprecating and removing features
+---------------------------------
+
+Neovim inherits many features and design decisions from Vim, not all of which
+align with the goals of this project. It is sometimes desired or necessary to
+remove existing features, or refactor parts of the code that would change
+user's workflow. In these cases, a deprecation policy is needed to properly
+inform users of the change.
+
+In general, when a feature is slated to be removed it should:
+
+1. Be marked deprecated in the _next_ release
+ - This includes a note in the release notes (include a "Deprecation Warning"
+ section just below "Breaking Changes")
+ - Lua features can use `vim.deprecate()`
+ - Features implemented in Vimscript or in C will need bespoke implementations
+ to communicate to users that the feature is deprecated
+2. Be removed in a release following the release in which it was marked
+ deprecated
+ - Usually this will be the next release, but it may be a later release if a
+ longer deprecation cycle is desired
+
+Feature removals which may benefit from community input or further discussion
+should also have a tracking issue (which should be linked to in the release
+notes).
+
Third-party dependencies
------------------------
@@ -93,6 +119,8 @@ These dependencies are "vendored" (inlined), we must update the sources manually
* `runtime/lua/vim/inspect.lua`: [inspect.lua](https://github.com/kikito/inspect.lua)
* `src/nvim/tui/terminfo_defs.h`: terminfo definitions
* Run `scripts/update_terminfo.sh` to update these definitions.
+* `runtime/lua/vim/lsp/types/protocol.lua`: LSP specification
+ * Run `scripts/lsp_types.lua` to update.
* `src/bit.c`: only for PUC lua: port of `require'bit'` from luajit https://bitop.luajit.org/
* [treesitter parsers](https://github.com/neovim/neovim/blob/fcc24e43e0b5f9d801a01ff2b8f78ce8c16dd551/cmake.deps/CMakeLists.txt#L197-L210)
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 1732c24f2f..9adca7620f 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -17,8 +17,15 @@ Applications can also embed libnvim to work with the C API directly.
API Usage *api-rpc* *RPC* *rpc*
*msgpack-rpc*
-RPC is the typical way to control Nvim programmatically. Nvim implements the
-MessagePack-RPC protocol:
+RPC is the main way to control Nvim programmatically. Nvim implements the
+MessagePack-RPC protocol with these extra (out-of-spec) constraints:
+
+1. Responses must be given in reverse order of requests (like "unwinding
+ a stack").
+2. Nvim processes all messages (requests and notifications) in the order they
+ are received.
+
+MessagePack-RPC specification:
https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md
https://github.com/msgpack/msgpack/blob/0b8f5ac/spec.md
@@ -1133,7 +1140,7 @@ nvim_list_chans() *nvim_list_chans()*
specified at |nvim_get_chan_info()|.
nvim_list_runtime_paths() *nvim_list_runtime_paths()*
- Gets the paths contained in 'runtimepath'.
+ Gets the paths contained in |runtime-search-path|.
Return: ~
List of paths
@@ -2819,6 +2826,9 @@ nvim_win_get_cursor({window}) *nvim_win_get_cursor()*
Return: ~
(row, col) tuple
+ See also: ~
+ • |getcurpos()|
+
nvim_win_get_height({window}) *nvim_win_get_height()*
Gets the window height
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 938523b6ee..f1c4782d1b 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -4542,6 +4542,8 @@ jobresize({job}, {width}, {height}) *jobresize()*
Fails if the job was not started with `"pty":v:true`.
jobstart({cmd} [, {opts}]) *jobstart()*
+ Note: Prefer |vim.system()| in Lua.
+
Spawns {cmd} as a job.
If {cmd} is a List it runs directly (no 'shell').
If {cmd} is a String it runs in the 'shell', like this: >
@@ -4597,11 +4599,9 @@ jobstart({cmd} [, {opts}]) *jobstart()*
stdout data.
|on_stderr|: (function) Callback invoked when the job emits
stderr data.
- overlapped: (boolean) Set FILE_FLAG_OVERLAPPED for the
- standard input/output passed to the child process.
- Normally you do not need to set this.
- (Only available on MS-Windows, On other
- platforms, this option is silently ignored.)
+ overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the
+ stdio passed to the child process. Only on
+ MS-Windows; ignored on other platforms.
pty: (boolean) Connect the job to a new pseudo
terminal, and its streams to the master file
descriptor. `on_stdout` receives all output,
@@ -8665,6 +8665,8 @@ synstack({lnum}, {col}) *synstack()*
valid positions.
system({cmd} [, {input}]) *system()* *E677*
+ Note: Prefer |vim.system()| in Lua.
+
Gets the output of {cmd} as a |string| (|systemlist()| returns
a |List|) and sets |v:shell_error| to the error code.
{cmd} is treated as in |jobstart()|:
@@ -8840,10 +8842,13 @@ termopen({cmd} [, {opts}]) *termopen()*
to the current (unmodified) buffer. Parameters and behavior
are the same as |jobstart()| except "pty", "width", "height",
and "TERM" are ignored: "height" and "width" are taken from
- the current window.
- Returns the same values as |jobstart()|.
+ the current window. Note that termopen() implies a "pty" arg
+ to jobstart(), and thus has the implications documented at
+ |jobstart()|.
+
+ Returns the same values as jobstart().
- Terminal environment is initialized as in ||jobstart-env|,
+ Terminal environment is initialized as in |jobstart-env|,
except $TERM is set to "xterm-256color". Full behavior is
described in |terminal|.
diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt
index 1c52b2d692..afc4ef3787 100644
--- a/runtime/doc/channel.txt
+++ b/runtime/doc/channel.txt
@@ -151,7 +151,7 @@ from the host TTY, or if Nvim is |--headless| it uses default values: >vim
When channels are opened with the `rpc` option set to true, the channel can be
used for remote method calls in both directions, see |msgpack-rpc|. Note that
rpc channels are implicitly trusted and the process at the other end can
-invoke any |api| function!
+invoke any |API| function!
==============================================================================
4. Standard IO channel *channel-stdio*
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt
index 73888a32cc..6fb11f0987 100644
--- a/runtime/doc/deprecated.txt
+++ b/runtime/doc/deprecated.txt
@@ -117,6 +117,13 @@ internally and are no longer exposed as part of the API. Instead, use
- *vim.lsp.diagnostic.set_virtual_text()*
LSP FUNCTIONS
+- *vim.lsp.buf.server_ready()*
+ Use |LspAttach| instead, depending on your use-case. "Server ready" is not
+ part of the LSP spec, so the Nvim LSP client cannot meaningfully implement
+ it. "Ready" is ambiguous because:
+ - Language servers may finish analyzing the workspace, but edits can always
+ re-trigger analysis/builds.
+ - Language servers can serve some requests even while processing changes.
- *vim.lsp.buf.range_code_action()* Use |vim.lsp.buf.code_action()| with
the `range` parameter.
- *vim.lsp.util.diagnostics_to_items()* Use |vim.diagnostic.toqflist()| instead.
@@ -163,27 +170,21 @@ OPTIONS
- 'viewoptions' Flags "unix", "slash" are ignored and always enabled.
- *'viminfo'* Deprecated alias to 'shada' option.
- *'viminfofile'* Deprecated alias to 'shadafile' option.
-- *'paste'* *'nopaste'* This option is obsolete; |paste| is handled automatically.
+- *'paste'* *'nopaste'* Just Paste It.™ The 'paste' option is obsolete:
+ |paste| is handled automatically when you paste text
+ using your terminal's or GUI's paste feature
+ (CTRL-SHIFT-v, CMD-v (macOS), middle-click, …).
Enables "paste mode":
- - mappings in Insert mode and Command-line mode are
- disabled
- - abbreviations are disabled
- - 'autoindent' is reset
- - 'expandtab' is reset
- - 'formatoptions' is used like it is empty
- - 'revins' is reset
- - 'ruler' is reset
- - 'showmatch' is reset
- - 'smartindent' is reset
- - 'smarttab' is reset
- - 'softtabstop' is set to 0
- - 'textwidth' is set to 0
- - 'wrapmargin' is set to 0
- These options keep their value, but their effect is
- disabled:
- - 'cindent'
- - 'indentexpr'
- - 'lisp'
+ - Disables mappings in Insert, Cmdline mode.
+ - Disables abbreviations.
+ - Resets 'autoindent' 'expandtab' 'revins' 'ruler'
+ 'showmatch' 'smartindent' 'smarttab' 'softtabstop'
+ 'textwidth' 'wrapmargin'.
+ - Treats 'formatoptions' as empty.
+ - Disables the effect of these options:
+ - 'cindent'
+ - 'indentexpr'
+ - 'lisp'
UI EXTENSIONS
- *ui-wildmenu* Use |ui-cmdline| with |ui-popupmenu| instead. Enabled
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt
index b090fd4f09..be4068d8c8 100644
--- a/runtime/doc/develop.txt
+++ b/runtime/doc/develop.txt
@@ -130,10 +130,14 @@ DOCUMENTATION *dev-doc*
(docstrings, user manual, website materials, newsletters, …). Don't mince
words. Personality and flavor, used sparingly, are welcome--but in general,
optimize for the reader's time and energy: be "precise yet concise".
- - See https://developers.google.com/style/tone
- Prefer the active voice: "Foo does X", not "X is done by Foo".
-- Start function docstrings with present tense ("Gets"), not imperative
- ("Get"). This tends to reduce ambiguity and improve clarity. >
+ - "The words you choose are an essential part of the user experience."
+ https://developer.apple.com/design/human-interface-guidelines/foundations/writing/
+ - "...without being overly colloquial or frivolous."
+ https://developers.google.com/style/tone
+- Write docstrings (as opposed to inline comments) with present tense ("Gets"),
+ not imperative ("Get"). This tends to reduce ambiguity and improve clarity
+ by describing "What" instead of "How". >
GOOD:
/// Gets a highlight definition.
BAD:
@@ -272,6 +276,12 @@ See also |dev-naming|.
- mimic the pairs() or ipairs() interface if the function is intended to be
used in a "for" loop.
+Interface conventions ~
+
+- When accepting a buffer id, etc., 0 means "current buffer", nil means "all
+ buffers". Likewise for window id, tabpage id, etc.
+ - Examples: |vim.lsp.codelens.clear()| |vim.diagnostic.enable()|
+
API DESIGN GUIDELINES *dev-api*
@@ -346,6 +356,7 @@ Use consistent names for {noun} (nouns) in API functions: buffer is called
Do NOT use these deprecated nouns:
- buffer
+ - callback Use on_foo instead
- command
- window
@@ -467,6 +478,8 @@ External UIs are expected to implement these common features:
- Consider the "option_set" |ui-global| event as a hint for other GUI
behaviors. Various UI-related options ('guifont', 'ambiwidth', …) are
published in this event. See also "mouse_on", "mouse_off".
+- UIs generally should NOT set |$NVIM_APPNAME| (unless explicitly requested by
+ the user).
vim:tw=78:ts=8:sw=4:et:ft=help:norl:
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index c774d1ad38..2e0f73a597 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1677,9 +1677,9 @@ mark a file as trusted or untrusted using the |:trust| command or the
:trust [++deny] [++remove] [file]
Manage trusted files. Without ++ options, :trust marks
- [file] (or current buffer if no [file]) as trusted,
- keyed on a hash of its contents. The trust list is
- stored on disk, Nvim will re-use it after restarting.
+ the current buffer as trusted, keyed on a hash of its
+ contents. The trust list is stored on disk, Nvim will
+ re-use it after restarting.
[++deny] marks [file] (or current buffer if no [file]) as
untrusted: it will never be executed, 'exrc' will
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index de1b850a3f..a1e0675b36 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1081,6 +1081,26 @@ Stop completion *compl-stop*
CTRL-X CTRL-Z Stop completion without changing the text.
+AUTO-COMPLETION *compl-autocomplete*
+
+To get basic "autocompletion" without installing a plugin, try this script: >lua
+
+ local triggers = {"."}
+ vim.api.nvim_create_autocmd("InsertCharPre", {
+ buffer = vim.api.nvim_get_current_buf(),
+ callback = function()
+ if vim.fn.pumvisible() == 1 then
+ return
+ end
+ local char = vim.v.char
+ if vim.tbl_contains(triggers, char) then
+ local key = vim.keycode("<C-x><C-n>")
+ vim.api.nvim_feedkeys(key, "m", false)
+ end
+ end
+ })
+<
+
FUNCTIONS FOR FINDING COMPLETIONS *complete-functions*
This applies to 'completefunc', 'thesaurusfunc' and 'omnifunc'.
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index c4322e9c24..bc924df39b 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -46,38 +46,40 @@ Follow these steps to get LSP features:
See |lsp-config|.
*lsp-config*
-
-Starting a LSP client will automatically report diagnostics via
-|vim.diagnostic|. Read |vim.diagnostic.config()| to learn how to customize the
-display.
-
-It also sets some buffer options if the language server supports the
-functionality and if the options are otherwise empty or have the default
-values set by Nvim runtime files (e.g. a ftplugin). In the latter case,
-the default values are not restored when the LSP client is detached from
-the buffer.
-
-- 'omnifunc' is set to |vim.lsp.omnifunc()|. This allows to trigger completion
- using |i_CTRL-X_CTRL-O|
+ *lsp-defaults*
+When the LSP client starts it enables diagnostics |vim.diagnostic| (see
+|vim.diagnostic.config()| to customize). It also sets various default options,
+listed below, if (1) the language server supports the functionality and (2)
+the options are empty or were set by the builtin runtime (ftplugin) files. The
+options are not restored when the LSP client is stopped or detached.
+
+- 'omnifunc' is set to |vim.lsp.omnifunc()|, use |i_CTRL-X_CTRL-O| to trigger
+ completion.
- 'tagfunc' is set to |vim.lsp.tagfunc()|. This enables features like
go-to-definition, |:tjump|, and keymaps like |CTRL-]|, |CTRL-W_]|,
|CTRL-W_}| to utilize the language server.
-- 'formatexpr' is set to |vim.lsp.formatexpr()| if both 'formatprg' and
- 'formatexpr' are empty. This allows to format lines via |gq| if the language
- server supports it.
+- 'formatexpr' is set to |vim.lsp.formatexpr()|, so you can format lines via
+ |gq| if the language server supports it.
+ - To opt out of this use |gw| instead of gq, or set 'formatexpr' on LspAttach.
-To use other LSP features like hover, rename, etc. you can setup some
-additional keymaps. It's recommended to setup them in a |LspAttach| autocmd to
-ensure they're only active if there is a LSP client running. An example:
->lua
+ *lsp-defaults-disable*
+To override the above defaults, set or unset the options on |LspAttach|: >lua
+ vim.api.nvim_create_autocmd('LspAttach', {
+ callback = function(ev)
+ vim.bo[ev.buf].formatexpr = nil
+ vim.bo[ev.buf].omnifunc = nil
+ end,
+ })
+
+To use other LSP features like hover, rename, etc. you can set other keymaps
+on |LspAttach|. Example: >lua
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = args.buf })
end,
})
-<
-The most used functions are:
+The most common functions are:
- |vim.lsp.buf.hover()|
- |vim.lsp.buf.format()|
@@ -138,19 +140,6 @@ FAQ *lsp-faq*
" (async = false is the default for format)
autocmd BufWritePre *.rs lua vim.lsp.buf.format({ async = false })
<
-- Q: How can I disable LSP formatting when using the |gq| command?
- A: To use the default internal formatting method and bypass the LSP client's
- 'formatexpr', use |gw| instead.
- Alternatively you can completely disable LSP formatting with gq by
- unsetting 'formatexpr':
-
->lua
- vim.api.nvim_create_autocmd('LspAttach', {
- callback = function(args)
- vim.bo[args.buf].formatexpr = nil
- end,
- })
-<
*lsp-vs-treesitter*
- Q: How do LSP and Treesitter compare?
A: LSP requires a client and language server. The language server uses
@@ -218,10 +207,10 @@ specification. These LSP requests/notifications are defined by default:
*lsp-handler*
-lsp-handlers are functions with special signatures that are designed to handle
-responses and notifications from LSP servers.
+LSP handlers are functions with signatures designed to handle LSP responses
+and notifications.
-For |lsp-request|, each |lsp-handler| has this signature: >
+For |lsp-response|, each |lsp-handler| has this signature: >
function(err, result, ctx, config)
<
@@ -374,42 +363,37 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method
Handlers can be set by:
- Setting a field in vim.lsp.handlers. *vim.lsp.handlers*
- vim.lsp.handlers is a global table that contains the default mapping of
- |lsp-method| names to |lsp-handlers|.
-
- To override the handler for the `"textDocument/definition"` method: >lua
+ vim.lsp.handlers is a global table that contains the default mapping of
+ |lsp-method| names to |lsp-handlers|. To override the handler for the
+ `"textDocument/definition"` method: >lua
vim.lsp.handlers["textDocument/definition"] = my_custom_default_definition
<
-- The {handlers} parameter for |vim.lsp.start_client()|.
- This will set the |lsp-handler| as the default handler for this server.
-
- For example: >lua
+- The {handlers} parameter of |vim.lsp.start()|. This sets the default
+ |lsp-handler| for the server being started. Example: >lua
- vim.lsp.start_client {
+ vim.lsp.start {
..., -- Other configuration omitted.
handlers = {
["textDocument/definition"] = my_custom_server_definition
},
}
-- The {handler} parameter for |vim.lsp.buf_request()|.
- This will set the |lsp-handler| ONLY for the current request.
-
- For example: >lua
+- The {handler} parameter of |vim.lsp.buf_request_all()|. This sets
+ the |lsp-handler| ONLY for the given request(s). Example: >lua
- vim.lsp.buf_request(
+ vim.lsp.buf_request_all(
0,
"textDocument/definition",
- definition_params,
- my_request_custom_definition
+ my_request_params,
+ my_handler
)
<
In summary, the |lsp-handler| will be chosen based on the current |lsp-method|
in the following order:
-1. Handler passed to |vim.lsp.buf_request()|, if any.
-2. Handler defined in |vim.lsp.start_client()|, if any.
+1. Handler passed to |vim.lsp.buf_request_all()|, if any.
+2. Handler defined in |vim.lsp.start()|, if any.
3. Handler defined in |vim.lsp.handlers|, if any.
*vim.lsp.log_levels*
@@ -478,6 +462,8 @@ LspReferenceText used for highlighting "text" references
LspReferenceRead used for highlighting "read" references
*hl-LspReferenceWrite*
LspReferenceWrite used for highlighting "write" references
+ *hl-LspInlayHint*
+LspInlayHint used for highlighting inlay hints
*lsp-highlight-codelens*
@@ -720,31 +706,27 @@ buf_notify({bufnr}, {method}, {params}) *vim.lsp.buf_notify()*
(boolean) success true if any client returns true; false otherwise
*vim.lsp.buf_request_all()*
-buf_request_all({bufnr}, {method}, {params}, {callback})
- Sends an async request for all active clients attached to the buffer.
- Executes the callback on the combined result. Parameters are the same as
- |vim.lsp.buf_request()| but the return result and callback are different.
+buf_request_all({bufnr}, {method}, {params}, {handler})
+ Sends an async request for all active clients attached to the buffer and
+ executes the `handler` callback with the combined result.
Parameters: ~
- • {bufnr} (integer) Buffer handle, or 0 for current.
- • {method} (string) LSP method name
- • {params} (table|nil) Parameters to send to the server
- • {callback} (function) The callback to call when all requests are
- finished. Unlike `buf_request`, this will collect all the
- responses from each server instead of handling them. A map
- of client_id:request_result will be provided to the
- callback.
+ • {bufnr} (integer) Buffer handle, or 0 for current.
+ • {method} (string) LSP method name
+ • {params} (table|nil) Parameters to send to the server
+ • {handler} (function) Handler called after all requests are completed.
+ Server results are passed as a `client_id:result` map.
Return: ~
- fun() cancel A function that will cancel all requests
+ fun() cancel Function that cancels all requests.
*vim.lsp.buf_request_sync()*
buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
Sends a request to all server and waits for the response of all of them.
Calls |vim.lsp.buf_request_all()| but blocks Nvim while awaiting the
- result. Parameters are the same as |vim.lsp.buf_request()| but the return
- result is different. Wait maximum of {timeout_ms} (default 1000) ms.
+ result. Parameters are the same as |vim.lsp.buf_request_all()| but the
+ result is different. Waits a maximum of {timeout_ms} (default 1000) ms.
Parameters: ~
• {bufnr} (integer) Buffer handle, or 0 for current.
@@ -1316,6 +1298,13 @@ incoming_calls() *vim.lsp.buf.incoming_calls()*
window. If the symbol can resolve to multiple items, the user can pick one
in the |inputlist()|.
+inlay_hint({bufnr}, {enable}) *vim.lsp.buf.inlay_hint()*
+ Enable/disable/toggle inlay hints for a buffer
+
+ Parameters: ~
+ • {bufnr} (integer) Buffer handle, or 0 for current
+ • {enable} (boolean|nil) true/false to enable/disable, nil to toggle
+
list_workspace_folders() *vim.lsp.buf.list_workspace_folders()*
List workspace folders.
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 737aa91e97..1110fb7fc3 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1002,10 +1002,18 @@ Log levels are one of the values defined in `vim.log.levels`:
------------------------------------------------------------------------------
LUA-VIMSCRIPT BRIDGE *lua-vimscript*
-Nvim Lua provides an interface to Vimscript variables and functions, and
-editor commands and options.
+Nvim Lua provides an interface or "bridge" to Vimscript variables and
+functions, and editor commands and options.
+
+Objects passed over this bridge are COPIED (marshalled): there are no
+"references". |lua-guide-variables| For example, using `vim.fn.remove()` on
+a Lua list copies the list object to Vimscript and does NOT modify the Lua
+list: >lua
+
+ local list = { 1, 2, 3 }
+ vim.fn.remove(list, 0)
+ vim.print(list) --> "{ 1, 2, 3 }"
-See also https://github.com/nanotee/nvim-lua-guide.
vim.call({func}, {...}) *vim.call()*
Invokes |vim-function| or |user-function| {func} with arguments {...}.
@@ -2970,8 +2978,9 @@ range({spec}) *vim.version.range()*
Lua module: iter *lua-iter*
-The *vim.iter* module provides a generic "iterator" interface over tables
-and iterator functions.
+The *vim.iter* module provides a generic interface for working with
+iterables: tables, lists, iterator functions, pair()/ipair()-like
+iterators, and `vim.iter()` objects.
*vim.iter()* wraps its table or function argument into an *Iter* object
with methods (such as |Iter:filter()| and |Iter:map()|) that transform the
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 25ab91b89e..ffd7b6bc1d 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -1546,6 +1546,7 @@ supports incremental command preview:
-- If invoked as a preview callback, performs 'inccommand' preview by
-- highlighting trailing whitespace in the current buffer.
local function trim_space_preview(opts, preview_ns, preview_buf)
+ vim.cmd('hi clear Whitespace')
local line1 = opts.line1
local line2 = opts.line2
local buf = vim.api.nvim_get_current_buf()
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index f2a878078d..2a25edc4eb 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -44,9 +44,13 @@ The following changes may require adaptations in user config or plugins.
• Renamed `vim.treesitter.playground` to `vim.treesitter.dev`.
==============================================================================
-ADDED FEATURES *news-added*
+NEW FEATURES *news-features*
-The following new APIs or features were added.
+The following new APIs and features were added.
+
+• Performance:
+ • 'diffopt' "linematch" scoring algorithm now favours larger and less groups
+ https://github.com/neovim/neovim/pull/23611
• Added |vim.lsp.status()| to consume the last progress messages as a string.
@@ -89,8 +93,9 @@ The following new APIs or features were added.
• |nvim_set_keymap()| and |nvim_del_keymap()| now support abbreviations.
-• Added |lsp-handler| for inlay hints: `textDocument/inlayHint` and
- `workspace/inlayHint/refresh`
+• Implemented LSP inlay hints: |vim.lsp.buf.inlay_hint()|
+ https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint
+
==============================================================================
CHANGED FEATURES *news-changed*
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 0f53288608..78d38095a8 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -2088,17 +2088,13 @@ A jump table for the options with a short description can be found at |Q_op|.
:set dir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces
< - For backwards compatibility with Vim version 3.0 a '>' at the start
of the option is removed.
- Using "." first in the list is recommended. This means that editing
- the same file twice will result in a warning. Using "/tmp" on Unix is
- discouraged: When the system crashes you lose the swap file.
- "/var/tmp" is often not cleared when rebooting, thus is a better
- choice than "/tmp". But others on the computer may be able to see the
- files, and it can contain a lot of files, your swap files get lost in
- the crowd. That is why a "tmp" directory in your home directory is
- tried first.
- The use of |:set+=| and |:set-=| is preferred when adding or removing
- directories from the list. This avoids problems when a future version
- uses another default.
+
+ Editing the same file twice will result in a warning. Using "/tmp" on
+ is discouraged: if the system crashes you lose the swap file. And
+ others on the computer may be able to see the files.
+ Use |:set+=| and |:set-=| when adding or removing directories from the
+ list, this avoids problems if the Nvim default is changed.
+
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index 625e1f95e1..8437496011 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -1298,7 +1298,6 @@ will probably never match.
When "\Z" appears anywhere in the pattern, all composing characters are
ignored. Thus only the base characters need to match, the composing
characters may be different and the number of composing characters may differ.
-Only relevant when 'encoding' is "utf-8".
Exception: If the pattern starts with one or more composing characters, these
must match.
*/\%C*
diff --git a/runtime/doc/russian.txt b/runtime/doc/russian.txt
index 8d3ed360c8..89be1a3c5a 100644
--- a/runtime/doc/russian.txt
+++ b/runtime/doc/russian.txt
@@ -34,7 +34,6 @@ enter Normal mode command, you can also set 'langmap' option:
:set langmap=ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,
фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz
-This is in utf-8, you cannot read this if your 'encoding' is not utf-8.
You have to type this command in one line, it is wrapped for the sake of
readability.
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 2c7b7ed61b..51cbf4c93d 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -1384,20 +1384,23 @@ STATE DIRECTORY (DEFAULT) ~
Unix: ~/.local/state ~/.local/state/nvim
Windows: ~/AppData/Local ~/AppData/Local/nvim-data
-Note: Throughout the user manual these defaults are used as placeholders, e.g.
+Note: Throughout the help pages these defaults are used as placeholders, e.g.
"~/.config" is understood to mean "$XDG_CONFIG_HOME or ~/.config".
NVIM_APPNAME *$NVIM_APPNAME*
-The XDG directories used by Nvim can be further configured by setting the
-`$NVIM_APPNAME` environment variable. This variable controls the directory
-Neovim will look for (and auto-create) in the various XDG parent directories.
-For example, setting `$NVIM_APPNAME` to "neovim" before running Neovim will
-result in Neovim looking for configuration files in `$XDG_CONFIG_HOME/neovim`
-instead of `$XDG_CONFIG_HOME/nvim`.
-
-Note: Similarly to the $XDG environment variables, when
-`$XDG_CONFIG_HOME/nvim` is mentioned, it should be understood as
-`$XDG_CONFIG_HOME/$NVIM_APPNAME`.
+The standard directories can be further configured by the `$NVIM_APPNAME`
+environment variable. This variable controls the sub-directory that Nvim will
+read from (and auto-create) in each of the base directories. For example,
+setting `$NVIM_APPNAME` to "foo" before starting will cause Nvim to look for
+configuration files in `$XDG_CONFIG_HOME/foo` instead of
+`$XDG_CONFIG_HOME/nvim`.
+
+One use-case for $NVIM_APPNAME is to "isolate" Nvim applications.
+Alternatively, for true isolation, on Linux you can use cgroups namespaces: >
+ systemd-run --user -qt -p PrivateUsers=yes -p BindPaths=/home/user/profile_xy:/home/user/.config/nvim nvim
+
+Note: Throughout the help pages, wherever `$XDG_CONFIG_…/nvim` is mentioned it
+is understood to mean `$XDG_CONFIG_…/$NVIM_APPNAME`.
LOG FILE *log* *$NVIM_LOG_FILE* *E5430*
Besides 'debug' and 'verbose', Nvim keeps a general log file for internal
diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt
index c64c450aa1..1391ef2808 100644
--- a/runtime/doc/ui.txt
+++ b/runtime/doc/ui.txt
@@ -199,7 +199,7 @@ the editor.
The following keys are deprecated:
`hl_id`: Use `attr_id` instead.
- `hl_lm`: Use `attr_id_lm` instead.
+ `id_lm`: Use `attr_id_lm` instead.
["option_set", name, value] ~
UI-related option changed, where `name` is one of:
diff --git a/runtime/doc/usr_11.txt b/runtime/doc/usr_11.txt
index 361fe51caa..1fa7fb6f77 100644
--- a/runtime/doc/usr_11.txt
+++ b/runtime/doc/usr_11.txt
@@ -82,9 +82,8 @@ You must be in the right directory, otherwise Vim can't find the swap file.
==============================================================================
*11.2* Where is the swap file?
-Vim can store the swap file in several places. Normally it is in the same
-directory as the original file. To find it, change to the directory of the
-file, and use: >
+Vim can store the swap file in several places. To find it, change to the
+directory of the file, and use: >
vim -r
diff --git a/runtime/doc/usr_45.txt b/runtime/doc/usr_45.txt
index 95a2bc8f79..85710b15d5 100644
--- a/runtime/doc/usr_45.txt
+++ b/runtime/doc/usr_45.txt
@@ -190,8 +190,7 @@ font. Example: >
xterm -u8 -fn -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1
-Now you can run Vim inside this terminal. Set 'encoding' to "utf-8" as
-before. That's all.
+Now you can run Vim inside this terminal.
USING UNICODE IN AN ORDINARY TERMINAL
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 7b0e724e31..4e2ee14537 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -88,13 +88,10 @@ g8 Print the hex values of the bytes used in the
*8g8*
8g8 Find an illegal UTF-8 byte sequence at or after the
- cursor. This works in two situations:
- 1. when 'encoding' is any 8-bit encoding
- 2. when 'encoding' is "utf-8" and 'fileencoding' is
- any 8-bit encoding
- Thus it can be used when editing a file that was
- supposed to be UTF-8 but was read as if it is an 8-bit
- encoding because it contains illegal bytes.
+ cursor.
+ Can be used when editing a file that was supposed to
+ be UTF-8 but was read as if it is an 8-bit encoding
+ because it contains illegal bytes.
Does not wrap around the end of the file.
Note that when the cursor is on an illegal byte or the
cursor is halfway through a multibyte character the
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index ab1b2056a2..ff3e19689b 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -15,6 +15,9 @@ centralized reference of the differences.
==============================================================================
Configuration *nvim-config*
+User configuration and data files are found in standard |base-directories|
+(see also |$NVIM_APPNAME|). Note in particular:
+
- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for your |config|.
- Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files.
- Use `$XDG_STATE_HOME/nvim/shada/main.shada` instead of `.viminfo` for persistent
@@ -29,7 +32,7 @@ Defaults *nvim-defaults*
":syntax off" to |init.vim|.
- 'autoindent' is enabled
-- 'autoread' is enabled
+- 'autoread' is enabled (works in all UIs, including terminal)
- 'background' defaults to "dark" (unless set automatically by the terminal/UI)
- 'backspace' defaults to "indent,eol,start"
- 'backupdir' defaults to .,~/.local/state/nvim/backup// (|xdg|), auto-created
@@ -195,7 +198,7 @@ server.
External plugins run in separate processes. |remote-plugin| This improves
stability and allows those plugins to work without blocking the editor. Even
"legacy" Python and Ruby plugins which use the old Vim interfaces (|if_pyth|,
-|if_ruby|) run out-of-process.
+|if_ruby|) run out-of-process, so they cannot crash Nvim.
Platform and I/O facilities are built upon libuv. Nvim benefits from libuv
features and bug fixes, and other projects benefit from improvements to libuv
@@ -273,6 +276,7 @@ Normal commands:
|Q| replays the last recorded macro instead of switching to Ex mode (|gQ|).
Options:
+ 'autoread' works in the terminal (if it supports "focus" events)
'cpoptions' flags: |cpo-_|
'diffopt' "linematch" feature
'exrc' searches for ".nvim.lua", ".nvimrc", or ".exrc" files. The
@@ -293,7 +297,6 @@ Options:
'shortmess' "F" flag does not affect output from autocommands
'signcolumn' supports up to 9 dynamic/fixed columns
'statuscolumn' full control of columns using 'statusline' format
- 'statusline' supports unlimited alignment sections
'tabline' %@Func@foo%X can call any function on mouse-click
'ttimeout', 'ttimeoutlen' behavior was simplified
'winblend' pseudo-transparency in floating windows |api-floatwin|
@@ -382,9 +385,9 @@ These Nvim features were later integrated into Vim.
- 'statusline' supports unlimited alignment sections
==============================================================================
-Changed features *nvim-changed*
+Other changes *nvim-changed*
-This section lists various low-level details about other behavior changes.
+This section documents various low-level behavior changes.
|mkdir()| behaviour changed:
1. Assuming /tmp/foo does not exist and /tmp can be written to
@@ -399,21 +402,21 @@ This section lists various low-level details about other behavior changes.
structures.
2. |string()| fails immediately on nested containers, not when recursion limit
was exceeded.
-2. When |:echo| encounters duplicate containers like >vim
+3. When |:echo| encounters duplicate containers like >vim
let l = []
echo [l, l]
<
it does not use "[...]" (was: "[[], [...]]", now: "[[], []]"). "..." is
only used for recursive containers.
-3. |:echo| printing nested containers adds "@level" after "..." designating
+4. |:echo| printing nested containers adds "@level" after "..." designating
the level at which recursive container was printed: |:echo-self-refer|.
Same thing applies to |string()| (though it uses construct like
"{E724@level}"), but this is not reliable because |string()| continues to
error out.
-4. Stringifyed infinite and NaN values now use |str2float()| and can be evaled
+5. Stringifyed infinite and NaN values now use |str2float()| and can be evaled
back.
-5. (internal) Trying to print or stringify VAR_UNKNOWN in Vim results in
+6. (internal) Trying to print or stringify VAR_UNKNOWN in Vim results in
nothing, E908, in Nvim it is internal error.
|json_decode()| behaviour changed:
@@ -634,7 +637,10 @@ Options:
'highlight' (Names of builtin |highlight-groups| cannot be changed.)
*'hkmap'* *'hk'* use `set keymap=hebrew` instead.
*'hkmapp'* *'hkp'* use `set keymap=hebrewp` instead.
- *'pastetoggle'* *'pt'*
+
+ *'pastetoggle'* *'pt'* Just Paste It.™ |paste| is handled automatically when
+ you paste text using your terminal's or GUI's paste feature (CTRL-SHIFT-v,
+ CMD-v (macOS), middle-click, …).
*'imactivatefunc'* *'imaf'*
*'imactivatekey'* *'imak'*
@@ -705,6 +711,11 @@ Options:
Performance:
Folds are not updated during insert-mode.
+Plugins:
+
+- logiPat
+- rrhelper
+
Providers:
- *if_lua* : Nvim |Lua| API is not compatible with Vim's "if_lua".
@@ -762,7 +773,8 @@ TUI:
Cscope:
*cscope*
- Cscope support has been removed in favour of plugin-based solutions.
+ Cscope support was removed in favour of plugin-based solutions such as:
+ https://github.com/dhananjaylatkar/cscope_maps.nvim
Hardcopy:
*hardcopy*
diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua
index c89147dbd2..cdb314fa3d 100644
--- a/runtime/lua/vim/fs.lua
+++ b/runtime/lua/vim/fs.lua
@@ -348,9 +348,7 @@ function M.normalize(path, opts)
path = path:gsub('%$([%w_]+)', vim.uv.os_getenv)
end
- path = path:gsub('\\', '/'):gsub('/+', '/')
-
- return path:sub(-1) == '/' and path:sub(1, -2) or path
+ return (path:gsub('\\', '/'):gsub('/+', '/'):gsub('(.)/$', '%1'))
end
return M
diff --git a/runtime/lua/vim/iter.lua b/runtime/lua/vim/iter.lua
index 204d22b9be..9c7bd13164 100644
--- a/runtime/lua/vim/iter.lua
+++ b/runtime/lua/vim/iter.lua
@@ -1,7 +1,8 @@
---@defgroup lua-iter
---
---- The \*vim.iter\* module provides a generic "iterator" interface over tables
---- and iterator functions.
+--- @brief The \*vim.iter\* module provides a generic interface for working with
+--- iterables: tables, lists, iterator functions, pair()/ipair()-like iterators,
+--- and \`vim.iter()\` objects.
---
--- \*vim.iter()\* wraps its table or function argument into an \*Iter\* object
--- with methods (such as |Iter:filter()| and |Iter:map()|) that transform the
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 9118e7e2e1..25e69a8006 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -17,7 +17,6 @@ local if_nil = vim.F.if_nil
local lsp = {
protocol = protocol,
- _inlay_hint = require('vim.lsp._inlay_hint'),
handlers = default_handlers,
@@ -1491,7 +1490,7 @@ function lsp.start_client(config)
---successful, then it will return {request_id} as the
---second result. You can use this with `client.cancel_request(request_id)`
---to cancel the-request.
- ---@see |vim.lsp.buf_request()|
+ ---@see |vim.lsp.buf_request_all()|
function client.request(method, params, handler, bufnr)
if not handler then
handler = assert(
@@ -1655,6 +1654,46 @@ function lsp.start_client(config)
end
---@private
+ --- Execute a lsp command, either via client command function (if available)
+ --- or via workspace/executeCommand (if supported by the server)
+ ---
+ ---@param command lsp.Command
+ ---@param context? {bufnr: integer}
+ ---@param handler? lsp-handler only called if a server command
+ function client._exec_cmd(command, context, handler)
+ context = vim.deepcopy(context or {})
+ context.bufnr = context.bufnr or api.nvim_get_current_buf()
+ context.client_id = client.id
+ local cmdname = command.command
+ local fn = client.commands[cmdname] or lsp.commands[cmdname]
+ if fn then
+ fn(command, context)
+ return
+ end
+
+ local command_provider = client.server_capabilities.executeCommandProvider
+ local commands = type(command_provider) == 'table' and command_provider.commands or {}
+ if not vim.list_contains(commands, cmdname) then
+ vim.notify_once(
+ string.format(
+ 'Language server `%s` does not support command `%s`. This command may require a client extension.',
+ client.name,
+ cmdname
+ ),
+ vim.log.levels.WARN
+ )
+ return
+ end
+ -- Not using command directly to exclude extra properties,
+ -- see https://github.com/python-lsp/python-lsp-server/issues/146
+ local params = {
+ command = command.command,
+ arguments = command.arguments,
+ }
+ client.request('workspace/executeCommand', params, handler, context.bufnr)
+ end
+
+ ---@private
--- Runs the on_attach function from the client's config if it was defined.
---@param bufnr integer Buffer number
function client._on_attach(bufnr)
@@ -2119,22 +2158,19 @@ function lsp.buf_request(bufnr, method, params, handler)
return client_request_ids, _cancel_all_requests
end
----Sends an async request for all active clients attached to the buffer.
----Executes the callback on the combined result.
----Parameters are the same as |vim.lsp.buf_request()| but the return result and callback are
----different.
+--- Sends an async request for all active clients attached to the buffer and executes the `handler`
+--- callback with the combined result.
---
---@param bufnr (integer) Buffer handle, or 0 for current.
---@param method (string) LSP method name
---@param params (table|nil) Parameters to send to the server
----@param callback fun(request_results: table<integer, {error: lsp.ResponseError, result: any}>) (function)
---- The callback to call when all requests are finished.
---- Unlike `buf_request`, this will collect all the responses from each server instead of handling them.
---- A map of client_id:request_result will be provided to the callback.
----
----@return fun() cancel A function that will cancel all requests
-function lsp.buf_request_all(bufnr, method, params, callback)
- local request_results = {}
+---@param handler fun(results: table<integer, {error: lsp.ResponseError, result: any}>) (function)
+--- Handler called after all requests are completed. Server results are passed as
+--- a `client_id:result` map.
+---
+---@return fun() cancel Function that cancels all requests.
+function lsp.buf_request_all(bufnr, method, params, handler)
+ local results = {}
local result_count = 0
local expected_result_count = 0
@@ -2147,12 +2183,12 @@ function lsp.buf_request_all(bufnr, method, params, callback)
end)
local function _sync_handler(err, result, ctx)
- request_results[ctx.client_id] = { error = err, result = result }
+ results[ctx.client_id] = { error = err, result = result }
result_count = result_count + 1
set_expected_result_count()
if result_count >= expected_result_count then
- callback(request_results)
+ handler(results)
end
end
@@ -2164,8 +2200,8 @@ end
--- Sends a request to all server and waits for the response of all of them.
---
--- Calls |vim.lsp.buf_request_all()| but blocks Nvim while awaiting the result.
---- Parameters are the same as |vim.lsp.buf_request()| but the return result is
---- different. Wait maximum of {timeout_ms} (default 1000) ms.
+--- Parameters are the same as |vim.lsp.buf_request_all()| but the result is
+--- different. Waits a maximum of {timeout_ms} (default 1000) ms.
---
---@param bufnr (integer) Buffer handle, or 0 for current.
---@param method (string) LSP method name
diff --git a/runtime/lua/vim/lsp/_inlay_hint.lua b/runtime/lua/vim/lsp/_inlay_hint.lua
index aa6ec9aca8..e7cc8ba7ae 100644
--- a/runtime/lua/vim/lsp/_inlay_hint.lua
+++ b/runtime/lua/vim/lsp/_inlay_hint.lua
@@ -6,22 +6,30 @@ local M = {}
---@class lsp._inlay_hint.bufstate
---@field version integer
---@field client_hint table<integer, table<integer, lsp.InlayHint[]>> client_id -> (lnum -> hints)
+---@field enabled boolean Whether inlay hints are enabled for the buffer
+---@field timer uv.uv_timer_t? Debounce timer associated with the buffer
---@type table<integer, lsp._inlay_hint.bufstate>
-local hint_cache_by_buf = setmetatable({}, {
- __index = function(t, b)
- local key = b > 0 and b or api.nvim_get_current_buf()
- return rawget(t, key)
- end,
-})
+local bufstates = {}
local namespace = api.nvim_create_namespace('vim_lsp_inlayhint')
+local augroup = api.nvim_create_augroup('vim_lsp_inlayhint', {})
-M.__explicit_buffers = {}
+--- Reset the request debounce timer of a buffer
+---@private
+local function reset_timer(reset_bufnr)
+ local timer = bufstates[reset_bufnr].timer
+ if timer then
+ bufstates[reset_bufnr].timer = nil
+ if not timer:is_closing() then
+ timer:stop()
+ timer:close()
+ end
+ end
+end
--- |lsp-handler| for the method `textDocument/inlayHint`
--- Store hints for a specific buffer and client
---- Resolves unresolved hints
---@private
function M.on_inlayhint(err, result, ctx, _)
if err then
@@ -36,23 +44,10 @@ function M.on_inlayhint(err, result, ctx, _)
if not result then
return
end
- local bufstate = hint_cache_by_buf[bufnr]
- if not bufstate then
- bufstate = {
- client_hint = vim.defaulttable(),
- version = ctx.version,
- }
- hint_cache_by_buf[bufnr] = bufstate
- api.nvim_buf_attach(bufnr, false, {
- on_detach = function(_, b)
- api.nvim_buf_clear_namespace(b, namespace, 0, -1)
- hint_cache_by_buf[b] = nil
- end,
- on_reload = function(_, b)
- api.nvim_buf_clear_namespace(b, namespace, 0, -1)
- hint_cache_by_buf[b] = nil
- end,
- })
+ local bufstate = bufstates[bufnr]
+ if not (bufstate.client_hint and bufstate.version) then
+ bufstate.client_hint = vim.defaulttable()
+ bufstate.version = ctx.version
end
local hints_by_client = bufstate.client_hint
local client = vim.lsp.get_client_by_id(client_id)
@@ -95,28 +90,24 @@ end
---@private
local function resolve_bufnr(bufnr)
- return bufnr == 0 and api.nvim_get_current_buf() or bufnr
+ return bufnr > 0 and bufnr or api.nvim_get_current_buf()
end
--- Refresh inlay hints for a buffer
---
---- It is recommended to trigger this using an autocmd or via keymap.
---@param opts (nil|table) Optional arguments
--- - bufnr (integer, default: 0): Buffer whose hints to refresh
--- - only_visible (boolean, default: false): Whether to only refresh hints for the visible regions of the buffer
---
---- Example:
---- <pre>vim
---- autocmd BufEnter,InsertLeave,BufWritePost <buffer> lua vim.lsp._inlay_hint.refresh()
---- </pre>
----
---@private
function M.refresh(opts)
opts = opts or {}
- local bufnr = opts.bufnr or 0
+ local bufnr = resolve_bufnr(opts.bufnr or 0)
+ local bufstate = bufstates[bufnr]
+ if not (bufstate and bufstate.enabled) then
+ return
+ end
local only_visible = opts.only_visible or false
- bufnr = resolve_bufnr(bufnr)
- M.__explicit_buffers[bufnr] = true
local buffer_windows = {}
for _, winid in ipairs(api.nvim_list_wins()) do
if api.nvim_win_get_buf(winid) == bufnr then
@@ -148,30 +139,97 @@ function M.refresh(opts)
end
--- Clear inlay hints
----
----@param client_id integer|nil filter by client_id. All clients if nil
----@param bufnr integer|nil filter by buffer. All buffers if nil
+---@param bufnr (integer) Buffer handle, or 0 for current
---@private
-function M.clear(client_id, bufnr)
- local buffers = bufnr and { resolve_bufnr(bufnr) } or vim.tbl_keys(hint_cache_by_buf)
- for _, iter_bufnr in ipairs(buffers) do
- M.__explicit_buffers[iter_bufnr] = false
- local bufstate = hint_cache_by_buf[iter_bufnr]
- local client_lens = (bufstate or {}).client_hint or {}
- local client_ids = client_id and { client_id } or vim.tbl_keys(client_lens)
- for _, iter_client_id in ipairs(client_ids) do
- if bufstate then
- bufstate.client_hint[iter_client_id] = {}
- end
+local function clear(bufnr)
+ bufnr = resolve_bufnr(bufnr)
+ reset_timer(bufnr)
+ local bufstate = bufstates[bufnr]
+ local client_lens = (bufstate or {}).client_hint or {}
+ local client_ids = vim.tbl_keys(client_lens)
+ for _, iter_client_id in ipairs(client_ids) do
+ if bufstate then
+ bufstate.client_hint[iter_client_id] = {}
end
- api.nvim_buf_clear_namespace(iter_bufnr, namespace, 0, -1)
end
- vim.cmd('redraw!')
+ api.nvim_buf_clear_namespace(bufnr, namespace, 0, -1)
+ api.nvim__buf_redraw_range(bufnr, 0, -1)
+end
+
+---@private
+local function make_request(request_bufnr)
+ reset_timer(request_bufnr)
+ M.refresh({ bufnr = request_bufnr })
+end
+
+--- Enable inlay hints for a buffer
+---@param bufnr (integer) Buffer handle, or 0 for current
+---@private
+function M.enable(bufnr)
+ bufnr = resolve_bufnr(bufnr)
+ local bufstate = bufstates[bufnr]
+ if not (bufstate and bufstate.enabled) then
+ bufstates[bufnr] = { enabled = true, timer = nil }
+ M.refresh({ bufnr = bufnr })
+ api.nvim_buf_attach(bufnr, true, {
+ on_lines = function(_, cb_bufnr)
+ if not bufstates[cb_bufnr].enabled then
+ return true
+ end
+ reset_timer(cb_bufnr)
+ bufstates[cb_bufnr].timer = vim.defer_fn(function()
+ make_request(cb_bufnr)
+ end, 200)
+ end,
+ on_reload = function(_, cb_bufnr)
+ clear(cb_bufnr)
+ bufstates[cb_bufnr] = nil
+ M.refresh({ bufnr = cb_bufnr })
+ end,
+ on_detach = function(_, cb_bufnr)
+ clear(cb_bufnr)
+ bufstates[cb_bufnr] = nil
+ end,
+ })
+ api.nvim_create_autocmd('LspDetach', {
+ buffer = bufnr,
+ callback = function(opts)
+ clear(opts.buf)
+ end,
+ once = true,
+ group = augroup,
+ })
+ end
+end
+
+--- Disable inlay hints for a buffer
+---@param bufnr (integer) Buffer handle, or 0 for current
+---@private
+function M.disable(bufnr)
+ bufnr = resolve_bufnr(bufnr)
+ if bufstates[bufnr] and bufstates[bufnr].enabled then
+ clear(bufnr)
+ bufstates[bufnr].enabled = nil
+ bufstates[bufnr].timer = nil
+ end
+end
+
+--- Toggle inlay hints for a buffer
+---@param bufnr (integer) Buffer handle, or 0 for current
+---@private
+function M.toggle(bufnr)
+ bufnr = resolve_bufnr(bufnr)
+ local bufstate = bufstates[bufnr]
+ if bufstate and bufstate.enabled then
+ M.disable(bufnr)
+ else
+ M.enable(bufnr)
+ end
end
api.nvim_set_decoration_provider(namespace, {
on_win = function(_, _, bufnr, topline, botline)
- local bufstate = hint_cache_by_buf[bufnr]
+ local bufstate = bufstates[bufnr]
if not bufstate then
return
end
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index e0034cf86e..45056cf272 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -646,21 +646,7 @@ local function on_code_action_results(results, ctx, options)
end
if action.command then
local command = type(action.command) == 'table' and action.command or action
- local fn = client.commands[command.command] or vim.lsp.commands[command.command]
- if fn then
- local enriched_ctx = vim.deepcopy(ctx)
- enriched_ctx.client_id = client.id
- fn(command, enriched_ctx)
- else
- -- Not using command directly to exclude extra properties,
- -- see https://github.com/python-lsp/python-lsp-server/issues/146
- local params = {
- command = command.command,
- arguments = command.arguments,
- workDoneToken = command.workDoneToken,
- }
- client.request('workspace/executeCommand', params, nil, ctx.bufnr)
- end
+ client._exec_cmd(command, ctx)
end
end
@@ -697,7 +683,7 @@ local function on_code_action_results(results, ctx, options)
return
end
apply_action(resolved_action, client)
- end)
+ end, ctx.bufnr)
else
apply_action(action, client)
end
@@ -810,4 +796,19 @@ function M.execute_command(command_params)
request('workspace/executeCommand', command_params)
end
+--- Enable/disable/toggle inlay hints for a buffer
+---@param bufnr (integer) Buffer handle, or 0 for current
+---@param enable (boolean|nil) true/false to enable/disable, nil to toggle
+function M.inlay_hint(bufnr, enable)
+ vim.validate({ enable = { enable, { 'boolean', 'nil' } }, bufnr = { bufnr, 'number' } })
+ local inlay_hint = require('vim.lsp._inlay_hint')
+ if enable then
+ inlay_hint.enable(bufnr)
+ elseif enable == false then
+ inlay_hint.disable(bufnr)
+ else
+ inlay_hint.toggle(bufnr)
+ end
+end
+
return M
diff --git a/runtime/lua/vim/lsp/codelens.lua b/runtime/lua/vim/lsp/codelens.lua
index e26bdcc6d4..5acfe90d5e 100644
--- a/runtime/lua/vim/lsp/codelens.lua
+++ b/runtime/lua/vim/lsp/codelens.lua
@@ -33,30 +33,12 @@ local function execute_lens(lens, bufnr, client_id)
local client = vim.lsp.get_client_by_id(client_id)
assert(client, 'Client is required to execute lens, client_id=' .. client_id)
- local command = lens.command
- local fn = client.commands[command.command] or vim.lsp.commands[command.command]
- if fn then
- fn(command, { bufnr = bufnr, client_id = client_id })
- return
- end
- -- Need to use the client that returned the lens → must not use buf_request
- local command_provider = client.server_capabilities.executeCommandProvider
- local commands = type(command_provider) == 'table' and command_provider.commands or {}
- if not vim.list_contains(commands, command.command) then
- vim.notify(
- string.format(
- 'Language server does not support command `%s`. This command may require a client extension.',
- command.command
- ),
- vim.log.levels.WARN
- )
- return
- end
- client.request('workspace/executeCommand', command, function(...)
+
+ client._exec_cmd(lens.command, { bufnr = bufnr }, function(...)
local result = vim.lsp.handlers['workspace/executeCommand'](...)
M.refresh()
return result
- end, bufnr)
+ end)
end
--- Return all lenses for the given buffer
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 44a9a58aca..284e3ef2d0 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -619,9 +619,6 @@ end
---@see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_inlayHint_refresh
M['workspace/inlayHint/refresh'] = function(err, _, ctx)
local inlay_hint = require('vim.lsp._inlay_hint')
- if not inlay_hint.__explicit_buffers[ctx.bufnr] then
- return vim.NIL
- end
if err then
return vim.NIL
end
diff --git a/runtime/lua/vim/lsp/types.lua b/runtime/lua/vim/lsp/types.lua
index 108aeeb922..cdfbcfb11b 100644
--- a/runtime/lua/vim/lsp/types.lua
+++ b/runtime/lua/vim/lsp/types.lua
@@ -1,6 +1,6 @@
---@meta
----@alias lsp-handler fun(err: lsp.ResponseError|nil, result: any, context: lsp.HandlerContext, config: table|nil)
+---@alias lsp-handler fun(err: lsp.ResponseError|nil, result: any, context: lsp.HandlerContext, config: table|nil): any?
---@class lsp.HandlerContext
---@field method string
diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua
index 4bb764c5c6..d4db6bc404 100644
--- a/runtime/lua/vim/treesitter/highlighter.lua
+++ b/runtime/lua/vim/treesitter/highlighter.lua
@@ -260,12 +260,14 @@ local function on_line_impl(self, buf, line, is_spell_nav)
local spell_pri_offset = capture_name == 'nospell' and 1 or 0
if hl and end_row >= line and (not is_spell_nav or spell ~= nil) then
+ local priority = (tonumber(metadata.priority) or vim.highlight.priorities.treesitter)
+ + spell_pri_offset
api.nvim_buf_set_extmark(buf, ns, start_row, start_col, {
end_line = end_row,
end_col = end_col,
hl_group = hl,
ephemeral = true,
- priority = (tonumber(metadata.priority) or 100) + spell_pri_offset, -- Low but leaves room below
+ priority = priority,
conceal = metadata.conceal,
spell = spell,
})
diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua
index 7bc48a0662..6cdf028f5c 100644
--- a/scripts/gen_help_html.lua
+++ b/scripts/gen_help_html.lua
@@ -62,7 +62,6 @@ local exclude_invalid = {
["'string'"] = "eval.txt",
Query = 'treesitter.txt',
['eq?'] = 'treesitter.txt',
- ['lsp-request'] = 'lsp.txt',
matchit = 'vim_diff.txt',
['matchit.txt'] = 'help.txt',
["set!"] = "treesitter.txt",
@@ -70,7 +69,6 @@ local exclude_invalid = {
['v:_null_dict'] = 'builtin.txt',
['v:_null_list'] = 'builtin.txt',
['v:_null_string'] = 'builtin.txt',
- ['vim.lsp.buf_request()'] = 'lsp.txt',
['vim.lsp.util.get_progress_messages()'] = 'lsp.txt',
}
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py
index 2d4c8b2234..b40f8526ea 100755
--- a/scripts/gen_vimdoc.py
+++ b/scripts/gen_vimdoc.py
@@ -223,7 +223,6 @@ CONFIG = {
'log.lua',
'rpc.lua',
'protocol.lua',
- 'inlay_hint.lua'
],
'files': [
'runtime/lua/vim/lsp',
diff --git a/src/man/nvim.1 b/src/man/nvim.1
index c32bdeadc6..b846ed4ba6 100644
--- a/src/man/nvim.1
+++ b/src/man/nvim.1
@@ -193,7 +193,7 @@ is
do not read or write a ShaDa file.
.Ic ":help shada"
.It Fl -noplugin
-Skip loading plugins.
+Skip loading plugins (by setting the 'noloadplugins' option).
Implied by
.Cm -u NONE .
.It Fl -clean
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 368bb866d7..a6f98a1915 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -487,7 +487,7 @@ Integer nvim_strwidth(String text, Error *err)
return (Integer)mb_string2cells(text.data);
}
-/// Gets the paths contained in 'runtimepath'.
+/// Gets the paths contained in |runtime-search-path|.
///
/// @return List of paths
ArrayOf(String) nvim_list_runtime_paths(Error *err)
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index c021fec220..97bf0f377a 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -57,6 +57,8 @@ void nvim_win_set_buf(Window window, Buffer buffer, Error *err)
/// (different windows showing the same buffer have independent cursor
/// positions). |api-indexing|
///
+/// @see |getcurpos()|
+///
/// @param window Window handle, or 0 for current window
/// @param[out] err Error details, if any
/// @return (row, col) tuple
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 475415272a..e22bb609b6 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -990,7 +990,8 @@ retry:
}
} else {
// Read bytes from the file.
- size = read_eintr(fd, ptr, (size_t)size);
+ size_t read_size = (size_t)size;
+ size = read_eintr(fd, ptr, read_size);
}
if (size <= 0) {
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 6ab7391b05..83e56c3066 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -2185,43 +2185,33 @@ static void usage(void)
signal_stop(); // kill us with CTRL-C here, if you like
os_msg(_("Usage:\n"));
- os_msg(_(" nvim [options] [file ...] Edit file(s)\n"));
- os_msg(_(" nvim [options] -t <tag> Edit file where tag is defined\n"));
- os_msg(_(" nvim [options] -q [errorfile] Edit file with first error\n"));
+ os_msg(_(" nvim [options] [file ...]\n"));
os_msg(_("\nOptions:\n"));
- os_msg(_(" -- Only file names after this\n"));
- os_msg(_(" + Start at end of file\n"));
os_msg(_(" --cmd <cmd> Execute <cmd> before any config\n"));
os_msg(_(" +<cmd>, -c <cmd> Execute <cmd> after config and first file\n"));
os_msg(_(" -l <script> [args...] Execute Lua <script> (with optional args)\n"));
+ os_msg(_(" -S <session> Source <session> after loading the first file\n"));
+ os_msg(_(" -s <scriptin> Read Normal mode commands from <scriptin>\n"));
+ os_msg(_(" -u <config> Use this config file\n"));
os_msg("\n");
- os_msg(_(" -b Binary mode\n"));
os_msg(_(" -d Diff mode\n"));
- os_msg(_(" -e, -E Ex mode\n"));
os_msg(_(" -es, -Es Silent (batch) mode\n"));
os_msg(_(" -h, --help Print this help message\n"));
os_msg(_(" -i <shada> Use this shada file\n"));
- os_msg(_(" -m Modifications (writing files) not allowed\n"));
- os_msg(_(" -M Modifications in text not allowed\n"));
os_msg(_(" -n No swap file, use memory only\n"));
os_msg(_(" -o[N] Open N windows (default: one per file)\n"));
os_msg(_(" -O[N] Open N vertical windows (default: one per file)\n"));
os_msg(_(" -p[N] Open N tab pages (default: one per file)\n"));
- os_msg(_(" -r, -L List swap files\n"));
- os_msg(_(" -r <file> Recover edit state for this file\n"));
- os_msg(_(" -R Read-only mode\n"));
- os_msg(_(" -S <session> Source <session> after loading the first file\n"));
- os_msg(_(" -s <scriptin> Read Normal mode commands from <scriptin>\n"));
- os_msg(_(" -u <config> Use this config file\n"));
+ os_msg(_(" -R Read-only (view) mode\n"));
os_msg(_(" -v, --version Print version information\n"));
os_msg(_(" -V[N][file] Verbose [level][file]\n"));
os_msg("\n");
+ os_msg(_(" -- Only file names after this\n"));
os_msg(_(" --api-info Write msgpack-encoded API metadata to stdout\n"));
os_msg(_(" --clean \"Factory defaults\" (skip user config and plugins, shada)\n"));
os_msg(_(" --embed Use stdin/stdout as a msgpack-rpc channel\n"));
os_msg(_(" --headless Don't start a user interface\n"));
os_msg(_(" --listen <address> Serve RPC API from this address\n"));
- os_msg(_(" --noplugin Don't load plugins\n"));
os_msg(_(" --remote[-subcommand] Execute commands remotely on a server\n"));
os_msg(_(" --server <address> Specify RPC server to send commands to\n"));
os_msg(_(" --startuptime <file> Write startup timing messages to <file>\n"));
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index ea5e03e0eb..6ee9dac2ca 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -788,6 +788,9 @@ function tests.code_action_server_side_command()
codeActionProvider = {
resolveProvider = false,
},
+ executeCommandProvider = {
+ commands = {"dummy1"}
+ },
},
}
end,
diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua
index aae0ed91a7..c1091cff60 100644
--- a/test/functional/lua/fs_spec.lua
+++ b/test/functional/lua/fs_spec.lua
@@ -281,6 +281,12 @@ describe('vim.fs', function()
it('works with backward slashes', function()
eq('C:/Users/jdoe', exec_lua [[ return vim.fs.normalize('C:\\Users\\jdoe') ]])
end)
+ it('removes trailing /', function()
+ eq('/home/user', exec_lua [[ return vim.fs.normalize('/home/user/') ]])
+ end)
+ it('works with /', function()
+ eq('/', exec_lua [[ return vim.fs.normalize('/') ]])
+ end)
it('works with ~', function()
eq( exec_lua([[
local home = ...
diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua
index b134095c4f..103fd8d968 100644
--- a/test/functional/plugin/lsp/inlay_hint_spec.lua
+++ b/test/functional/plugin/lsp/inlay_hint_spec.lua
@@ -63,7 +63,7 @@ describe('inlay hints', function()
end)
it(
- 'inlay hints are applied when vim.lsp._inlay_hint.refresh() is called',
+ 'inlay hints are applied when vim.lsp.buf.inlay_hint(true) is called',
function()
exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
@@ -72,7 +72,7 @@ describe('inlay hints', function()
]])
insert(text)
- exec_lua([[vim.lsp._inlay_hint.refresh({bufnr = bufnr})]])
+ exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])
screen:expect({
grid = [[
auto add(int a, int b)-> int { return a + b; } |
@@ -89,7 +89,7 @@ describe('inlay hints', function()
end)
it(
- 'inlay hints are cleared when vim.lsp._inlay_hint.clear() is called',
+ 'inlay hints are cleared when vim.lsp.buf.inlay_hint(false) is called',
function()
exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
@@ -98,7 +98,7 @@ describe('inlay hints', function()
]])
insert(text)
- exec_lua([[vim.lsp._inlay_hint.refresh({bufnr = bufnr})]])
+ exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])
screen:expect({
grid = [[
auto add(int a, int b)-> int { return a + b; } |
@@ -112,7 +112,7 @@ describe('inlay hints', function()
|
]]
})
- exec_lua([[vim.lsp._inlay_hint.clear()]])
+ exec_lua([[vim.lsp.buf.inlay_hint(bufnr, false)]])
screen:expect({
grid = [[
auto add(int a, int b) { return a + b; } |
diff --git a/test/old/testdir/test_startup.vim b/test/old/testdir/test_startup.vim
index da467ea23f..d2ffbd0e2f 100644
--- a/test/old/testdir/test_startup.vim
+++ b/test/old/testdir/test_startup.vim
@@ -125,15 +125,15 @@ func Test_help_arg()
" check if couple of lines are there
let found = []
for line in lines
- if line =~ '-R.*Read-only mode'
- call add(found, 'Readonly mode')
+ if line =~ '-l.*Execute Lua'
+ call add(found, 'Execute Lua')
endif
" Watch out for a second --version line in the Gnome version.
if line =~ '--version.*Print version information'
call add(found, "--version")
endif
endfor
- call assert_equal(['Readonly mode', '--version'], found)
+ call assert_equal(['Execute Lua', '--version'], found)
endif
call delete('Xtestout')
endfunc