docs: json, tests, lsp #35754

Close #35926
Close #35818

Co-authored-by: skewb1k <skewb1kunix@gmail.com>
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
Justin M. Keyes
2025-09-28 23:57:59 -04:00
committed by GitHub
parent af1b17f17e
commit 2739ab485e
18 changed files with 186 additions and 138 deletions

View File

@@ -696,8 +696,8 @@ nvim_echo({chunks}, {history}, {opts}) *nvim_echo()*
• running: The progress is ongoing • running: The progress is ongoing
• failed: The progress item failed • failed: The progress item failed
• cancel: The progressing process should be canceled. • cancel: The progressing process should be canceled.
note: Cancel needs to be handled by progress initiator NOTE: Cancel must be handled by progress initiator by
by listening for the `Progress` event listening for the `Progress` event
• percent: How much progress is done on the progress • percent: How much progress is done on the progress
message message
• data: dictionary containing additional information • data: dictionary containing additional information
@@ -1500,7 +1500,7 @@ nvim_set_current_tabpage({tabpage}) *nvim_set_current_tabpage()*
• {tabpage} (`integer`) |tab-ID| to focus • {tabpage} (`integer`) |tab-ID| to focus
nvim_set_current_win({window}) *nvim_set_current_win()* nvim_set_current_win({window}) *nvim_set_current_win()*
Sets the current window (and tabpage, implicitly). Navigates to the given window (and tabpage, implicitly).
Attributes: ~ Attributes: ~
not allowed when |textlock| is active or in the |cmdwin| not allowed when |textlock| is active or in the |cmdwin|

View File

