mirror of
https://github.com/neovim/neovim.git
synced 2026-04-27 01:34:16 +00:00
feat(docs): replace lua2dox.lua
Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
This commit is contained in:
committed by
Lewis Russell
parent
7ad2e3c645
commit
9beb40a4db
@@ -127,10 +127,10 @@ vim.log = {
|
||||
--- timeout the process is sent the KILL signal (9) and the exit code is set to 124. Cannot
|
||||
--- be called in |api-fast|.
|
||||
--- - SystemCompleted is an object with the fields:
|
||||
--- - code: (integer)
|
||||
--- - signal: (integer)
|
||||
--- - stdout: (string), nil if stdout argument is passed
|
||||
--- - stderr: (string), nil if stderr argument is passed
|
||||
--- - code: (integer)
|
||||
--- - signal: (integer)
|
||||
--- - stdout: (string), nil if stdout argument is passed
|
||||
--- - stderr: (string), nil if stderr argument is passed
|
||||
--- - kill (fun(signal: integer|string))
|
||||
--- - write (fun(data: string|nil)) Requires `stdin=true`. Pass `nil` to close the stream.
|
||||
--- - is_closing (fun(): boolean)
|
||||
@@ -706,8 +706,8 @@ end
|
||||
--- Generates a list of possible completions for the string.
|
||||
--- String has the pattern.
|
||||
---
|
||||
--- 1. Can we get it to just return things in the global namespace with that name prefix
|
||||
--- 2. Can we get it to return things from global namespace even with `print(` in front.
|
||||
--- 1. Can we get it to just return things in the global namespace with that name prefix
|
||||
--- 2. Can we get it to return things from global namespace even with `print(` in front.
|
||||
---
|
||||
--- @param pat string
|
||||
function vim._expand_pat(pat, env)
|
||||
@@ -885,6 +885,7 @@ do
|
||||
--- similar to the builtin completion for the `:lua` command.
|
||||
---
|
||||
--- Activate using `set omnifunc=v:lua.vim.lua_omnifunc` in a Lua buffer.
|
||||
--- @param find_start 1|0
|
||||
function vim.lua_omnifunc(find_start, _)
|
||||
if find_start == 1 then
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
@@ -914,6 +915,7 @@ end
|
||||
---
|
||||
--- @see |vim.inspect()|
|
||||
--- @see |:=|
|
||||
--- @param ... any
|
||||
--- @return any # given arguments.
|
||||
function vim.print(...)
|
||||
if vim.in_fast_event() then
|
||||
|
||||
@@ -17,7 +17,7 @@ local defaults = {
|
||||
---@param bufnr? integer defaults to the current buffer
|
||||
---@param row? integer row to inspect, 0-based. Defaults to the row of the current cursor
|
||||
---@param col? integer col to inspect, 0-based. Defaults to the col of the current cursor
|
||||
---@param filter? InspectorFilter (table|nil) a table with key-value pairs to filter the items
|
||||
---@param filter? InspectorFilter (table) a table with key-value pairs to filter the items
|
||||
--- - syntax (boolean): include syntax based highlight groups (defaults to true)
|
||||
--- - treesitter (boolean): include treesitter based highlight groups (defaults to true)
|
||||
--- - extmarks (boolean|"all"): include extmarks. When `all`, then extmarks without a `hl_group` will also be included (defaults to true)
|
||||
@@ -139,7 +139,7 @@ end
|
||||
---@param bufnr? integer defaults to the current buffer
|
||||
---@param row? integer row to inspect, 0-based. Defaults to the row of the current cursor
|
||||
---@param col? integer col to inspect, 0-based. Defaults to the col of the current cursor
|
||||
---@param filter? InspectorFilter (table|nil) see |vim.inspect_pos()|
|
||||
---@param filter? InspectorFilter (table) see |vim.inspect_pos()|
|
||||
function vim.show_pos(bufnr, row, col, filter)
|
||||
local items = vim.inspect_pos(bufnr, row, col, filter)
|
||||
|
||||
|
||||
843
runtime/lua/vim/_meta/api.lua
generated
843
runtime/lua/vim/_meta/api.lua
generated
File diff suppressed because it is too large
Load Diff
@@ -3,65 +3,63 @@
|
||||
|
||||
error('Cannot require a meta file')
|
||||
|
||||
---@defgroup vim.builtin
|
||||
--- @brief <pre>help
|
||||
--- vim.api.{func}({...}) *vim.api*
|
||||
--- Invokes Nvim |API| function {func} with arguments {...}.
|
||||
--- Example: call the "nvim_get_current_line()" API function: >lua
|
||||
--- print(tostring(vim.api.nvim_get_current_line()))
|
||||
---
|
||||
---@brief <pre>help
|
||||
---vim.api.{func}({...}) *vim.api*
|
||||
--- Invokes Nvim |API| function {func} with arguments {...}.
|
||||
--- Example: call the "nvim_get_current_line()" API function: >lua
|
||||
--- print(tostring(vim.api.nvim_get_current_line()))
|
||||
--- vim.NIL *vim.NIL*
|
||||
--- Special value representing NIL in |RPC| and |v:null| in Vimscript
|
||||
--- conversion, and similar cases. Lua `nil` cannot be used as part of a Lua
|
||||
--- table representing a Dictionary or Array, because it is treated as
|
||||
--- missing: `{"foo", nil}` is the same as `{"foo"}`.
|
||||
---
|
||||
---vim.NIL *vim.NIL*
|
||||
--- Special value representing NIL in |RPC| and |v:null| in Vimscript
|
||||
--- conversion, and similar cases. Lua `nil` cannot be used as part of a Lua
|
||||
--- table representing a Dictionary or Array, because it is treated as
|
||||
--- missing: `{"foo", nil}` is the same as `{"foo"}`.
|
||||
--- vim.type_idx *vim.type_idx*
|
||||
--- Type index for use in |lua-special-tbl|. Specifying one of the values from
|
||||
--- |vim.types| allows typing the empty table (it is unclear whether empty Lua
|
||||
--- table represents empty list or empty array) and forcing integral numbers
|
||||
--- to be |Float|. See |lua-special-tbl| for more details.
|
||||
---
|
||||
---vim.type_idx *vim.type_idx*
|
||||
--- Type index for use in |lua-special-tbl|. Specifying one of the values from
|
||||
--- |vim.types| allows typing the empty table (it is unclear whether empty Lua
|
||||
--- table represents empty list or empty array) and forcing integral numbers
|
||||
--- to be |Float|. See |lua-special-tbl| for more details.
|
||||
--- vim.val_idx *vim.val_idx*
|
||||
--- Value index for tables representing |Float|s. A table representing
|
||||
--- floating-point value 1.0 looks like this: >lua
|
||||
--- {
|
||||
--- [vim.type_idx] = vim.types.float,
|
||||
--- [vim.val_idx] = 1.0,
|
||||
--- }
|
||||
--- < See also |vim.type_idx| and |lua-special-tbl|.
|
||||
---
|
||||
---vim.val_idx *vim.val_idx*
|
||||
--- Value index for tables representing |Float|s. A table representing
|
||||
--- floating-point value 1.0 looks like this: >lua
|
||||
--- {
|
||||
--- [vim.type_idx] = vim.types.float,
|
||||
--- [vim.val_idx] = 1.0,
|
||||
--- }
|
||||
---< See also |vim.type_idx| and |lua-special-tbl|.
|
||||
--- vim.types *vim.types*
|
||||
--- Table with possible values for |vim.type_idx|. Contains two sets of
|
||||
--- key-value pairs: first maps possible values for |vim.type_idx| to
|
||||
--- human-readable strings, second maps human-readable type names to values
|
||||
--- for |vim.type_idx|. Currently contains pairs for `float`, `array` and
|
||||
--- `dictionary` types.
|
||||
---
|
||||
---vim.types *vim.types*
|
||||
--- Table with possible values for |vim.type_idx|. Contains two sets of
|
||||
--- key-value pairs: first maps possible values for |vim.type_idx| to
|
||||
--- human-readable strings, second maps human-readable type names to values
|
||||
--- for |vim.type_idx|. Currently contains pairs for `float`, `array` and
|
||||
--- `dictionary` types.
|
||||
--- Note: One must expect that values corresponding to `vim.types.float`,
|
||||
--- `vim.types.array` and `vim.types.dictionary` fall under only two following
|
||||
--- assumptions:
|
||||
--- 1. Value may serve both as a key and as a value in a table. Given the
|
||||
--- properties of Lua tables this basically means “value is not `nil`”.
|
||||
--- 2. For each value in `vim.types` table `vim.types[vim.types[value]]` is the
|
||||
--- same as `value`.
|
||||
--- No other restrictions are put on types, and it is not guaranteed that
|
||||
--- values corresponding to `vim.types.float`, `vim.types.array` and
|
||||
--- `vim.types.dictionary` will not change or that `vim.types` table will only
|
||||
--- contain values for these three types.
|
||||
---
|
||||
--- Note: One must expect that values corresponding to `vim.types.float`,
|
||||
--- `vim.types.array` and `vim.types.dictionary` fall under only two following
|
||||
--- assumptions:
|
||||
--- 1. Value may serve both as a key and as a value in a table. Given the
|
||||
--- properties of Lua tables this basically means “value is not `nil`”.
|
||||
--- 2. For each value in `vim.types` table `vim.types[vim.types[value]]` is the
|
||||
--- same as `value`.
|
||||
--- No other restrictions are put on types, and it is not guaranteed that
|
||||
--- values corresponding to `vim.types.float`, `vim.types.array` and
|
||||
--- `vim.types.dictionary` will not change or that `vim.types` table will only
|
||||
--- contain values for these three types.
|
||||
--- *log_levels* *vim.log.levels*
|
||||
--- Log levels are one of the values defined in `vim.log.levels`:
|
||||
---
|
||||
--- *log_levels* *vim.log.levels*
|
||||
---Log levels are one of the values defined in `vim.log.levels`:
|
||||
--- vim.log.levels.DEBUG
|
||||
--- vim.log.levels.ERROR
|
||||
--- vim.log.levels.INFO
|
||||
--- vim.log.levels.TRACE
|
||||
--- vim.log.levels.WARN
|
||||
--- vim.log.levels.OFF
|
||||
---
|
||||
--- vim.log.levels.DEBUG
|
||||
--- vim.log.levels.ERROR
|
||||
--- vim.log.levels.INFO
|
||||
--- vim.log.levels.TRACE
|
||||
--- vim.log.levels.WARN
|
||||
--- vim.log.levels.OFF
|
||||
---
|
||||
---</pre>
|
||||
--- </pre>
|
||||
|
||||
---@class vim.NIL
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ vim.json = {}
|
||||
|
||||
-- luacheck: no unused args
|
||||
|
||||
---@defgroup vim.json
|
||||
---@brief
|
||||
---
|
||||
--- This module provides encoding and decoding of Lua objects to and
|
||||
--- from JSON-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|.
|
||||
|
||||
@@ -5,22 +5,20 @@ error('Cannot require a meta file')
|
||||
-- (based on revision 4aded588f9531d89555566bb1de27490354b91c7)
|
||||
-- with types being renamed to include the vim namespace and with some descriptions made less verbose.
|
||||
|
||||
---@defgroup vim.lpeg
|
||||
---<pre>help
|
||||
---LPeg is a pattern-matching library for Lua, based on
|
||||
---Parsing Expression Grammars (https://bford.info/packrat/) (PEGs).
|
||||
--- @brief <pre>help
|
||||
--- LPeg is a pattern-matching library for Lua, based on
|
||||
--- Parsing Expression Grammars (https://bford.info/packrat/) (PEGs).
|
||||
---
|
||||
--- *lua-lpeg*
|
||||
--- *vim.lpeg.Pattern*
|
||||
---The LPeg library for parsing expression grammars is included as `vim.lpeg`
|
||||
---(https://www.inf.puc-rio.br/~roberto/lpeg/).
|
||||
--- *lua-lpeg*
|
||||
--- *vim.lpeg.Pattern*
|
||||
--- The LPeg library for parsing expression grammars is included as `vim.lpeg`
|
||||
--- (https://www.inf.puc-rio.br/~roberto/lpeg/).
|
||||
---
|
||||
---In addition, its regex-like interface is available as |vim.re|
|
||||
---(https://www.inf.puc-rio.br/~roberto/lpeg/re.html).
|
||||
--- In addition, its regex-like interface is available as |vim.re|
|
||||
--- (https://www.inf.puc-rio.br/~roberto/lpeg/re.html).
|
||||
---
|
||||
---</pre>
|
||||
--- </pre>
|
||||
|
||||
--- *LPeg* is a new pattern-matching library for Lua, based on [Parsing Expression Grammars](https://bford.info/packrat/) (PEGs).
|
||||
vim.lpeg = {}
|
||||
|
||||
--- @class vim.lpeg.Pattern
|
||||
@@ -88,6 +86,7 @@ function Pattern:match(subject, init) end
|
||||
|
||||
--- Returns the string `"pattern"` if the given value is a pattern, otherwise `nil`.
|
||||
---
|
||||
--- @param value vim.lpeg.Pattern|string|integer|boolean|table|function
|
||||
--- @return "pattern"|nil
|
||||
function vim.lpeg.type(value) end
|
||||
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
|
||||
-- luacheck: no unused args
|
||||
|
||||
--- @defgroup vim.mpack
|
||||
--- @brief
|
||||
---
|
||||
--- This module provides encoding and decoding of Lua objects to and
|
||||
--- from msgpack-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|.
|
||||
|
||||
--- Decodes (or "unpacks") the msgpack-encoded {str} to a Lua object.
|
||||
--- @param str string
|
||||
--- @return any
|
||||
function vim.mpack.decode(str) end
|
||||
|
||||
--- Encodes (or "packs") Lua object {obj} as msgpack in a Lua string.
|
||||
--- @param obj any
|
||||
--- @return string
|
||||
function vim.mpack.encode(obj) end
|
||||
|
||||
@@ -7,15 +7,12 @@ error('Cannot require a meta file')
|
||||
-- Copyright © 2007-2023 Lua.org, PUC-Rio.
|
||||
-- See 'lpeg.html' for license
|
||||
|
||||
--- @defgroup vim.re
|
||||
---<pre>help
|
||||
---The `vim.re` module provides a conventional regex-like syntax for pattern usage
|
||||
---within LPeg |vim.lpeg|.
|
||||
--- @brief
|
||||
--- The `vim.re` module provides a conventional regex-like syntax for pattern usage
|
||||
--- within LPeg |vim.lpeg|.
|
||||
---
|
||||
---See https://www.inf.puc-rio.br/~roberto/lpeg/re.html for the original
|
||||
---documentation including regex syntax and more concrete examples.
|
||||
---
|
||||
---</pre>
|
||||
--- See https://www.inf.puc-rio.br/~roberto/lpeg/re.html for the original
|
||||
--- documentation including regex syntax and more concrete examples.
|
||||
|
||||
--- Compiles the given {string} and returns an equivalent LPeg pattern. The given string may define
|
||||
--- either an expression or a grammar. The optional {defs} table provides extra Lua values to be used
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
-- luacheck: no unused args
|
||||
|
||||
--- @defgroup vim.regex
|
||||
---
|
||||
--- @brief Vim regexes can be used directly from Lua. Currently they only allow
|
||||
--- matching within a single line.
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
---@defgroup lua-vimscript
|
||||
--- @brief Nvim Lua provides an interface or "bridge" to Vimscript variables and
|
||||
--- functions, and editor commands and options.
|
||||
---
|
||||
---@brief 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:
|
||||
--- 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 }
|
||||
@@ -14,86 +12,85 @@
|
||||
--- vim.print(list) --> "{ 1, 2, 3 }"
|
||||
--- ```
|
||||
|
||||
---@addtogroup lua-vimscript
|
||||
---@brief <pre>help
|
||||
---vim.call({func}, {...}) *vim.call()*
|
||||
--- Invokes |vim-function| or |user-function| {func} with arguments {...}.
|
||||
--- See also |vim.fn|.
|
||||
--- Equivalent to: >lua
|
||||
--- vim.fn[func]({...})
|
||||
---<
|
||||
---vim.cmd({command})
|
||||
--- See |vim.cmd()|.
|
||||
--- @brief <pre>help
|
||||
--- vim.call({func}, {...}) *vim.call()*
|
||||
--- Invokes |vim-function| or |user-function| {func} with arguments {...}.
|
||||
--- See also |vim.fn|.
|
||||
--- Equivalent to: >lua
|
||||
--- vim.fn[func]({...})
|
||||
--- <
|
||||
--- vim.cmd({command})
|
||||
--- See |vim.cmd()|.
|
||||
---
|
||||
---vim.fn.{func}({...}) *vim.fn*
|
||||
--- Invokes |vim-function| or |user-function| {func} with arguments {...}.
|
||||
--- To call autoload functions, use the syntax: >lua
|
||||
--- vim.fn['some\#function']({...})
|
||||
---<
|
||||
--- Unlike vim.api.|nvim_call_function()| this converts directly between Vim
|
||||
--- objects and Lua objects. If the Vim function returns a float, it will be
|
||||
--- represented directly as a Lua number. Empty lists and dictionaries both
|
||||
--- are represented by an empty table.
|
||||
--- vim.fn.{func}({...}) *vim.fn*
|
||||
--- Invokes |vim-function| or |user-function| {func} with arguments {...}.
|
||||
--- To call autoload functions, use the syntax: >lua
|
||||
--- vim.fn['some#function']({...})
|
||||
--- <
|
||||
--- Unlike vim.api.|nvim_call_function()| this converts directly between Vim
|
||||
--- objects and Lua objects. If the Vim function returns a float, it will be
|
||||
--- represented directly as a Lua number. Empty lists and dictionaries both
|
||||
--- are represented by an empty table.
|
||||
---
|
||||
--- Note: |v:null| values as part of the return value is represented as
|
||||
--- |vim.NIL| special value
|
||||
--- Note: |v:null| values as part of the return value is represented as
|
||||
--- |vim.NIL| special value
|
||||
---
|
||||
--- Note: vim.fn keys are generated lazily, thus `pairs(vim.fn)` only
|
||||
--- enumerates functions that were called at least once.
|
||||
--- Note: vim.fn keys are generated lazily, thus `pairs(vim.fn)` only
|
||||
--- enumerates functions that were called at least once.
|
||||
---
|
||||
--- Note: The majority of functions cannot run in |api-fast| callbacks with some
|
||||
--- undocumented exceptions which are allowed.
|
||||
--- Note: The majority of functions cannot run in |api-fast| callbacks with some
|
||||
--- undocumented exceptions which are allowed.
|
||||
---
|
||||
--- *lua-vim-variables*
|
||||
---The Vim editor global dictionaries |g:| |w:| |b:| |t:| |v:| can be accessed
|
||||
---from Lua conveniently and idiomatically by referencing the `vim.*` Lua tables
|
||||
---described below. In this way you can easily read and modify global Vimscript
|
||||
---variables from Lua.
|
||||
--- *lua-vim-variables*
|
||||
--- The Vim editor global dictionaries |g:| |w:| |b:| |t:| |v:| can be accessed
|
||||
--- from Lua conveniently and idiomatically by referencing the `vim.*` Lua tables
|
||||
--- described below. In this way you can easily read and modify global Vimscript
|
||||
--- variables from Lua.
|
||||
---
|
||||
---Example: >lua
|
||||
--- Example: >lua
|
||||
---
|
||||
--- vim.g.foo = 5 -- Set the g:foo Vimscript variable.
|
||||
--- print(vim.g.foo) -- Get and print the g:foo Vimscript variable.
|
||||
--- vim.g.foo = nil -- Delete (:unlet) the Vimscript variable.
|
||||
--- vim.b[2].foo = 6 -- Set b:foo for buffer 2
|
||||
---<
|
||||
--- vim.g.foo = 5 -- Set the g:foo Vimscript variable.
|
||||
--- print(vim.g.foo) -- Get and print the g:foo Vimscript variable.
|
||||
--- vim.g.foo = nil -- Delete (:unlet) the Vimscript variable.
|
||||
--- vim.b[2].foo = 6 -- Set b:foo for buffer 2
|
||||
--- <
|
||||
---
|
||||
---Note that setting dictionary fields directly will not write them back into
|
||||
---Nvim. This is because the index into the namespace simply returns a copy.
|
||||
---Instead the whole dictionary must be written as one. This can be achieved by
|
||||
---creating a short-lived temporary.
|
||||
--- Note that setting dictionary fields directly will not write them back into
|
||||
--- Nvim. This is because the index into the namespace simply returns a copy.
|
||||
--- Instead the whole dictionary must be written as one. This can be achieved by
|
||||
--- creating a short-lived temporary.
|
||||
---
|
||||
---Example: >lua
|
||||
--- Example: >lua
|
||||
---
|
||||
--- vim.g.my_dict.field1 = 'value' -- Does not work
|
||||
--- vim.g.my_dict.field1 = 'value' -- Does not work
|
||||
---
|
||||
--- local my_dict = vim.g.my_dict --
|
||||
--- my_dict.field1 = 'value' -- Instead do
|
||||
--- vim.g.my_dict = my_dict --
|
||||
--- local my_dict = vim.g.my_dict --
|
||||
--- my_dict.field1 = 'value' -- Instead do
|
||||
--- vim.g.my_dict = my_dict --
|
||||
---
|
||||
---vim.g *vim.g*
|
||||
--- Global (|g:|) editor variables.
|
||||
--- Key with no value returns `nil`.
|
||||
--- vim.g *vim.g*
|
||||
--- Global (|g:|) editor variables.
|
||||
--- Key with no value returns `nil`.
|
||||
---
|
||||
---vim.b *vim.b*
|
||||
--- Buffer-scoped (|b:|) variables for the current buffer.
|
||||
--- Invalid or unset key returns `nil`. Can be indexed with
|
||||
--- an integer to access variables for a specific buffer.
|
||||
--- vim.b *vim.b*
|
||||
--- Buffer-scoped (|b:|) variables for the current buffer.
|
||||
--- Invalid or unset key returns `nil`. Can be indexed with
|
||||
--- an integer to access variables for a specific buffer.
|
||||
---
|
||||
---vim.w *vim.w*
|
||||
--- Window-scoped (|w:|) variables for the current window.
|
||||
--- Invalid or unset key returns `nil`. Can be indexed with
|
||||
--- an integer to access variables for a specific window.
|
||||
--- vim.w *vim.w*
|
||||
--- Window-scoped (|w:|) variables for the current window.
|
||||
--- Invalid or unset key returns `nil`. Can be indexed with
|
||||
--- an integer to access variables for a specific window.
|
||||
---
|
||||
---vim.t *vim.t*
|
||||
--- Tabpage-scoped (|t:|) variables for the current tabpage.
|
||||
--- Invalid or unset key returns `nil`. Can be indexed with
|
||||
--- an integer to access variables for a specific tabpage.
|
||||
--- vim.t *vim.t*
|
||||
--- Tabpage-scoped (|t:|) variables for the current tabpage.
|
||||
--- Invalid or unset key returns `nil`. Can be indexed with
|
||||
--- an integer to access variables for a specific tabpage.
|
||||
---
|
||||
---vim.v *vim.v*
|
||||
--- |v:| variables.
|
||||
--- Invalid or unset key returns `nil`.
|
||||
---</pre>
|
||||
--- vim.v *vim.v*
|
||||
--- |v:| variables.
|
||||
--- Invalid or unset key returns `nil`.
|
||||
--- </pre>
|
||||
|
||||
local api = vim.api
|
||||
|
||||
@@ -142,7 +139,6 @@ end
|
||||
--- vim.env.FOO = 'bar'
|
||||
--- print(vim.env.TERM)
|
||||
--- ```
|
||||
---
|
||||
---@param var string
|
||||
vim.env = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
@@ -205,31 +201,30 @@ local function new_win_opt_accessor(winid, bufnr)
|
||||
})
|
||||
end
|
||||
|
||||
---@addtogroup lua-vimscript
|
||||
---@brief <pre>help
|
||||
---` ` *lua-options*
|
||||
--- *lua-vim-options*
|
||||
--- *lua-vim-set*
|
||||
--- *lua-vim-setlocal*
|
||||
--- @brief <pre>help
|
||||
--- *lua-options*
|
||||
--- *lua-vim-options*
|
||||
--- *lua-vim-set*
|
||||
--- *lua-vim-setlocal*
|
||||
---
|
||||
---Vim options can be accessed through |vim.o|, which behaves like Vimscript
|
||||
---|:set|.
|
||||
--- Vim options can be accessed through |vim.o|, which behaves like Vimscript
|
||||
--- |:set|.
|
||||
---
|
||||
--- Examples: ~
|
||||
--- Examples: ~
|
||||
---
|
||||
--- To set a boolean toggle:
|
||||
--- Vimscript: `set number`
|
||||
--- Lua: `vim.o.number = true`
|
||||
--- To set a boolean toggle:
|
||||
--- Vimscript: `set number`
|
||||
--- Lua: `vim.o.number = true`
|
||||
---
|
||||
--- To set a string value:
|
||||
--- Vimscript: `set wildignore=*.o,*.a,__pycache__`
|
||||
--- Lua: `vim.o.wildignore = '*.o,*.a,__pycache__'`
|
||||
--- To set a string value:
|
||||
--- Vimscript: `set wildignore=*.o,*.a,__pycache__`
|
||||
--- Lua: `vim.o.wildignore = '*.o,*.a,__pycache__'`
|
||||
---
|
||||
---Similarly, there is |vim.bo| and |vim.wo| for setting buffer-scoped and
|
||||
---window-scoped options. Note that this must NOT be confused with
|
||||
---|local-options| and |:setlocal|. There is also |vim.go| that only accesses the
|
||||
---global value of a |global-local| option, see |:setglobal|.
|
||||
---</pre>
|
||||
--- Similarly, there is |vim.bo| and |vim.wo| for setting buffer-scoped and
|
||||
--- window-scoped options. Note that this must NOT be confused with
|
||||
--- |local-options| and |:setlocal|. There is also |vim.go| that only accesses the
|
||||
--- global value of a |global-local| option, see |:setglobal|.
|
||||
--- </pre>
|
||||
|
||||
--- Get or set |options|. Like `:set`. Invalid key is an error.
|
||||
---
|
||||
@@ -310,13 +305,10 @@ vim.bo = new_buf_opt_accessor()
|
||||
--- ```
|
||||
vim.wo = new_win_opt_accessor()
|
||||
|
||||
---@brief [[
|
||||
--- vim.opt, vim.opt_local and vim.opt_global implementation
|
||||
---
|
||||
--- To be used as helpers for working with options within neovim.
|
||||
--- For information on how to use, see :help vim.opt
|
||||
---
|
||||
---@brief ]]
|
||||
|
||||
--- Preserves the order and does not mutate the original list
|
||||
local function remove_duplicate_values(t)
|
||||
@@ -739,74 +731,73 @@ local function create_option_accessor(scope)
|
||||
})
|
||||
end
|
||||
|
||||
---@addtogroup lua-vimscript
|
||||
---@brief <pre>help
|
||||
---` ` *vim.opt_local*
|
||||
--- *vim.opt_global*
|
||||
--- *vim.opt*
|
||||
--- @brief <pre>help
|
||||
--- *vim.opt_local*
|
||||
--- *vim.opt_global*
|
||||
--- *vim.opt*
|
||||
---
|
||||
---
|
||||
---A special interface |vim.opt| exists for conveniently interacting with list-
|
||||
---and map-style option from Lua: It allows accessing them as Lua tables and
|
||||
---offers object-oriented method for adding and removing entries.
|
||||
--- A special interface |vim.opt| exists for conveniently interacting with list-
|
||||
--- and map-style option from Lua: It allows accessing them as Lua tables and
|
||||
--- offers object-oriented method for adding and removing entries.
|
||||
---
|
||||
--- Examples: ~
|
||||
--- Examples: ~
|
||||
---
|
||||
--- The following methods of setting a list-style option are equivalent:
|
||||
--- In Vimscript: >vim
|
||||
--- set wildignore=*.o,*.a,__pycache__
|
||||
---<
|
||||
--- In Lua using `vim.o`: >lua
|
||||
--- vim.o.wildignore = '*.o,*.a,__pycache__'
|
||||
---<
|
||||
--- In Lua using `vim.opt`: >lua
|
||||
--- vim.opt.wildignore = { '*.o', '*.a', '__pycache__' }
|
||||
---<
|
||||
--- To replicate the behavior of |:set+=|, use: >lua
|
||||
--- The following methods of setting a list-style option are equivalent:
|
||||
--- In Vimscript: >vim
|
||||
--- set wildignore=*.o,*.a,__pycache__
|
||||
--- <
|
||||
--- In Lua using `vim.o`: >lua
|
||||
--- vim.o.wildignore = '*.o,*.a,__pycache__'
|
||||
--- <
|
||||
--- In Lua using `vim.opt`: >lua
|
||||
--- vim.opt.wildignore = { '*.o', '*.a', '__pycache__' }
|
||||
--- <
|
||||
--- To replicate the behavior of |:set+=|, use: >lua
|
||||
---
|
||||
--- vim.opt.wildignore:append { "*.pyc", "node_modules" }
|
||||
---<
|
||||
--- To replicate the behavior of |:set^=|, use: >lua
|
||||
--- vim.opt.wildignore:append { "*.pyc", "node_modules" }
|
||||
--- <
|
||||
--- To replicate the behavior of |:set^=|, use: >lua
|
||||
---
|
||||
--- vim.opt.wildignore:prepend { "new_first_value" }
|
||||
---<
|
||||
--- To replicate the behavior of |:set-=|, use: >lua
|
||||
--- vim.opt.wildignore:prepend { "new_first_value" }
|
||||
--- <
|
||||
--- To replicate the behavior of |:set-=|, use: >lua
|
||||
---
|
||||
--- vim.opt.wildignore:remove { "node_modules" }
|
||||
---<
|
||||
--- The following methods of setting a map-style option are equivalent:
|
||||
--- In Vimscript: >vim
|
||||
--- set listchars=space:_,tab:>~
|
||||
---<
|
||||
--- In Lua using `vim.o`: >lua
|
||||
--- vim.o.listchars = 'space:_,tab:>~'
|
||||
---<
|
||||
--- In Lua using `vim.opt`: >lua
|
||||
--- vim.opt.listchars = { space = '_', tab = '>~' }
|
||||
---<
|
||||
--- vim.opt.wildignore:remove { "node_modules" }
|
||||
--- <
|
||||
--- The following methods of setting a map-style option are equivalent:
|
||||
--- In Vimscript: >vim
|
||||
--- set listchars=space:_,tab:>~
|
||||
--- <
|
||||
--- In Lua using `vim.o`: >lua
|
||||
--- vim.o.listchars = 'space:_,tab:>~'
|
||||
--- <
|
||||
--- In Lua using `vim.opt`: >lua
|
||||
--- vim.opt.listchars = { space = '_', tab = '>~' }
|
||||
--- <
|
||||
---
|
||||
---Note that |vim.opt| returns an `Option` object, not the value of the option,
|
||||
---which is accessed through |vim.opt:get()|:
|
||||
--- Note that |vim.opt| returns an `Option` object, not the value of the option,
|
||||
--- which is accessed through |vim.opt:get()|:
|
||||
---
|
||||
--- Examples: ~
|
||||
--- Examples: ~
|
||||
---
|
||||
--- The following methods of getting a list-style option are equivalent:
|
||||
--- In Vimscript: >vim
|
||||
--- echo wildignore
|
||||
---<
|
||||
--- In Lua using `vim.o`: >lua
|
||||
--- print(vim.o.wildignore)
|
||||
---<
|
||||
--- In Lua using `vim.opt`: >lua
|
||||
--- vim.print(vim.opt.wildignore:get())
|
||||
---<
|
||||
--- The following methods of getting a list-style option are equivalent:
|
||||
--- In Vimscript: >vim
|
||||
--- echo wildignore
|
||||
--- <
|
||||
--- In Lua using `vim.o`: >lua
|
||||
--- print(vim.o.wildignore)
|
||||
--- <
|
||||
--- In Lua using `vim.opt`: >lua
|
||||
--- vim.print(vim.opt.wildignore:get())
|
||||
--- <
|
||||
---
|
||||
---In any of the above examples, to replicate the behavior |:setlocal|, use
|
||||
---`vim.opt_local`. Additionally, to replicate the behavior of |:setglobal|, use
|
||||
---`vim.opt_global`.
|
||||
---</pre>
|
||||
--- In any of the above examples, to replicate the behavior |:setlocal|, use
|
||||
--- `vim.opt_local`. Additionally, to replicate the behavior of |:setglobal|, use
|
||||
--- `vim.opt_global`.
|
||||
--- </pre>
|
||||
|
||||
--- @diagnostic disable-next-line:unused-local used for gen_vimdoc
|
||||
--- @class vim.Option
|
||||
local Option = {} -- luacheck: no unused
|
||||
|
||||
--- Returns a Lua-representation of the option. Boolean, number and string
|
||||
@@ -856,9 +847,7 @@ local Option = {} -- luacheck: no unused
|
||||
--- print("J is enabled!")
|
||||
--- end
|
||||
--- ```
|
||||
---
|
||||
---@return string|integer|boolean|nil value of option
|
||||
---@diagnostic disable-next-line:unused-local used for gen_vimdoc
|
||||
function Option:get() end
|
||||
|
||||
--- Append a value to string-style options. See |:set+=|
|
||||
@@ -869,7 +858,6 @@ function Option:get() end
|
||||
--- vim.opt.formatoptions:append('j')
|
||||
--- vim.opt.formatoptions = vim.opt.formatoptions + 'j'
|
||||
--- ```
|
||||
---
|
||||
---@param value string Value to append
|
||||
---@diagnostic disable-next-line:unused-local used for gen_vimdoc
|
||||
function Option:append(value) end -- luacheck: no unused
|
||||
@@ -882,7 +870,6 @@ function Option:append(value) end -- luacheck: no unused
|
||||
--- vim.opt.wildignore:prepend('*.o')
|
||||
--- vim.opt.wildignore = vim.opt.wildignore ^ '*.o'
|
||||
--- ```
|
||||
---
|
||||
---@param value string Value to prepend
|
||||
---@diagnostic disable-next-line:unused-local used for gen_vimdoc
|
||||
function Option:prepend(value) end -- luacheck: no unused
|
||||
@@ -895,7 +882,6 @@ function Option:prepend(value) end -- luacheck: no unused
|
||||
--- vim.opt.wildignore:remove('*.pyc')
|
||||
--- vim.opt.wildignore = vim.opt.wildignore - '*.pyc'
|
||||
--- ```
|
||||
---
|
||||
---@param value string Value to remove
|
||||
---@diagnostic disable-next-line:unused-local used for gen_vimdoc
|
||||
function Option:remove(value) end -- luacheck: no unused
|
||||
|
||||
@@ -70,6 +70,7 @@ local M = {}
|
||||
--- @field linehl? table<vim.diagnostic.Severity,string>
|
||||
--- @field texthl? table<vim.diagnostic.Severity,string>
|
||||
|
||||
--- @nodoc
|
||||
--- @enum vim.diagnostic.Severity
|
||||
M.severity = {
|
||||
ERROR = 1,
|
||||
@@ -107,6 +108,7 @@ local global_diagnostic_options = {
|
||||
--- @field show? fun(namespace: integer, bufnr: integer, diagnostics: vim.Diagnostic[], opts?: vim.diagnostic.OptsResolved)
|
||||
--- @field hide? fun(namespace:integer, bufnr:integer)
|
||||
|
||||
--- @nodoc
|
||||
--- @type table<string,vim.diagnostic.Handler>
|
||||
M.handlers = setmetatable({}, {
|
||||
__newindex = function(t, name, handler)
|
||||
@@ -731,71 +733,71 @@ end
|
||||
--- - `function`: Function with signature (namespace, bufnr) that returns any of the above.
|
||||
---
|
||||
---@param opts vim.diagnostic.Opts? (table?) When omitted or "nil", retrieve the current
|
||||
--- configuration. Otherwise, a configuration table with the following keys:
|
||||
--- configuration. Otherwise, a configuration table with the following keys:
|
||||
--- - underline: (default true) Use underline for diagnostics. Options:
|
||||
--- * severity: Only underline diagnostics matching the given
|
||||
--- severity |diagnostic-severity|
|
||||
--- * severity: Only underline diagnostics matching the given
|
||||
--- severity |diagnostic-severity|
|
||||
--- - virtual_text: (default true) Use virtual text for diagnostics. If multiple diagnostics
|
||||
--- are set for a namespace, one prefix per diagnostic + the last diagnostic
|
||||
--- message are shown. In addition to the options listed below, the
|
||||
--- "virt_text" options of |nvim_buf_set_extmark()| may also be used here
|
||||
--- (e.g. "virt_text_pos" and "hl_mode").
|
||||
--- Options:
|
||||
--- * severity: Only show virtual text for diagnostics matching the given
|
||||
--- severity |diagnostic-severity|
|
||||
--- * source: (boolean or string) Include the diagnostic source in virtual
|
||||
--- text. Use "if_many" to only show sources if there is more than
|
||||
--- one diagnostic source in the buffer. Otherwise, any truthy value
|
||||
--- means to always show the diagnostic source.
|
||||
--- * spacing: (number) Amount of empty spaces inserted at the beginning
|
||||
--- of the virtual text.
|
||||
--- * prefix: (string or function) prepend diagnostic message with prefix.
|
||||
--- If a function, it must have the signature (diagnostic, i, total)
|
||||
--- -> string, where {diagnostic} is of type |diagnostic-structure|,
|
||||
--- {i} is the index of the diagnostic being evaluated, and {total}
|
||||
--- is the total number of diagnostics for the line. This can be
|
||||
--- used to render diagnostic symbols or error codes.
|
||||
--- * suffix: (string or function) Append diagnostic message with suffix.
|
||||
--- If a function, it must have the signature (diagnostic) ->
|
||||
--- string, where {diagnostic} is of type |diagnostic-structure|.
|
||||
--- This can be used to render an LSP diagnostic error code.
|
||||
--- * 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. Example:
|
||||
--- <pre>lua
|
||||
--- function(diagnostic)
|
||||
--- if diagnostic.severity == vim.diagnostic.severity.ERROR then
|
||||
--- return string.format("E: %s", diagnostic.message)
|
||||
--- end
|
||||
--- return diagnostic.message
|
||||
--- end
|
||||
--- </pre>
|
||||
--- are set for a namespace, one prefix per diagnostic + the last diagnostic
|
||||
--- message are shown. In addition to the options listed below, the
|
||||
--- "virt_text" options of |nvim_buf_set_extmark()| may also be used here
|
||||
--- (e.g. "virt_text_pos" and "hl_mode").
|
||||
--- Options:
|
||||
--- * severity: Only show virtual text for diagnostics matching the given
|
||||
--- severity |diagnostic-severity|
|
||||
--- * source: (boolean or string) Include the diagnostic source in virtual
|
||||
--- text. Use "if_many" to only show sources if there is more than
|
||||
--- one diagnostic source in the buffer. Otherwise, any truthy value
|
||||
--- means to always show the diagnostic source.
|
||||
--- * spacing: (number) Amount of empty spaces inserted at the beginning
|
||||
--- of the virtual text.
|
||||
--- * prefix: (string or function) prepend diagnostic message with prefix.
|
||||
--- If a function, it must have the signature (diagnostic, i, total)
|
||||
--- -> string, where {diagnostic} is of type |diagnostic-structure|,
|
||||
--- {i} is the index of the diagnostic being evaluated, and {total}
|
||||
--- is the total number of diagnostics for the line. This can be
|
||||
--- used to render diagnostic symbols or error codes.
|
||||
--- * suffix: (string or function) Append diagnostic message with suffix.
|
||||
--- If a function, it must have the signature (diagnostic) ->
|
||||
--- string, where {diagnostic} is of type |diagnostic-structure|.
|
||||
--- This can be used to render an LSP diagnostic error code.
|
||||
--- * 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. Example:
|
||||
--- ```lua
|
||||
--- function(diagnostic)
|
||||
--- if diagnostic.severity == vim.diagnostic.severity.ERROR then
|
||||
--- return string.format("E: %s", diagnostic.message)
|
||||
--- end
|
||||
--- return diagnostic.message
|
||||
--- end
|
||||
--- ```
|
||||
--- - signs: (default true) Use signs for diagnostics |diagnostic-signs|. Options:
|
||||
--- * severity: Only show signs for diagnostics matching the given
|
||||
--- severity |diagnostic-severity|
|
||||
--- * priority: (number, default 10) Base priority to use for signs. When
|
||||
--- {severity_sort} is used, the priority of a sign is adjusted based on
|
||||
--- its severity. Otherwise, all signs use the same priority.
|
||||
--- * text: (table) A table mapping |diagnostic-severity| to the sign text
|
||||
--- to display in the sign column. The default is to use "E", "W", "I", and "H"
|
||||
--- for errors, warnings, information, and hints, respectively. Example:
|
||||
--- <pre>lua
|
||||
--- vim.diagnostic.config({
|
||||
--- signs = { text = { [vim.diagnostic.severity.ERROR] = 'E', ... } }
|
||||
--- })
|
||||
--- </pre>
|
||||
--- * numhl: (table) A table mapping |diagnostic-severity| to the highlight
|
||||
--- group used for the line number where the sign is placed.
|
||||
--- * linehl: (table) A table mapping |diagnostic-severity| to the highlight group
|
||||
--- used for the whole line the sign is placed in.
|
||||
--- * severity: Only show signs for diagnostics matching the given
|
||||
--- severity |diagnostic-severity|
|
||||
--- * priority: (number, default 10) Base priority to use for signs. When
|
||||
--- {severity_sort} is used, the priority of a sign is adjusted based on
|
||||
--- its severity. Otherwise, all signs use the same priority.
|
||||
--- * text: (table) A table mapping |diagnostic-severity| to the sign text
|
||||
--- to display in the sign column. The default is to use "E", "W", "I", and "H"
|
||||
--- for errors, warnings, information, and hints, respectively. Example:
|
||||
--- ```lua
|
||||
--- vim.diagnostic.config({
|
||||
--- signs = { text = { [vim.diagnostic.severity.ERROR] = 'E', ... } }
|
||||
--- })
|
||||
--- ```
|
||||
--- * numhl: (table) A table mapping |diagnostic-severity| to the highlight
|
||||
--- group used for the line number where the sign is placed.
|
||||
--- * linehl: (table) A table mapping |diagnostic-severity| to the highlight group
|
||||
--- used for the whole line the sign is placed in.
|
||||
--- - float: Options for floating windows. See |vim.diagnostic.open_float()|.
|
||||
--- - update_in_insert: (default false) Update diagnostics in Insert mode (if false,
|
||||
--- diagnostics are updated on InsertLeave)
|
||||
--- - severity_sort: (default false) Sort diagnostics by severity. This affects the order in
|
||||
--- which signs and virtual text are displayed. When true, higher severities
|
||||
--- are displayed before lower severities (e.g. ERROR is displayed before WARN).
|
||||
--- Options:
|
||||
--- * reverse: (boolean) Reverse sort order
|
||||
--- which signs and virtual text are displayed. When true, higher severities
|
||||
--- are displayed before lower severities (e.g. ERROR is displayed before WARN).
|
||||
--- Options:
|
||||
--- * reverse: (boolean) Reverse sort order
|
||||
---
|
||||
---@param namespace integer? Update the options for the given namespace. When omitted, update the
|
||||
--- global diagnostic options.
|
||||
@@ -1090,8 +1092,8 @@ M.handlers.signs = {
|
||||
api.nvim_create_namespace(string.format('%s/diagnostic/signs', ns.name))
|
||||
end
|
||||
|
||||
--- Handle legacy diagnostic sign definitions
|
||||
--- These were deprecated in 0.10 and will be removed in 0.12
|
||||
-- Handle legacy diagnostic sign definitions
|
||||
-- These were deprecated in 0.10 and will be removed in 0.12
|
||||
if opts.signs and not opts.signs.text and not opts.signs.numhl and not opts.signs.texthl then
|
||||
for _, v in ipairs({ 'Error', 'Warn', 'Info', 'Hint' }) do
|
||||
local name = string.format('DiagnosticSign%s', v)
|
||||
@@ -1543,7 +1545,8 @@ end
|
||||
--- Overrides the setting from |vim.diagnostic.config()|.
|
||||
--- - suffix: Same as {prefix}, but appends the text to the diagnostic instead of
|
||||
--- prepending it. Overrides the setting from |vim.diagnostic.config()|.
|
||||
---@return integer?, integer?: ({float_bufnr}, {win_id})
|
||||
---@return integer? float_bufnr
|
||||
---@return integer? win_id
|
||||
function M.open_float(opts, ...)
|
||||
-- Support old (bufnr, opts) signature
|
||||
local bufnr --- @type integer?
|
||||
|
||||
@@ -2279,9 +2279,9 @@ end
|
||||
--- Perform filetype detection.
|
||||
---
|
||||
--- The filetype can be detected using one of three methods:
|
||||
--- 1. Using an existing buffer
|
||||
--- 2. Using only a file name
|
||||
--- 3. Using only file contents
|
||||
--- 1. Using an existing buffer
|
||||
--- 2. Using only a file name
|
||||
--- 3. Using only file contents
|
||||
---
|
||||
--- Of these, option 1 provides the most accurate result as it uses both the buffer's filename and
|
||||
--- (optionally) the buffer contents. Options 2 and 3 can be used without an existing buffer, but
|
||||
|
||||
@@ -320,7 +320,7 @@ end
|
||||
|
||||
--- Normalize a path to a standard format. A tilde (~) character at the
|
||||
--- beginning of the path is expanded to the user's home directory and any
|
||||
--- backslash (\\) characters are converted to forward slashes (/). Environment
|
||||
--- backslash (\) characters are converted to forward slashes (/). Environment
|
||||
--- variables are also expanded.
|
||||
---
|
||||
--- Examples:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
---@defgroup vim.highlight
|
||||
---@brief
|
||||
---
|
||||
--- Nvim includes a function for highlighting a selection on yank.
|
||||
---
|
||||
@@ -19,18 +19,19 @@
|
||||
--- ```vim
|
||||
--- au TextYankPost * silent! lua vim.highlight.on_yank {on_visual=false}
|
||||
--- ```
|
||||
---
|
||||
|
||||
local api = vim.api
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Table with default priorities used for highlighting:
|
||||
--- - `syntax`: `50`, used for standard syntax highlighting
|
||||
--- - `treesitter`: `100`, used for treesitter-based highlighting
|
||||
--- - `semantic_tokens`: `125`, used for LSP semantic token highlighting
|
||||
--- - `diagnostics`: `150`, used for code analysis such as diagnostics
|
||||
--- - `user`: `200`, used for user-triggered highlights such as LSP document
|
||||
--- symbols or `on_yank` autocommands
|
||||
--- - `syntax`: `50`, used for standard syntax highlighting
|
||||
--- - `treesitter`: `100`, used for treesitter-based highlighting
|
||||
--- - `semantic_tokens`: `125`, used for LSP semantic token highlighting
|
||||
--- - `diagnostics`: `150`, used for code analysis such as diagnostics
|
||||
--- - `user`: `200`, used for user-triggered highlights such as LSP document
|
||||
--- symbols or `on_yank` autocommands
|
||||
M.priorities = {
|
||||
syntax = 50,
|
||||
treesitter = 100,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
---@defgroup vim.iter
|
||||
--- @brief
|
||||
---
|
||||
--- \*vim.iter()\* is an interface for |iterable|s: it wraps a table or function argument into an
|
||||
--- \*Iter\* object with methods (such as |Iter:filter()| and |Iter:map()|) that transform the
|
||||
@@ -66,6 +66,7 @@
|
||||
|
||||
---@class IterMod
|
||||
---@operator call:Iter
|
||||
|
||||
local M = {}
|
||||
|
||||
---@class Iter
|
||||
@@ -599,7 +600,7 @@ end
|
||||
--- -- 12
|
||||
---
|
||||
--- ```
|
||||
---
|
||||
---@param f any
|
||||
---@return any
|
||||
function Iter.find(self, f)
|
||||
if type(f) ~= 'function' then
|
||||
@@ -645,6 +646,7 @@ end
|
||||
---
|
||||
---@see Iter.find
|
||||
---
|
||||
---@param f any
|
||||
---@return any
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
function Iter.rfind(self, f) -- luacheck: no unused args
|
||||
@@ -724,6 +726,7 @@ function Iter.nextback(self) -- luacheck: no unused args
|
||||
error('nextback() requires a list-like table')
|
||||
end
|
||||
|
||||
--- @nodoc
|
||||
function ListIter.nextback(self)
|
||||
if self._head ~= self._tail then
|
||||
local inc = self._head < self._tail and 1 or -1
|
||||
@@ -754,6 +757,7 @@ function Iter.peekback(self) -- luacheck: no unused args
|
||||
error('peekback() requires a list-like table')
|
||||
end
|
||||
|
||||
---@nodoc
|
||||
function ListIter.peekback(self)
|
||||
if self._head ~= self._tail then
|
||||
local inc = self._head < self._tail and 1 or -1
|
||||
|
||||
@@ -90,6 +90,8 @@ end
|
||||
--- vim.keymap.del({'n', 'i', 'v'}, '<leader>w', { buffer = 5 })
|
||||
--- ```
|
||||
---
|
||||
---@param modes string|string[]
|
||||
---@param lhs string
|
||||
---@param opts table|nil A table of optional arguments:
|
||||
--- - "buffer": (integer|boolean) Remove a mapping from the given buffer.
|
||||
--- When `0` or `true`, use the current buffer.
|
||||
|
||||
@@ -190,7 +190,6 @@ function Loader.loader_lib(modname)
|
||||
local sysname = uv.os_uname().sysname:lower() or ''
|
||||
local is_win = sysname:find('win', 1, true) and not sysname:find('darwin', 1, true)
|
||||
local ret = M.find(modname, { patterns = is_win and { '.dll' } or { '.so' } })[1]
|
||||
---@type function?, string?
|
||||
if ret then
|
||||
-- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is
|
||||
-- a) strip prefix up to and including the first dash, if any
|
||||
@@ -208,15 +207,13 @@ end
|
||||
--- `loadfile` using the cache
|
||||
--- Note this has the mode and env arguments which is supported by LuaJIT and is 5.1 compatible.
|
||||
---@param filename? string
|
||||
---@param mode? "b"|"t"|"bt"
|
||||
---@param _mode? "b"|"t"|"bt"
|
||||
---@param env? table
|
||||
---@return function?, string? error_message
|
||||
---@private
|
||||
-- luacheck: ignore 312
|
||||
function Loader.loadfile(filename, mode, env)
|
||||
function Loader.loadfile(filename, _mode, env)
|
||||
-- ignore mode, since we byte-compile the Lua source files
|
||||
mode = nil
|
||||
return Loader.load(normalize(filename), { mode = mode, env = env })
|
||||
return Loader.load(normalize(filename), { env = env })
|
||||
end
|
||||
|
||||
--- Checks whether two cache hashes are the same based on:
|
||||
@@ -273,14 +270,14 @@ end
|
||||
|
||||
--- Finds Lua modules for the given module name.
|
||||
---@param modname string Module name, or `"*"` to find the top-level modules instead
|
||||
---@param opts? ModuleFindOpts (table|nil) Options for finding a module:
|
||||
---@param opts? ModuleFindOpts (table) Options for finding a module:
|
||||
--- - rtp: (boolean) Search for modname in the runtime path (defaults to `true`)
|
||||
--- - paths: (string[]) Extra paths to search for modname (defaults to `{}`)
|
||||
--- - patterns: (string[]) List of patterns to use when searching for modules.
|
||||
--- A pattern is a string added to the basename of the Lua module being searched.
|
||||
--- (defaults to `{"/init.lua", ".lua"}`)
|
||||
--- - all: (boolean) Return all matches instead of just the first one (defaults to `false`)
|
||||
---@return ModuleInfo[] (list) A list of results with the following properties:
|
||||
---@return ModuleInfo[] (table) A list of results with the following properties:
|
||||
--- - modpath: (string) the path to the module
|
||||
--- - modname: (string) the name of the module
|
||||
--- - stat: (table|nil) the fs_stat of the module path. Won't be returned for `modname="*"`
|
||||
|
||||
@@ -206,99 +206,96 @@ end
|
||||
--- |vim.lsp.get_client_by_id()| or |vim.lsp.get_clients()|.
|
||||
---
|
||||
--- - Methods:
|
||||
--- - request(method, params, [handler], bufnr)
|
||||
--- Sends a request to the server.
|
||||
--- This is a thin wrapper around {client.rpc.request} with some additional
|
||||
--- checking.
|
||||
--- If {handler} is not specified, If one is not found there, then an error will occur.
|
||||
--- Returns: {status}, {[client_id]}. {status} is a boolean indicating if
|
||||
--- the notification was successful. If it is `false`, then it will always
|
||||
--- be `false` (the client has shutdown).
|
||||
--- If {status} is `true`, the function returns {request_id} as the second
|
||||
--- result. You can use this with `client.cancel_request(request_id)`
|
||||
--- to cancel the request.
|
||||
---
|
||||
--- - request(method, params, [handler], bufnr)
|
||||
--- Sends a request to the server.
|
||||
--- This is a thin wrapper around {client.rpc.request} with some additional
|
||||
--- checking.
|
||||
--- If {handler} is not specified, If one is not found there, then an error will occur.
|
||||
--- Returns: {status}, {[client_id]}. {status} is a boolean indicating if
|
||||
--- the notification was successful. If it is `false`, then it will always
|
||||
--- be `false` (the client has shutdown).
|
||||
--- If {status} is `true`, the function returns {request_id} as the second
|
||||
--- result. You can use this with `client.cancel_request(request_id)`
|
||||
--- to cancel the request.
|
||||
--- - request_sync(method, params, timeout_ms, bufnr)
|
||||
--- Sends a request to the server and synchronously waits for the response.
|
||||
--- This is a wrapper around {client.request}
|
||||
--- Returns: { err=err, result=result }, a dictionary, where `err` and `result` come from
|
||||
--- the |lsp-handler|. On timeout, cancel or error, returns `(nil, err)` where `err` is a
|
||||
--- string describing the failure reason. If the request was unsuccessful returns `nil`.
|
||||
---
|
||||
--- - request_sync(method, params, timeout_ms, bufnr)
|
||||
--- Sends a request to the server and synchronously waits for the response.
|
||||
--- This is a wrapper around {client.request}
|
||||
--- Returns: { err=err, result=result }, a dictionary, where `err` and `result` come from
|
||||
--- the |lsp-handler|. On timeout, cancel or error, returns `(nil, err)` where `err` is a
|
||||
--- string describing the failure reason. If the request was unsuccessful returns `nil`.
|
||||
--- - notify(method, params)
|
||||
--- Sends a notification to an LSP server.
|
||||
--- Returns: a boolean to indicate if the notification was successful. If
|
||||
--- it is false, then it will always be false (the client has shutdown).
|
||||
---
|
||||
--- - notify(method, params)
|
||||
--- Sends a notification to an LSP server.
|
||||
--- Returns: a boolean to indicate if the notification was successful. If
|
||||
--- it is false, then it will always be false (the client has shutdown).
|
||||
--- - cancel_request(id)
|
||||
--- Cancels a request with a given request id.
|
||||
--- Returns: same as `notify()`.
|
||||
---
|
||||
--- - cancel_request(id)
|
||||
--- Cancels a request with a given request id.
|
||||
--- Returns: same as `notify()`.
|
||||
--- - stop([force])
|
||||
--- Stops a client, optionally with force.
|
||||
--- By default, it will just ask the server to shutdown without force.
|
||||
--- If you request to stop a client which has previously been requested to
|
||||
--- shutdown, it will automatically escalate and force shutdown.
|
||||
---
|
||||
--- - stop([force])
|
||||
--- Stops a client, optionally with force.
|
||||
--- By default, it will just ask the server to shutdown without force.
|
||||
--- If you request to stop a client which has previously been requested to
|
||||
--- shutdown, it will automatically escalate and force shutdown.
|
||||
--- - is_stopped()
|
||||
--- Checks whether a client is stopped.
|
||||
--- Returns: true if the client is fully stopped.
|
||||
---
|
||||
--- - is_stopped()
|
||||
--- Checks whether a client is stopped.
|
||||
--- Returns: true if the client is fully stopped.
|
||||
--- - on_attach(client, bufnr)
|
||||
--- Runs the on_attach function from the client's config if it was defined.
|
||||
--- Useful for buffer-local setup.
|
||||
---
|
||||
--- - on_attach(client, bufnr)
|
||||
--- Runs the on_attach function from the client's config if it was defined.
|
||||
--- Useful for buffer-local setup.
|
||||
---
|
||||
--- - supports_method(method, [opts]): boolean
|
||||
--- Checks if a client supports a given method.
|
||||
--- Always returns true for unknown off-spec methods.
|
||||
--- [opts] is a optional `{bufnr?: integer}` table.
|
||||
--- Some language server capabilities can be file specific.
|
||||
--- - supports_method(method, [opts]): boolean
|
||||
--- Checks if a client supports a given method.
|
||||
--- Always returns true for unknown off-spec methods.
|
||||
--- [opts] is a optional `{bufnr?: integer}` table.
|
||||
--- Some language server capabilities can be file specific.
|
||||
---
|
||||
--- - Members
|
||||
--- - {id} (number): The id allocated to the client.
|
||||
--- - {id} (number): The id allocated to the client.
|
||||
---
|
||||
--- - {name} (string): If a name is specified on creation, that will be
|
||||
--- used. Otherwise it is just the client id. This is used for
|
||||
--- logs and messages.
|
||||
--- - {name} (string): If a name is specified on creation, that will be
|
||||
--- used. Otherwise it is just the client id. This is used for
|
||||
--- logs and messages.
|
||||
---
|
||||
--- - {rpc} (table): RPC client object, for low level interaction with the
|
||||
--- client. See |vim.lsp.rpc.start()|.
|
||||
--- - {rpc} (table): RPC client object, for low level interaction with the
|
||||
--- client. See |vim.lsp.rpc.start()|.
|
||||
---
|
||||
--- - {offset_encoding} (string): The encoding used for communicating
|
||||
--- with the server. You can modify this in the `config`'s `on_init` method
|
||||
--- before text is sent to the server.
|
||||
--- - {offset_encoding} (string): The encoding used for communicating
|
||||
--- with the server. You can modify this in the `config`'s `on_init` method
|
||||
--- before text is sent to the server.
|
||||
---
|
||||
--- - {handlers} (table): The handlers used by the client as described in |lsp-handler|.
|
||||
--- - {handlers} (table): The handlers used by the client as described in |lsp-handler|.
|
||||
---
|
||||
--- - {commands} (table): Table of command name to function which is called if
|
||||
--- any LSP action (code action, code lenses, ...) triggers the command.
|
||||
--- Client commands take precedence over the global command registry.
|
||||
--- - {commands} (table): Table of command name to function which is called if
|
||||
--- any LSP action (code action, code lenses, ...) triggers the command.
|
||||
--- Client commands take precedence over the global command registry.
|
||||
---
|
||||
--- - {requests} (table): The current pending requests in flight
|
||||
--- to the server. Entries are key-value pairs with the key
|
||||
--- being the request ID while the value is a table with `type`,
|
||||
--- `bufnr`, and `method` key-value pairs. `type` is either "pending"
|
||||
--- for an active request, or "cancel" for a cancel request. It will
|
||||
--- be "complete" ephemerally while executing |LspRequest| autocmds
|
||||
--- when replies are received from the server.
|
||||
--- - {requests} (table): The current pending requests in flight
|
||||
--- to the server. Entries are key-value pairs with the key
|
||||
--- being the request ID while the value is a table with `type`,
|
||||
--- `bufnr`, and `method` key-value pairs. `type` is either "pending"
|
||||
--- for an active request, or "cancel" for a cancel request. It will
|
||||
--- be "complete" ephemerally while executing |LspRequest| autocmds
|
||||
--- when replies are received from the server.
|
||||
---
|
||||
--- - {config} (table): Reference of the table that was passed by the user
|
||||
--- to |vim.lsp.start_client()|.
|
||||
--- - {config} (table): Reference of the table that was passed by the user
|
||||
--- to |vim.lsp.start_client()|.
|
||||
---
|
||||
--- - {server_capabilities} (table): Response from the server sent on
|
||||
--- `initialize` describing the server's capabilities.
|
||||
--- - {server_capabilities} (table): Response from the server sent on
|
||||
--- `initialize` describing the server's capabilities.
|
||||
---
|
||||
--- - {progress} A ring buffer (|vim.ringbuf()|) containing progress messages
|
||||
--- sent by the server.
|
||||
--- - {progress} A ring buffer (|vim.ringbuf()|) containing progress messages
|
||||
--- sent by the server.
|
||||
---
|
||||
--- - {settings} Map with language server specific settings.
|
||||
--- See {config} in |vim.lsp.start_client()|
|
||||
--- - {settings} Map with language server specific settings.
|
||||
--- See {config} in |vim.lsp.start_client()|
|
||||
---
|
||||
--- - {flags} A table with flags for the client. See {config} in |vim.lsp.start_client()|
|
||||
function lsp.client()
|
||||
error()
|
||||
end
|
||||
--- - {flags} A table with flags for the client. See {config} in |vim.lsp.start_client()|
|
||||
lsp.client = nil
|
||||
|
||||
--- @class lsp.StartOpts
|
||||
--- @field reuse_client fun(client: lsp.Client, config: table): boolean
|
||||
@@ -581,9 +578,9 @@ end
|
||||
--- spawn. Must be specified using a table.
|
||||
--- Non-string values are coerced to string.
|
||||
--- Example:
|
||||
--- <pre>
|
||||
--- { PORT = 8080; HOST = "0.0.0.0"; }
|
||||
--- </pre>
|
||||
--- ```
|
||||
--- { PORT = 8080; HOST = "0.0.0.0"; }
|
||||
--- ```
|
||||
---
|
||||
--- - detached: (boolean, default true) Daemonize the server process so that it runs in a
|
||||
--- separate process group from Nvim. Nvim will shutdown the process on exit, but if Nvim fails to
|
||||
@@ -598,8 +595,9 @@ end
|
||||
--- \|vim.lsp.protocol.make_client_capabilities()|, passed to the language
|
||||
--- server on initialization. Hint: use make_client_capabilities() and modify
|
||||
--- its result.
|
||||
--- - Note: To send an empty dictionary use |vim.empty_dict()|, else it will be encoded as an
|
||||
--- array.
|
||||
---
|
||||
--- - Note: To send an empty dictionary use |vim.empty_dict()|, else it will be encoded as an
|
||||
--- array.
|
||||
---
|
||||
--- - handlers: Map of language server method names to |lsp-handler|
|
||||
---
|
||||
@@ -645,9 +643,9 @@ end
|
||||
---
|
||||
--- - on_exit Callback (code, signal, client_id) invoked on client
|
||||
--- exit.
|
||||
--- - code: exit code of the process
|
||||
--- - signal: number describing the signal used to terminate (if any)
|
||||
--- - client_id: client handle
|
||||
--- - code: exit code of the process
|
||||
--- - signal: number describing the signal used to terminate (if any)
|
||||
--- - client_id: client handle
|
||||
---
|
||||
--- - on_attach: Callback (client, bufnr) invoked when client
|
||||
--- attaches to a buffer.
|
||||
@@ -656,13 +654,13 @@ end
|
||||
--- server in the initialize request. Invalid/empty values will default to "off"
|
||||
---
|
||||
--- - flags: A table with flags for the client. The current (experimental) flags are:
|
||||
--- - allow_incremental_sync (bool, default true): Allow using incremental sync for buffer edits
|
||||
--- - debounce_text_changes (number, default 150): Debounce didChange
|
||||
--- notifications to the server by the given number in milliseconds. No debounce
|
||||
--- occurs if nil
|
||||
--- - exit_timeout (number|boolean, default false): Milliseconds to wait for server to
|
||||
--- exit cleanly after sending the "shutdown" request before sending kill -15.
|
||||
--- If set to false, nvim exits immediately after sending the "shutdown" request to the server.
|
||||
--- - allow_incremental_sync (bool, default true): Allow using incremental sync for buffer edits
|
||||
--- - debounce_text_changes (number, default 150): Debounce didChange
|
||||
--- notifications to the server by the given number in milliseconds. No debounce
|
||||
--- occurs if nil
|
||||
--- - exit_timeout (number|boolean, default false): Milliseconds to wait for server to
|
||||
--- exit cleanly after sending the "shutdown" request before sending kill -15.
|
||||
--- If set to false, nvim exits immediately after sending the "shutdown" request to the server.
|
||||
---
|
||||
--- - root_dir: (string) Directory where the LSP
|
||||
--- server will base its workspaceFolders, rootUri, and rootPath
|
||||
@@ -1239,7 +1237,7 @@ end
|
||||
---
|
||||
--- Currently only supports a single client. This can be set via
|
||||
--- `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach`
|
||||
--- via ``vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})'``.
|
||||
--- via `vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})'`.
|
||||
---
|
||||
---@param opts table options for customizing the formatting expression which takes the
|
||||
--- following optional keys:
|
||||
|
||||
@@ -12,7 +12,7 @@ local M = {}
|
||||
---@param method (string) LSP method name
|
||||
---@param params (table|nil) Parameters to send to the server
|
||||
---@param handler (function|nil) See |lsp-handler|. Follows |lsp-handler-resolution|
|
||||
--
|
||||
---
|
||||
---@return table<integer, integer> client_request_ids Map of client-id:request-id pairs
|
||||
---for all successful requests.
|
||||
---@return function _cancel_all_requests Function which can be used to
|
||||
@@ -172,12 +172,13 @@ end
|
||||
---
|
||||
--- - filter (function|nil):
|
||||
--- Predicate used to filter clients. Receives a client as argument and must return a
|
||||
--- boolean. Clients matching the predicate are included. Example: <pre>lua
|
||||
--- -- Never request typescript-language-server for formatting
|
||||
--- vim.lsp.buf.format {
|
||||
--- filter = function(client) return client.name ~= "tsserver" end
|
||||
--- }
|
||||
--- </pre>
|
||||
--- boolean. Clients matching the predicate are included. Example:
|
||||
--- ```lua
|
||||
--- -- Never request typescript-language-server for formatting
|
||||
--- vim.lsp.buf.format {
|
||||
--- filter = function(client) return client.name ~= "tsserver" end
|
||||
--- }
|
||||
--- ```
|
||||
---
|
||||
--- - async boolean|nil
|
||||
--- If true the method won't block. Defaults to false.
|
||||
@@ -472,6 +473,7 @@ end
|
||||
|
||||
--- Add the folder at path to the workspace folders. If {path} is
|
||||
--- not provided, the user will be prompted for a path using |input()|.
|
||||
--- @param workspace_folder? string
|
||||
function M.add_workspace_folder(workspace_folder)
|
||||
workspace_folder = workspace_folder
|
||||
or npcall(vim.fn.input, 'Workspace Folder: ', vim.fn.expand('%:p:h'), 'dir')
|
||||
@@ -511,6 +513,7 @@ end
|
||||
--- Remove the folder at path from the workspace folders. If
|
||||
--- {path} is not provided, the user will be prompted for
|
||||
--- a path using |input()|.
|
||||
--- @param workspace_folder? string
|
||||
function M.remove_workspace_folder(workspace_folder)
|
||||
workspace_folder = workspace_folder
|
||||
or npcall(vim.fn.input, 'Workspace Folder: ', vim.fn.expand('%:p:h'))
|
||||
@@ -725,15 +728,15 @@ end
|
||||
---
|
||||
---@param options table|nil Optional table which holds the following optional fields:
|
||||
--- - context: (table|nil)
|
||||
--- Corresponds to `CodeActionContext` of the LSP specification:
|
||||
--- - diagnostics (table|nil):
|
||||
--- LSP `Diagnostic[]`. Inferred from the current
|
||||
--- position if not provided.
|
||||
--- - only (table|nil):
|
||||
--- List of LSP `CodeActionKind`s used to filter the code actions.
|
||||
--- Most language servers support values like `refactor`
|
||||
--- or `quickfix`.
|
||||
--- - triggerKind (number|nil): The reason why code actions were requested.
|
||||
--- Corresponds to `CodeActionContext` of the LSP specification:
|
||||
--- - diagnostics (table|nil):
|
||||
--- LSP `Diagnostic[]`. Inferred from the current
|
||||
--- position if not provided.
|
||||
--- - only (table|nil):
|
||||
--- List of LSP `CodeActionKind`s used to filter the code actions.
|
||||
--- Most language servers support values like `refactor`
|
||||
--- or `quickfix`.
|
||||
--- - triggerKind (number|nil): The reason why code actions were requested.
|
||||
--- - filter: (function|nil)
|
||||
--- Predicate taking an `CodeAction` and returning a boolean.
|
||||
--- - apply: (boolean|nil)
|
||||
|
||||
@@ -258,6 +258,8 @@ end
|
||||
|
||||
--- |lsp-handler| for the method `textDocument/codeLens`
|
||||
---
|
||||
---@param err lsp.ResponseError?
|
||||
---@param result lsp.CodeLens[]
|
||||
---@param ctx lsp.HandlerContext
|
||||
function M.on_codelens(err, result, ctx, _)
|
||||
if err then
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
---@brief lsp-diagnostic
|
||||
|
||||
local protocol = require('vim.lsp.protocol')
|
||||
local ms = protocol.Methods
|
||||
|
||||
@@ -287,6 +285,7 @@ end
|
||||
--- )
|
||||
--- ```
|
||||
---
|
||||
---@param _ lsp.ResponseError?
|
||||
---@param result lsp.PublishDiagnosticsParams
|
||||
---@param ctx lsp.HandlerContext
|
||||
---@param config? vim.diagnostic.Opts Configuration table (see |vim.diagnostic.config()|).
|
||||
@@ -319,6 +318,7 @@ end
|
||||
--- )
|
||||
--- ```
|
||||
---
|
||||
---@param _ lsp.ResponseError?
|
||||
---@param result lsp.DocumentDiagnosticReport
|
||||
---@param ctx lsp.HandlerContext
|
||||
---@param config table Configuration table (see |vim.diagnostic.config()|).
|
||||
|
||||
@@ -368,6 +368,8 @@ end
|
||||
--- )
|
||||
--- ```
|
||||
---
|
||||
---@param _ lsp.ResponseError?
|
||||
---@param result lsp.Hover
|
||||
---@param ctx lsp.HandlerContext
|
||||
---@param config table Configuration table.
|
||||
--- - border: (default=nil)
|
||||
@@ -464,7 +466,8 @@ M[ms.textDocument_implementation] = location_handler
|
||||
--- )
|
||||
--- ```
|
||||
---
|
||||
---@param result table Response from the language server
|
||||
---@param _ lsp.ResponseError?
|
||||
---@param result lsp.SignatureHelp Response from the language server
|
||||
---@param ctx lsp.HandlerContext Client context
|
||||
---@param config table Configuration table.
|
||||
--- - border: (default=nil)
|
||||
|
||||
@@ -165,7 +165,7 @@ end
|
||||
|
||||
--- Checks whether the level is sufficient for logging.
|
||||
---@param level integer log level
|
||||
---@returns (bool) true if would log, false if not
|
||||
---@return bool : true if would log, false if not
|
||||
function log.should_log(level)
|
||||
return level >= current_log_level
|
||||
end
|
||||
|
||||
@@ -273,8 +273,6 @@ end
|
||||
---@field notify_reply_callbacks table<integer, function> dict of message_id to callback
|
||||
---@field transport vim.lsp.rpc.Transport
|
||||
---@field dispatchers vim.lsp.rpc.Dispatchers
|
||||
|
||||
---@class vim.lsp.rpc.Client
|
||||
local Client = {}
|
||||
|
||||
---@private
|
||||
|
||||
@@ -53,7 +53,7 @@ local str_utf_end = vim.str_utf_end
|
||||
---@param line string the line to index into
|
||||
---@param byte integer the byte idx
|
||||
---@param offset_encoding string utf-8|utf-16|utf-32|nil (default: utf-8)
|
||||
--@returns integer the utf idx for the given encoding
|
||||
---@return integer utf_idx for the given encoding
|
||||
local function byte_to_utf(line, byte, offset_encoding)
|
||||
-- convert to 0 based indexing for str_utfindex
|
||||
byte = byte - 1
|
||||
@@ -204,7 +204,7 @@ end
|
||||
--- Normalized to the next codepoint.
|
||||
--- prev_end_range is the text range sent to the server representing the changed region.
|
||||
--- curr_end_range is the text that should be collected and sent to the server.
|
||||
--
|
||||
---
|
||||
---@param prev_lines string[] list of lines
|
||||
---@param curr_lines string[] list of lines
|
||||
---@param start_range vim.lsp.sync.Range
|
||||
|
||||
@@ -574,6 +574,7 @@ end
|
||||
---
|
||||
---@param text_document_edit table: a `TextDocumentEdit` object
|
||||
---@param index integer: Optional index of the edit, if from a list of edits (or nil, if not from a list)
|
||||
---@param offset_encoding? string
|
||||
---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentEdit
|
||||
function M.apply_text_document_edit(text_document_edit, index, offset_encoding)
|
||||
local text_document = text_document_edit.textDocument
|
||||
@@ -770,7 +771,7 @@ end
|
||||
---
|
||||
---@param workspace_edit table `WorkspaceEdit`
|
||||
---@param offset_encoding string utf-8|utf-16|utf-32 (required)
|
||||
--see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit
|
||||
---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit
|
||||
function M.apply_workspace_edit(workspace_edit, offset_encoding)
|
||||
if offset_encoding == nil then
|
||||
vim.notify_once(
|
||||
@@ -1130,6 +1131,7 @@ end
|
||||
--- - for LocationLink, targetRange is shown (e.g., body of function definition)
|
||||
---
|
||||
---@param location table a single `Location` or `LocationLink`
|
||||
---@param opts table
|
||||
---@return integer|nil buffer id of float window
|
||||
---@return integer|nil window id of float window
|
||||
function M.preview_location(location, opts)
|
||||
@@ -1243,6 +1245,7 @@ end
|
||||
---
|
||||
--- If you want to open a popup with fancy markdown, use `open_floating_preview` instead
|
||||
---
|
||||
---@param bufnr integer
|
||||
---@param contents table of lines to show in window
|
||||
---@param opts table with optional fields
|
||||
--- - height of floating window
|
||||
@@ -1603,7 +1606,7 @@ end
|
||||
---@param contents table of lines to show in window
|
||||
---@param syntax string of syntax to set for opened buffer
|
||||
---@param opts table with optional fields (additional keys are filtered with |vim.lsp.util.make_floating_popup_options()|
|
||||
--- before they are passed on to |nvim_open_win()|)
|
||||
--- before they are passed on to |nvim_open_win()|)
|
||||
--- - height: (integer) height of floating window
|
||||
--- - width: (integer) width of floating window
|
||||
--- - wrap: (boolean, default true) wrap long lines
|
||||
@@ -1868,6 +1871,7 @@ end
|
||||
--- Converts symbols to quickfix list items.
|
||||
---
|
||||
---@param symbols table DocumentSymbol[] or SymbolInformation[]
|
||||
---@param bufnr integer
|
||||
function M.symbols_to_items(symbols, bufnr)
|
||||
local function _symbols_to_items(_symbols, _items, _bufnr)
|
||||
for _, symbol in ipairs(_symbols) do
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
-- 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)
|
||||
|
||||
---@nodoc
|
||||
---@diagnostic disable-next-line: lowercase-global
|
||||
vim = vim or {}
|
||||
|
||||
@@ -191,8 +192,8 @@ end
|
||||
---
|
||||
---@param s string String to split
|
||||
---@param sep string Separator or pattern
|
||||
---@param opts (table|nil) Keyword arguments |kwargs| accepted by |vim.gsplit()|
|
||||
---@return string[] List of split components
|
||||
---@param opts? table Keyword arguments |kwargs| accepted by |vim.gsplit()|
|
||||
---@return string[] : List of split components
|
||||
function vim.split(s, sep, opts)
|
||||
local t = {}
|
||||
for c in vim.gsplit(s, sep, opts) do
|
||||
@@ -206,9 +207,9 @@ end
|
||||
---
|
||||
---@see From https://github.com/premake/premake-core/blob/master/src/base/table.lua
|
||||
---
|
||||
---@generic T: table
|
||||
---@generic T
|
||||
---@param t table<T, any> (table) Table
|
||||
---@return T[] (list) List of keys
|
||||
---@return T[] : List of keys
|
||||
function vim.tbl_keys(t)
|
||||
vim.validate({ t = { t, 't' } })
|
||||
--- @cast t table<any,any>
|
||||
@@ -225,7 +226,7 @@ end
|
||||
---
|
||||
---@generic T
|
||||
---@param t table<any, T> (table) Table
|
||||
---@return T[] (list) List of values
|
||||
---@return T[] : List of values
|
||||
function vim.tbl_values(t)
|
||||
vim.validate({ t = { t, 't' } })
|
||||
|
||||
@@ -243,7 +244,7 @@ end
|
||||
---@generic T
|
||||
---@param func fun(value: T): any (function) Function
|
||||
---@param t table<any, T> (table) Table
|
||||
---@return table Table of transformed values
|
||||
---@return table : Table of transformed values
|
||||
function vim.tbl_map(func, t)
|
||||
vim.validate({ func = { func, 'c' }, t = { t, 't' } })
|
||||
--- @cast t table<any,any>
|
||||
@@ -260,7 +261,7 @@ end
|
||||
---@generic T
|
||||
---@param func fun(value: T): boolean (function) Function
|
||||
---@param t table<any, T> (table) Table
|
||||
---@return T[] (table) Table of filtered values
|
||||
---@return T[] : Table of filtered values
|
||||
function vim.tbl_filter(func, t)
|
||||
vim.validate({ func = { func, 'c' }, t = { t, 't' } })
|
||||
--- @cast t table<any,any>
|
||||
@@ -401,7 +402,7 @@ end
|
||||
--- - "keep": use value from the leftmost map
|
||||
--- - "force": use value from the rightmost map
|
||||
---@param ... table Two or more tables
|
||||
---@return table Merged table
|
||||
---@return table : Merged table
|
||||
function vim.tbl_extend(behavior, ...)
|
||||
return tbl_extend(behavior, false, ...)
|
||||
end
|
||||
@@ -456,7 +457,7 @@ end
|
||||
|
||||
--- Add the reverse lookup values to an existing table.
|
||||
--- For example:
|
||||
--- ``tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }``
|
||||
--- `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }`
|
||||
---
|
||||
--- Note that this *modifies* the input.
|
||||
---@param o table Table to add the reverse to
|
||||
@@ -493,7 +494,7 @@ end
|
||||
---
|
||||
---@param o table Table to index
|
||||
---@param ... any Optional keys (0 or more, variadic) via which to index the table
|
||||
---@return any Nested value indexed by key (if it exists), else nil
|
||||
---@return any : Nested value indexed by key (if it exists), else nil
|
||||
function vim.tbl_get(o, ...)
|
||||
local keys = { ... }
|
||||
if #keys == 0 then
|
||||
@@ -519,8 +520,8 @@ end
|
||||
---@generic T: table
|
||||
---@param dst T List which will be modified and appended to
|
||||
---@param src table List from which values will be inserted
|
||||
---@param start (integer|nil) Start index on src. Defaults to 1
|
||||
---@param finish (integer|nil) Final index on src. Defaults to `#src`
|
||||
---@param start integer? Start index on src. Defaults to 1
|
||||
---@param finish integer? Final index on src. Defaults to `#src`
|
||||
---@return T dst
|
||||
function vim.list_extend(dst, src, start, finish)
|
||||
vim.validate({
|
||||
@@ -666,7 +667,7 @@ end
|
||||
---
|
||||
---@see https://github.com/Tieske/Penlight/blob/master/lua/pl/tablex.lua
|
||||
---@param t table Table
|
||||
---@return integer Number of non-nil values in table
|
||||
---@return integer : Number of non-nil values in table
|
||||
function vim.tbl_count(t)
|
||||
vim.validate({ t = { t, 't' } })
|
||||
--- @cast t table<any,any>
|
||||
@@ -681,10 +682,10 @@ end
|
||||
--- Creates a copy of a table containing only elements from start to end (inclusive)
|
||||
---
|
||||
---@generic T
|
||||
---@param list T[] (list) Table
|
||||
---@param list T[] Table
|
||||
---@param start integer|nil Start range of slice
|
||||
---@param finish integer|nil End range of slice
|
||||
---@return T[] (list) Copy of table sliced from start to finish (inclusive)
|
||||
---@return T[] Copy of table sliced from start to finish (inclusive)
|
||||
function vim.list_slice(list, start, finish)
|
||||
local new_list = {} --- @type `T`[]
|
||||
for i = start or 1, finish or #list do
|
||||
@@ -840,38 +841,37 @@ do
|
||||
--- Usage example:
|
||||
---
|
||||
--- ```lua
|
||||
--- function user.new(name, age, hobbies)
|
||||
--- vim.validate{
|
||||
--- name={name, 'string'},
|
||||
--- age={age, 'number'},
|
||||
--- hobbies={hobbies, 'table'},
|
||||
--- }
|
||||
--- ...
|
||||
--- end
|
||||
--- function user.new(name, age, hobbies)
|
||||
--- vim.validate{
|
||||
--- name={name, 'string'},
|
||||
--- age={age, 'number'},
|
||||
--- hobbies={hobbies, 'table'},
|
||||
--- }
|
||||
--- ...
|
||||
--- end
|
||||
--- ```
|
||||
---
|
||||
--- Examples with explicit argument values (can be run directly):
|
||||
---
|
||||
--- ```lua
|
||||
--- vim.validate{arg1={{'foo'}, 'table'}, arg2={'foo', 'string'}}
|
||||
--- --> NOP (success)
|
||||
--- vim.validate{arg1={{'foo'}, 'table'}, arg2={'foo', 'string'}}
|
||||
--- --> NOP (success)
|
||||
---
|
||||
--- vim.validate{arg1={1, 'table'}}
|
||||
--- --> error('arg1: expected table, got number')
|
||||
--- vim.validate{arg1={1, 'table'}}
|
||||
--- --> error('arg1: expected table, got number')
|
||||
---
|
||||
--- vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}}
|
||||
--- --> error('arg1: expected even number, got 3')
|
||||
--- vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}}
|
||||
--- --> error('arg1: expected even number, got 3')
|
||||
--- ```
|
||||
---
|
||||
--- If multiple types are valid they can be given as a list.
|
||||
---
|
||||
--- ```lua
|
||||
--- vim.validate{arg1={{'foo'}, {'table', 'string'}}, arg2={'foo', {'table', 'string'}}}
|
||||
--- -- NOP (success)
|
||||
---
|
||||
--- vim.validate{arg1={1, {'string', 'table'}}}
|
||||
--- -- error('arg1: expected string|table, got number')
|
||||
--- vim.validate{arg1={{'foo'}, {'table', 'string'}}, arg2={'foo', {'table', 'string'}}}
|
||||
--- -- NOP (success)
|
||||
---
|
||||
--- vim.validate{arg1={1, {'string', 'table'}}}
|
||||
--- -- error('arg1: expected string|table, got number')
|
||||
--- ```
|
||||
---
|
||||
---@param opt table<vim.validate.Type,vim.validate.Spec> (table) Names of parameters to validate. Each key is a parameter
|
||||
@@ -989,19 +989,19 @@ do
|
||||
--- Once the buffer is full, adding a new entry overrides the oldest entry.
|
||||
---
|
||||
--- ```lua
|
||||
--- local ringbuf = vim.ringbuf(4)
|
||||
--- ringbuf:push("a")
|
||||
--- ringbuf:push("b")
|
||||
--- ringbuf:push("c")
|
||||
--- ringbuf:push("d")
|
||||
--- ringbuf:push("e") -- overrides "a"
|
||||
--- print(ringbuf:pop()) -- returns "b"
|
||||
--- print(ringbuf:pop()) -- returns "c"
|
||||
--- local ringbuf = vim.ringbuf(4)
|
||||
--- ringbuf:push("a")
|
||||
--- ringbuf:push("b")
|
||||
--- ringbuf:push("c")
|
||||
--- ringbuf:push("d")
|
||||
--- ringbuf:push("e") -- overrides "a"
|
||||
--- print(ringbuf:pop()) -- returns "b"
|
||||
--- print(ringbuf:pop()) -- returns "c"
|
||||
---
|
||||
--- -- Can be used as iterator. Pops remaining items:
|
||||
--- for val in ringbuf do
|
||||
--- print(val)
|
||||
--- end
|
||||
--- -- Can be used as iterator. Pops remaining items:
|
||||
--- for val in ringbuf do
|
||||
--- print(val)
|
||||
--- end
|
||||
--- ```
|
||||
---
|
||||
--- Returns a Ringbuf instance with the following methods:
|
||||
|
||||
@@ -245,8 +245,6 @@ function Session:set_group_gravity(index, right_gravity)
|
||||
end
|
||||
end
|
||||
|
||||
--- @class vim.snippet.Snippet
|
||||
--- @field private _session? vim.snippet.Session
|
||||
local M = { session = nil }
|
||||
|
||||
--- Displays the choices for the given tabstop as completion items.
|
||||
|
||||
@@ -432,7 +432,7 @@ end
|
||||
--- Can be used in an ftplugin or FileType autocommand.
|
||||
---
|
||||
--- Note: By default, disables regex syntax highlighting, which may be required for some plugins.
|
||||
--- In this case, add ``vim.bo.syntax = 'on'`` after the call to `start`.
|
||||
--- In this case, add `vim.bo.syntax = 'on'` after the call to `start`.
|
||||
---
|
||||
--- Example:
|
||||
---
|
||||
|
||||
@@ -197,7 +197,7 @@ function M.clear(buf)
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- @param findstart integer
|
||||
--- @param findstart 0|1
|
||||
--- @param base string
|
||||
function M.omnifunc(findstart, base)
|
||||
if findstart == 1 then
|
||||
|
||||
@@ -231,7 +231,6 @@ function TSHighlighter:on_changedtree(changes)
|
||||
end
|
||||
|
||||
--- Gets the query used for @param lang
|
||||
--
|
||||
---@package
|
||||
---@param lang string Language used by the highlighter.
|
||||
---@return vim.treesitter.highlighter.Query
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
--- @defgroup lua-treesitter-languagetree
|
||||
---
|
||||
--- @brief A \*LanguageTree\* contains a tree of parsers: the root treesitter parser for {lang} and
|
||||
--- any "injected" language parsers, which themselves may inject other languages, recursively.
|
||||
--- For example a Lua buffer containing some Vimscript commands needs multiple parsers to fully
|
||||
@@ -433,7 +431,7 @@ function LanguageTree:parse(range)
|
||||
local query_time = 0
|
||||
local total_parse_time = 0
|
||||
|
||||
--- At least 1 region is invalid
|
||||
-- At least 1 region is invalid
|
||||
if not self:is_valid(true) then
|
||||
changes, no_regions_parsed, total_parse_time = self:_parse_regions(range)
|
||||
-- Need to run injections when we parsed something
|
||||
|
||||
@@ -231,7 +231,7 @@ end
|
||||
---@param lang string Language to use for the query
|
||||
---@param query_name string Name of the query (e.g. "highlights")
|
||||
---
|
||||
---@return vim.treesitter.Query|nil -- Parsed query. `nil` if no query files are found.
|
||||
---@return vim.treesitter.Query|nil : Parsed query. `nil` if no query files are found.
|
||||
M.get = vim.func._memoize('concat-2', function(lang, query_name)
|
||||
if explicit_queries[lang][query_name] then
|
||||
return explicit_queries[lang][query_name]
|
||||
@@ -1019,6 +1019,8 @@ end
|
||||
--- vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc'
|
||||
--- ```
|
||||
---
|
||||
--- @param findstart 0|1
|
||||
--- @param base string
|
||||
function M.omnifunc(findstart, base)
|
||||
return vim.treesitter._query_linter.omnifunc(findstart, base)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
---TODO: This is implemented only for files currently.
|
||||
-- TODO: This is implemented only for files currently.
|
||||
-- https://tools.ietf.org/html/rfc3986
|
||||
-- https://tools.ietf.org/html/rfc2732
|
||||
-- https://tools.ietf.org/html/rfc2396
|
||||
@@ -116,7 +116,6 @@ end
|
||||
|
||||
---Gets the buffer for a uri.
|
||||
---Creates a new unloaded buffer if no buffer for the uri already exists.
|
||||
--
|
||||
---@param uri string
|
||||
---@return integer bufnr
|
||||
function M.uri_to_bufnr(uri)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
--- @defgroup vim.version
|
||||
---
|
||||
--- @brief The \`vim.version\` module provides functions for comparing versions and ranges
|
||||
--- @brief
|
||||
--- The `vim.version` module provides functions for comparing versions and ranges
|
||||
--- conforming to the https://semver.org spec. Plugins, and plugin managers, can use this to check
|
||||
--- available tools and dependencies on the current system.
|
||||
---
|
||||
@@ -13,9 +12,9 @@
|
||||
--- end
|
||||
--- ```
|
||||
---
|
||||
--- \*vim.version()\* returns the version of the current Nvim process.
|
||||
--- *vim.version()* returns the version of the current Nvim process.
|
||||
---
|
||||
--- VERSION RANGE SPEC \*version-range\*
|
||||
--- VERSION RANGE SPEC *version-range*
|
||||
---
|
||||
--- A version "range spec" defines a semantic version range which can be tested against a version,
|
||||
--- using |vim.version.range()|.
|
||||
|
||||
Reference in New Issue
Block a user