Skip to content

Commit

Permalink
docs(vvars): adjust lua types for vim.v variables neovim#31510
Browse files Browse the repository at this point in the history
- classes for v:event and v:completed_item
- add remaining unknown types
  • Loading branch information
luukvbaal authored Dec 10, 2024
1 parent 1b90f4a commit 4889935
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 10 deletions.
20 changes: 10 additions & 10 deletions runtime/lua/vim/_meta/vvars.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

0 comments on commit 4889935

Please sign in to comment.