docs(vvars): adjust lua types for vim.v variables #31510

- classes for v:event and v:completed_item
- add remaining unknown types
This commit is contained in:
luukvbaal 2024-12-10 01:27:39 +01:00 committed by GitHub
parent 1b90f4a9c4
commit 4889935a7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 97 additions and 10 deletions

View File

@ -15,7 +15,7 @@ vim.v.argv = ...
--- Argument for evaluating 'formatexpr' and used for the typed --- Argument for evaluating 'formatexpr' and used for the typed
--- character when using <expr> in an abbreviation `:map-<expr>`. --- character when using <expr> in an abbreviation `:map-<expr>`.
--- It is also used by the `InsertCharPre` and `InsertEnter` events. --- It is also used by the `InsertCharPre` and `InsertEnter` events.
--- @type any --- @type string
vim.v.char = ... vim.v.char = ...
--- The name of the character encoding of a file to be converted. --- The name of the character encoding of a file to be converted.
@ -60,7 +60,7 @@ vim.v.collate = ...
--- mode. --- mode.
--- Note: Plugins can modify the value to emulate the builtin --- Note: Plugins can modify the value to emulate the builtin
--- `CompleteDone` event behavior. --- `CompleteDone` event behavior.
--- @type any --- @type vim.v.completed_item
vim.v.completed_item = ... vim.v.completed_item = ...
--- The count given for the last Normal mode command. Can be used --- The count given for the last Normal mode command. Can be used
@ -90,7 +90,7 @@ vim.v.count1 = ...
--- This variable can not be set directly, use the `:language` --- This variable can not be set directly, use the `:language`
--- command. --- command.
--- See `multi-lang`. --- See `multi-lang`.
--- @type any --- @type string
vim.v.ctype = ... vim.v.ctype = ...
--- Normally zero. When a deadly signal is caught it's set to --- Normally zero. When a deadly signal is caught it's set to
@ -199,7 +199,7 @@ vim.v.errors = ...
--- reason Reason for completion being done. `CompleteDone` --- reason Reason for completion being done. `CompleteDone`
--- complete_word The word that was selected, empty if abandoned complete. --- complete_word The word that was selected, empty if abandoned complete.
--- complete_type See `complete_info_mode` --- complete_type See `complete_info_mode`
--- @type any --- @type vim.v.event
vim.v.event = ... vim.v.event = ...
--- The value of the exception most recently caught and not --- The value of the exception most recently caught and not
@ -225,7 +225,7 @@ vim.v.exception = ...
--- ```vim --- ```vim
--- :au VimLeave * echo "Exit value is " .. v:exiting --- :au VimLeave * echo "Exit value is " .. v:exiting
--- ``` --- ```
--- @type any --- @type integer?
vim.v.exiting = ... vim.v.exiting = ...
--- Special value used to put "false" in JSON and msgpack. See --- Special value used to put "false" in JSON and msgpack. See
@ -421,7 +421,7 @@ vim.v.mouse_winid = ...
--- and `msgpackdump()`. All types inside dictionary are fixed --- and `msgpackdump()`. All types inside dictionary are fixed
--- (not editable) empty lists. To check whether some list is one --- (not editable) empty lists. To check whether some list is one
--- of msgpack types, use `is` operator. --- of msgpack types, use `is` operator.
--- @type any --- @type table
vim.v.msgpack_types = ... vim.v.msgpack_types = ...
--- Special value used to put "null" in JSON and NIL in msgpack. --- Special value used to put "null" in JSON and NIL in msgpack.
@ -565,7 +565,7 @@ vim.v.relnum = ...
--- typed command. --- typed command.
--- This can be used to find out why your script causes the --- This can be used to find out why your script causes the
--- hit-enter prompt. --- hit-enter prompt.
--- @type any --- @type string
vim.v.scrollstart = ... vim.v.scrollstart = ...
--- Search direction: 1 after a forward search, 0 after a --- Search direction: 1 after a forward search, 0 after a
@ -707,13 +707,13 @@ vim.v.termrequest = ...
vim.v.termresponse = ... vim.v.termresponse = ...
--- Must be set before using `test_garbagecollect_now()`. --- Must be set before using `test_garbagecollect_now()`.
--- @type any --- @type integer
vim.v.testing = ... vim.v.testing = ...
--- Full filename of the last loaded or saved session file. --- Full filename of the last loaded or saved session file.
--- Empty when no session file has been saved. See `:mksession`. --- Empty when no session file has been saved. See `:mksession`.
--- Modifiable (can be set). --- Modifiable (can be set).
--- @type any --- @type string
vim.v.this_session = ... vim.v.this_session = ...
--- The point where the exception most recently caught and not --- The point where the exception most recently caught and not
@ -730,7 +730,7 @@ vim.v.this_session = ...
--- ``` --- ```
--- ---
--- Output: "Exception from test.vim, line 2" --- Output: "Exception from test.vim, line 2"
--- @type any --- @type string
vim.v.throwpoint = ... vim.v.throwpoint = ...
--- Special value used to put "true" in JSON and msgpack. See --- Special value used to put "true" in JSON and msgpack. See

