mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(options): generate BV_ and WV_ constants (#26705)
This commit is contained in:
parent
6700127b30
commit
089b934352
13
src/clint.py
13
src/clint.py
@ -901,7 +901,6 @@ def CheckIncludes(filename, lines, error):
|
||||
"src/nvim/api/private/validate.h",
|
||||
"src/nvim/assert_defs.h",
|
||||
"src/nvim/buffer.h",
|
||||
"src/nvim/buffer_defs.h",
|
||||
"src/nvim/channel.h",
|
||||
"src/nvim/charset.h",
|
||||
"src/nvim/eval.h",
|
||||
@ -910,34 +909,22 @@ def CheckIncludes(filename, lines, error):
|
||||
"src/nvim/eval/typval_defs.h",
|
||||
"src/nvim/eval/userfunc.h",
|
||||
"src/nvim/event/libuv_process.h",
|
||||
"src/nvim/event/loop.h",
|
||||
"src/nvim/event/multiqueue.h",
|
||||
"src/nvim/event/process.h",
|
||||
"src/nvim/event/rstream.h",
|
||||
"src/nvim/event/signal.h",
|
||||
"src/nvim/event/socket.h",
|
||||
"src/nvim/event/stream.h",
|
||||
"src/nvim/event/time.h",
|
||||
"src/nvim/event/wstream.h",
|
||||
"src/nvim/garray.h",
|
||||
"src/nvim/globals.h",
|
||||
"src/nvim/grid.h",
|
||||
"src/nvim/highlight.h",
|
||||
"src/nvim/input.h",
|
||||
"src/nvim/keycodes.h",
|
||||
"src/nvim/lua/executor.h",
|
||||
"src/nvim/main.h",
|
||||
"src/nvim/mark.h",
|
||||
"src/nvim/msgpack_rpc/channel_defs.h",
|
||||
"src/nvim/msgpack_rpc/helpers.h",
|
||||
"src/nvim/msgpack_rpc/unpacker.h",
|
||||
"src/nvim/option.h",
|
||||
"src/nvim/os/input.h",
|
||||
"src/nvim/os/pty_conpty_win.h",
|
||||
"src/nvim/os/pty_process_unix.h",
|
||||
"src/nvim/os/pty_process_win.h",
|
||||
"src/nvim/tui/input.h",
|
||||
"src/nvim/ui.h",
|
||||
"src/nvim/viml/parser/expressions.h",
|
||||
"src/nvim/viml/parser/parser.h",
|
||||
]
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "nvim/mark_defs.h"
|
||||
#include "nvim/marktree_defs.h"
|
||||
#include "nvim/memline_defs.h"
|
||||
#include "nvim/option_vars.h"
|
||||
#include "nvim/option_defs.h"
|
||||
#include "nvim/os/fs_defs.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/regexp_defs.h"
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/types_defs.h" // IWYU pragma: keep
|
||||
|
||||
struct funccal_entry;
|
||||
|
||||
// From user function to hashitem and back.
|
||||
#define UF2HIKEY(fp) ((fp)->uf_name)
|
||||
#define HIKEY2UF(p) ((ufunc_T *)((p) - offsetof(ufunc_T, uf_name)))
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option_defs.h"
|
||||
#include "nvim/option_vars.h"
|
||||
#include "nvim/os/input.h"
|
||||
#include "nvim/plines.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
-- Generates option index enum and map of option name to option index.
|
||||
-- Handles option full name, short name and aliases.
|
||||
-- Also generates BV_ and WV_ enum constants.
|
||||
|
||||
local options_enum_file = arg[1]
|
||||
local options_map_file = arg[2]
|
||||
@ -16,6 +17,9 @@ local function map_w(s)
|
||||
options_map_fd:write(s .. '\n')
|
||||
end
|
||||
|
||||
enum_w('// IWYU pragma: private, include "nvim/option_defs.h"')
|
||||
enum_w('')
|
||||
|
||||
--- @param s string
|
||||
--- @return string
|
||||
local lowercase_to_titlecase = function(s)
|
||||
@ -24,6 +28,55 @@ end
|
||||
|
||||
--- @type vim.option_meta[]
|
||||
local options = require('options').options
|
||||
|
||||
-- Generate BV_ enum constants.
|
||||
enum_w('/// "indir" values for buffer-local options.')
|
||||
enum_w('/// These need to be defined globally, so that the BV_COUNT can be used with')
|
||||
enum_w('/// b_p_script_stx[].')
|
||||
enum_w('enum {')
|
||||
|
||||
local bv_val = 0
|
||||
|
||||
for _, o in ipairs(options) do
|
||||
assert(#o.scope == 1 or #o.scope == 2)
|
||||
assert(#o.scope == 1 or o.scope[1] == 'global')
|
||||
local min_scope = o.scope[#o.scope]
|
||||
if min_scope == 'buffer' then
|
||||
local varname = o.pv_name or o.varname or ('p_' .. (o.abbreviation or o.full_name))
|
||||
local bv_name = 'BV_' .. varname:sub(3):upper()
|
||||
enum_w((' %s = %u,'):format(bv_name, bv_val))
|
||||
bv_val = bv_val + 1
|
||||
end
|
||||
end
|
||||
|
||||
enum_w((' BV_COUNT = %u, ///< must be the last one'):format(bv_val))
|
||||
enum_w('};')
|
||||
enum_w('')
|
||||
|
||||
-- Generate WV_ enum constants.
|
||||
enum_w('/// "indir" values for window-local options.')
|
||||
enum_w('/// These need to be defined globally, so that the WV_COUNT can be used in the')
|
||||
enum_w('/// window structure.')
|
||||
enum_w('enum {')
|
||||
|
||||
local wv_val = 0
|
||||
|
||||
for _, o in ipairs(options) do
|
||||
assert(#o.scope == 1 or #o.scope == 2)
|
||||
assert(#o.scope == 1 or o.scope[1] == 'global')
|
||||
local min_scope = o.scope[#o.scope]
|
||||
if min_scope == 'window' then
|
||||
local varname = o.pv_name or o.varname or ('p_' .. (o.abbreviation or o.full_name))
|
||||
local wv_name = 'WV_' .. varname:sub(3):upper()
|
||||
enum_w((' %s = %u,'):format(wv_name, wv_val))
|
||||
wv_val = wv_val + 1
|
||||
end
|
||||
end
|
||||
|
||||
enum_w((' WV_COUNT = %u, ///< must be the last one'):format(wv_val))
|
||||
enum_w('};')
|
||||
enum_w('')
|
||||
|
||||
--- @type { [string]: string }
|
||||
local option_index = {}
|
||||
|
||||
|
@ -11,10 +11,9 @@
|
||||
#include "nvim/getchar_defs.h"
|
||||
#include "nvim/iconv_defs.h"
|
||||
#include "nvim/macros_defs.h"
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/menu_defs.h"
|
||||
#include "nvim/os/os_defs.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/runtime_defs.h"
|
||||
#include "nvim/state_defs.h"
|
||||
#include "nvim/syntax_defs.h"
|
||||
#include "nvim/types_defs.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "nvim/event/multiqueue.h" // IWYU pragma: keep
|
||||
#include "nvim/event/defs.h" // IWYU pragma: keep
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "input.h.generated.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
|
||||
#include "nvim/func_attr.h"
|
||||
#include "nvim/macros_defs.h"
|
||||
#include "nvim/map_defs.h"
|
||||
#include "nvim/types_defs.h"
|
||||
#include "nvim/usercmd.h" // IWYU pragma: keep
|
||||
|
||||
|
@ -779,156 +779,6 @@ EXTERN int p_wb; ///< 'writebackup'
|
||||
EXTERN OptInt p_wd; ///< 'writedelay'
|
||||
EXTERN int p_cdh; ///< 'cdhome'
|
||||
|
||||
/// "indir" values for buffer-local options.
|
||||
/// These need to be defined globally, so that the BV_COUNT can be used with
|
||||
/// b_p_script_stx[].
|
||||
enum {
|
||||
BV_AI = 0,
|
||||
BV_AR,
|
||||
BV_BH,
|
||||
BV_BKC,
|
||||
BV_BT,
|
||||
BV_EFM,
|
||||
BV_GP,
|
||||
BV_MP,
|
||||
BV_BIN,
|
||||
BV_BL,
|
||||
BV_BOMB,
|
||||
BV_CHANNEL,
|
||||
BV_CI,
|
||||
BV_CIN,
|
||||
BV_CINK,
|
||||
BV_CINO,
|
||||
BV_CINW,
|
||||
BV_CINSD,
|
||||
BV_CM,
|
||||
BV_CMS,
|
||||
BV_COM,
|
||||
BV_CPT,
|
||||
BV_DICT,
|
||||
BV_TSR,
|
||||
BV_CSL,
|
||||
BV_CFU,
|
||||
BV_DEF,
|
||||
BV_INC,
|
||||
BV_EOF,
|
||||
BV_EOL,
|
||||
BV_FIXEOL,
|
||||
BV_EP,
|
||||
BV_ET,
|
||||
BV_FENC,
|
||||
BV_FP,
|
||||
BV_BEXPR,
|
||||
BV_FEX,
|
||||
BV_FF,
|
||||
BV_FLP,
|
||||
BV_FO,
|
||||
BV_FT,
|
||||
BV_IMI,
|
||||
BV_IMS,
|
||||
BV_INDE,
|
||||
BV_INDK,
|
||||
BV_INEX,
|
||||
BV_INF,
|
||||
BV_ISK,
|
||||
BV_KMAP,
|
||||
BV_KP,
|
||||
BV_LISP,
|
||||
BV_LOP,
|
||||
BV_LW,
|
||||
BV_MENC,
|
||||
BV_MA,
|
||||
BV_ML,
|
||||
BV_MOD,
|
||||
BV_MPS,
|
||||
BV_NF,
|
||||
BV_OFU,
|
||||
BV_PATH,
|
||||
BV_PI,
|
||||
BV_QE,
|
||||
BV_RO,
|
||||
BV_SCBK,
|
||||
BV_SI,
|
||||
BV_SMC,
|
||||
BV_SYN,
|
||||
BV_SPC,
|
||||
BV_SPF,
|
||||
BV_SPL,
|
||||
BV_SPO,
|
||||
BV_STS,
|
||||
BV_SUA,
|
||||
BV_SW,
|
||||
BV_SWF,
|
||||
BV_TFU,
|
||||
BV_TSRFU,
|
||||
BV_TAGS,
|
||||
BV_TC,
|
||||
BV_TS,
|
||||
BV_TW,
|
||||
BV_TX,
|
||||
BV_UDF,
|
||||
BV_UL,
|
||||
BV_WM,
|
||||
BV_VSTS,
|
||||
BV_VTS,
|
||||
BV_COUNT, // must be the last one
|
||||
};
|
||||
|
||||
/// "indir" values for window-local options.
|
||||
/// These need to be defined globally, so that the WV_COUNT can be used in the
|
||||
/// window structure.
|
||||
enum {
|
||||
WV_LIST = 0,
|
||||
WV_ARAB,
|
||||
WV_COCU,
|
||||
WV_COLE,
|
||||
WV_CRBIND,
|
||||
WV_BRI,
|
||||
WV_BRIOPT,
|
||||
WV_DIFF,
|
||||
WV_FDC,
|
||||
WV_FEN,
|
||||
WV_FDI,
|
||||
WV_FDL,
|
||||
WV_FDM,
|
||||
WV_FML,
|
||||
WV_FDN,
|
||||
WV_FDE,
|
||||
WV_FDT,
|
||||
WV_FMR,
|
||||
WV_LBR,
|
||||
WV_NU,
|
||||
WV_RNU,
|
||||
WV_VE,
|
||||
WV_NUW,
|
||||
WV_PVW,
|
||||
WV_RL,
|
||||
WV_RLC,
|
||||
WV_SCBIND,
|
||||
WV_SCROLL,
|
||||
WV_SMS,
|
||||
WV_SISO,
|
||||
WV_SO,
|
||||
WV_SPELL,
|
||||
WV_CUC,
|
||||
WV_CUL,
|
||||
WV_CULOPT,
|
||||
WV_CC,
|
||||
WV_SBR,
|
||||
WV_STC,
|
||||
WV_STL,
|
||||
WV_WFH,
|
||||
WV_WFW,
|
||||
WV_WRAP,
|
||||
WV_SCL,
|
||||
WV_WINHL,
|
||||
WV_LCS,
|
||||
WV_FCS,
|
||||
WV_WINBL,
|
||||
WV_WBR,
|
||||
WV_COUNT, // must be the last one
|
||||
};
|
||||
|
||||
// Value for b_p_ul indicating the global value must be used.
|
||||
#define NO_LOCAL_UNDOLEVEL (-123456)
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include "nvim/types_defs.h"
|
||||
#include "nvim/viml/parser/parser.h"
|
||||
|
||||
struct expr_ast_node;
|
||||
|
||||
// Defines whether to ignore case:
|
||||
// == kCCStrategyUseOption
|
||||
// ==# kCCStrategyMatchCase
|
||||
|
Loading…
Reference in New Issue
Block a user