diff options
Diffstat (limited to 'src/nvim/options.lua')
| -rw-r--r-- | src/nvim/options.lua | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 734d9a4a02..d49621490c 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -8,8 +8,7 @@ --- @field short_desc? string|fun(): string --- @field varname? string --- @field pv_name? string ---- @field type 'boolean'|'number'|'string' ---- @field hidden? boolean +--- @field type vim.option_type|vim.option_type[] --- @field immutable? boolean --- @field list? 'comma'|'onecomma'|'commacolon'|'onecommacolon'|'flags'|'flagscomma' --- @field scope vim.option_scope[] @@ -43,6 +42,8 @@ --- @field meta? integer|boolean|string Default to use in Lua meta files --- @alias vim.option_scope 'global'|'buffer'|'window' +--- @alias vim.option_type 'boolean'|'number'|'string' +--- @alias vim.option_value boolean|number|string --- @alias vim.option_redraw --- |'statuslines' @@ -61,18 +62,11 @@ local function cstr(s) end --- @param s string ---- @return fun(): string -local function macros(s) +--- @param t vim.option_type +--- @return fun(): string, vim.option_type +local function macros(s, t) return function() - return '.string=' .. s - end -end - ---- @param s string ---- @return fun(): string -local function imacros(s) - return function() - return '.number=' .. s + return s, t end end @@ -994,7 +988,7 @@ return { { cb = 'did_set_cedit', defaults = { - if_true = macros('CTRL_F_STR'), + if_true = macros('CTRL_F_STR', 'string'), doc = 'CTRL-F', }, desc = [=[ @@ -1288,7 +1282,7 @@ return { abbreviation = 'co', cb = 'did_set_lines_or_columns', defaults = { - if_true = imacros('DFLT_COLS'), + if_true = macros('DFLT_COLS', 'number'), doc = '80 or terminal width', }, desc = [=[ @@ -1630,7 +1624,7 @@ return { { abbreviation = 'cpo', cb = 'did_set_cpoptions', - defaults = { if_true = macros('CPO_VIM') }, + defaults = { if_true = macros('CPO_VIM', 'string') }, desc = [=[ A sequence of single character flags. When a character is present this indicates Vi-compatible behavior. This is used for things where @@ -2368,7 +2362,7 @@ return { { abbreviation = 'enc', cb = 'did_set_encoding', - defaults = { if_true = macros('ENC_DFLT') }, + defaults = { if_true = macros('ENC_DFLT', 'string') }, deny_in_modelines = true, desc = [=[ String-encoding used internally and for |RPC| communication. @@ -2492,7 +2486,7 @@ return { }, { abbreviation = 'ef', - defaults = { if_true = macros('DFLT_ERRORFILE') }, + defaults = { if_true = macros('DFLT_ERRORFILE', 'string') }, desc = [=[ Name of the errorfile for the QuickFix mode (see |:cf|). When the "-q" command-line argument is used, 'errorfile' is set to the @@ -2514,7 +2508,7 @@ return { { abbreviation = 'efm', defaults = { - if_true = macros('DFLT_EFM'), + if_true = macros('DFLT_EFM', 'string'), doc = 'is very long', }, deny_duplicates = true, @@ -2706,7 +2700,7 @@ return { alloced = true, cb = 'did_set_fileformat', defaults = { - if_true = macros('DFLT_FF'), + if_true = macros('DFLT_FF', 'string'), doc = 'Windows: "dos", Unix: "unix"', }, desc = [=[ @@ -2739,7 +2733,7 @@ return { abbreviation = 'ffs', cb = 'did_set_fileformats', defaults = { - if_true = macros('DFLT_FFS_VIM'), + if_true = macros('DFLT_FFS_VIM', 'string'), doc = 'Windows: "dos,unix", Unix: "unix,dos"', }, deny_duplicates = true, @@ -3316,7 +3310,7 @@ return { abbreviation = 'fo', alloced = true, cb = 'did_set_formatoptions', - defaults = { if_true = macros('DFLT_FO_VIM') }, + defaults = { if_true = macros('DFLT_FO_VIM', 'string') }, desc = [=[ This is a sequence of letters which describes how automatic formatting is to be done. @@ -3409,7 +3403,7 @@ return { }, { abbreviation = 'gfm', - defaults = { if_true = macros('DFLT_GREPFORMAT') }, + defaults = { if_true = macros('DFLT_GREPFORMAT', 'string') }, deny_duplicates = true, desc = [=[ Format to recognize for the ":grep" command output. @@ -3773,6 +3767,7 @@ return { }, { abbreviation = 'gtl', + defaults = { if_true = '' }, desc = [=[ When non-empty describes the text to use in a label of the GUI tab pages line. When empty and when the result is empty Vim will use a @@ -3798,6 +3793,7 @@ return { }, { abbreviation = 'gtt', + defaults = { if_true = '' }, desc = [=[ When non-empty describes the text to use in a tooltip for the GUI tab pages line. When empty Vim will use a default tooltip. @@ -3817,7 +3813,7 @@ return { abbreviation = 'hf', cb = 'did_set_helpfile', defaults = { - if_true = macros('DFLT_HELPFILE'), + if_true = macros('DFLT_HELPFILE', 'string'), doc = [[(MS-Windows) "$VIMRUNTIME\doc\help.txt" (others) "$VIMRUNTIME/doc/help.txt"]], }, @@ -3914,7 +3910,7 @@ return { { abbreviation = 'hl', cb = 'did_set_highlight', - defaults = { if_true = macros('HIGHLIGHT_INIT') }, + defaults = { if_true = macros('HIGHLIGHT_INIT', 'string') }, deny_duplicates = true, full_name = 'highlight', list = 'onecomma', @@ -4080,7 +4076,7 @@ return { { abbreviation = 'imi', cb = 'did_set_iminsert', - defaults = { if_true = imacros('B_IMODE_NONE') }, + defaults = { if_true = macros('B_IMODE_NONE', 'number') }, desc = [=[ Specifies whether :lmap or an Input Method (IM) is to be used in Insert mode. Valid values: @@ -4106,7 +4102,7 @@ return { }, { abbreviation = 'ims', - defaults = { if_true = imacros('B_IMODE_USE_INSERT') }, + defaults = { if_true = macros('B_IMODE_USE_INSERT', 'number') }, desc = [=[ Specifies whether :lmap or an Input Method (IM) is to be used when entering a search pattern. Valid values: @@ -4812,7 +4808,7 @@ return { { cb = 'did_set_lines_or_columns', defaults = { - if_true = imacros('DFLT_ROWS'), + if_true = macros('DFLT_ROWS', 'number'), doc = '24 or terminal height', }, desc = [=[ @@ -4900,7 +4896,7 @@ return { { abbreviation = 'lw', defaults = { - if_true = macros('LISPWORD_VALUE'), + if_true = macros('LISPWORD_VALUE', 'string'), doc = 'is very long', }, deny_duplicates = true, @@ -5210,7 +5206,7 @@ return { }, { abbreviation = 'mco', - defaults = { if_true = imacros('MAX_MCO') }, + defaults = { if_true = macros('MAX_MCO', 'number') }, full_name = 'maxcombine', scope = { 'global' }, short_desc = N_('maximum nr of combining characters displayed'), @@ -9613,7 +9609,7 @@ return { abbreviation = 'wc', cb = 'did_set_wildchar', defaults = { - if_true = imacros('TAB'), + if_true = macros('TAB', 'number'), doc = '<Tab>', }, desc = [=[ |