View File

@ -0,0 +1,77 @@
--- @meta _
error('Cannot require a meta file')
--- Extra types for vim.v dictionary fields
--- @class vim.v.completed_item
--- @field word? string the text that will be inserted, mandatory
--- abbreviation of "word"; when not empty it is used in the menu instead of "word"
--- @field abbr? string
--- extra text for the popup menu, displayed after "word" or "abbr"
--- @field menu? string
--- more information about the item, can be displayed in a preview window
--- @field info? string
--- @field kind? string single letter indicating the type of completion
--- when non-zero case is to be ignored when comparing items to be equal; when
--- omitted zero is used, thus items that only differ in case are added
--- @field icase? integer
--- when non-zero, always treat this item to be equal when comparing. Which
--- means, "equal=1" disables filtering of this item.
--- @field equal? integer
--- when non-zero this match will be added even when an item with the same word
--- is already present.
--- @field dup? integer
--- when non-zero this match will be added even when it is an empty string
--- @field empty? integer
--- custom data which is associated with the item and available
--- in |v:completed_item|; it can be any type; defaults to an empty string
--- @field user_data? any
--- an additional highlight group whose attributes are combined
--- with |hl-PmenuSel| and |hl-Pmenu| or |hl-PmenuMatchSel| and |hl-PmenuMatch|
--- highlight attributes in the popup menu to apply cterm and gui properties
--- (with higher priority) like strikethrough to the completion items abbreviation
--- @field abbr_hlgroup? string
--- an additional highlight group specifically for setting the highlight
--- attributes of the completion kind. When this field is present, it will
--- override the |hl-PmenuKind| highlight group, allowing for the customization
--- of ctermfg and guifg properties for the completion kind
--- @field kind_hlgroup? string
--- @class vim.v.event
--- Whether the event triggered during an aborting condition (e.g. |c_Esc| or
--- |c_CTRL-C| for |CmdlineLeave|).
--- @field abort? boolean
--- @field chan? integer See |channel-id|
--- @field info? table Dict of arbitrary event data.
--- @field cmdlevel? integer Level of cmdline.
--- @field cmdtype? string Type of cmdline, |cmdline-char|.
--- @field cwd? string Current working directory.
--- @field inclusive? boolean Motion is |inclusive|, else exclusive.
--- @field scope? string Event-specific scope name.
--- Current |operator|. Also set for Ex commands (unlike |v:operator|). For
--- example if |TextYankPost| is triggered by the |:yank| Ex command then
--- `v:event.operator` is "y".
--- @field operator? string
--- Text stored in the register as a |readfile()|-style list of lines.
--- @field regcontents? string
--- Requested register (e.g "x" for "xyy) or the empty string for an unnamed operation.
--- @field regname? string
--- @field regtype? string Type of register as returned by |getregtype()|.
--- @field visual? boolean Selection is visual (as opposed to, e.g., via motion).
--- @field completed_item? vim.v.completed_item
--- Current selected complete item on |CompleteChanged|, Is `{}` when no
--- complete item selected.
--- @field height? integer
--- @field width? integer Height of popup menu on |CompleteChanged|
--- @field row? integer Width of popup menu on |CompleteChanged|
--- Col count of popup menu on |CompleteChanged|, relative to screen.
--- @field col? integer
--- @field size? integer Total number of completion items on |CompleteChanged|.
--- Is |v:true| if popup menu have scrollbar, or |v:false| if not.
--- @field scrollbar? boolean
--- Is |v:true| if the event fired while changing window (or tab) on |DirChanged|.
--- @field changed_window? boolean
--- @field status? boolean Job status or exit code, -1 means "unknown". |TermClose|
--- @field reason? string Reason for completion being done. |CompleteDone|
--- The word that was selected, empty if abandoned complete. @field complete_word? string
--- @field complete_type? string See |complete_info_mode|

View File

@ -10,6 +10,7 @@ M.vars = {
]=], ]=],
}, },
char = { char = {
type = 'string',
desc = [=[ desc = [=[
Argument for evaluating 'formatexpr' and used for the typed Argument for evaluating 'formatexpr' and used for the typed
character when using <expr> in an abbreviation |:map-<expr>|. character when using <expr> in an abbreviation |:map-<expr>|.
@ -63,6 +64,7 @@ M.vars = {
]=], ]=],
}, },
completed_item = { completed_item = {
type = 'vim.v.completed_item',
desc = [=[ desc = [=[
Dictionary containing the |complete-items| for the most Dictionary containing the |complete-items| for the most
recently completed word after |CompleteDone|. Empty if the recently completed word after |CompleteDone|. Empty if the
@ -94,6 +96,7 @@ M.vars = {
]=], ]=],
}, },
ctype = { ctype = {
type = 'string',
desc = [=[ desc = [=[
The current locale setting for characters of the runtime The current locale setting for characters of the runtime
environment. This allows Vim scripts to be aware of the environment. This allows Vim scripts to be aware of the
@ -158,6 +161,7 @@ M.vars = {
]=], ]=],
}, },
event = { event = {
type = 'vim.v.event',
desc = [=[ desc = [=[
Dictionary of event data for the current |autocommand|. Valid Dictionary of event data for the current |autocommand|. Valid
only during the event lifetime; storing or passing v:event is only during the event lifetime; storing or passing v:event is
@ -238,6 +242,7 @@ M.vars = {
]=], ]=],
}, },
exiting = { exiting = {
type = 'integer?',
desc = [=[ desc = [=[
Exit code, or |v:null| before invoking the |VimLeavePre| Exit code, or |v:null| before invoking the |VimLeavePre|
and |VimLeave| autocmds. See |:q|, |:x| and |:cquit|. and |VimLeave| autocmds. See |:q|, |:x| and |:cquit|.
@ -470,6 +475,7 @@ M.vars = {
]=], ]=],
}, },
msgpack_types = { msgpack_types = {
type = 'table',
desc = [=[ desc = [=[
Dictionary containing msgpack types used by |msgpackparse()| Dictionary containing msgpack types used by |msgpackparse()|
and |msgpackdump()|. All types inside dictionary are fixed and |msgpackdump()|. All types inside dictionary are fixed
@ -635,6 +641,7 @@ M.vars = {
]=], ]=],
}, },
scrollstart = { scrollstart = {
type = 'string',
desc = [=[ desc = [=[
String describing the script or function that caused the String describing the script or function that caused the
screen to scroll up. It's only set when it is empty, thus the screen to scroll up. It's only set when it is empty, thus the
@ -798,11 +805,13 @@ M.vars = {
]=], ]=],
}, },
testing = { testing = {
type = 'integer',
desc = [=[ desc = [=[
Must be set before using `test_garbagecollect_now()`. Must be set before using `test_garbagecollect_now()`.
]=], ]=],
}, },
this_session = { this_session = {
type = 'string',
desc = [=[ desc = [=[
Full filename of the last loaded or saved session file. Full filename of the last loaded or saved session file.
Empty when no session file has been saved. See |:mksession|. Empty when no session file has been saved. See |:mksession|.
@ -810,6 +819,7 @@ M.vars = {
]=], ]=],
}, },
throwpoint = { throwpoint = {
type = 'string',
desc = [=[ desc = [=[
The point where the exception most recently caught and not The point where the exception most recently caught and not
finished was thrown. Not set when commands are typed. See finished was thrown. Not set when commands are typed. See