mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(lua): improve annotations for stricter luals diagnostics (#24609)
Problem: luals returns stricter diagnostics with bundled luarc.json Solution: Improve some function and type annotations: * use recognized uv.* types * disable diagnostic for global `vim` in shared.lua * docs: don't start comment lines with taglink (otherwise LuaLS will interpret it as a type) * add type alias for lpeg pattern * fix return annotation for `vim.secure.trust` * rename local Range object in vim.version (shadows `Range` in vim.treesitter) * fix some "missing fields" warnings * add missing required fields for test functions in eval.lua * rename lsp meta files for consistency
This commit is contained in:
@ -119,7 +119,7 @@ These dependencies are "vendored" (inlined), we must update the sources manually
|
|||||||
* `runtime/lua/vim/inspect.lua`: [inspect.lua](https://github.com/kikito/inspect.lua)
|
* `runtime/lua/vim/inspect.lua`: [inspect.lua](https://github.com/kikito/inspect.lua)
|
||||||
* `src/nvim/tui/terminfo_defs.h`: terminfo definitions
|
* `src/nvim/tui/terminfo_defs.h`: terminfo definitions
|
||||||
* Run `scripts/update_terminfo.sh` to update these definitions.
|
* Run `scripts/update_terminfo.sh` to update these definitions.
|
||||||
* `runtime/lua/vim/lsp/types/protocol.lua`: LSP specification
|
* `runtime/lua/vim/lsp/_meta/protocol.lua`: LSP specification
|
||||||
* Run `scripts/gen_lsp.lua` to update.
|
* Run `scripts/gen_lsp.lua` to update.
|
||||||
* `src/bit.c`: only for PUC lua: port of `require'bit'` from luajit https://bitop.luajit.org/
|
* `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)
|
* [treesitter parsers](https://github.com/neovim/neovim/blob/fcc24e43e0b5f9d801a01ff2b8f78ce8c16dd551/cmake.deps/CMakeLists.txt#L197-L210)
|
||||||
|
8
runtime/doc/builtin.txt
generated
8
runtime/doc/builtin.txt
generated
@ -1857,6 +1857,7 @@ foldtextresult({lnum}) *foldtextresult()*
|
|||||||
line, "'m" mark m, etc.
|
line, "'m" mark m, etc.
|
||||||
Useful when exporting folded text, e.g., to HTML.
|
Useful when exporting folded text, e.g., to HTML.
|
||||||
|
|
||||||
|
|
||||||
fullcommand({name}) *fullcommand()*
|
fullcommand({name}) *fullcommand()*
|
||||||
Get the full command name from a short abbreviated command
|
Get the full command name from a short abbreviated command
|
||||||
name; see |20.2| for details on command abbreviations.
|
name; see |20.2| for details on command abbreviations.
|
||||||
@ -7993,6 +7994,13 @@ termopen({cmd} [, {opts}]) *termopen()*
|
|||||||
except $TERM is set to "xterm-256color". Full behavior is
|
except $TERM is set to "xterm-256color". Full behavior is
|
||||||
described in |terminal|.
|
described in |terminal|.
|
||||||
|
|
||||||
|
test_garbagecollect_now() *test_garbagecollect_now()*
|
||||||
|
Like |garbagecollect()|, but executed right away. This must
|
||||||
|
only be called directly to avoid any structure to exist
|
||||||
|
internally, and |v:testing| must have been set before calling
|
||||||
|
any function.
|
||||||
|
|
||||||
|
|
||||||
timer_info([{id}]) *timer_info()*
|
timer_info([{id}]) *timer_info()*
|
||||||
Return a list with information about timers.
|
Return a list with information about timers.
|
||||||
When {id} is given only information about this timer is
|
When {id} is given only information about this timer is
|
||||||
|
@ -459,7 +459,7 @@ fromqflist({list}) *vim.diagnostic.fromqflist()*
|
|||||||
Convert a list of quickfix items to a list of diagnostics.
|
Convert a list of quickfix items to a list of diagnostics.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {list} (table) A list of quickfix items from |getqflist()| or
|
• {list} table[] List of quickfix items from |getqflist()| or
|
||||||
|getloclist()|.
|
|getloclist()|.
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
|
@ -2127,7 +2127,8 @@ request({method}, {params}, {callback}, {notify_reply_callback})
|
|||||||
• {method} (string) The invoked LSP method
|
• {method} (string) The invoked LSP method
|
||||||
• {params} (table|nil) Parameters for the invoked LSP
|
• {params} (table|nil) Parameters for the invoked LSP
|
||||||
method
|
method
|
||||||
• {callback} fun(err: lsp.ResponseError | nil, result: any) Callback to invoke
|
• {callback} fun(err: lsp.ResponseError | nil, result:
|
||||||
|
any) Callback to invoke
|
||||||
• {notify_reply_callback} (function|nil) Callback to invoke as soon as
|
• {notify_reply_callback} (function|nil) Callback to invoke as soon as
|
||||||
a request is no longer pending
|
a request is no longer pending
|
||||||
|
|
||||||
|
@ -2073,7 +2073,7 @@ vim.spairs({t}) *vim.spairs()*
|
|||||||
• {t} (table) Dict-like table
|
• {t} (table) Dict-like table
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
iterator over sorted keys and their values
|
(function) iterator over sorted keys and their values
|
||||||
|
|
||||||
See also: ~
|
See also: ~
|
||||||
• Based on https://github.com/premake/premake-core/blob/master/src/base/table.lua
|
• Based on https://github.com/premake/premake-core/blob/master/src/base/table.lua
|
||||||
@ -3007,10 +3007,9 @@ vim.secure.trust({opts}) *vim.secure.trust()*
|
|||||||
• bufnr (number|nil): Buffer number to update. Mutually
|
• bufnr (number|nil): Buffer number to update. Mutually
|
||||||
exclusive with {path}.
|
exclusive with {path}.
|
||||||
|
|
||||||
Return: ~
|
Return (multiple): ~
|
||||||
(boolean, string) success, msg:
|
(boolean) success true if operation was successful
|
||||||
• true and full path of target file if operation was successful
|
(string) msg full path if operation was successful, else error message
|
||||||
• false and error message on failure
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -31,11 +31,7 @@ Find more information in the file src/testdir/README.txt.
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
2. Test functions *test-functions-details*
|
2. Test functions *test-functions-details*
|
||||||
|
|
||||||
test_garbagecollect_now() *test_garbagecollect_now()*
|
See |test_garbagecollect_now()|.
|
||||||
Like garbagecollect(), but executed right away. This must
|
|
||||||
only be called directly to avoid any structure to exist
|
|
||||||
internally, and |v:testing| must have been set before calling
|
|
||||||
any function.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
3. Assert functions *assert-functions-details*
|
3. Assert functions *assert-functions-details*
|
||||||
|
@ -620,8 +620,8 @@ local on_key_cbs = {}
|
|||||||
---
|
---
|
||||||
---@param fn fun(key: string) Function invoked on every key press. |i_CTRL-V|
|
---@param fn fun(key: string) Function invoked on every key press. |i_CTRL-V|
|
||||||
--- Returning nil removes the callback associated with namespace {ns_id}.
|
--- Returning nil removes the callback associated with namespace {ns_id}.
|
||||||
---@param ns_id integer? Namespace ID. If nil or 0, generates and returns a new
|
---@param ns_id integer? Namespace ID. If nil or 0, generates and returns a
|
||||||
--- |nvim_create_namespace()| id.
|
--- new |nvim_create_namespace()| id.
|
||||||
---
|
---
|
||||||
---@return integer Namespace id associated with {fn}. Or count of all callbacks
|
---@return integer Namespace id associated with {fn}. Or count of all callbacks
|
||||||
---if on_key() is called without arguments.
|
---if on_key() is called without arguments.
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
local uv = vim.uv
|
local uv = vim.uv
|
||||||
|
|
||||||
--- @class SystemOpts
|
--- @class SystemOpts
|
||||||
--- @field cmd string[]
|
--- @field stdin? string|string[]|true
|
||||||
--- @field stdin string|string[]|true
|
--- @field stdout? fun(err:string, data: string)|false
|
||||||
--- @field stdout fun(err:string, data: string)|false
|
--- @field stderr? fun(err:string, data: string)|false
|
||||||
--- @field stderr fun(err:string, data: string)|false
|
|
||||||
--- @field cwd? string
|
--- @field cwd? string
|
||||||
--- @field env? table<string,string|number>
|
--- @field env? table<string,string|number>
|
||||||
--- @field clear_env? boolean
|
--- @field clear_env? boolean
|
||||||
--- @field text boolean?
|
--- @field text? boolean
|
||||||
--- @field timeout? integer Timeout in ms
|
--- @field timeout? integer Timeout in ms
|
||||||
--- @field detach? boolean
|
--- @field detach? boolean
|
||||||
|
|
||||||
@ -19,15 +18,14 @@ local uv = vim.uv
|
|||||||
--- @field stderr? string
|
--- @field stderr? string
|
||||||
|
|
||||||
--- @class SystemState
|
--- @class SystemState
|
||||||
--- @field handle uv_process_t
|
--- @field handle? uv.uv_process_t
|
||||||
--- @field timer uv_timer_t
|
--- @field timer? uv.uv_timer_t
|
||||||
--- @field pid integer
|
--- @field pid? integer
|
||||||
--- @field timeout? integer
|
--- @field timeout? integer
|
||||||
--- @field done boolean
|
--- @field done? boolean
|
||||||
--- @field stdin uv_stream_t?
|
--- @field stdin? uv.uv_stream_t
|
||||||
--- @field stdout uv_stream_t?
|
--- @field stdout? uv.uv_stream_t
|
||||||
--- @field stderr uv_stream_t?
|
--- @field stderr? uv.uv_stream_t
|
||||||
--- @field cmd string[]
|
|
||||||
--- @field result? SystemCompleted
|
--- @field result? SystemCompleted
|
||||||
|
|
||||||
---@param state SystemState
|
---@param state SystemState
|
||||||
@ -128,7 +126,7 @@ function SystemObj:is_closing()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param output function|'false'
|
---@param output function|'false'
|
||||||
---@return uv_stream_t?
|
---@return uv.uv_stream_t?
|
||||||
---@return function? Handler
|
---@return function? Handler
|
||||||
local function setup_output(output)
|
local function setup_output(output)
|
||||||
if output == nil then
|
if output == nil then
|
||||||
@ -144,7 +142,7 @@ local function setup_output(output)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param input string|string[]|true|nil
|
---@param input string|string[]|true|nil
|
||||||
---@return uv_stream_t?
|
---@return uv.uv_stream_t?
|
||||||
---@return string|string[]?
|
---@return string|string[]?
|
||||||
local function setup_input(input)
|
local function setup_input(input)
|
||||||
if not input then
|
if not input then
|
||||||
@ -189,7 +187,7 @@ local function setup_env(env, clear_env)
|
|||||||
return renv
|
return renv
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param stream uv_stream_t
|
--- @param stream uv.uv_stream_t
|
||||||
--- @param text? boolean
|
--- @param text? boolean
|
||||||
--- @param bucket string[]
|
--- @param bucket string[]
|
||||||
--- @return fun(err: string?, data: string?)
|
--- @return fun(err: string?, data: string?)
|
||||||
@ -217,7 +215,7 @@ local M = {}
|
|||||||
--- @param opts uv.aliases.spawn_options
|
--- @param opts uv.aliases.spawn_options
|
||||||
--- @param on_exit fun(code: integer, signal: integer)
|
--- @param on_exit fun(code: integer, signal: integer)
|
||||||
--- @param on_error fun()
|
--- @param on_error fun()
|
||||||
--- @return uv_process_t, integer
|
--- @return uv.uv_process_t, integer
|
||||||
local function spawn(cmd, opts, on_exit, on_error)
|
local function spawn(cmd, opts, on_exit, on_error)
|
||||||
local handle, pid_or_err = uv.spawn(cmd, opts, on_exit)
|
local handle, pid_or_err = uv.spawn(cmd, opts, on_exit)
|
||||||
if not handle then
|
if not handle then
|
||||||
|
@ -17,7 +17,7 @@ end
|
|||||||
|
|
||||||
--- Stops and closes a libuv |uv_fs_event_t| or |uv_fs_poll_t| handle
|
--- Stops and closes a libuv |uv_fs_event_t| or |uv_fs_poll_t| handle
|
||||||
---
|
---
|
||||||
---@param handle (uv_fs_event_t|uv_fs_poll_t) The handle to stop
|
---@param handle (uv.uv_fs_event_t|uv.uv_fs_poll_t) The handle to stop
|
||||||
local function stop(handle)
|
local function stop(handle)
|
||||||
local _, stop_err = handle:stop()
|
local _, stop_err = handle:stop()
|
||||||
assert(not stop_err, stop_err)
|
assert(not stop_err, stop_err)
|
||||||
@ -79,7 +79,7 @@ local default_poll_interval_ms = 2000
|
|||||||
--- @field children? table<string,watch.Watches>
|
--- @field children? table<string,watch.Watches>
|
||||||
--- @field cancel? fun()
|
--- @field cancel? fun()
|
||||||
--- @field started? boolean
|
--- @field started? boolean
|
||||||
--- @field handle? uv_fs_poll_t
|
--- @field handle? uv.uv_fs_poll_t
|
||||||
|
|
||||||
--- @class watch.PollOpts
|
--- @class watch.PollOpts
|
||||||
--- @field interval? integer
|
--- @field interval? integer
|
||||||
|
@ -562,8 +562,8 @@ end
|
|||||||
---@param opts table|nil When omitted or "nil", retrieve the current configuration. Otherwise, a
|
---@param opts table|nil When omitted or "nil", retrieve the current configuration. Otherwise, a
|
||||||
--- configuration table with the following keys:
|
--- configuration table with the following keys:
|
||||||
--- - underline: (default true) Use underline for diagnostics. Options:
|
--- - underline: (default true) Use underline for diagnostics. Options:
|
||||||
--- * severity: Only underline diagnostics matching the given severity
|
--- * severity: Only underline diagnostics matching the given
|
||||||
--- |diagnostic-severity|
|
--- severity |diagnostic-severity|
|
||||||
--- - virtual_text: (default true) Use virtual text for diagnostics. If multiple diagnostics
|
--- - virtual_text: (default true) Use virtual text for diagnostics. If multiple diagnostics
|
||||||
--- are set for a namespace, one prefix per diagnostic + the last diagnostic
|
--- are set for a namespace, one prefix per diagnostic + the last diagnostic
|
||||||
--- message are shown.
|
--- message are shown.
|
||||||
@ -596,8 +596,8 @@ end
|
|||||||
--- end
|
--- end
|
||||||
--- </pre>
|
--- </pre>
|
||||||
--- - signs: (default true) Use signs for diagnostics. Options:
|
--- - signs: (default true) Use signs for diagnostics. Options:
|
||||||
--- * severity: Only show signs for diagnostics matching the given severity
|
--- * severity: Only show signs for diagnostics matching the given
|
||||||
--- |diagnostic-severity|
|
--- severity |diagnostic-severity|
|
||||||
--- * priority: (number, default 10) Base priority to use for signs. When
|
--- * priority: (number, default 10) Base priority to use for signs. When
|
||||||
--- {severity_sort} is used, the priority of a sign is adjusted based on
|
--- {severity_sort} is used, the priority of a sign is adjusted based on
|
||||||
--- its severity. Otherwise, all signs use the same priority.
|
--- its severity. Otherwise, all signs use the same priority.
|
||||||
@ -723,17 +723,17 @@ function M.get_namespaces()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@class Diagnostic
|
---@class Diagnostic
|
||||||
---@field bufnr integer
|
---@field bufnr? integer
|
||||||
---@field lnum integer 0-indexed
|
---@field lnum integer 0-indexed
|
||||||
---@field end_lnum nil|integer 0-indexed
|
---@field end_lnum? integer 0-indexed
|
||||||
---@field col integer 0-indexed
|
---@field col integer 0-indexed
|
||||||
---@field end_col nil|integer 0-indexed
|
---@field end_col? integer 0-indexed
|
||||||
---@field severity DiagnosticSeverity
|
---@field severity? DiagnosticSeverity
|
||||||
---@field message string
|
---@field message string
|
||||||
---@field source nil|string
|
---@field source? string
|
||||||
---@field code nil|string
|
---@field code? string
|
||||||
---@field _tags { deprecated: boolean, unnecessary: boolean}
|
---@field _tags? { deprecated: boolean, unnecessary: boolean}
|
||||||
---@field user_data nil|any arbitrary data plugins can add
|
---@field user_data? any arbitrary data plugins can add
|
||||||
|
|
||||||
--- Get current diagnostics.
|
--- Get current diagnostics.
|
||||||
---
|
---
|
||||||
@ -819,13 +819,13 @@ end
|
|||||||
---
|
---
|
||||||
---@param opts table|nil Configuration table with the following keys:
|
---@param opts table|nil Configuration table with the following keys:
|
||||||
--- - namespace: (number) Only consider diagnostics from the given namespace.
|
--- - namespace: (number) Only consider diagnostics from the given namespace.
|
||||||
--- - cursor_position: (cursor position) Cursor position as a (row, col) tuple. See
|
--- - cursor_position: (cursor position) Cursor position as a (row, col) tuple.
|
||||||
--- |nvim_win_get_cursor()|. Defaults to the current cursor position.
|
--- See |nvim_win_get_cursor()|. Defaults to the current cursor position.
|
||||||
--- - wrap: (boolean, default true) Whether to loop around file or not. Similar to 'wrapscan'.
|
--- - wrap: (boolean, default true) Whether to loop around file or not. Similar to 'wrapscan'.
|
||||||
--- - severity: See |diagnostic-severity|.
|
--- - severity: See |diagnostic-severity|.
|
||||||
--- - float: (boolean or table, default true) If "true", call |vim.diagnostic.open_float()|
|
--- - float: (boolean or table, default true) If "true", call |vim.diagnostic.open_float()|
|
||||||
--- after moving. If a table, pass the table as the {opts} parameter to
|
--- after moving. If a table, pass the table as the {opts} parameter
|
||||||
--- |vim.diagnostic.open_float()|. Unless overridden, the float will show
|
--- to |vim.diagnostic.open_float()|. Unless overridden, the float will show
|
||||||
--- diagnostics at the new cursor position (as if "cursor" were passed to
|
--- diagnostics at the new cursor position (as if "cursor" were passed to
|
||||||
--- the "scope" option).
|
--- the "scope" option).
|
||||||
--- - win_id: (number, default 0) Window ID
|
--- - win_id: (number, default 0) Window ID
|
||||||
@ -1213,8 +1213,8 @@ end
|
|||||||
|
|
||||||
--- Show diagnostics in a floating window.
|
--- Show diagnostics in a floating window.
|
||||||
---
|
---
|
||||||
---@param opts table|nil Configuration table with the same keys as
|
---@param opts table|nil Configuration table with the same keys
|
||||||
--- |vim.lsp.util.open_floating_preview()| in addition to the following:
|
--- as |vim.lsp.util.open_floating_preview()| in addition to the following:
|
||||||
--- - bufnr: (number) Buffer number to show diagnostics from.
|
--- - bufnr: (number) Buffer number to show diagnostics from.
|
||||||
--- Defaults to the current buffer.
|
--- Defaults to the current buffer.
|
||||||
--- - namespace: (number) Limit diagnostics to the given namespace
|
--- - namespace: (number) Limit diagnostics to the given namespace
|
||||||
@ -1227,16 +1227,15 @@ end
|
|||||||
--- otherwise, a (row, col) tuple.
|
--- otherwise, a (row, col) tuple.
|
||||||
--- - severity_sort: (default false) Sort diagnostics by severity. Overrides the setting
|
--- - severity_sort: (default false) Sort diagnostics by severity. Overrides the setting
|
||||||
--- from |vim.diagnostic.config()|.
|
--- from |vim.diagnostic.config()|.
|
||||||
--- - severity: See |diagnostic-severity|. Overrides the setting from
|
--- - severity: See |diagnostic-severity|. Overrides the setting
|
||||||
--- |vim.diagnostic.config()|.
|
--- from |vim.diagnostic.config()|.
|
||||||
--- - header: (string or table) String to use as the header for the floating window. If a
|
--- - header: (string or table) String to use as the header for the floating window. If a
|
||||||
--- table, it is interpreted as a [text, hl_group] tuple. Overrides the setting
|
--- table, it is interpreted as a [text, hl_group] tuple. Overrides the setting
|
||||||
--- from |vim.diagnostic.config()|.
|
--- from |vim.diagnostic.config()|.
|
||||||
--- - source: (boolean or string) Include the diagnostic source in the message.
|
--- - source: (boolean or string) Include the diagnostic source in the message.
|
||||||
--- Use "if_many" to only show sources if there is more than one source of
|
--- Use "if_many" to only show sources if there is more than one source of
|
||||||
--- diagnostics in the buffer. Otherwise, any truthy value means to always show
|
--- diagnostics in the buffer. Otherwise, any truthy value means to always show
|
||||||
--- the diagnostic source. Overrides the setting from
|
--- the diagnostic source. Overrides the setting from |vim.diagnostic.config()|.
|
||||||
--- |vim.diagnostic.config()|.
|
|
||||||
--- - format: (function) A function that takes a diagnostic as input and returns a
|
--- - format: (function) A function that takes a diagnostic as input and returns a
|
||||||
--- string. The return value is the text used to display the diagnostic.
|
--- string. The return value is the text used to display the diagnostic.
|
||||||
--- Overrides the setting from |vim.diagnostic.config()|.
|
--- Overrides the setting from |vim.diagnostic.config()|.
|
||||||
@ -1692,8 +1691,7 @@ end
|
|||||||
|
|
||||||
--- Convert a list of quickfix items to a list of diagnostics.
|
--- Convert a list of quickfix items to a list of diagnostics.
|
||||||
---
|
---
|
||||||
---@param list table A list of quickfix items from |getqflist()| or
|
---@param list table[] List of quickfix items from |getqflist()| or |getloclist()|.
|
||||||
--- |getloclist()|.
|
|
||||||
---@return Diagnostic[] array of |diagnostic-structure|
|
---@return Diagnostic[] array of |diagnostic-structure|
|
||||||
function M.fromqflist(list)
|
function M.fromqflist(list)
|
||||||
vim.validate({
|
vim.validate({
|
||||||
|
@ -18,7 +18,7 @@ local M = {}
|
|||||||
---@class ModuleInfo
|
---@class ModuleInfo
|
||||||
---@field modpath string Path of the module
|
---@field modpath string Path of the module
|
||||||
---@field modname string Name of the module
|
---@field modname string Name of the module
|
||||||
---@field stat? uv_fs_t File stat of the module path
|
---@field stat? uv.uv_fs_t File stat of the module path
|
||||||
|
|
||||||
---@alias LoaderStats table<string, {total:number, time:number, [string]:number?}?>
|
---@alias LoaderStats table<string, {total:number, time:number, [string]:number?}?>
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ do
|
|||||||
--- @field lines string[] snapshot of buffer lines from last didChange
|
--- @field lines string[] snapshot of buffer lines from last didChange
|
||||||
--- @field lines_tmp string[]
|
--- @field lines_tmp string[]
|
||||||
--- @field pending_changes table[] List of debounced changes in incremental sync mode
|
--- @field pending_changes table[] List of debounced changes in incremental sync mode
|
||||||
--- @field timer nil|uv_timer_t uv_timer
|
--- @field timer nil|uv.uv_timer_t uv_timer
|
||||||
--- @field last_flush nil|number uv.hrtime of the last flush/didChange-notification
|
--- @field last_flush nil|number uv.hrtime of the last flush/didChange-notification
|
||||||
--- @field needs_flush boolean true if buffer updates haven't been sent to clients/servers yet
|
--- @field needs_flush boolean true if buffer updates haven't been sent to clients/servers yet
|
||||||
--- @field refs integer how many clients are using this group
|
--- @field refs integer how many clients are using this group
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
---@meta
|
---@meta
|
||||||
|
error('Cannot require a meta file')
|
||||||
|
|
||||||
---@alias lsp-handler fun(err: lsp.ResponseError|nil, result: any, context: lsp.HandlerContext, config: table|nil): any?
|
---@alias lsp-handler fun(err: lsp.ResponseError|nil, result: any, context: lsp.HandlerContext, config: table|nil): any?
|
||||||
|
|
@ -1,9 +1,12 @@
|
|||||||
--[[
|
--[[
|
||||||
This file is autogenerated from scripts/gen_lsp.lua
|
This file is autogenerated from scripts/gen_lsp.lua
|
||||||
Regenerate:
|
Regenerate:
|
||||||
nvim -l scripts/gen_lsp.lua gen --version 3.18 --runtime/lua/vim/lsp/types/protocol.lua
|
nvim -l scripts/gen_lsp.lua gen --version 3.18 --runtime/lua/vim/lsp/_meta/protocol.lua
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
---@meta
|
||||||
|
error('Cannot require a meta file')
|
||||||
|
|
||||||
---@alias lsp.null nil
|
---@alias lsp.null nil
|
||||||
---@alias uinteger integer
|
---@alias uinteger integer
|
||||||
---@alias lsp.decimal number
|
---@alias lsp.decimal number
|
@ -6,11 +6,13 @@ local lpeg = vim.lpeg
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
---@alias lpeg userdata
|
||||||
|
|
||||||
--- Parses the raw pattern into an |lpeg| pattern. LPeg patterns natively support the "this" or "that"
|
--- Parses the raw pattern into an |lpeg| pattern. LPeg patterns natively support the "this" or "that"
|
||||||
--- alternative constructions described in the LSP spec that cannot be expressed in a standard Lua pattern.
|
--- alternative constructions described in the LSP spec that cannot be expressed in a standard Lua pattern.
|
||||||
---
|
---
|
||||||
---@param pattern string The raw glob pattern
|
---@param pattern string The raw glob pattern
|
||||||
---@return userdata An |lpeg| representation of the pattern, or nil if the pattern is invalid.
|
---@return lpeg An |lpeg| representation of the pattern, or nil if the pattern is invalid.
|
||||||
local function parse(pattern)
|
local function parse(pattern)
|
||||||
local l = lpeg
|
local l = lpeg
|
||||||
|
|
||||||
@ -109,7 +111,7 @@ local to_lsp_change_type = {
|
|||||||
|
|
||||||
--- Default excludes the same as VSCode's `files.watcherExclude` setting.
|
--- Default excludes the same as VSCode's `files.watcherExclude` setting.
|
||||||
--- https://github.com/microsoft/vscode/blob/eef30e7165e19b33daa1e15e92fa34ff4a5df0d3/src/vs/workbench/contrib/files/browser/files.contribution.ts#L261
|
--- https://github.com/microsoft/vscode/blob/eef30e7165e19b33daa1e15e92fa34ff4a5df0d3/src/vs/workbench/contrib/files/browser/files.contribution.ts#L261
|
||||||
---@type Lpeg pattern
|
---@type lpeg parsed Lpeg pattern
|
||||||
M._poll_exclude_pattern = parse('**/.git/{objects,subtree-cache}/**')
|
M._poll_exclude_pattern = parse('**/.git/{objects,subtree-cache}/**')
|
||||||
+ parse('**/node_modules/*/**')
|
+ parse('**/node_modules/*/**')
|
||||||
+ parse('**/.hg/store/**')
|
+ parse('**/.hg/store/**')
|
||||||
@ -132,7 +134,7 @@ function M.register(reg, ctx)
|
|||||||
if not has_capability or not client.workspace_folders then
|
if not has_capability or not client.workspace_folders then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local watch_regs = {} --- @type table<string,{pattern:userdata,kind:integer}>
|
local watch_regs = {} --- @type table<string,{pattern:lpeg,kind:integer}>
|
||||||
for _, w in ipairs(reg.registerOptions.watchers) do
|
for _, w in ipairs(reg.registerOptions.watchers) do
|
||||||
local relative_pattern = false
|
local relative_pattern = false
|
||||||
local glob_patterns = {} --- @type {baseUri:string, pattern: string}[]
|
local glob_patterns = {} --- @type {baseUri:string, pattern: string}[]
|
||||||
|
@ -5,8 +5,8 @@ local api = vim.api
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@class lsp.inlay_hint.bufstate
|
---@class lsp.inlay_hint.bufstate
|
||||||
---@field version integer
|
---@field version? integer
|
||||||
---@field client_hint table<integer, table<integer, lsp.InlayHint[]>> client_id -> (lnum -> hints)
|
---@field client_hint? table<integer, table<integer, lsp.InlayHint[]>> client_id -> (lnum -> hints)
|
||||||
---@field applied table<integer, integer> Last version of hints applied to this line
|
---@field applied table<integer, integer> Last version of hints applied to this line
|
||||||
---@field enabled boolean Whether inlay hints are enabled for this buffer
|
---@field enabled boolean Whether inlay hints are enabled for this buffer
|
||||||
---@type table<integer, lsp.inlay_hint.bufstate>
|
---@type table<integer, lsp.inlay_hint.bufstate>
|
||||||
|
@ -14,11 +14,11 @@ local uv = vim.uv
|
|||||||
--- @field marked boolean whether this token has had extmarks applied
|
--- @field marked boolean whether this token has had extmarks applied
|
||||||
---
|
---
|
||||||
--- @class STCurrentResult
|
--- @class STCurrentResult
|
||||||
--- @field version integer document version associated with this result
|
--- @field version? integer document version associated with this result
|
||||||
--- @field result_id string resultId from the server; used with delta requests
|
--- @field result_id? string resultId from the server; used with delta requests
|
||||||
--- @field highlights STTokenRange[] cache of highlight ranges for this document version
|
--- @field highlights? STTokenRange[] cache of highlight ranges for this document version
|
||||||
--- @field tokens integer[] raw token array as received by the server. used for calculating delta responses
|
--- @field tokens? integer[] raw token array as received by the server. used for calculating delta responses
|
||||||
--- @field namespace_cleared boolean whether the namespace was cleared for this result yet
|
--- @field namespace_cleared? boolean whether the namespace was cleared for this result yet
|
||||||
---
|
---
|
||||||
--- @class STActiveRequest
|
--- @class STActiveRequest
|
||||||
--- @field request_id integer the LSP request ID of the most recent request sent to the server
|
--- @field request_id integer the LSP request ID of the most recent request sent to the server
|
||||||
@ -717,8 +717,7 @@ end
|
|||||||
--- mark will be deleted by the semantic token engine when appropriate; for
|
--- mark will be deleted by the semantic token engine when appropriate; for
|
||||||
--- example, when the LSP sends updated tokens. This function is intended for
|
--- example, when the LSP sends updated tokens. This function is intended for
|
||||||
--- use inside |LspTokenUpdate| callbacks.
|
--- use inside |LspTokenUpdate| callbacks.
|
||||||
---@param token (table) a semantic token, found as `args.data.token` in
|
---@param token (table) a semantic token, found as `args.data.token` in |LspTokenUpdate|.
|
||||||
--- |LspTokenUpdate|.
|
|
||||||
---@param bufnr (integer) the buffer to highlight
|
---@param bufnr (integer) the buffer to highlight
|
||||||
---@param client_id (integer) The ID of the |vim.lsp.client|
|
---@param client_id (integer) The ID of the |vim.lsp.client|
|
||||||
---@param hl_group (string) Highlight group name
|
---@param hl_group (string) Highlight group name
|
||||||
|
@ -715,8 +715,8 @@ end
|
|||||||
--- Turns the result of a `textDocument/completion` request into vim-compatible
|
--- Turns the result of a `textDocument/completion` request into vim-compatible
|
||||||
--- |complete-items|.
|
--- |complete-items|.
|
||||||
---
|
---
|
||||||
---@param result table The result of a `textDocument/completion` call, e.g. from
|
---@param result table The result of a `textDocument/completion` call, e.g.
|
||||||
---|vim.lsp.buf.completion()|, which may be one of `CompletionItem[]`,
|
--- from |vim.lsp.buf.completion()|, which may be one of `CompletionItem[]`,
|
||||||
--- `CompletionList` or `null`
|
--- `CompletionList` or `null`
|
||||||
---@param prefix (string) the prefix to filter the completion items
|
---@param prefix (string) the prefix to filter the completion items
|
||||||
---@return table { matches = complete-items table, incomplete = bool }
|
---@return table { matches = complete-items table, incomplete = bool }
|
||||||
|
@ -119,9 +119,8 @@ end
|
|||||||
--- - path (string|nil): Path to a file to update. Mutually exclusive with {bufnr}.
|
--- - path (string|nil): Path to a file to update. Mutually exclusive with {bufnr}.
|
||||||
--- Cannot be used when {action} is "allow".
|
--- Cannot be used when {action} is "allow".
|
||||||
--- - bufnr (number|nil): Buffer number to update. Mutually exclusive with {path}.
|
--- - bufnr (number|nil): Buffer number to update. Mutually exclusive with {path}.
|
||||||
---@return (boolean, string) success, msg:
|
---@return boolean success true if operation was successful
|
||||||
--- - true and full path of target file if operation was successful
|
---@return string msg full path if operation was successful, else error message
|
||||||
--- - false and error message on failure
|
|
||||||
function M.trust(opts)
|
function M.trust(opts)
|
||||||
vim.validate({
|
vim.validate({
|
||||||
path = { opts.path, 's', true },
|
path = { opts.path, 's', true },
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
-- or the test suite. (Eventually the test suite will be run in a worker process,
|
-- or the test suite. (Eventually the test suite will be run in a worker process,
|
||||||
-- so this wouldn't be a separate case to consider)
|
-- so this wouldn't be a separate case to consider)
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: lowercase-global
|
||||||
vim = vim or {}
|
vim = vim or {}
|
||||||
|
|
||||||
local function _id(v)
|
local function _id(v)
|
||||||
@ -533,7 +534,7 @@ end
|
|||||||
---@see Based on https://github.com/premake/premake-core/blob/master/src/base/table.lua
|
---@see Based on https://github.com/premake/premake-core/blob/master/src/base/table.lua
|
||||||
---
|
---
|
||||||
---@param t table Dict-like table
|
---@param t table Dict-like table
|
||||||
---@return # iterator over sorted keys and their values
|
---@return function iterator over sorted keys and their values
|
||||||
function vim.spairs(t)
|
function vim.spairs(t)
|
||||||
assert(type(t) == 'table', string.format('Expected table, got %s', type(t)))
|
assert(type(t) == 'table', string.format('Expected table, got %s', type(t)))
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ local predicate_handlers = {
|
|||||||
predicate_handlers['vim-match?'] = predicate_handlers['match?']
|
predicate_handlers['vim-match?'] = predicate_handlers['match?']
|
||||||
|
|
||||||
---@class TSMetadata
|
---@class TSMetadata
|
||||||
---@field range Range
|
---@field range? Range
|
||||||
---@field [integer] TSMetadata
|
---@field [integer] TSMetadata
|
||||||
---@field [string] integer|string
|
---@field [string] integer|string
|
||||||
|
|
||||||
|
@ -212,15 +212,15 @@ function M.last(versions)
|
|||||||
return last
|
return last
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class Range
|
---@class VersionRange
|
||||||
---@field from Version
|
---@field from Version
|
||||||
---@field to? Version
|
---@field to? Version
|
||||||
local Range = {}
|
local VersionRange = {}
|
||||||
|
|
||||||
--- @private
|
--- @private
|
||||||
---
|
---
|
||||||
---@param version string|Version
|
---@param version string|Version
|
||||||
function Range:has(version)
|
function VersionRange:has(version)
|
||||||
if type(version) == 'string' then
|
if type(version) == 'string' then
|
||||||
---@diagnostic disable-next-line: cast-local-type
|
---@diagnostic disable-next-line: cast-local-type
|
||||||
version = M.parse(version)
|
version = M.parse(version)
|
||||||
@ -266,7 +266,7 @@ end
|
|||||||
--- @param spec string Version range "spec"
|
--- @param spec string Version range "spec"
|
||||||
function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim
|
function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim
|
||||||
if spec == '*' or spec == '' then
|
if spec == '*' or spec == '' then
|
||||||
return setmetatable({ from = M.parse('0.0.0') }, { __index = Range })
|
return setmetatable({ from = M.parse('0.0.0') }, { __index = VersionRange })
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type number?
|
---@type number?
|
||||||
@ -280,7 +280,7 @@ function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim
|
|||||||
return setmetatable({
|
return setmetatable({
|
||||||
from = ra and ra.from,
|
from = ra and ra.from,
|
||||||
to = rb and (#parts == 3 and rb.from or rb.to),
|
to = rb and (#parts == 3 and rb.from or rb.to),
|
||||||
}, { __index = Range })
|
}, { __index = VersionRange })
|
||||||
end
|
end
|
||||||
---@type string, string
|
---@type string, string
|
||||||
local mods, version = spec:lower():match('^([%^=<>~]*)(.*)$')
|
local mods, version = spec:lower():match('^([%^=<>~]*)(.*)$')
|
||||||
@ -326,7 +326,7 @@ function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return setmetatable({ from = from, to = to }, { __index = Range })
|
return setmetatable({ from = from, to = to }, { __index = VersionRange })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
--[[
|
--[[
|
||||||
Generates lua-ls annotations for lsp
|
Generates lua-ls annotations for lsp
|
||||||
USAGE:
|
USAGE:
|
||||||
nvim -l scripts/gen_lsp.lua gen # this will overwrite runtime/lua/vim/lsp/types/protocol.lua
|
nvim -l scripts/gen_lsp.lua gen # this will overwrite runtime/lua/vim/lsp/_meta/protocol.lua
|
||||||
nvim -l scripts/gen_lsp.lua gen --version 3.18 --build/new_lsp_types.lua
|
nvim -l scripts/gen_lsp.lua gen --version 3.18 --build/new_lsp_types.lua
|
||||||
nvim -l scripts/gen_lsp.lua gen --version 3.18 --out runtime/lua/vim/lsp/types/protocol.lua
|
nvim -l scripts/gen_lsp.lua gen --version 3.18 --out runtime/lua/vim/lsp/_meta/protocol.lua
|
||||||
nvim -l scripts/gen_lsp.lua gen --version 3.18 --methods
|
nvim -l scripts/gen_lsp.lua gen --version 3.18 --methods
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ function M.gen(opt)
|
|||||||
'--[[',
|
'--[[',
|
||||||
'This file is autogenerated from scripts/gen_lsp.lua',
|
'This file is autogenerated from scripts/gen_lsp.lua',
|
||||||
'Regenerate:',
|
'Regenerate:',
|
||||||
[=[nvim -l scripts/gen_lsp.lua gen --version 3.18 --runtime/lua/vim/lsp/types/protocol.lua]=],
|
[=[nvim -l scripts/gen_lsp.lua gen --version 3.18 --runtime/lua/vim/lsp/_meta/protocol.lua]=],
|
||||||
'--]]',
|
'--]]',
|
||||||
'',
|
'',
|
||||||
'---@alias lsp.null nil',
|
'---@alias lsp.null nil',
|
||||||
@ -264,7 +264,7 @@ function M.gen(opt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local opt = {
|
local opt = {
|
||||||
output_file = 'runtime/lua/vim/lsp/types/protocol.lua',
|
output_file = 'runtime/lua/vim/lsp/_meta/protocol.lua',
|
||||||
version = nil,
|
version = nil,
|
||||||
methods = nil,
|
methods = nil,
|
||||||
}
|
}
|
||||||
|
@ -2898,6 +2898,9 @@ M.funcs = {
|
|||||||
signature = 'foldtextresult({lnum})',
|
signature = 'foldtextresult({lnum})',
|
||||||
},
|
},
|
||||||
foreground = {
|
foreground = {
|
||||||
|
args = 0,
|
||||||
|
params = {},
|
||||||
|
signature = '',
|
||||||
lua = false,
|
lua = false,
|
||||||
},
|
},
|
||||||
fullcommand = {
|
fullcommand = {
|
||||||
@ -11326,10 +11329,21 @@ M.funcs = {
|
|||||||
signature = 'termopen({cmd} [, {opts}])',
|
signature = 'termopen({cmd} [, {opts}])',
|
||||||
},
|
},
|
||||||
test_garbagecollect_now = {
|
test_garbagecollect_now = {
|
||||||
|
args = 0,
|
||||||
|
desc = [=[
|
||||||
|
Like |garbagecollect()|, but executed right away. This must
|
||||||
|
only be called directly to avoid any structure to exist
|
||||||
|
internally, and |v:testing| must have been set before calling
|
||||||
|
any function.
|
||||||
|
]=],
|
||||||
|
params = {},
|
||||||
|
signature = 'test_garbagecollect_now()',
|
||||||
lua = false,
|
lua = false,
|
||||||
},
|
},
|
||||||
test_write_list_log = {
|
test_write_list_log = {
|
||||||
args = 1,
|
args = 1,
|
||||||
|
params = { { 'fname' } },
|
||||||
|
signature = '',
|
||||||
lua = false,
|
lua = false,
|
||||||
},
|
},
|
||||||
timer_info = {
|
timer_info = {
|
||||||
|
@ -12,7 +12,7 @@ local Set = {}
|
|||||||
|
|
||||||
--- @param items? string[]
|
--- @param items? string[]
|
||||||
function Set:new(items)
|
function Set:new(items)
|
||||||
local obj = {} --- @ type Set
|
local obj = {} --- @type Set
|
||||||
setmetatable(obj, self)
|
setmetatable(obj, self)
|
||||||
self.__index = self
|
self.__index = self
|
||||||
|
|
||||||
@ -33,10 +33,7 @@ end
|
|||||||
|
|
||||||
--- @return Set
|
--- @return Set
|
||||||
function Set:copy()
|
function Set:copy()
|
||||||
local obj = {} --- @ type Set
|
local obj = {nelem = self.nelem, tbl = {}, items = {}} --- @type Set
|
||||||
obj.nelem = self.nelem
|
|
||||||
obj.tbl = {}
|
|
||||||
obj.items = {}
|
|
||||||
for k, v in pairs(self.tbl) do
|
for k, v in pairs(self.tbl) do
|
||||||
obj.tbl[k] = v
|
obj.tbl[k] = v
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user