@@ -19,7 +19,7 @@ For a list of Vim variables see |vim-variable|.
============================================================================== ==============================================================================
1. Insert mode *insert-index* 1. Insert mode *insert-index*
tag char action in Insert mode ~ Tag Char Insert-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|i_CTRL-@| CTRL-@ insert previously inserted text and stop |i_CTRL-@| CTRL-@ insert previously inserted text and stop
insert insert
@@ -182,7 +182,7 @@ SECTION a section that possibly starts with '}' instead of '{'
note: 1 = cursor movement command; 2 = can be undone/redone note: 1 = cursor movement command; 2 = can be undone/redone
tag char note action in Normal mode ~ Tag Char Note Normal-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
CTRL-@ not used CTRL-@ not used
|CTRL-A| CTRL-A 2 add N to number at/after cursor |CTRL-A| CTRL-A 2 add N to number at/after cursor
@@ -471,7 +471,7 @@ tag char note action in Normal mode ~
These can be used after an operator or in Visual mode to select an object. These can be used after an operator or in Visual mode to select an object.
tag command action in op-pending and Visual mode ~ Tag Command Op-pending and Visual-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|v_aquote| a" double quoted string |v_aquote| a" double quoted string
|v_a'| a' single quoted string |v_a'| a' single quoted string
@@ -513,7 +513,7 @@ tag command action in op-pending and Visual mode ~
============================================================================== ==============================================================================
2.2 Window commands *CTRL-W* 2.2 Window commands *CTRL-W*
tag command action in Normal mode ~ Tag Command Normal-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|CTRL-W_CTRL-B| CTRL-W CTRL-B same as "CTRL-W b" |CTRL-W_CTRL-B| CTRL-W CTRL-B same as "CTRL-W b"
|CTRL-W_CTRL-C| CTRL-W CTRL-C no-op |CTRL-W_CTRL-C| CTRL-W CTRL-C no-op
@@ -611,7 +611,7 @@ tag command action in Normal mode ~
============================================================================== ==============================================================================
2.3 Square bracket commands *[* *]* 2.3 Square bracket commands *[* *]*
tag char note action in Normal mode ~ Tag Char Note Normal-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|[_CTRL-D| [ CTRL-D jump to first #define found in current and |[_CTRL-D| [ CTRL-D jump to first #define found in current and
included files matching the word under the included files matching the word under the
@@ -701,7 +701,7 @@ tag char note action in Normal mode ~
============================================================================== ==============================================================================
2.4 Commands starting with 'g' *g* 2.4 Commands starting with 'g' *g*
tag char note action in Normal mode ~ Tag Char Note Normal-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|g_CTRL-G| g CTRL-G show information about current cursor |g_CTRL-G| g CTRL-G show information about current cursor
position position
@@ -802,7 +802,7 @@ tag char note action in Normal mode ~
============================================================================== ==============================================================================
2.5 Commands starting with 'z' *z* 2.5 Commands starting with 'z' *z*
tag char note action in Normal mode ~ Tag Char Note Normal-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|z<CR>| z<CR> redraw, cursor line to top of window, |z<CR>| z<CR> redraw, cursor line to top of window,
cursor on first non-blank cursor on first non-blank
@@ -876,7 +876,7 @@ tag char note action in Normal mode ~
These can be used after an operator, but before a {motion} has been entered. These can be used after an operator, but before a {motion} has been entered.
tag char action in Operator-pending mode ~ Tag Char Operator-pending-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|o_v| v force operator to work charwise |o_v| v force operator to work charwise
|o_V| V force operator to work linewise |o_V| V force operator to work linewise
@@ -888,7 +888,7 @@ tag char action in Operator-pending mode ~
Most commands in Visual mode are the same as in Normal mode. The ones listed Most commands in Visual mode are the same as in Normal mode. The ones listed
here are those that are different. here are those that are different.
tag command note action in Visual mode ~ Tag Command Note Visual-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|v_CTRL-\_CTRL-N| CTRL-\ CTRL-N stop Visual mode |v_CTRL-\_CTRL-N| CTRL-\ CTRL-N stop Visual mode
|v_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to Normal mode |v_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to Normal mode
@@ -1007,7 +1007,7 @@ Normal characters are inserted at the current cursor position.
"Completion" below refers to context-sensitive completion. It will complete "Completion" below refers to context-sensitive completion. It will complete
file names, tags, commands etc. as appropriate. file names, tags, commands etc. as appropriate.
tag command action in Command-line editing mode ~ Tag Command Command-line editing-mode action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
CTRL-@ not used CTRL-@ not used
|c_CTRL-A| CTRL-A do completion on the pattern in front of the |c_CTRL-A| CTRL-A do completion on the pattern in front of the
@@ -1131,7 +1131,7 @@ This is a brief but complete listing of all the ":" commands, without
mentioning any arguments. The optional part of the command name is inside []. mentioning any arguments. The optional part of the command name is inside [].
The commands are sorted on the non-optional part of their name. The commands are sorted on the non-optional part of their name.
tag command action ~ Tag Command Action ~
------------------------------------------------------------------------------ ~ ------------------------------------------------------------------------------ ~
|:| : nothing |:| : nothing
|:range| :{range} go to last line in {range} |:range| :{range} go to last line in {range}

View File

@@ -769,9 +769,22 @@ Lua module: vim.lsp *lsp-core*
See `cmd` in |vim.lsp.ClientConfig|. See also See `cmd` in |vim.lsp.ClientConfig|. See also
`reuse_client` to dynamically decide (per-buffer) `reuse_client` to dynamically decide (per-buffer)
when `cmd` should be re-invoked. when `cmd` should be re-invoked.
• {filetypes}? (`string[]`) Filetypes the client will attach to, if • {filetypes}? (`string[]`) Filetypes the client will attach to, or
activated by `vim.lsp.enable()`. If not provided, the `nil` for ALL filetypes. To match files by name,
client will attach to all filetypes. pattern, or contents, you can define a custom
filetype using |vim.filetype.add()|: >lua
vim.filetype.add({
filename = {
['my_filename'] = 'my_filetype1',
},
pattern = {
['.*/etc/my_file_pattern/.*'] = 'my_filetype2',
},
})
vim.lsp.config('…', {
filetypes = { 'my_filetype1', 'my_filetype2' },
}
<
• {reuse_client}? (`fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig): boolean`) • {reuse_client}? (`fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig): boolean`)
Predicate which decides if a client should be Predicate which decides if a client should be
re-used. Used on all running clients. The default re-used. Used on all running clients. The default
@@ -793,23 +806,21 @@ Lua module: vim.lsp *lsp-core*
defined. The list order decides priority. To indicate defined. The list order decides priority. To indicate
"equal priority", specify names in a nested list "equal priority", specify names in a nested list
`{ { 'a.txt', 'b.lua' }, ... }`. `{ { 'a.txt', 'b.lua' }, ... }`.
• For each item, Nvim will search upwards (from the
For each item, Nvim will search upwards (from the buffer file) for that marker, or list of markers;
buffer file) for that marker, or list of markers; search stops at the first directory containing that
search stops at the first directory containing that marker, and the directory is used as the root dir
marker, and the directory is used as the root dir (workspace folder).
(workspace folder). • Example: Find the first ancestor directory
containing file or directory "stylua.toml"; if not
Example: Find the first ancestor directory containing found, find the first ancestor containing ".git": >
file or directory "stylua.toml"; if not found, find root_markers = { 'stylua.toml', '.git' }
the first ancestor containing ".git": >lua
root_markers = { 'stylua.toml', '.git' }
< <
• Example: Find the first ancestor directory
Example: Find the first ancestor directory containing containing EITHER "stylua.toml" or ".luarc.json";
EITHER "stylua.toml" or ".luarc.json"; if not found, if not found, find the first ancestor containing
find the first ancestor containing ".git": >lua ".git": >
root_markers = { { 'stylua.toml', '.luarc.json' }, '.git' } root_markers = { { 'stylua.toml', '.luarc.json' }, '.git' }
< <

View File

@@ -873,7 +873,7 @@ vim.wait({time}, {callback}, {interval}, {fast_only}) *vim.wait()*
Parameters: ~ Parameters: ~
• {time} (`integer`) Number of milliseconds to wait • {time} (`integer`) Number of milliseconds to wait
• {callback} (`fun(): boolean?`) Optional callback. Waits until • {callback} (`fun(): boolean, ...?`) Optional callback. Waits until
{callback} returns true {callback} returns true
• {interval} (`integer?`) (Approximate) number of milliseconds to wait • {interval} (`integer?`) (Approximate) number of milliseconds to wait
between polls between polls
@@ -3356,12 +3356,10 @@ vim.json.decode({str}, {opts}) *vim.json.decode()*
Parameters: ~ Parameters: ~
• {str} (`string`) Stringified JSON data. • {str} (`string`) Stringified JSON data.
• {opts} (`table<string,any>?`) Options table with keys: • {opts} (`table?`) A table with the following fields:
• luanil: (table) Table with keys: {luanil}? (`{ object?: boolean, array?: boolean }`, default:
• object: (boolean) When true, converts `null` in JSON `nil`) Convert `null` in JSON objects and/or arrays to Lua
objects to Lua `nil` instead of |vim.NIL|. `nil` instead of |vim.NIL|.
• array: (boolean) When true, converts `null` in JSON arrays
to Lua `nil` instead of |vim.NIL|.
Return: ~ Return: ~
(`any`) (`any`)
@@ -3369,14 +3367,14 @@ vim.json.decode({str}, {opts}) *vim.json.decode()*
vim.json.encode({obj}, {opts}) *vim.json.encode()* vim.json.encode({obj}, {opts}) *vim.json.encode()*
Encodes (or "packs") a Lua object to stringified JSON. Encodes (or "packs") a Lua object to stringified JSON.
Example: use the `indent` flag to implement a basic 'formatexpr' for JSON, Example: Implement a basic 'formatexpr' for JSON, so |gq| with a motion
so you can use |gq| with a motion to format JSON in a buffer. (The motion formats JSON in a buffer. (The motion must operate on a valid JSON
must operate on a valid JSON object.) >lua object.) >lua
function _G.fmt_json() function _G.fmt_json()
local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t' local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t'
local lines = vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum + vim.v.count - 1, true) local lines = vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum + vim.v.count - 1, true)
local o = vim.json.decode(table.concat(lines, '\n')) local o = vim.json.decode(table.concat(lines, '\n'))
local stringified = vim.json.encode(o, { indent = indent }) local stringified = vim.json.encode(o, { indent = indent, sort_keys = true })
lines = vim.split(stringified, '\n') lines = vim.split(stringified, '\n')
vim.api.nvim_buf_set_lines(0, vim.v.lnum - 1, vim.v.count, true, lines) vim.api.nvim_buf_set_lines(0, vim.v.lnum - 1, vim.v.count, true, lines)
end end
@@ -3385,14 +3383,14 @@ vim.json.encode({obj}, {opts}) *vim.json.encode()*
Parameters: ~ Parameters: ~
• {obj} (`any`) • {obj} (`any`)
• {opts} (`table<string,any>?`) Options table with keys: • {opts} (`table?`) A table with the following fields:
• escape_slash: (boolean) (default false) Escape slash {escape_slash}? (`boolean`, default: `false`) Escape slash
characters "/" in string values. characters "/" in string values.
• indent: (string) (default "") String used for indentation at {indent}? (`string`, default: `""`) If non-empty, the
each nesting level. If non-empty enables newlines and a returned JSON is formatted with newlines and whitespace,
space after colons. where `indent` defines the whitespace at each nesting level.
• sort_keys: (boolean) (default false) Sort object keys in {sort_keys}? (`boolean`, default: `false`) Sort object keys
alphabetical order. in alphabetical order.
Return: ~ Return: ~
(`string`) (`string`)

View File

@@ -71,18 +71,16 @@ The following new APIs or features were added.
the contents >lua the contents >lua
vim.treesitter.start() vim.treesitter.start()
< <
Note: Highlighted code examples are only available in the Nvim manual, not Note: Highlighted code examples are only available in the Nvim manual, not
in help files taken from Vim. The treesitter `vimdoc` parser is also work in in help files taken from Vim. The treesitter `vimdoc` parser is also work
progress and not guaranteed to correctly highlight every help file in the in progress and not guaranteed to correctly highlight every help file in
wild. the wild.
• Added support for semantic token highlighting to the LSP client. This • Added support for semantic token highlighting to the LSP client. This
functionality is enabled by default when a client that supports this feature functionality is enabled by default when a client that supports this feature
is attached to a buffer. Opt-out can be performed by deleting the is attached to a buffer. Opt-out can be performed by deleting the
`semanticTokensProvider` from the LSP client's {server_capabilities} in the `semanticTokensProvider` from the LSP client's {server_capabilities} in the
`LspAttach` callback. `LspAttach` callback. See |lsp-semantic-highlight| for more information.
See |lsp-semantic-highlight| for more information.
• |vim.inspect_pos()|, |vim.show_pos()| and |:Inspect| allow a user to get or show items • |vim.inspect_pos()|, |vim.show_pos()| and |:Inspect| allow a user to get or show items
at a given buffer position. Currently this includes treesitter captures, at a given buffer position. Currently this includes treesitter captures,
@@ -102,12 +100,9 @@ The following new APIs or features were added.
trusted and, if so, returns the file's contents. Used by 'exrc' trusted and, if so, returns the file's contents. Used by 'exrc'
• EditorConfig support is now builtin. This is enabled by default and happens • EditorConfig support is now builtin. This is enabled by default and happens
automatically. To disable it, users should add >lua automatically. To disable it, add the following to your |config|: >lua
vim.g.editorconfig = false vim.g.editorconfig = false
< <
(or the Vimscript equivalent) to their |config| file.
• A new environment variable named NVIM_APPNAME enables configuring the • A new environment variable named NVIM_APPNAME enables configuring the
directories where Nvim should find its configuration and state files. See directories where Nvim should find its configuration and state files. See
`:help $NVIM_APPNAME` . `:help $NVIM_APPNAME` .

View File

@@ -2891,6 +2891,7 @@ A jump table for the options with a short description can be found at |Q_op|.
foldclose FoldColumn |hl-FoldColumn| foldclose FoldColumn |hl-FoldColumn|
foldsep FoldColumn |hl-FoldColumn| foldsep FoldColumn |hl-FoldColumn|
diff DiffDelete |hl-DiffDelete| diff DiffDelete |hl-DiffDelete|
msgsep MsgSeparator |hl-MsgSeparator|
eob EndOfBuffer |hl-EndOfBuffer| eob EndOfBuffer |hl-EndOfBuffer|
lastline NonText |hl-NonText| lastline NonText |hl-NonText|
trunc one of the many Popup menu highlighting groups like trunc one of the many Popup menu highlighting groups like

View File

@@ -6280,7 +6280,7 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()*
• {count} (`integer?`) • {count} (`integer?`)
Return: ~ Return: ~
(`any`) (`integer`)
*matchadd()* *E798* *E799* *E801* *E957* *matchadd()* *E798* *E799* *E801* *E957*
matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
@@ -6346,10 +6346,10 @@ matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
• {pattern} (`string`) • {pattern} (`string`)
• {priority} (`integer?`) • {priority} (`integer?`)
• {id} (`integer?`) • {id} (`integer?`)
• {dict} (`string?`) • {dict} (`table?`)
Return: ~ Return: ~
(`any`) (`integer`)
matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()* matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()*
Same as |matchadd()|, but requires a list of positions {pos} Same as |matchadd()|, but requires a list of positions {pos}
@@ -6393,10 +6393,10 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()*
• {pos} (`any[]`) • {pos} (`any[]`)
• {priority} (`integer?`) • {priority} (`integer?`)
• {id} (`integer?`) • {id} (`integer?`)
• {dict} (`string?`) • {dict} (`table?`)
Return: ~ Return: ~
(`any`) (`integer|table`)
matcharg({nr}) *matcharg()* matcharg({nr}) *matcharg()*
Selects the {nr} match item, as set with a |:match|, Selects the {nr} match item, as set with a |:match|,
@@ -6414,7 +6414,7 @@ matcharg({nr}) *matcharg()*
• {nr} (`integer`) • {nr} (`integer`)
Return: ~ Return: ~
(`any`) (`string[]`)
matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()* matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
Returns the |List| of matches in lines from {lnum} to {end} in Returns the |List| of matches in lines from {lnum} to {end} in
@@ -6468,7 +6468,7 @@ matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
• {dict} (`table?`) • {dict} (`table?`)
Return: ~ Return: ~
(`any`) (`string[]`)
matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803* matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
Deletes a match with ID {id} previously defined by |matchadd()| Deletes a match with ID {id} previously defined by |matchadd()|
@@ -6511,7 +6511,7 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
• {count} (`integer?`) • {count} (`integer?`)
Return: ~ Return: ~
(`any`) (`integer`)
matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
If {list} is a list of strings, then returns a |List| with all If {list} is a list of strings, then returns a |List| with all
@@ -6582,7 +6582,7 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
• {dict} (`table?`) • {dict} (`table?`)
Return: ~ Return: ~
(`any`) (`table`)
matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()* matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
Same as |matchfuzzy()|, but returns the list of matched Same as |matchfuzzy()|, but returns the list of matched
@@ -6612,7 +6612,7 @@ matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
• {dict} (`table?`) • {dict} (`table?`)
Return: ~ Return: ~
(`any`) (`table`)
matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
Same as |match()|, but return a |List|. The first item in the Same as |match()|, but return a |List|. The first item in the
@@ -6633,7 +6633,7 @@ matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
• {count} (`integer?`) • {count} (`integer?`)
Return: ~ Return: ~
(`any`) (`string[]`)
matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()* matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
Same as |match()|, but return the matched string. Example: >vim Same as |match()|, but return the matched string. Example: >vim
@@ -6655,7 +6655,7 @@ matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
• {count} (`integer?`) • {count} (`integer?`)
Return: ~ Return: ~
(`any`) (`string`)
matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()* matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()*
Returns the |List| of matches in {list} where {pat} matches. Returns the |List| of matches in {list} where {pat} matches.
@@ -6696,7 +6696,7 @@ matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()*
• {dict} (`table?`) • {dict} (`table?`)
Return: ~ Return: ~
(`any`) (`string[]`)
matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()* matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
Same as |matchstr()|, but return the matched string, the start Same as |matchstr()|, but return the matched string, the start
@@ -6723,7 +6723,7 @@ matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
• {count} (`integer?`) • {count} (`integer?`)
Return: ~ Return: ~
(`any`) (`table`)
max({expr}) *max()* max({expr}) *max()*
Return the maximum value of all items in {expr}. Example: >vim Return the maximum value of all items in {expr}. Example: >vim

View File

@@ -1117,11 +1117,9 @@ function vim.api.nvim_del_var(name) end
--- - success: The progress item completed successfully --- - success: The progress item completed successfully
--- - running: The progress is ongoing --- - running: The progress is ongoing
--- - failed: The progress item failed --- - failed: The progress item failed
--- - cancel: The progressing process should be canceled. --- - cancel: The progressing process should be canceled. NOTE: Cancel must be handled by
--- note: Cancel needs to be handled by progress --- progress initiator by listening for the `Progress` event
--- initiator by listening for the `Progress` event --- - percent: How much progress is done on the progress message
--- - percent: How much progress is done on the progress
--- message
--- - data: dictionary containing additional information --- - data: dictionary containing additional information
--- @return integer|string # Message id. --- @return integer|string # Message id.
--- - -1 means nvim_echo didn't show a message --- - -1 means nvim_echo didn't show a message
@@ -2116,7 +2114,7 @@ function vim.api.nvim_set_current_line(line) end
--- @param tabpage integer `tab-ID` to focus --- @param tabpage integer `tab-ID` to focus
function vim.api.nvim_set_current_tabpage(tabpage) end function vim.api.nvim_set_current_tabpage(tabpage) end
--- Sets the current window (and tabpage, implicitly). --- Navigates to the given window (and tabpage, implicitly).
--- ---
--- @param window integer `window-ID` to focus --- @param window integer `window-ID` to focus
function vim.api.nvim_set_current_win(window) end function vim.api.nvim_set_current_win(window) end

View File

@@ -209,7 +209,7 @@ function vim.schedule(fn) end
--- ``` --- ```
--- ---
--- @param time integer Number of milliseconds to wait --- @param time integer Number of milliseconds to wait
--- @param callback? fun(): boolean Optional callback. Waits until {callback} returns true --- @param callback? fun(): boolean, ... Optional callback. Waits until {callback} returns true
--- @param interval? integer (Approximate) number of milliseconds to wait between polls --- @param interval? integer (Approximate) number of milliseconds to wait between polls
--- @param fast_only? boolean If true, only |api-fast| events will be processed. --- @param fast_only? boolean If true, only |api-fast| events will be processed.
--- @return boolean, nil|-1|-2, ... --- @return boolean, nil|-1|-2, ...

View File

@@ -5,6 +5,30 @@ vim.json = {}
-- luacheck: no unused args -- luacheck: no unused args
--- @class vim.json.decode.Opts
--- @inlinedoc
---
--- Convert `null` in JSON objects and/or arrays to Lua `nil` instead of |vim.NIL|.
--- (default: `nil`)
--- @field luanil? { object?: boolean, array?: boolean }
--- @class vim.json.encode.Opts
--- @inlinedoc
---
--- Escape slash characters "/" in string values.
--- (default: `false`)
--- @field escape_slash? boolean
---
---
--- If non-empty, the returned JSON is formatted with newlines and whitespace, where `indent`
--- defines the whitespace at each nesting level.
--- (default: `""`)
--- @field indent? string
---
--- Sort object keys in alphabetical order.
--- (default: `false`)
--- @field sort_keys? boolean
---@brief ---@brief
--- ---
--- This module provides encoding and decoding of Lua objects to and --- This module provides encoding and decoding of Lua objects to and
@@ -24,26 +48,21 @@ vim.json = {}
--- ``` --- ```
--- ---
---@param str string Stringified JSON data. ---@param str string Stringified JSON data.
---@param opts? table<string,any> Options table with keys: ---@param opts? vim.json.decode.Opts
--- - luanil: (table) Table with keys:
--- - object: (boolean) When true, converts `null` in JSON objects
--- to Lua `nil` instead of |vim.NIL|.
--- - array: (boolean) When true, converts `null` in JSON arrays
--- to Lua `nil` instead of |vim.NIL|.
---@return any ---@return any
function vim.json.decode(str, opts) end function vim.json.decode(str, opts) end
--- Encodes (or "packs") a Lua object to stringified JSON. --- Encodes (or "packs") a Lua object to stringified JSON.
--- ---
--- Example: use the `indent` flag to implement a basic 'formatexpr' for JSON, so you can use |gq| --- Example: Implement a basic 'formatexpr' for JSON, so |gq| with a motion formats JSON in
--- with a motion to format JSON in a buffer. (The motion must operate on a valid JSON object.) --- a buffer. (The motion must operate on a valid JSON object.)
--- ---
--- ```lua --- ```lua
--- function _G.fmt_json() --- function _G.fmt_json()
--- local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t' --- local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t'
--- local lines = vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum + vim.v.count - 1, true) --- local lines = vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum + vim.v.count - 1, true)
--- local o = vim.json.decode(table.concat(lines, '\n')) --- local o = vim.json.decode(table.concat(lines, '\n'))
--- local stringified = vim.json.encode(o, { indent = indent }) --- local stringified = vim.json.encode(o, { indent = indent, sort_keys = true })
--- lines = vim.split(stringified, '\n') --- lines = vim.split(stringified, '\n')
--- vim.api.nvim_buf_set_lines(0, vim.v.lnum - 1, vim.v.count, true, lines) --- vim.api.nvim_buf_set_lines(0, vim.v.lnum - 1, vim.v.count, true, lines)
--- end --- end
@@ -51,12 +70,6 @@ function vim.json.decode(str, opts) end
--- ``` --- ```
--- ---
---@param obj any ---@param obj any
---@param opts? table<string,any> Options table with keys: ---@param opts? vim.json.encode.Opts
--- - escape_slash: (boolean) (default false) Escape slash
--- characters "/" in string values.
--- - indent: (string) (default "") String used for indentation at each nesting level.
--- If non-empty enables newlines and a space after colons.
--- - sort_keys: (boolean) (default false) Sort object
--- keys in alphabetical order.
---@return string ---@return string
function vim.json.encode(obj, opts) end function vim.json.encode(obj, opts) end

View File

@@ -2612,6 +2612,7 @@ vim.bo.ft = vim.bo.filetype
--- foldclose FoldColumn `hl-FoldColumn` --- foldclose FoldColumn `hl-FoldColumn`
--- foldsep FoldColumn `hl-FoldColumn` --- foldsep FoldColumn `hl-FoldColumn`
--- diff DiffDelete `hl-DiffDelete` --- diff DiffDelete `hl-DiffDelete`
--- msgsep MsgSeparator `hl-MsgSeparator`
--- eob EndOfBuffer `hl-EndOfBuffer` --- eob EndOfBuffer `hl-EndOfBuffer`
--- lastline NonText `hl-NonText` --- lastline NonText `hl-NonText`
--- trunc one of the many Popup menu highlighting groups like --- trunc one of the many Popup menu highlighting groups like

View File

@@ -5697,7 +5697,7 @@ function vim.fn.mapset(dict) end
--- @param pat string --- @param pat string
--- @param start? integer --- @param start? integer
--- @param count? integer --- @param count? integer
--- @return any --- @return integer
function vim.fn.match(expr, pat, start, count) end function vim.fn.match(expr, pat, start, count) end
--- Defines a pattern to be highlighted in the current window (a --- Defines a pattern to be highlighted in the current window (a
@@ -5761,8 +5761,8 @@ function vim.fn.match(expr, pat, start, count) end
--- @param pattern string --- @param pattern string
--- @param priority? integer --- @param priority? integer
--- @param id? integer --- @param id? integer
--- @param dict? string --- @param dict? table
--- @return any --- @return integer
function vim.fn.matchadd(group, pattern, priority, id, dict) end function vim.fn.matchadd(group, pattern, priority, id, dict) end
--- Same as |matchadd()|, but requires a list of positions {pos} --- Same as |matchadd()|, but requires a list of positions {pos}
@@ -5805,8 +5805,8 @@ function vim.fn.matchadd(group, pattern, priority, id, dict) end
--- @param pos any[] --- @param pos any[]
--- @param priority? integer --- @param priority? integer
--- @param id? integer --- @param id? integer
--- @param dict? string --- @param dict? table
--- @return any --- @return integer|table
function vim.fn.matchaddpos(group, pos, priority, id, dict) end function vim.fn.matchaddpos(group, pos, priority, id, dict) end
--- Selects the {nr} match item, as set with a |:match|, --- Selects the {nr} match item, as set with a |:match|,
@@ -5821,7 +5821,7 @@ function vim.fn.matchaddpos(group, pos, priority, id, dict) end
--- to three matches. |matchadd()| does not have this limitation. --- to three matches. |matchadd()| does not have this limitation.
--- ---
--- @param nr integer --- @param nr integer
--- @return any --- @return string[]
function vim.fn.matcharg(nr) end function vim.fn.matcharg(nr) end
--- Returns the |List| of matches in lines from {lnum} to {end} in --- Returns the |List| of matches in lines from {lnum} to {end} in
@@ -5872,7 +5872,7 @@ function vim.fn.matcharg(nr) end
--- @param lnum string|integer --- @param lnum string|integer
--- @param end_ string|integer --- @param end_ string|integer
--- @param dict? table --- @param dict? table
--- @return any --- @return string[]
function vim.fn.matchbufline(buf, pat, lnum, end_, dict) end function vim.fn.matchbufline(buf, pat, lnum, end_, dict) end
--- Deletes a match with ID {id} previously defined by |matchadd()| --- Deletes a match with ID {id} previously defined by |matchadd()|
@@ -5909,7 +5909,7 @@ function vim.fn.matchdelete(id, win) end
--- @param pat string --- @param pat string
--- @param start? integer --- @param start? integer
--- @param count? integer --- @param count? integer
--- @return any --- @return integer
function vim.fn.matchend(expr, pat, start, count) end function vim.fn.matchend(expr, pat, start, count) end
--- If {list} is a list of strings, then returns a |List| with all --- If {list} is a list of strings, then returns a |List| with all
@@ -5977,7 +5977,7 @@ function vim.fn.matchend(expr, pat, start, count) end
--- @param list any[] --- @param list any[]
--- @param str string --- @param str string
--- @param dict? table --- @param dict? table
--- @return any --- @return table
function vim.fn.matchfuzzy(list, str, dict) end function vim.fn.matchfuzzy(list, str, dict) end
--- Same as |matchfuzzy()|, but returns the list of matched --- Same as |matchfuzzy()|, but returns the list of matched
@@ -6004,7 +6004,7 @@ function vim.fn.matchfuzzy(list, str, dict) end
--- @param list any[] --- @param list any[]
--- @param str string --- @param str string
--- @param dict? table --- @param dict? table
--- @return any --- @return table
function vim.fn.matchfuzzypos(list, str, dict) end function vim.fn.matchfuzzypos(list, str, dict) end
--- Same as |match()|, but return a |List|. The first item in the --- Same as |match()|, but return a |List|. The first item in the
@@ -6022,7 +6022,7 @@ function vim.fn.matchfuzzypos(list, str, dict) end
--- @param pat string --- @param pat string
--- @param start? integer --- @param start? integer
--- @param count? integer --- @param count? integer
--- @return any --- @return string[]
function vim.fn.matchlist(expr, pat, start, count) end function vim.fn.matchlist(expr, pat, start, count) end
--- Same as |match()|, but return the matched string. Example: >vim --- Same as |match()|, but return the matched string. Example: >vim
@@ -6041,7 +6041,7 @@ function vim.fn.matchlist(expr, pat, start, count) end
--- @param pat string --- @param pat string
--- @param start? integer --- @param start? integer
--- @param count? integer --- @param count? integer
--- @return any --- @return string
function vim.fn.matchstr(expr, pat, start, count) end function vim.fn.matchstr(expr, pat, start, count) end
--- Returns the |List| of matches in {list} where {pat} matches. --- Returns the |List| of matches in {list} where {pat} matches.
@@ -6079,7 +6079,7 @@ function vim.fn.matchstr(expr, pat, start, count) end
--- @param list string[] --- @param list string[]
--- @param pat string --- @param pat string
--- @param dict? table --- @param dict? table
--- @return any --- @return string[]
function vim.fn.matchstrlist(list, pat, dict) end function vim.fn.matchstrlist(list, pat, dict) end
--- Same as |matchstr()|, but return the matched string, the start --- Same as |matchstr()|, but return the matched string, the start
@@ -6103,7 +6103,7 @@ function vim.fn.matchstrlist(list, pat, dict) end
--- @param pat string --- @param pat string
--- @param start? integer --- @param start? integer
--- @param count? integer --- @param count? integer
--- @return any --- @return table
function vim.fn.matchstrpos(expr, pat, start, count) end function vim.fn.matchstrpos(expr, pat, start, count) end
--- Return the maximum value of all items in {expr}. Example: >vim --- Return the maximum value of all items in {expr}. Example: >vim

View File

@@ -199,8 +199,21 @@ end
--- See also `reuse_client` to dynamically decide (per-buffer) when `cmd` should be re-invoked. --- See also `reuse_client` to dynamically decide (per-buffer) when `cmd` should be re-invoked.
--- @field cmd? string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers, config: vim.lsp.ClientConfig): vim.lsp.rpc.PublicClient --- @field cmd? string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers, config: vim.lsp.ClientConfig): vim.lsp.rpc.PublicClient
--- ---
--- Filetypes the client will attach to, if activated by `vim.lsp.enable()`. If not provided, the --- Filetypes the client will attach to, or `nil` for ALL filetypes. To match files by name,
--- client will attach to all filetypes. --- pattern, or contents, you can define a custom filetype using |vim.filetype.add()|:
--- ```lua
--- vim.filetype.add({
--- filename = {
--- ['my_filename'] = 'my_filetype1',
--- },
--- pattern = {
--- ['.*/etc/my_file_pattern/.*'] = 'my_filetype2',
--- },
--- })
--- vim.lsp.config('…', {
--- filetypes = { 'my_filetype1', 'my_filetype2' },
--- }
--- ```
--- @field filetypes? string[] --- @field filetypes? string[]
--- ---
--- Predicate which decides if a client should be re-used. Used on all running clients. The default --- Predicate which decides if a client should be re-used. Used on all running clients. The default
@@ -219,22 +232,19 @@ end
--- Filename(s) (".git/", "package.json", …) used to decide the workspace root. Unused if `root_dir` --- Filename(s) (".git/", "package.json", …) used to decide the workspace root. Unused if `root_dir`
--- is defined. The list order decides priority. To indicate "equal priority", specify names in --- is defined. The list order decides priority. To indicate "equal priority", specify names in
--- a nested list `{ { 'a.txt', 'b.lua' }, ... }`. --- a nested list `{ { 'a.txt', 'b.lua' }, ... }`.
--- --- - For each item, Nvim will search upwards (from the buffer file) for that marker, or list of
--- For each item, Nvim will search upwards (from the buffer file) for that marker, or list of --- markers; search stops at the first directory containing that marker, and the directory is used
--- markers; search stops at the first directory containing that marker, and the directory is used --- as the root dir (workspace folder).
--- as the root dir (workspace folder). --- - Example: Find the first ancestor directory containing file or directory "stylua.toml"; if not
--- --- found, find the first ancestor containing ".git":
--- Example: Find the first ancestor directory containing file or directory "stylua.toml"; if not --- ```
--- found, find the first ancestor containing ".git":
--- ```lua
--- root_markers = { 'stylua.toml', '.git' } --- root_markers = { 'stylua.toml', '.git' }
--- ``` --- ```
--- --- - Example: Find the first ancestor directory containing EITHER "stylua.toml" or ".luarc.json";
--- Example: Find the first ancestor directory containing EITHER "stylua.toml" or ".luarc.json"; if --- if not found, find the first ancestor containing ".git":
--- not found, find the first ancestor containing ".git": --- ```
--- ```lua
--- root_markers = { { 'stylua.toml', '.luarc.json' }, '.git' } --- root_markers = { { 'stylua.toml', '.luarc.json' }, '.git' }
--- ``` --- ```
--- ---
--- @field root_markers? (string|string[])[] --- @field root_markers? (string|string[])[]

View File

@@ -1094,7 +1094,7 @@ local function gen_helptags_json(fname)
-- "foo.html#tag" -- "foo.html#tag"
t[tag] = ('%s#%s'):format(htmlpage, url_encode(tag)) t[tag] = ('%s#%s'):format(htmlpage, url_encode(tag))
end end
tofile(fname, vim.json.encode(t)) tofile(fname, vim.json.encode(t, { indent = ' ', sort_keys = true }))
end end
local function gen_css(fname) local function gen_css(fname)

View File

@@ -770,11 +770,9 @@ void nvim_set_vvar(String name, Object value, Error *err)
/// - success: The progress item completed successfully /// - success: The progress item completed successfully
/// - running: The progress is ongoing /// - running: The progress is ongoing
/// - failed: The progress item failed /// - failed: The progress item failed
/// - cancel: The progressing process should be canceled. /// - cancel: The progressing process should be canceled. NOTE: Cancel must be handled by
/// note: Cancel needs to be handled by progress /// progress initiator by listening for the `Progress` event
/// initiator by listening for the `Progress` event /// - percent: How much progress is done on the progress message
/// - percent: How much progress is done on the progress
/// message
/// - data: dictionary containing additional information /// - data: dictionary containing additional information
/// @return Message id. /// @return Message id.
/// - -1 means nvim_echo didn't show a message /// - -1 means nvim_echo didn't show a message
@@ -927,7 +925,7 @@ Window nvim_get_current_win(void)
return curwin->handle; return curwin->handle;
} }
/// Sets the current window (and tabpage, implicitly). /// Navigates to the given window (and tabpage, implicitly).
/// ///
/// @param window |window-ID| to focus /// @param window |window-ID| to focus
/// @param[out] err Error details, if any /// @param[out] err Error details, if any

View File

@@ -7011,6 +7011,7 @@ M.funcs = {
{ 'count', 'integer' }, { 'count', 'integer' },
}, },
signature = 'match({expr}, {pat} [, {start} [, {count}]])', signature = 'match({expr}, {pat} [, {start} [, {count}]])',
returns = 'integer',
}, },
matchadd = { matchadd = {
args = { 2, 5 }, args = { 2, 5 },
@@ -7080,10 +7081,11 @@ M.funcs = {
{ 'pattern', 'string' }, { 'pattern', 'string' },
{ 'priority', 'integer' }, { 'priority', 'integer' },
{ 'id', 'integer' }, { 'id', 'integer' },
{ 'dict', 'string' }, { 'dict', 'table' },
}, },
signature = 'matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])', signature = 'matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])',
tags = { 'E798', 'E799', 'E801', 'E957' }, tags = { 'E798', 'E799', 'E801', 'E957' },
returns = 'integer',
}, },
matchaddpos = { matchaddpos = {
args = { 2, 5 }, args = { 2, 5 },
@@ -7132,9 +7134,10 @@ M.funcs = {
{ 'pos', 'any[]' }, { 'pos', 'any[]' },
{ 'priority', 'integer' }, { 'priority', 'integer' },
{ 'id', 'integer' }, { 'id', 'integer' },
{ 'dict', 'string' }, { 'dict', 'table' },
}, },
signature = 'matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])', signature = 'matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])',
returns = 'integer|table',
}, },
matcharg = { matcharg = {
args = 1, args = 1,
@@ -7155,6 +7158,7 @@ M.funcs = {
name = 'matcharg', name = 'matcharg',
params = { { 'nr', 'integer' } }, params = { { 'nr', 'integer' } },
signature = 'matcharg({nr})', signature = 'matcharg({nr})',
returns = 'string[]',
}, },
matchbufline = { matchbufline = {
args = { 4, 5 }, args = { 4, 5 },
@@ -7212,6 +7216,7 @@ M.funcs = {
{ 'dict', 'table' }, { 'dict', 'table' },
}, },
signature = 'matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}])', signature = 'matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}])',
returns = 'string[]',
}, },
matchdelete = { matchdelete = {
args = { 1, 2 }, args = { 1, 2 },
@@ -7261,6 +7266,7 @@ M.funcs = {
{ 'count', 'integer' }, { 'count', 'integer' },
}, },
signature = 'matchend({expr}, {pat} [, {start} [, {count}]])', signature = 'matchend({expr}, {pat} [, {start} [, {count}]])',
returns = 'integer',
}, },
matchfuzzy = { matchfuzzy = {
args = { 2, 3 }, args = { 2, 3 },
@@ -7331,6 +7337,7 @@ M.funcs = {
name = 'matchfuzzy', name = 'matchfuzzy',
params = { { 'list', 'any[]' }, { 'str', 'string' }, { 'dict', 'table' } }, params = { { 'list', 'any[]' }, { 'str', 'string' }, { 'dict', 'table' } },
signature = 'matchfuzzy({list}, {str} [, {dict}])', signature = 'matchfuzzy({list}, {str} [, {dict}])',
returns = 'table',
}, },
matchfuzzypos = { matchfuzzypos = {
args = { 2, 3 }, args = { 2, 3 },
@@ -7360,6 +7367,7 @@ M.funcs = {
name = 'matchfuzzypos', name = 'matchfuzzypos',
params = { { 'list', 'any[]' }, { 'str', 'string' }, { 'dict', 'table' } }, params = { { 'list', 'any[]' }, { 'str', 'string' }, { 'dict', 'table' } },
signature = 'matchfuzzypos({list}, {str} [, {dict}])', signature = 'matchfuzzypos({list}, {str} [, {dict}])',
returns = 'table',
}, },
matchlist = { matchlist = {
args = { 2, 4 }, args = { 2, 4 },
@@ -7385,6 +7393,7 @@ M.funcs = {
{ 'count', 'integer' }, { 'count', 'integer' },
}, },
signature = 'matchlist({expr}, {pat} [, {start} [, {count}]])', signature = 'matchlist({expr}, {pat} [, {start} [, {count}]])',
returns = 'string[]',
}, },
matchstr = { matchstr = {
args = { 2, 4 }, args = { 2, 4 },
@@ -7411,6 +7420,7 @@ M.funcs = {
{ 'count', 'integer' }, { 'count', 'integer' },
}, },
signature = 'matchstr({expr}, {pat} [, {start} [, {count}]])', signature = 'matchstr({expr}, {pat} [, {start} [, {count}]])',
returns = 'string',
}, },
matchstrlist = { matchstrlist = {
args = { 2, 3 }, args = { 2, 3 },
@@ -7451,6 +7461,7 @@ M.funcs = {
name = 'matchstrlist', name = 'matchstrlist',
params = { { 'list', 'string[]' }, { 'pat', 'string' }, { 'dict', 'table' } }, params = { { 'list', 'string[]' }, { 'pat', 'string' }, { 'dict', 'table' } },
signature = 'matchstrlist({list}, {pat} [, {dict}])', signature = 'matchstrlist({list}, {pat} [, {dict}])',
returns = 'string[]',
}, },
matchstrpos = { matchstrpos = {
args = { 2, 4 }, args = { 2, 4 },
@@ -7482,6 +7493,7 @@ M.funcs = {
{ 'count', 'integer' }, { 'count', 'integer' },
}, },
signature = 'matchstrpos({expr}, {pat} [, {start} [, {count}]])', signature = 'matchstrpos({expr}, {pat} [, {start} [, {count}]])',
returns = 'table',
}, },
max = { max = {
args = 1, args = 1,

View File

@@ -3292,6 +3292,7 @@ local options = {
foldclose FoldColumn |hl-FoldColumn| foldclose FoldColumn |hl-FoldColumn|
foldsep FoldColumn |hl-FoldColumn| foldsep FoldColumn |hl-FoldColumn|
diff DiffDelete |hl-DiffDelete| diff DiffDelete |hl-DiffDelete|
msgsep MsgSeparator |hl-MsgSeparator|
eob EndOfBuffer |hl-EndOfBuffer| eob EndOfBuffer |hl-EndOfBuffer|
lastline NonText |hl-NonText| lastline NonText |hl-NonText|
trunc one of the many Popup menu highlighting groups like trunc one of the many Popup menu highlighting groups like

View File

@@ -417,6 +417,16 @@ by the semantic component they are testing.
sense, before creating a new one. sense, before creating a new one.
Fixing tests
============
> Nvim session T123 took 2000 milliseconds to exit
> This indicates a likely problem with the test even if it passed!
This may indicate a leak, because Nvim waits on uv handles before exiting.
Example: https://github.com/neovim/neovim/pull/35768
Lint Lint
==== ====