aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2024-11-23 14:22:06 +0600
committerGitHub <noreply@github.com>2024-11-23 08:22:06 +0000
commit8516c2dc1f301c439695629fff771227dbe00d30 (patch)
tree5e052ad234f99cdbfce89b03ba71796a8cd274ef
parent9a681ad09e2add96d47bf3f39cca8029f3bf09df (diff)
downloadrneovim-8516c2dc1f301c439695629fff771227dbe00d30.tar.gz
rneovim-8516c2dc1f301c439695629fff771227dbe00d30.tar.bz2
rneovim-8516c2dc1f301c439695629fff771227dbe00d30.zip
refactor(options): autogenerate valid values and flag enums for options (#31089)
Problem: Option metadata like list of valid values for an option and option flags are not listed in the `options.lua` file and are instead manually defined in C, which means option metadata is split between several places. Solution: Put metadata such as list of valid values for an option and option flags in `options.lua`, and autogenerate the corresponding C variables and enums. Supersedes #28659 Co-authored-by: glepnir <glephunter@gmail.com>
-rw-r--r--src/nvim/CMakeLists.txt6
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/buffer.c20
-rw-r--r--src/nvim/buffer_defs.h2
-rw-r--r--src/nvim/bufwrite.c10
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/charset.c8
-rw-r--r--src/nvim/cmdexpand.c10
-rw-r--r--src/nvim/cursor.c6
-rw-r--r--src/nvim/diff.c6
-rw-r--r--src/nvim/drawline.c14
-rw-r--r--src/nvim/drawscreen.c10
-rw-r--r--src/nvim/edit.c54
-rw-r--r--src/nvim/ex_getln.c46
-rw-r--r--src/nvim/ex_session.c80
-rw-r--r--src/nvim/generators/gen_options.lua92
-rw-r--r--src/nvim/getchar.c2
-rw-r--r--src/nvim/grid.c8
-rw-r--r--src/nvim/indent.c6
-rw-r--r--src/nvim/insexpand.c28
-rw-r--r--src/nvim/main.c2
-rw-r--r--src/nvim/mark.c4
-rw-r--r--src/nvim/mbyte.c8
-rw-r--r--src/nvim/message.c6
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/normal.c53
-rw-r--r--src/nvim/ops.c38
-rw-r--r--src/nvim/option.c15
-rw-r--r--src/nvim/option_vars.h140
-rw-r--r--src/nvim/options.lua229
-rw-r--r--src/nvim/optionstr.c434
-rw-r--r--src/nvim/popupmenu.c8
-rw-r--r--src/nvim/quickfix.c6
-rw-r--r--src/nvim/search.c6
-rw-r--r--src/nvim/spell.c4
-rw-r--r--src/nvim/spellsuggest.c4
-rw-r--r--src/nvim/state.c6
-rw-r--r--src/nvim/tag.c16
-rw-r--r--src/nvim/terminal.c20
-rw-r--r--src/nvim/ui.c8
-rw-r--r--src/nvim/ui_compositor.c6
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/window.c10
43 files changed, 774 insertions, 665 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 38b54082c3..e2b1036d95 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -322,6 +322,7 @@ set(GENERATED_KEYSETS_DEFS ${GENERATED_DIR}/keysets_defs.generated.h)
set(GENERATED_OPTIONS ${GENERATED_DIR}/options.generated.h)
set(GENERATED_OPTIONS_ENUM ${GENERATED_DIR}/options_enum.generated.h)
set(GENERATED_OPTIONS_MAP ${GENERATED_DIR}/options_map.generated.h)
+set(GENERATED_OPTION_VARS ${GENERATED_DIR}/option_vars.generated.h)
set(GENERATED_UI_EVENTS_CALL ${GENERATED_DIR}/ui_events_call.generated.h)
set(GENERATED_UI_EVENTS_CLIENT ${GENERATED_DIR}/ui_events_client.generated.h)
set(GENERATED_UI_EVENTS_REMOTE ${GENERATED_DIR}/ui_events_remote.generated.h)
@@ -657,6 +658,7 @@ list(APPEND NVIM_GENERATED_FOR_HEADERS
"${GENERATED_EVENTS_ENUM}"
"${GENERATED_KEYSETS_DEFS}"
"${GENERATED_OPTIONS_ENUM}"
+ "${GENERATED_OPTION_VARS}"
)
list(APPEND NVIM_GENERATED_FOR_SOURCES
@@ -686,8 +688,8 @@ add_custom_command(OUTPUT ${GENERATED_EVENTS_ENUM} ${GENERATED_EVENTS_NAMES_MAP}
DEPENDS ${LUA_GEN_DEPS} ${EVENTS_GENERATOR} ${CMAKE_CURRENT_LIST_DIR}/auevents.lua
)
-add_custom_command(OUTPUT ${GENERATED_OPTIONS} ${GENERATED_OPTIONS_ENUM} ${GENERATED_OPTIONS_MAP}
- COMMAND ${LUA_GEN} ${OPTIONS_GENERATOR} ${GENERATED_OPTIONS} ${GENERATED_OPTIONS_ENUM} ${GENERATED_OPTIONS_MAP}
+add_custom_command(OUTPUT ${GENERATED_OPTIONS} ${GENERATED_OPTIONS_ENUM} ${GENERATED_OPTIONS_MAP} ${GENERATED_OPTION_VARS}
+ COMMAND ${LUA_GEN} ${OPTIONS_GENERATOR} ${GENERATED_OPTIONS} ${GENERATED_OPTIONS_ENUM} ${GENERATED_OPTIONS_MAP} ${GENERATED_OPTION_VARS}
DEPENDS ${LUA_GEN_DEPS} ${OPTIONS_GENERATOR} ${CMAKE_CURRENT_LIST_DIR}/options.lua
)
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 83f9aa573d..ab52612f9f 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -2156,7 +2156,7 @@ Dict nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *arena,
if (statuscol.foldinfo.fi_level != 0 && statuscol.foldinfo.fi_lines > 0) {
wp->w_cursorline = statuscol.foldinfo.fi_lnum;
}
- statuscol.use_cul = lnum == wp->w_cursorline && (wp->w_p_culopt_flags & CULOPT_NBR);
+ statuscol.use_cul = lnum == wp->w_cursorline && (wp->w_p_culopt_flags & kOptCuloptFlagNumber);
}
statuscol.sign_cul_id = statuscol.use_cul ? cul_id : 0;
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 1908516e85..56ddadeb5c 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1393,7 +1393,7 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
// If the buffer to be deleted is not the current one, delete it here.
if (buf != curbuf) {
- if (jop_flags & JOP_CLEAN) {
+ if (jop_flags & kOptJopFlagClean) {
// Remove the buffer to be deleted from the jump list.
mark_jumplist_forget_file(curwin, buf_fnum);
}
@@ -1419,7 +1419,7 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
if (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf)) {
buf = au_new_curbuf.br_buf;
} else if (curwin->w_jumplistlen > 0) {
- if (jop_flags & JOP_CLEAN) {
+ if (jop_flags & kOptJopFlagClean) {
// Remove the buffer from the jump list.
mark_jumplist_forget_file(curwin, buf_fnum);
}
@@ -1429,7 +1429,7 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
if (curwin->w_jumplistlen > 0) {
int jumpidx = curwin->w_jumplistidx;
- if (jop_flags & JOP_CLEAN) {
+ if (jop_flags & kOptJopFlagClean) {
// If the index is the same as the length, the current position was not yet added to the
// jump list. So we can safely go back to the last entry and search from there.
if (jumpidx == curwin->w_jumplistlen) {
@@ -1443,7 +1443,7 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
}
forward = jumpidx;
- while ((jop_flags & JOP_CLEAN) || jumpidx != curwin->w_jumplistidx) {
+ while ((jop_flags & kOptJopFlagClean) || jumpidx != curwin->w_jumplistidx) {
buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum);
if (buf != NULL) {
@@ -1460,7 +1460,7 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
}
}
if (buf != NULL) { // found a valid buffer: stop searching
- if (jop_flags & JOP_CLEAN) {
+ if (jop_flags & kOptJopFlagClean) {
curwin->w_jumplistidx = jumpidx;
update_jumplist = false;
}
@@ -2159,11 +2159,11 @@ int buflist_getfile(int n, linenr_T lnum, int options, int forceit)
// If 'switchbuf' contains "split", "vsplit" or "newtab" and the
// current buffer isn't empty: open new tab or window
- if (wp == NULL && (swb_flags & (SWB_VSPLIT | SWB_SPLIT | SWB_NEWTAB))
+ if (wp == NULL && (swb_flags & (kOptSwbFlagVsplit | kOptSwbFlagSplit | kOptSwbFlagNewtab))
&& !buf_is_empty(curbuf)) {
- if (swb_flags & SWB_NEWTAB) {
+ if (swb_flags & kOptSwbFlagNewtab) {
tabpage_new();
- } else if (win_split(0, (swb_flags & SWB_VSPLIT) ? WSP_VERT : 0)
+ } else if (win_split(0, (swb_flags & kOptSwbFlagVsplit) ? WSP_VERT : 0)
== FAIL) {
return FAIL;
}
@@ -2183,7 +2183,7 @@ int buflist_getfile(int n, linenr_T lnum, int options, int forceit)
curwin->w_cursor.coladd = 0;
curwin->w_set_curswant = true;
}
- if (jop_flags & JOP_VIEW && restore_view) {
+ if (jop_flags & kOptJopFlagView && restore_view) {
mark_view_restore(fm);
}
return OK;
@@ -3638,7 +3638,7 @@ void ex_buffer_all(exarg_T *eap)
// Open the buffer in this window.
swap_exists_action = SEA_DIALOG;
- set_curbuf(buf, DOBUF_GOTO, !(jop_flags & JOP_CLEAN));
+ set_curbuf(buf, DOBUF_GOTO, !(jop_flags & kOptJopFlagClean));
if (!bufref_valid(&bufref)) {
// Autocommands deleted the buffer.
swap_exists_action = SEA_NONE;
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index a8f3fc45b9..bb6eef3c29 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -316,8 +316,6 @@ typedef struct {
char *b_p_spf; // 'spellfile'
char *b_p_spl; // 'spelllang'
char *b_p_spo; // 'spelloptions'
-#define SPO_CAMEL 0x1
-#define SPO_NPBUFFER 0x2
unsigned b_p_spo_flags; // 'spelloptions' flags
int b_cjk; // all CJK letters as OK
uint8_t b_syn_chartab[32]; // syntax iskeyword option
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c
index 5f830b4219..95639bed70 100644
--- a/src/nvim/bufwrite.c
+++ b/src/nvim/bufwrite.c
@@ -725,9 +725,9 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
FileInfo file_info;
const bool no_prepend_dot = false;
- if ((bkc & BKC_YES) || append) { // "yes"
+ if ((bkc & kOptBkcFlagYes) || append) { // "yes"
*backup_copyp = true;
- } else if ((bkc & BKC_AUTO)) { // "auto"
+ } else if ((bkc & kOptBkcFlagAuto)) { // "auto"
// Don't rename the file when:
// - it's a hard link
// - it's a symbolic link
@@ -773,19 +773,19 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
}
// Break symlinks and/or hardlinks if we've been asked to.
- if ((bkc & BKC_BREAKSYMLINK) || (bkc & BKC_BREAKHARDLINK)) {
+ if ((bkc & kOptBkcFlagBreaksymlink) || (bkc & kOptBkcFlagBreakhardlink)) {
#ifdef UNIX
bool file_info_link_ok = os_fileinfo_link(fname, &file_info);
// Symlinks.
- if ((bkc & BKC_BREAKSYMLINK)
+ if ((bkc & kOptBkcFlagBreaksymlink)
&& file_info_link_ok
&& !os_fileinfo_id_equal(&file_info, file_info_old)) {
*backup_copyp = false;
}
// Hardlinks.
- if ((bkc & BKC_BREAKHARDLINK)
+ if ((bkc & kOptBkcFlagBreakhardlink)
&& os_fileinfo_hardlinks(file_info_old) > 1
&& (!file_info_link_ok
|| os_fileinfo_id_equal(&file_info, file_info_old))) {
diff --git a/src/nvim/change.c b/src/nvim/change.c
index f3a8e0b208..faaae96af9 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -914,7 +914,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
// fixpos is true, we don't want to end up positioned at the NUL,
// unless "restart_edit" is set or 'virtualedit' contains "onemore".
if (col > 0 && fixpos && restart_edit == 0
- && (get_ve_flags(curwin) & VE_ONEMORE) == 0) {
+ && (get_ve_flags(curwin) & kOptVeFlagOnemore) == 0) {
curwin->w_cursor.col--;
curwin->w_cursor.coladd = 0;
curwin->w_cursor.col -= utf_head_off(oldp, oldp + curwin->w_cursor.col);
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 1afd590b0e..f72420a00f 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -95,7 +95,7 @@ int buf_init_chartab(buf_T *buf, bool global)
int c = 0;
while (c < ' ') {
- g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;
+ g_chartab[c++] = (dy_flags & kOptDyFlagUhex) ? 4 : 2;
}
while (c <= '~') {
@@ -109,7 +109,7 @@ int buf_init_chartab(buf_T *buf, bool global)
g_chartab[c++] = (CT_PRINT_CHAR | CT_FNAME_CHAR) + 1;
} else {
// the rest is unprintable by default
- g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;
+ g_chartab[c++] = (dy_flags & kOptDyFlagUhex) ? 4 : 2;
}
}
}
@@ -237,7 +237,7 @@ static int parse_isopt(const char *var, buf_T *buf, bool only_check)
if (c < ' ' || c > '~') {
if (tilde) {
g_chartab[c] = (uint8_t)((g_chartab[c] & ~CT_CELL_MASK)
- + ((dy_flags & DY_UHEX) ? 4 : 2));
+ + ((dy_flags & kOptDyFlagUhex) ? 4 : 2));
g_chartab[c] &= (uint8_t) ~CT_PRINT_CHAR;
} else {
g_chartab[c] = (uint8_t)((g_chartab[c] & ~CT_CELL_MASK) + 1);
@@ -614,7 +614,7 @@ void transchar_nonprint(const buf_T *buf, char *charbuf, int c)
}
assert(c <= 0xff);
- if (dy_flags & DY_UHEX || c > 0x7f) {
+ if (dy_flags & kOptDyFlagUhex || c > 0x7f) {
// 'display' has "uhex"
transchar_hex(charbuf, c);
} else {
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 9b1193b4e0..d977b20cc4 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -100,7 +100,7 @@ static int compl_selected;
static bool cmdline_fuzzy_completion_supported(const expand_T *const xp)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
{
- return (wop_flags & WOP_FUZZY)
+ return (wop_flags & kOptWopFlagFuzzy)
&& xp->xp_context != EXPAND_BOOL_SETTINGS
&& xp->xp_context != EXPAND_COLORS
&& xp->xp_context != EXPAND_COMPILER
@@ -133,7 +133,7 @@ static bool cmdline_fuzzy_completion_supported(const expand_T *const xp)
bool cmdline_fuzzy_complete(const char *const fuzzystr)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
{
- return (wop_flags & WOP_FUZZY) && *fuzzystr != NUL;
+ return (wop_flags & kOptWopFlagFuzzy) && *fuzzystr != NUL;
}
/// Sort function for the completion matches.
@@ -806,7 +806,7 @@ static char *find_longest_match(expand_T *xp, int options)
}
if (i < xp->xp_numfiles) {
if (!(options & WILD_NO_BEEP)) {
- vim_beep(BO_WILD);
+ vim_beep(kOptBoFlagWildmode);
}
break;
}
@@ -1069,7 +1069,7 @@ int showmatches(expand_T *xp, bool wildmenu)
bool compl_use_pum = (ui_has(kUICmdline)
? ui_has(kUIPopupmenu)
- : wildmenu && (wop_flags & WOP_PUM))
+ : wildmenu && (wop_flags & kOptWopFlagPum))
|| ui_has(kUIWildmenu);
if (compl_use_pum) {
@@ -1939,7 +1939,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa
case CMD_tjump:
case CMD_stjump:
case CMD_ptjump:
- if (wop_flags & WOP_TAGFILE) {
+ if (wop_flags & kOptWopFlagTagfile) {
xp->xp_context = EXPAND_TAGS_LISTFILES;
} else {
xp->xp_context = EXPAND_TAGS;
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index 35afca2fe9..2b18c51571 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -105,7 +105,7 @@ static int coladvance2(win_T *wp, pos_T *pos, bool addspaces, bool finetune, col
|| (State & MODE_TERMINAL)
|| restart_edit != NUL
|| (VIsual_active && *p_sel != 'o')
- || ((get_ve_flags(wp) & VE_ONEMORE) && wcol < MAXCOL);
+ || ((get_ve_flags(wp) & kOptVeFlagOnemore) && wcol < MAXCOL);
char *line = ml_get_buf(wp->w_buffer, pos->lnum);
int linelen = ml_get_buf_len(wp->w_buffer, pos->lnum);
@@ -345,7 +345,7 @@ void check_cursor_col(win_T *win)
// - 'virtualedit' is set
if ((State & MODE_INSERT) || restart_edit
|| (VIsual_active && *p_sel != 'o')
- || (cur_ve_flags & VE_ONEMORE)
+ || (cur_ve_flags & kOptVeFlagOnemore)
|| virtual_active(win)) {
win->w_cursor.col = len;
} else {
@@ -362,7 +362,7 @@ void check_cursor_col(win_T *win)
// line.
if (oldcol == MAXCOL) {
win->w_cursor.coladd = 0;
- } else if (cur_ve_flags == VE_ALL) {
+ } else if (cur_ve_flags == kOptVeFlagAll) {
if (oldcoladd > win->w_cursor.col) {
win->w_cursor.coladd = oldcoladd - win->w_cursor.col;
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index f1dd08f0e6..20f93049c1 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -2417,7 +2417,7 @@ int diffopt_changed(void)
char *p = p_dip;
while (*p != NUL) {
- // Note: Keep this in sync with p_dip_values
+ // Note: Keep this in sync with opt_dip_values.
if (strncmp(p, "filler", 6) == 0) {
p += 6;
diff_flags_new |= DIFF_FILLER;
@@ -2464,7 +2464,7 @@ int diffopt_changed(void)
p += 8;
diff_flags_new |= DIFF_INTERNAL;
} else if (strncmp(p, "algorithm:", 10) == 0) {
- // Note: Keep this in sync with p_dip_algorithm_values.
+ // Note: Keep this in sync with opt_dip_algorithm_values.
p += 10;
if (strncmp(p, "myers", 5) == 0) {
p += 5;
@@ -2745,7 +2745,7 @@ bool diff_infold(win_T *wp, linenr_T lnum)
void nv_diffgetput(bool put, size_t count)
{
if (bt_prompt(curbuf)) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
return;
}
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 79f3298eb4..10811d40f8 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -395,7 +395,7 @@ static bool use_cursor_line_highlight(win_T *wp, linenr_T lnum)
{
return wp->w_p_cul
&& lnum == wp->w_cursorline
- && (wp->w_p_culopt_flags & CULOPT_NBR);
+ && (wp->w_p_culopt_flags & kOptCuloptFlagNumber);
}
/// Setup for drawing the 'foldcolumn', if there is one.
@@ -507,10 +507,10 @@ static bool use_cursor_line_nr(win_T *wp, winlinevars_T *wlv)
{
return wp->w_p_cul
&& wlv->lnum == wp->w_cursorline
- && (wp->w_p_culopt_flags & CULOPT_NBR)
+ && (wp->w_p_culopt_flags & kOptCuloptFlagNumber)
&& (wlv->row == wlv->startrow + wlv->filler_lines
|| (wlv->row > wlv->startrow + wlv->filler_lines
- && (wp->w_p_culopt_flags & CULOPT_LINE)));
+ && (wp->w_p_culopt_flags & kOptCuloptFlagLine)));
}
static int get_line_number_attr(win_T *wp, winlinevars_T *wlv)
@@ -1165,11 +1165,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
wlv.filler_todo = wlv.filler_lines;
// Cursor line highlighting for 'cursorline' in the current window.
- if (wp->w_p_cul && wp->w_p_culopt_flags != CULOPT_NBR && lnum == wp->w_cursorline
+ if (wp->w_p_cul && wp->w_p_culopt_flags != kOptCuloptFlagNumber && lnum == wp->w_cursorline
// Do not show the cursor line in the text when Visual mode is active,
// because it's not clear what is selected then.
&& !(wp == curwin && VIsual_active)) {
- cul_screenline = (is_wrapped && (wp->w_p_culopt_flags & CULOPT_SCRLINE));
+ cul_screenline = (is_wrapped && (wp->w_p_culopt_flags & kOptCuloptFlagScreenline));
if (!cul_screenline) {
apply_cursorline_highlight(wp, &wlv);
} else {
@@ -1949,7 +1949,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
decor_attr = 0;
if (extra_check) {
- const bool no_plain_buffer = (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) != 0;
+ const bool no_plain_buffer = (wp->w_s->b_p_spo_flags & kOptSpoFlagNoplainbuffer) != 0;
bool can_spell = !no_plain_buffer;
// Get extmark and syntax attributes, unless still at the start of the line
@@ -2324,7 +2324,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
if (wlv.n_extra == 0) {
wlv.n_extra = byte2cells(mb_c) - 1;
}
- if ((dy_flags & DY_UHEX) && wp->w_p_rl) {
+ if ((dy_flags & kOptDyFlagUhex) && wp->w_p_rl) {
rl_mirror_ascii(wlv.p_extra, NULL); // reverse "<12>"
}
wlv.sc_extra = NUL;
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index e90a0d945f..3719d38df2 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -1882,7 +1882,7 @@ static void win_update(win_T *wp)
unsigned save_ve_flags = curwin->w_ve_flags;
if (curwin->w_p_lbr) {
- curwin->w_ve_flags = VE_ALL;
+ curwin->w_ve_flags = kOptVeFlagAll;
}
getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
@@ -1891,7 +1891,7 @@ static void win_update(win_T *wp)
// Highlight to the end of the line, unless 'virtualedit' has
// "block".
if (curwin->w_curswant == MAXCOL) {
- if (get_ve_flags(curwin) & VE_BLOCK) {
+ if (get_ve_flags(curwin) & kOptVeFlagBlock) {
pos_T pos;
int cursor_above = curwin->w_cursor.lnum < VIsual.lnum;
@@ -2227,7 +2227,7 @@ static void win_update(win_T *wp)
&& wp->w_lines[idx].wl_valid
&& wp->w_lines[idx].wl_lnum == lnum
&& lnum > wp->w_topline
- && !(dy_flags & (DY_LASTLINE | DY_TRUNCATE))
+ && !(dy_flags & (kOptDyFlagLastline | kOptDyFlagTruncate))
&& srow + wp->w_lines[idx].wl_size > wp->w_grid.rows
&& win_get_fill(wp, lnum) == 0) {
// This line is not going to fit. Don't draw anything here,
@@ -2354,7 +2354,7 @@ redr_statuscol:
// Window ends in filler lines.
wp->w_botline = lnum;
wp->w_filler_rows = wp->w_grid.rows - srow;
- } else if (dy_flags & DY_TRUNCATE) { // 'display' has "truncate"
+ } else if (dy_flags & kOptDyFlagTruncate) { // 'display' has "truncate"
// Last line isn't finished: Display "@@@" in the last screen line.
grid_line_start(&wp->w_grid, wp->w_grid.rows - 1);
grid_line_fill(0, MIN(wp->w_grid.cols, 3), wp->w_p_fcs_chars.lastline, at_attr);
@@ -2362,7 +2362,7 @@ redr_statuscol:
grid_line_flush();
set_empty_rows(wp, srow);
wp->w_botline = lnum;
- } else if (dy_flags & DY_LASTLINE) { // 'display' has "lastline"
+ } else if (dy_flags & kOptDyFlagLastline) { // 'display' has "lastline"
// Last line isn't finished: Display "@@@" at the end.
// If this would split a doublewidth char in two, we need to display "@@@@" instead
grid_line_start(&wp->w_grid, wp->w_grid.rows - 1);
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index f06dc124f0..248f419807 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -440,7 +440,7 @@ static int insert_check(VimState *state)
msg_scroll = false;
// Open fold at the cursor line, according to 'foldopen'.
- if (fdo_flags & FDO_INSERT) {
+ if (fdo_flags & kOptFdoFlagInsert) {
foldOpenCursor();
}
@@ -751,7 +751,7 @@ static int insert_handle_key(InsertState *s)
ins_ctrl_o();
// don't move the cursor left when 'virtualedit' has "onemore".
- if (get_ve_flags(curwin) & VE_ONEMORE) {
+ if (get_ve_flags(curwin) & kOptVeFlagOnemore) {
ins_at_eol = false;
s->nomove = true;
}
@@ -2518,7 +2518,7 @@ int oneright(void)
// move "l" bytes right, but don't end up on the NUL, unless 'virtualedit'
// contains "onemore".
- if (ptr[l] == NUL && (get_ve_flags(curwin) & VE_ONEMORE) == 0) {
+ if (ptr[l] == NUL && (get_ve_flags(curwin) & kOptVeFlagOnemore) == 0) {
return FAIL;
}
curwin->w_cursor.col += l;
@@ -2600,7 +2600,7 @@ void cursor_up_inner(win_T *wp, linenr_T n)
// If we entered a fold, move to the beginning, unless in
// Insert mode or when 'foldopen' contains "all": it will open
// in a moment.
- if (n > 0 || !((State & MODE_INSERT) || (fdo_flags & FDO_ALL))) {
+ if (n > 0 || !((State & MODE_INSERT) || (fdo_flags & kOptFdoFlagAll))) {
hasFolding(wp, lnum, &lnum, NULL);
}
}
@@ -3223,7 +3223,7 @@ static void ins_reg(void)
check_cursor(curwin);
}
if (regname == NUL || !valid_yank_reg(regname, false)) {
- vim_beep(BO_REG);
+ vim_beep(kOptBoFlagRegister);
need_redraw = true; // remove the '"'
} else {
if (literally == Ctrl_O || literally == Ctrl_P) {
@@ -3235,7 +3235,7 @@ static void ins_reg(void)
do_put(regname, NULL, BACKWARD, 1,
(literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND);
} else if (insert_reg(regname, literally) == FAIL) {
- vim_beep(BO_REG);
+ vim_beep(kOptBoFlagRegister);
need_redraw = true; // remove the '"'
} else if (stop_insert_mode) {
// When the '=' register was used and a function was invoked that
@@ -3314,7 +3314,7 @@ static void ins_ctrl_g(void)
// Unknown CTRL-G command, reserved for future expansion.
default:
- vim_beep(BO_CTRLG);
+ vim_beep(kOptBoFlagCtrlg);
}
}
@@ -3412,7 +3412,7 @@ static bool ins_esc(int *count, int cmdchar, bool nomove)
&& (curwin->w_cursor.col != 0 || curwin->w_cursor.coladd > 0)
&& (restart_edit == NUL || (gchar_cursor() == NUL && !VIsual_active))
&& !revins_on) {
- if (curwin->w_cursor.coladd > 0 || get_ve_flags(curwin) == VE_ALL) {
+ if (curwin->w_cursor.coladd > 0 || get_ve_flags(curwin) == kOptVeFlagAll) {
oneleft();
if (restart_edit != NUL) {
curwin->w_cursor.coladd++;
@@ -3598,7 +3598,7 @@ static void ins_del(void)
const int temp = curwin->w_cursor.col;
if (!can_bs(BS_EOL) // only if "eol" included
|| do_join(2, false, true, false, false) == FAIL) {
- vim_beep(BO_BS);
+ vim_beep(kOptBoFlagBackspace);
} else {
curwin->w_cursor.col = temp;
// Adjust orig_line_count in case more lines have been deleted than
@@ -3610,7 +3610,7 @@ static void ins_del(void)
}
}
} else if (del_char(false) == FAIL) { // delete char under cursor
- vim_beep(BO_BS);
+ vim_beep(kOptBoFlagBackspace);
}
did_ai = false;
did_si = false;
@@ -3649,7 +3649,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|| (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0
&& curwin->w_cursor.col <= ai_col)
|| (!can_bs(BS_EOL) && curwin->w_cursor.col == 0)))) {
- vim_beep(BO_BS);
+ vim_beep(kOptBoFlagBackspace);
return false;
}
@@ -3962,7 +3962,7 @@ static void ins_left(void)
{
const bool end_change = dont_sync_undo == kFalse; // end undoable change
- if ((fdo_flags & FDO_HOR) && KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped) {
foldOpenCursor();
}
undisplay_dollar();
@@ -3985,14 +3985,14 @@ static void ins_left(void)
coladvance(curwin, MAXCOL);
curwin->w_set_curswant = true; // so we stay at the end
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
dont_sync_undo = kFalse;
}
static void ins_home(int c)
{
- if ((fdo_flags & FDO_HOR) && KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped) {
foldOpenCursor();
}
undisplay_dollar();
@@ -4008,7 +4008,7 @@ static void ins_home(int c)
static void ins_end(int c)
{
- if ((fdo_flags & FDO_HOR) && KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped) {
foldOpenCursor();
}
undisplay_dollar();
@@ -4025,7 +4025,7 @@ static void ins_end(int c)
static void ins_s_left(void)
{
const bool end_change = dont_sync_undo == kFalse; // end undoable change
- if ((fdo_flags & FDO_HOR) && KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped) {
foldOpenCursor();
}
undisplay_dollar();
@@ -4037,7 +4037,7 @@ static void ins_s_left(void)
bck_word(1, false, false);
curwin->w_set_curswant = true;
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
dont_sync_undo = kFalse;
}
@@ -4046,7 +4046,7 @@ static void ins_s_left(void)
static void ins_right(void)
{
const bool end_change = dont_sync_undo == kFalse; // end undoable change
- if ((fdo_flags & FDO_HOR) && KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped) {
foldOpenCursor();
}
undisplay_dollar();
@@ -4075,7 +4075,7 @@ static void ins_right(void)
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
dont_sync_undo = kFalse;
}
@@ -4083,7 +4083,7 @@ static void ins_right(void)
static void ins_s_right(void)
{
const bool end_change = dont_sync_undo == kFalse; // end undoable change
- if ((fdo_flags & FDO_HOR) && KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped) {
foldOpenCursor();
}
undisplay_dollar();
@@ -4096,7 +4096,7 @@ static void ins_s_right(void)
fwd_word(1, false, 0);
curwin->w_set_curswant = true;
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
dont_sync_undo = kFalse;
}
@@ -4120,7 +4120,7 @@ static void ins_up(bool startcol)
start_arrow(&tpos);
can_cindent = true;
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
}
@@ -4142,7 +4142,7 @@ static void ins_pageup(void)
start_arrow(&tpos);
can_cindent = true;
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
}
@@ -4165,7 +4165,7 @@ static void ins_down(bool startcol)
start_arrow(&tpos);
can_cindent = true;
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
}
@@ -4187,7 +4187,7 @@ static void ins_pagedown(void)
start_arrow(&tpos);
can_cindent = true;
} else {
- vim_beep(BO_CRSR);
+ vim_beep(kOptBoFlagCursor);
}
}
@@ -4535,7 +4535,7 @@ static int ins_digraph(void)
int ins_copychar(linenr_T lnum)
{
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) {
- vim_beep(BO_COPY);
+ vim_beep(kOptBoFlagCopy);
return NUL;
}
@@ -4558,7 +4558,7 @@ int ins_copychar(linenr_T lnum)
int c = ci.chr.value < 0 ? (uint8_t)(*ci.ptr) : ci.chr.value;
if (c == NUL) {
- vim_beep(BO_COPY);
+ vim_beep(kOptBoFlagCopy);
}
return c;
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index ace62ea729..2d9d4417dd 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1070,23 +1070,23 @@ static int command_line_wildchar_complete(CommandLineState *s)
{
int res;
int options = WILD_NO_BEEP;
- if (wim_flags[s->wim_index] & WIM_BUFLASTUSED) {
+ if (wim_flags[s->wim_index] & kOptWimFlagLastused) {
options |= WILD_BUFLASTUSED;
}
if (s->xpc.xp_numfiles > 0) { // typed p_wc at least twice
// if 'wildmode' contains "list" may still need to list
if (s->xpc.xp_numfiles > 1
&& !s->did_wild_list
- && ((wim_flags[s->wim_index] & WIM_LIST)
- || (p_wmnu && (wim_flags[s->wim_index] & WIM_FULL) != 0))) {
- showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
+ && ((wim_flags[s->wim_index] & kOptWimFlagList)
+ || (p_wmnu && (wim_flags[s->wim_index] & kOptWimFlagFull) != 0))) {
+ showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & kOptWimFlagList) == 0));
redrawcmd();
s->did_wild_list = true;
}
- if (wim_flags[s->wim_index] & WIM_LONGEST) {
+ if (wim_flags[s->wim_index] & kOptWimFlagLongest) {
res = nextwild(&s->xpc, WILD_LONGEST, options, s->firstc != '@');
- } else if (wim_flags[s->wim_index] & WIM_FULL) {
+ } else if (wim_flags[s->wim_index] & kOptWimFlagFull) {
res = nextwild(&s->xpc, WILD_NEXT, options, s->firstc != '@');
} else {
res = OK; // don't insert 'wildchar' now
@@ -1097,7 +1097,7 @@ static int command_line_wildchar_complete(CommandLineState *s)
// if 'wildmode' first contains "longest", get longest
// common part
- if (wim_flags[0] & WIM_LONGEST) {
+ if (wim_flags[0] & kOptWimFlagLongest) {
res = nextwild(&s->xpc, WILD_LONGEST, options, s->firstc != '@');
} else {
res = nextwild(&s->xpc, WILD_EXPAND_KEEP, options, s->firstc != '@');
@@ -1118,12 +1118,12 @@ static int command_line_wildchar_complete(CommandLineState *s)
if (res == OK && s->xpc.xp_numfiles > 1) {
// a "longest" that didn't do anything is skipped (but not
// "list:longest")
- if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j) {
+ if (wim_flags[0] == kOptWimFlagLongest && ccline.cmdpos == j) {
s->wim_index = 1;
}
- if ((wim_flags[s->wim_index] & WIM_LIST)
- || (p_wmnu && (wim_flags[s->wim_index] & WIM_FULL) != 0)) {
- if (!(wim_flags[0] & WIM_LONGEST)) {
+ if ((wim_flags[s->wim_index] & kOptWimFlagList)
+ || (p_wmnu && (wim_flags[s->wim_index] & kOptWimFlagFull) != 0)) {
+ if (!(wim_flags[0] & kOptWimFlagLongest)) {
int p_wmnu_save = p_wmnu;
p_wmnu = 0;
// remove match
@@ -1131,17 +1131,17 @@ static int command_line_wildchar_complete(CommandLineState *s)
p_wmnu = p_wmnu_save;
}
- showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
+ showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & kOptWimFlagList) == 0));
redrawcmd();
s->did_wild_list = true;
- if (wim_flags[s->wim_index] & WIM_LONGEST) {
+ if (wim_flags[s->wim_index] & kOptWimFlagLongest) {
nextwild(&s->xpc, WILD_LONGEST, options, s->firstc != '@');
- } else if (wim_flags[s->wim_index] & WIM_FULL) {
+ } else if (wim_flags[s->wim_index] & kOptWimFlagFull) {
nextwild(&s->xpc, WILD_NEXT, options, s->firstc != '@');
}
} else {
- vim_beep(BO_WILD);
+ vim_beep(kOptBoFlagWildmode);
}
} else if (s->xpc.xp_numfiles == -1) {
s->xpc.xp_context = EXPAND_NOTHING;
@@ -1380,9 +1380,9 @@ static int command_line_execute(VimState *state, int key)
if (s->c == K_S_TAB && KeyTyped) {
if (nextwild(&s->xpc, WILD_EXPAND_KEEP, 0, s->firstc != '@') == OK) {
if (s->xpc.xp_numfiles > 1
- && ((!s->did_wild_list && (wim_flags[s->wim_index] & WIM_LIST)) || p_wmnu)) {
+ && ((!s->did_wild_list && (wim_flags[s->wim_index] & kOptWimFlagList)) || p_wmnu)) {
// Trigger the popup menu when wildoptions=pum
- showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
+ showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & kOptWimFlagList) == 0));
}
nextwild(&s->xpc, WILD_PREV, 0, s->firstc != '@');
nextwild(&s->xpc, WILD_PREV, 0, s->firstc != '@');
@@ -1511,7 +1511,7 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s
redrawcmdline();
curwin->w_cursor = s->match_end;
} else {
- vim_beep(BO_ERROR);
+ vim_beep(kOptBoFlagError);
}
restore_last_search_pattern();
return FAIL;
@@ -2820,19 +2820,19 @@ int check_opt_wim(void)
}
for (char *p = p_wim; *p; p++) {
- // Note: Keep this in sync with p_wim_values.
+ // Note: Keep this in sync with opt_wim_values.
for (i = 0; ASCII_ISALPHA(p[i]); i++) {}
if (p[i] != NUL && p[i] != ',' && p[i] != ':') {
return FAIL;
}
if (i == 7 && strncmp(p, "longest", 7) == 0) {
- new_wim_flags[idx] |= WIM_LONGEST;
+ new_wim_flags[idx] |= kOptWimFlagLongest;
} else if (i == 4 && strncmp(p, "full", 4) == 0) {
- new_wim_flags[idx] |= WIM_FULL;
+ new_wim_flags[idx] |= kOptWimFlagFull;
} else if (i == 4 && strncmp(p, "list", 4) == 0) {
- new_wim_flags[idx] |= WIM_LIST;
+ new_wim_flags[idx] |= kOptWimFlagList;
} else if (i == 8 && strncmp(p, "lastused", 8) == 0) {
- new_wim_flags[idx] |= WIM_BUFLASTUSED;
+ new_wim_flags[idx] |= kOptWimFlagLastused;
} else {
return FAIL;
}
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 50ee197ef4..e7837467e4 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -71,7 +71,7 @@ static int put_view_curpos(FILE *fd, const win_T *wp, char *spaces)
static int ses_winsizes(FILE *fd, bool restore_size, win_T *tab_firstwin)
{
- if (restore_size && (ssop_flags & SSOP_WINSIZE)) {
+ if (restore_size && (ssop_flags & kOptSsopFlagWinsize)) {
int n = 0;
for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
if (!ses_do_win(wp)) {
@@ -198,13 +198,13 @@ static int ses_do_win(win_T *wp)
if (wp->w_buffer->b_fname == NULL
// When 'buftype' is "nofile" can't restore the window contents.
|| (!wp->w_buffer->terminal && bt_nofilename(wp->w_buffer))) {
- return ssop_flags & SSOP_BLANK;
+ return ssop_flags & kOptSsopFlagBlank;
}
if (bt_help(wp->w_buffer)) {
- return ssop_flags & SSOP_HELP;
+ return ssop_flags & kOptSsopFlagHelp;
}
if (bt_terminal(wp->w_buffer)) {
- return ssop_flags & SSOP_TERMINAL;
+ return ssop_flags & kOptSsopFlagTerminal;
}
return true;
}
@@ -257,7 +257,7 @@ static char *ses_get_fname(buf_T *buf, const unsigned *flagp)
// directory is.
if (buf->b_sfname != NULL
&& flagp == &ssop_flags
- && (ssop_flags & (SSOP_CURDIR | SSOP_SESDIR))
+ && (ssop_flags & (kOptSsopFlagCurdir | kOptSsopFlagSesdir))
&& !p_acd
&& !did_lcd) {
return buf->b_sfname;
@@ -289,7 +289,7 @@ static char *ses_escape_fname(char *name, unsigned *flagp)
char *p;
char *sname = home_replace_save(NULL, name);
- // Always SSOP_SLASH: change all backslashes to forward slashes.
+ // Always kOptSsopFlagSlash: change all backslashes to forward slashes.
for (p = sname; *p != NUL; MB_PTR_ADV(p)) {
if (*p == '\\') {
*p = '/';
@@ -328,7 +328,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
// Always restore cursor position for ":mksession". For ":mkview" only
// when 'viewoptions' contains "cursor".
- bool do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR);
+ bool do_cursor = (flagp == &ssop_flags || *flagp & kOptSsopFlagCursor);
// Local argument list.
if (wp->w_alist == &global_alist) {
@@ -336,7 +336,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
} else {
if (ses_arglist(fd, "arglocal", &wp->w_alist->al_ga,
flagp == &vop_flags
- || !(*flagp & SSOP_CURDIR)
+ || !(*flagp & kOptSsopFlagCurdir)
|| wp->w_localdir != NULL, flagp) == FAIL) {
return FAIL;
}
@@ -417,7 +417,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
&& *alt->b_fname != NUL
&& alt->b_p_bl
// do not set balt if buffer is terminal and "terminal" is not set in options
- && !(bt_terminal(alt) && !(ssop_flags & SSOP_TERMINAL))
+ && !(bt_terminal(alt) && !(ssop_flags & kOptSsopFlagTerminal))
&& (fputs("balt ", fd) < 0
|| ses_fname(fd, alt, flagp, true) == FAIL)) {
return FAIL;
@@ -425,7 +425,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
}
// Local mappings and abbreviations.
- if ((*flagp & (SSOP_OPTIONS | SSOP_LOCALOPTIONS))
+ if ((*flagp & (kOptSsopFlagOptions | kOptSsopFlagLocaloptions))
&& makemap(fd, wp->w_buffer) == FAIL) {
return FAIL;
}
@@ -438,10 +438,10 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
win_T *save_curwin = curwin;
curwin = wp;
curbuf = curwin->w_buffer;
- if (*flagp & (SSOP_OPTIONS | SSOP_LOCALOPTIONS)) {
+ if (*flagp & (kOptSsopFlagOptions | kOptSsopFlagLocaloptions)) {
f = makeset(fd, OPT_LOCAL,
- flagp == &vop_flags || !(*flagp & SSOP_OPTIONS));
- } else if (*flagp & SSOP_FOLDS) {
+ flagp == &vop_flags || !(*flagp & kOptSsopFlagOptions));
+ } else if (*flagp & kOptSsopFlagFolds) {
f = makefoldset(fd);
} else {
f = OK;
@@ -453,7 +453,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
}
// Save Folds when 'buftype' is empty and for help files.
- if ((*flagp & SSOP_FOLDS)
+ if ((*flagp & kOptSsopFlagFolds)
&& wp->w_buffer->b_ffname != NULL
&& (bt_normal(wp->w_buffer)
|| bt_help(wp->w_buffer))) {
@@ -516,7 +516,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
// Local directory, if the current flag is not view options or the "curdir"
// option is included.
if (wp->w_localdir != NULL
- && (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) {
+ && (flagp != &vop_flags || (*flagp & kOptSsopFlagCurdir))) {
if (fputs("lcd ", fd) < 0
|| ses_put_fname(fd, wp->w_localdir, flagp) == FAIL
|| fprintf(fd, "\n") < 0) {
@@ -574,7 +574,7 @@ static int store_session_globals(FILE *fd)
/// Writes commands for restoring the current buffers, for :mksession.
///
-/// Legacy 'sessionoptions'/'viewoptions' flags SSOP_UNIX, SSOP_SLASH are
+/// Legacy 'sessionoptions'/'viewoptions' flags kOptSsopFlagUnix, kOptSsopFlagSlash are
/// always enabled.
///
/// @param dirnow Current directory name
@@ -591,13 +591,13 @@ static int makeopens(FILE *fd, char *dirnow)
int cur_arg_idx = 0;
int next_arg_idx = 0;
- if (ssop_flags & SSOP_BUFFERS) {
+ if (ssop_flags & kOptSsopFlagBuffers) {
only_save_windows = false; // Save ALL buffers
}
// Begin by setting v:this_session, and then other sessionable variables.
PUTLINE_FAIL("let v:this_session=expand(\"<sfile>:p\")");
- if (ssop_flags & SSOP_GLOBALS) {
+ if (ssop_flags & kOptSsopFlagGlobals) {
if (store_session_globals(fd) == FAIL) {
return FAIL;
}
@@ -605,15 +605,15 @@ static int makeopens(FILE *fd, char *dirnow)
// Close all windows and tabs but one.
PUTLINE_FAIL("silent only");
- if ((ssop_flags & SSOP_TABPAGES)
+ if ((ssop_flags & kOptSsopFlagTabpages)
&& put_line(fd, "silent tabonly") == FAIL) {
return FAIL;
}
// Now a :cd command to the session directory or the current directory
- if (ssop_flags & SSOP_SESDIR) {
+ if (ssop_flags & kOptSsopFlagSesdir) {
PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')");
- } else if (ssop_flags & SSOP_CURDIR) {
+ } else if (ssop_flags & kOptSsopFlagCurdir) {
char *sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow);
char *fname_esc = ses_escape_fname(sname, &ssop_flags);
if (fprintf(fd, "cd %s\n", fname_esc) < 0) {
@@ -637,7 +637,7 @@ static int makeopens(FILE *fd, char *dirnow)
}
// save 'shortmess' if not storing options
- if ((ssop_flags & SSOP_OPTIONS) == 0) {
+ if ((ssop_flags & kOptSsopFlagOptions) == 0) {
PUTLINE_FAIL("let s:shortmess_save = &shortmess");
}
@@ -654,8 +654,8 @@ static int makeopens(FILE *fd, char *dirnow)
// can be disrupted by prior `edit` or `tabedit` calls).
FOR_ALL_BUFFERS(buf) {
if (!(only_save_windows && buf->b_nwindows == 0)
- && !(buf->b_help && !(ssop_flags & SSOP_HELP))
- && !(bt_terminal(buf) && !(ssop_flags & SSOP_TERMINAL))
+ && !(buf->b_help && !(ssop_flags & kOptSsopFlagHelp))
+ && !(bt_terminal(buf) && !(ssop_flags & kOptSsopFlagTerminal))
&& buf->b_fname != NULL
&& buf->b_p_bl) {
if (fprintf(fd, "badd +%" PRId64 " ",
@@ -670,11 +670,11 @@ static int makeopens(FILE *fd, char *dirnow)
// the global argument list
if (ses_arglist(fd, "argglobal", &global_alist.al_ga,
- !(ssop_flags & SSOP_CURDIR), &ssop_flags) == FAIL) {
+ !(ssop_flags & kOptSsopFlagCurdir), &ssop_flags) == FAIL) {
return FAIL;
}
- if (ssop_flags & SSOP_RESIZE) {
+ if (ssop_flags & kOptSsopFlagResize) {
// Note: after the restore we still check it worked!
if (fprintf(fd, "set lines=%" PRId64 " columns=%" PRId64 "\n",
(int64_t)Rows, (int64_t)Columns) < 0) {
@@ -692,7 +692,7 @@ static int makeopens(FILE *fd, char *dirnow)
restore_stal = true;
}
- if ((ssop_flags & SSOP_TABPAGES)) {
+ if ((ssop_flags & kOptSsopFlagTabpages)) {
// "tabpages" is in 'sessionoptions': Similar to ses_win_rec() below,
// populate the tab pages first so later local options won't be copied
// to the new tabs.
@@ -720,7 +720,7 @@ static int makeopens(FILE *fd, char *dirnow)
// 'sessionoptions'.
// Don't use goto_tabpage(), it may change directory and trigger
// autocommands.
- if ((ssop_flags & SSOP_TABPAGES)) {
+ if ((ssop_flags & kOptSsopFlagTabpages)) {
if (tp == curtab) {
tab_firstwin = firstwin;
tab_topframe = topframe;
@@ -820,7 +820,7 @@ static int makeopens(FILE *fd, char *dirnow)
// Restore the tab-local working directory if specified
// Do this before the windows, so that the window-local directory can
// override the tab-local directory.
- if ((ssop_flags & SSOP_CURDIR) && tp->tp_localdir != NULL) {
+ if ((ssop_flags & kOptSsopFlagCurdir) && tp->tp_localdir != NULL) {
if (fputs("tcd ", fd) < 0
|| ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL
|| put_eol(fd) == FAIL) {
@@ -862,12 +862,12 @@ static int makeopens(FILE *fd, char *dirnow)
// Don't continue in another tab page when doing only the current one
// or when at the last tab page.
- if (!(ssop_flags & SSOP_TABPAGES)) {
+ if (!(ssop_flags & kOptSsopFlagTabpages)) {
break;
}
}
- if (ssop_flags & SSOP_TABPAGES) {
+ if (ssop_flags & kOptSsopFlagTabpages) {
if (fprintf(fd, "tabnext %d\n", tabpage_index(curtab)) < 0) {
return FAIL;
}
@@ -894,7 +894,7 @@ static int makeopens(FILE *fd, char *dirnow)
}
// Restore 'shortmess'.
- if (ssop_flags & SSOP_OPTIONS) {
+ if (ssop_flags & kOptSsopFlagOptions) {
if (fprintf(fd, "set shortmess=%s\n", p_shm) < 0) {
return FAIL;
}
@@ -937,8 +937,8 @@ void ex_loadview(exarg_T *eap)
/// ":mkexrc", ":mkvimrc", ":mkview", ":mksession".
///
/// Legacy 'sessionoptions'/'viewoptions' flags are always enabled:
-/// - SSOP_UNIX: line-endings are LF
-/// - SSOP_SLASH: filenames are written with "/" slash
+/// - kOptSsopFlagUnix: line-endings are LF
+/// - kOptSsopFlagSlash: filenames are written with "/" slash
void ex_mkrc(exarg_T *eap)
{
bool view_session = false; // :mkview, :mksession
@@ -1002,10 +1002,10 @@ void ex_mkrc(exarg_T *eap)
}
if (!view_session || (eap->cmdidx == CMD_mksession
- && (*flagp & SSOP_OPTIONS))) {
+ && (*flagp & kOptSsopFlagOptions))) {
int flags = OPT_GLOBAL;
- if (eap->cmdidx == CMD_mksession && (*flagp & SSOP_SKIP_RTP)) {
+ if (eap->cmdidx == CMD_mksession && (*flagp & kOptSsopFlagSkiprtp)) {
flags |= OPT_SKIPRTP;
}
failed |= (makemap(fd, NULL) == FAIL
@@ -1028,12 +1028,12 @@ void ex_mkrc(exarg_T *eap)
|| os_chdir(dirnow) != 0) {
*dirnow = NUL;
}
- if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
+ if (*dirnow != NUL && (ssop_flags & kOptSsopFlagSesdir)) {
if (vim_chdirfile(fname, kCdCauseOther) == OK) {
shorten_fnames(true);
}
} else if (*dirnow != NUL
- && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) {
+ && (ssop_flags & kOptSsopFlagCurdir) && globaldir != NULL) {
if (os_chdir(globaldir) == 0) {
shorten_fnames(true);
}
@@ -1042,8 +1042,8 @@ void ex_mkrc(exarg_T *eap)
failed |= (makeopens(fd, dirnow) == FAIL);
// restore original dir
- if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR)
- || ((ssop_flags & SSOP_CURDIR) && globaldir !=
+ if (*dirnow != NUL && ((ssop_flags & kOptSsopFlagSesdir)
+ || ((ssop_flags & kOptSsopFlagCurdir) && globaldir !=
NULL))) {
if (os_chdir(dirnow) != 0) {
emsg(_(e_prev_dir));
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua
index 02f3ac3257..779b31e7a0 100644
--- a/src/nvim/generators/gen_options.lua
+++ b/src/nvim/generators/gen_options.lua
@@ -1,10 +1,12 @@
local options_file = arg[1]
local options_enum_file = arg[2]
local options_map_file = arg[3]
+local option_vars_file = arg[4]
local opt_fd = assert(io.open(options_file, 'w'))
local opt_enum_fd = assert(io.open(options_enum_file, 'w'))
local opt_map_fd = assert(io.open(options_map_file, 'w'))
+local opt_vars_fd = assert(io.open(option_vars_file, 'w'))
local w = function(s)
if s:match('^ %.') then
@@ -24,6 +26,10 @@ local function map_w(s)
opt_map_fd:write(s .. '\n')
end
+local function vars_w(s)
+ opt_vars_fd:write(s .. '\n')
+end
+
--- @module 'nvim.options'
local options = require('options')
local options_meta = options.options
@@ -138,6 +144,92 @@ map_w('static ' .. hashfun)
opt_map_fd:close()
+vars_w('// IWYU pragma: private, include "nvim/option_vars.h"')
+
+-- Generate enums for option flags.
+for _, option in ipairs(options_meta) do
+ if option.flags and (type(option.flags) == 'table' or option.values) then
+ vars_w('')
+ vars_w('typedef enum {')
+
+ local opt_name = lowercase_to_titlecase(option.abbreviation or option.full_name)
+ --- @type table<string,integer>
+ local enum_values
+
+ if type(option.flags) == 'table' then
+ enum_values = option.flags --[[ @as table<string,integer> ]]
+ else
+ enum_values = {}
+ for i, flag_name in ipairs(option.values) do
+ assert(type(flag_name) == 'string')
+ enum_values[flag_name] = math.pow(2, i - 1)
+ end
+ end
+
+ -- Sort the keys by the flag value so that the enum can be generated in order.
+ --- @type string[]
+ local flag_names = vim.tbl_keys(enum_values)
+ table.sort(flag_names, function(a, b)
+ return enum_values[a] < enum_values[b]
+ end)
+
+ for _, flag_name in pairs(flag_names) do
+ vars_w(
+ (' kOpt%sFlag%s = 0x%02x,'):format(
+ opt_name,
+ lowercase_to_titlecase(flag_name),
+ enum_values[flag_name]
+ )
+ )
+ end
+
+ vars_w(('} Opt%sFlags;'):format(opt_name))
+ end
+end
+
+-- Generate valid values for each option.
+for _, option in ipairs(options_meta) do
+ --- @type function
+ local preorder_traversal
+ --- @param prefix string
+ --- @param values vim.option_valid_values
+ preorder_traversal = function(prefix, values)
+ vars_w('')
+ vars_w(
+ ('EXTERN const char *(%s_values[%s]) INIT( = {'):format(prefix, #vim.tbl_keys(values) + 1)
+ )
+
+ --- @type [string,vim.option_valid_values][]
+ local children = {}
+
+ for _, value in ipairs(values) do
+ if type(value) == 'string' then
+ vars_w((' "%s",'):format(value))
+ else
+ assert(type(value) == 'table' and type(value[1]) == 'string' and type(value[2]) == 'table')
+
+ vars_w((' "%s",'):format(value[1]))
+ table.insert(children, value)
+ end
+ end
+
+ vars_w(' NULL')
+ vars_w('});')
+
+ for _, value in pairs(children) do
+ -- Remove trailing colon from the added prefix to prevent syntax errors.
+ preorder_traversal(prefix .. '_' .. value[1]:gsub(':$', ''), value[2])
+ end
+ end
+
+ -- Since option values can be nested, we need to do preorder traversal to generate the values.
+ if option.values then
+ preorder_traversal(('opt_%s'):format(option.abbreviation or option.full_name), option.values)
+ end
+end
+
+opt_vars_fd:close()
+
local redraw_flags = {
ui_option = 'kOptFlagUIOption',
tabline = 'kOptFlagRedrTabl',
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 82abd2888a..bca224c7d1 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -471,7 +471,7 @@ void beep_flush(void)
{
if (emsg_silent == 0) {
flush_buffers(FLUSH_MINIMAL);
- vim_beep(BO_ERROR);
+ vim_beep(kOptBoFlagError);
}
}
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index acb336c725..e863cb3476 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -383,7 +383,7 @@ void grid_line_start(ScreenGrid *grid, int row)
assert((size_t)grid_line_maxcol <= linebuf_size);
- if (rdb_flags & RDB_INVALID) {
+ if (rdb_flags & kOptRdbFlagInvalid) {
// Current batch must not depend on previous contents of linebuf_char.
// Set invalid values which will cause assertion failures later if they are used.
memset(linebuf_char, 0xFF, sizeof(schar_T) * linebuf_size);
@@ -602,7 +602,7 @@ void grid_line_flush(void)
void grid_line_flush_if_valid_row(void)
{
if (grid_line_row < 0 || grid_line_row >= grid_line_grid->rows) {
- if (rdb_flags & RDB_INVALID) {
+ if (rdb_flags & kOptRdbFlagInvalid) {
abort();
} else {
grid_line_grid = NULL;
@@ -639,7 +639,7 @@ static int grid_char_needs_redraw(ScreenGrid *grid, int col, size_t off_to, int
|| (cols > 1 && linebuf_char[col + 1] == 0
&& linebuf_char[col + 1] != grid->chars[off_to + 1]))
|| exmode_active // TODO(bfredl): what in the actual fuck
- || rdb_flags & RDB_NODELTA));
+ || rdb_flags & kOptRdbFlagNodelta));
}
/// Move one buffered line to the window grid, but only the characters that
@@ -784,7 +784,7 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int col, int endcol
size_t off = off_to + (size_t)col;
if (grid->chars[off] != schar_from_ascii(' ')
|| grid->attrs[off] != bg_attr
- || rdb_flags & RDB_NODELTA) {
+ || rdb_flags & kOptRdbFlagNodelta) {
grid->chars[off] = schar_from_ascii(' ');
grid->attrs[off] = bg_attr;
if (clear_dirty_start == -1) {
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index e487728901..7da61091d4 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -793,7 +793,7 @@ bool briopt_check(char *briopt, win_T *wp)
}
while (*p != NUL) {
- // Note: Keep this in sync with p_briopt_values
+ // Note: Keep this in sync with opt_briopt_values.
if (strncmp(p, "shift:", 6) == 0
&& ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6]))) {
p += 6;
@@ -872,7 +872,7 @@ int get_breakindent_win(win_T *wp, char *line)
|| prev_tick != buf_get_changedtick(wp->w_buffer)
|| prev_listopt != wp->w_briopt_list
|| prev_no_ts != no_ts
- || prev_dy_uhex != (dy_flags & DY_UHEX)
+ || prev_dy_uhex != (dy_flags & kOptDyFlagUhex)
|| prev_flp == NULL
|| strcmp(prev_flp, get_flp_value(wp->w_buffer)) != 0
|| prev_line == NULL || strcmp(prev_line, line) != 0) {
@@ -893,7 +893,7 @@ int get_breakindent_win(win_T *wp, char *line)
prev_listopt = wp->w_briopt_list;
prev_list = 0;
prev_no_ts = no_ts;
- prev_dy_uhex = (dy_flags & DY_UHEX);
+ prev_dy_uhex = (dy_flags & kOptDyFlagUhex);
xfree(prev_flp);
prev_flp = xstrdup(get_flp_value(wp->w_buffer));
// add additional indent for numbered lists
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index bd7ee55722..d3517667fb 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -475,7 +475,7 @@ bool check_compl_option(bool dict_opt)
msg((dict_opt ? _("'dictionary' option is empty") : _("'thesaurus' option is empty")),
HLF_E);
if (emsg_silent == 0 && !in_assert_fails) {
- vim_beep(BO_COMPL);
+ vim_beep(kOptBoFlagComplete);
setcursor();
ui_flush();
os_delay(2004, false);
@@ -1069,7 +1069,7 @@ bool pum_wanted(void)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
// "completeopt" must contain "menu" or "menuone"
- return (get_cot_flags() & COT_ANY_MENU) != 0;
+ return (get_cot_flags() & (kOptCotFlagMenu | kOptCotFlagMenuone)) != 0;
}
/// Check that there are two or more matches to be shown in the popup menu.
@@ -1088,7 +1088,7 @@ static bool pum_enough_matches(void)
comp = comp->cp_next;
} while (!is_first_match(comp));
- if (get_cot_flags() & COT_MENUONE) {
+ if (get_cot_flags() & kOptCotFlagMenuone) {
return i >= 1;
}
return i >= 2;
@@ -1171,8 +1171,8 @@ static int ins_compl_build_pum(void)
const int lead_len = compl_leader != NULL ? (int)strlen(compl_leader) : 0;
int max_fuzzy_score = 0;
unsigned cur_cot_flags = get_cot_flags();
- bool compl_no_select = (cur_cot_flags & COT_NOSELECT) != 0;
- bool compl_fuzzy_match = (cur_cot_flags & COT_FUZZY) != 0;
+ bool compl_no_select = (cur_cot_flags & kOptCotFlagNoselect) != 0;
+ bool compl_fuzzy_match = (cur_cot_flags & kOptCotFlagFuzzy) != 0;
do {
// When 'completeopt' contains "fuzzy" and leader is not NULL or empty,
@@ -2236,7 +2236,7 @@ bool ins_compl_prep(int c)
// Set "compl_get_longest" when finding the first matches.
if (ctrl_x_mode_not_defined_yet()
|| (ctrl_x_mode_normal() && !compl_started)) {
- compl_get_longest = (get_cot_flags() & COT_LONGEST) != 0;
+ compl_get_longest = (get_cot_flags() & kOptCotFlagLongest) != 0;
compl_used_match = true;
}
@@ -2682,9 +2682,9 @@ static void set_completion(colnr_T startcol, list_T *list)
{
int flags = CP_ORIGINAL_TEXT;
unsigned cur_cot_flags = get_cot_flags();
- bool compl_longest = (cur_cot_flags & COT_LONGEST) != 0;
- bool compl_no_insert = (cur_cot_flags & COT_NOINSERT) != 0;
- bool compl_no_select = (cur_cot_flags & COT_NOSELECT) != 0;
+ bool compl_longest = (cur_cot_flags & kOptCotFlagLongest) != 0;
+ bool compl_no_insert = (cur_cot_flags & kOptCotFlagNoinsert) != 0;
+ bool compl_no_select = (cur_cot_flags & kOptCotFlagNoselect) != 0;
// If already doing completions stop it.
if (ctrl_x_mode_not_default()) {
@@ -3731,8 +3731,8 @@ static int find_next_completion_match(bool allow_get_expansion, int todo, bool a
bool found_end = false;
compl_T *found_compl = NULL;
unsigned cur_cot_flags = get_cot_flags();
- bool compl_no_select = (cur_cot_flags & COT_NOSELECT) != 0;
- bool compl_fuzzy_match = (cur_cot_flags & COT_FUZZY) != 0;
+ bool compl_no_select = (cur_cot_flags & kOptCotFlagNoselect) != 0;
+ bool compl_fuzzy_match = (cur_cot_flags & kOptCotFlagFuzzy) != 0;
while (--todo >= 0) {
if (compl_shows_dir_forward() && compl_shown_match->cp_next != NULL) {
@@ -3836,8 +3836,8 @@ static int ins_compl_next(bool allow_get_expansion, int count, bool insert_match
const bool started = compl_started;
buf_T *const orig_curbuf = curbuf;
unsigned cur_cot_flags = get_cot_flags();
- bool compl_no_insert = (cur_cot_flags & COT_NOINSERT) != 0;
- bool compl_fuzzy_match = (cur_cot_flags & COT_FUZZY) != 0;
+ bool compl_no_insert = (cur_cot_flags & kOptCotFlagNoinsert) != 0;
+ bool compl_fuzzy_match = (cur_cot_flags & kOptCotFlagFuzzy) != 0;
// When user complete function return -1 for findstart which is next
// time of 'always', compl_shown_match become NULL.
@@ -3976,7 +3976,7 @@ void ins_compl_check_keys(int frequency, bool in_compl_func)
}
}
}
- if (compl_pending != 0 && !got_int && !(cot_flags & COT_NOINSERT)) {
+ if (compl_pending != 0 && !got_int && !(cot_flags & kOptCotFlagNoinsert)) {
int todo = compl_pending > 0 ? compl_pending : -compl_pending;
compl_pending = 0;
diff --git a/src/nvim/main.c b/src/nvim/main.c
index dc4969759d..17990a6735 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -628,7 +628,7 @@ int main(int argc, char **argv)
}
// WORKAROUND(mhi): #3023
- if (cb_flags & CB_UNNAMEDMASK) {
+ if (cb_flags & (kOptCbFlagUnnamed | kOptCbFlagUnnamedplus)) {
eval_has_provider("clipboard", false);
}
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 3dbcbbd47b..f1de557f50 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -234,7 +234,7 @@ void setpcmark(void)
curwin->w_pcmark.lnum = 1;
}
- if (jop_flags & JOP_STACK) {
+ if (jop_flags & kOptJopFlagStack) {
// jumpoptions=stack: if we're somewhere in the middle of the jumplist
// discard everything after the current index.
if (curwin->w_jumplistidx < curwin->w_jumplistlen - 1) {
@@ -1473,7 +1473,7 @@ void cleanup_jumplist(win_T *wp, bool loadfiles)
mustfree = false;
} else if (i > from + 1) { // non-adjacent duplicate
// jumpoptions=stack: remove duplicates only when adjacent.
- mustfree = !(jop_flags & JOP_STACK);
+ mustfree = !(jop_flags & kOptJopFlagStack);
} else { // adjacent duplicate
mustfree = true;
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index b5a8588edd..3e35cdaa15 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1400,11 +1400,11 @@ int utf_fold(int a)
int mb_toupper(int a)
{
// If 'casemap' contains "keepascii" use ASCII style toupper().
- if (a < 128 && (cmp_flags & CMP_KEEPASCII)) {
+ if (a < 128 && (cmp_flags & kOptCmpFlagKeepascii)) {
return TOUPPER_ASC(a);
}
- if (!(cmp_flags & CMP_INTERNAL)) {
+ if (!(cmp_flags & kOptCmpFlagInternal)) {
return (int)towupper((wint_t)a);
}
@@ -1426,11 +1426,11 @@ bool mb_islower(int a)
int mb_tolower(int a)
{
// If 'casemap' contains "keepascii" use ASCII style tolower().
- if (a < 128 && (cmp_flags & CMP_KEEPASCII)) {
+ if (a < 128 && (cmp_flags & kOptCmpFlagKeepascii)) {
return TOLOWER_ASC(a);
}
- if (!(cmp_flags & CMP_INTERNAL)) {
+ if (!(cmp_flags & kOptCmpFlagInternal)) {
return (int)towlower((wint_t)a);
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index c927a2546c..c758d5d76f 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -2277,7 +2277,7 @@ static void msg_puts_display(const char *str, int maxlen, int hl_id, int recurse
}
} while (msg_col & 7);
} else if (c == BELL) { // beep (from ":sh")
- vim_beep(BO_SH);
+ vim_beep(kOptBoFlagShell);
}
}
}
@@ -2332,7 +2332,7 @@ int msg_scrollsize(void)
bool msg_do_throttle(void)
{
- return msg_use_grid() && !(rdb_flags & RDB_NOTHROTTLE);
+ return msg_use_grid() && !(rdb_flags & kOptRdbFlagNothrottle);
}
/// Scroll the screen up one line for displaying the next message line.
@@ -2597,7 +2597,7 @@ void show_sb_text(void)
// weird, typing a command without output results in one line.
msgchunk_T *mp = msg_sb_start(last_msgchunk);
if (mp == NULL || mp->sb_prev == NULL) {
- vim_beep(BO_MESS);
+ vim_beep(kOptBoFlagMess);
} else {
do_more_prompt('G');
wait_return(false);
diff --git a/src/nvim/move.c b/src/nvim/move.c
index b298592683..dbd86bb0c8 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -170,7 +170,7 @@ static void redraw_for_cursorcolumn(win_T *wp)
if (wp->w_p_cuc) {
// When 'cursorcolumn' is set need to redraw with UPD_SOME_VALID.
redraw_later(wp, UPD_SOME_VALID);
- } else if (wp->w_p_cul && (wp->w_p_culopt_flags & CULOPT_SCRLINE)) {
+ } else if (wp->w_p_cul && (wp->w_p_culopt_flags & kOptCuloptFlagScreenline)) {
// When 'cursorlineopt' contains "screenline" need to redraw with UPD_VALID.
redraw_later(wp, UPD_VALID);
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 55aa385b33..ba84380529 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1348,7 +1348,7 @@ static void normal_check_folds(NormalState *s)
if (hasAnyFolding(curwin) && !char_avail()) {
foldCheckClose();
- if (fdo_flags & FDO_ALL) {
+ if (fdo_flags & kOptFdoFlagAll) {
foldOpenCursor();
}
}
@@ -2310,7 +2310,7 @@ static void nv_gd(oparg_T *oap, int nchar, int thisblock)
return;
}
- if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagSearch) && KeyTyped && oap->op_type == OP_NOP) {
foldOpenCursor();
}
// clear any search statistics
@@ -3752,7 +3752,7 @@ static void nv_right(cmdarg_T *cap)
}
}
}
- if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped
+ if (n != cap->count1 && (fdo_flags & kOptFdoFlagHor) && KeyTyped
&& cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
@@ -3811,7 +3811,7 @@ static void nv_left(cmdarg_T *cap)
break;
}
}
- if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped
+ if (n != cap->count1 && (fdo_flags & kOptFdoFlagHor) && KeyTyped
&& cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
@@ -3929,7 +3929,7 @@ static void nv_dollar(cmdarg_T *cap)
if (cursor_down(cap->count1 - 1,
cap->oap->op_type == OP_NOP) == false) {
clearopbeep(cap->oap);
- } else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ } else if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -4016,7 +4016,7 @@ static int normal_search(cmdarg_T *cap, int dir, char *pat, size_t patlen, int o
cap->oap->motion_type = kMTLineWise;
}
curwin->w_cursor.coladd = 0;
- if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) {
+ if (cap->oap->op_type == OP_NOP && (fdo_flags & kOptFdoFlagSearch) && KeyTyped) {
foldOpenCursor();
}
}
@@ -4065,7 +4065,7 @@ static void nv_csearch(cmdarg_T *cap)
curwin->w_cursor.coladd = 0;
}
adjust_for_sel(cap);
- if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -4181,7 +4181,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos)
setpcmark();
curwin->w_cursor = *pos;
curwin->w_set_curswant = true;
- if ((fdo_flags & FDO_BLOCK) && KeyTyped
+ if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped
&& cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
@@ -4261,7 +4261,7 @@ static void nv_brackets(cmdarg_T *cap)
if (cap->oap->op_type == OP_NOP) {
beginline(BL_WHITE | BL_FIX);
}
- if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -4319,7 +4319,7 @@ static void nv_brackets(cmdarg_T *cap)
}
curwin->w_set_curswant = true;
}
- if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) {
+ if (cap->oap->op_type == OP_NOP && (fdo_flags & kOptFdoFlagSearch) && KeyTyped) {
foldOpenCursor();
}
} else {
@@ -4371,7 +4371,7 @@ static void nv_percent(cmdarg_T *cap)
}
if (cap->oap->op_type == OP_NOP
&& lnum != curwin->w_cursor.lnum
- && (fdo_flags & FDO_PERCENT)
+ && (fdo_flags & kOptFdoFlagPercent)
&& KeyTyped) {
foldOpenCursor();
}
@@ -4395,7 +4395,7 @@ static void nv_brace(cmdarg_T *cap)
// Don't leave the cursor on the NUL past end of line.
adjust_cursor(cap->oap);
curwin->w_cursor.coladd = 0;
- if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -4426,7 +4426,7 @@ static void nv_findpar(cmdarg_T *cap)
}
curwin->w_cursor.coladd = 0;
- if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -4864,7 +4864,7 @@ static void nv_optrans(cmdarg_T *cap)
static void nv_gomark(cmdarg_T *cap)
{
int name;
- MarkMove flags = jop_flags & JOP_VIEW ? kMarkSetView : 0; // flags for moving to the mark
+ MarkMove flags = jop_flags & kOptJopFlagView ? kMarkSetView : 0; // flags for moving to the mark
if (cap->oap->op_type != OP_NOP) {
// When there is a pending operator, do not restore the view as this is usually unexpected.
flags = 0;
@@ -4893,7 +4893,7 @@ static void nv_gomark(cmdarg_T *cap)
if (cap->oap->op_type == OP_NOP
&& move_res & kMarkMoveSuccess
&& (move_res & kMarkSwitchedBuf || move_res & kMarkChangedCursor)
- && (fdo_flags & FDO_MARK)
+ && (fdo_flags & kOptFdoFlagMark)
&& old_KeyTyped) {
foldOpenCursor();
}
@@ -4904,7 +4904,7 @@ static void nv_gomark(cmdarg_T *cap)
static void nv_pcmark(cmdarg_T *cap)
{
fmark_T *fm = NULL;
- MarkMove flags = jop_flags & JOP_VIEW ? kMarkSetView : 0; // flags for moving to the mark
+ MarkMove flags = jop_flags & kOptJopFlagView ? kMarkSetView : 0; // flags for moving to the mark
MarkMoveRes move_res = 0; // Result from moving to the mark
const bool old_KeyTyped = KeyTyped; // getting file may reset it.
@@ -4943,7 +4943,7 @@ static void nv_pcmark(cmdarg_T *cap)
}
if (cap->oap->op_type == OP_NOP
&& (move_res & kMarkSwitchedBuf || move_res & kMarkChangedLine)
- && (fdo_flags & FDO_MARK)
+ && (fdo_flags & kOptFdoFlagMark)
&& old_KeyTyped) {
foldOpenCursor();
}
@@ -5094,7 +5094,7 @@ static void n_start_visual_mode(int c)
// Corner case: the 0 position in a tab may change when going into
// virtualedit. Recalculate curwin->w_cursor to avoid bad highlighting.
//
- if (c == Ctrl_V && (get_ve_flags(curwin) & VE_BLOCK) && gchar_cursor() == TAB) {
+ if (c == Ctrl_V && (get_ve_flags(curwin) & kOptVeFlagBlock) && gchar_cursor() == TAB) {
validate_virtcol(curwin);
coladvance(curwin, curwin->w_virtcol);
}
@@ -5915,7 +5915,7 @@ static void nv_bck_word(cmdarg_T *cap)
curwin->w_set_curswant = true;
if (bck_word(cap->count1, cap->arg, false) == false) {
clearopbeep(cap->oap);
- } else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ } else if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -5975,7 +5975,7 @@ static void nv_wordcmd(cmdarg_T *cap)
clearopbeep(cap->oap);
} else {
adjust_for_sel(cap);
- if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -5993,7 +5993,7 @@ static void adjust_cursor(oparg_T *oap)
if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL
&& (!VIsual_active || *p_sel == 'o')
&& !virtual_active(curwin)
- && (get_ve_flags(curwin) & VE_ONEMORE) == 0) {
+ && (get_ve_flags(curwin) & kOptVeFlagOnemore) == 0) {
curwin->w_cursor.col--;
// prevent cursor from moving on the trail byte
mb_adjust_cursor();
@@ -6008,7 +6008,7 @@ static void nv_beginline(cmdarg_T *cap)
cap->oap->motion_type = kMTCharWise;
cap->oap->inclusive = false;
beginline(cap->arg);
- if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
ins_at_eol = false; // Don't move cursor past eol (only necessary in a
@@ -6097,7 +6097,7 @@ static void nv_goto(cmdarg_T *cap)
lnum = MIN(MAX(lnum, 1), curbuf->b_ml.ml_line_count);
curwin->w_cursor.lnum = lnum;
beginline(BL_SOL | BL_FIX);
- if ((fdo_flags & FDO_JUMP) && KeyTyped && cap->oap->op_type == OP_NOP) {
+ if ((fdo_flags & kOptFdoFlagJump) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
}
@@ -6167,7 +6167,7 @@ static void nv_esc(cmdarg_T *cap)
curwin->w_set_curswant = true;
redraw_curbuf_later(UPD_INVERTED);
} else if (no_reason) {
- vim_beep(BO_ESC);
+ vim_beep(kOptBoFlagEsc);
}
clearop(cap->oap);
}
@@ -6176,7 +6176,7 @@ static void nv_esc(cmdarg_T *cap)
void set_cursor_for_append_to_line(void)
{
curwin->w_set_curswant = true;
- if (get_ve_flags(curwin) == VE_ALL) {
+ if (get_ve_flags(curwin) == kOptVeFlagAll) {
const int save_State = State;
// Pretend Insert mode here to allow the cursor on the
// character past the end of the line
@@ -6501,7 +6501,8 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
int regname = cap->oap->regname;
bool keep_registers = cap->cmdchar == 'P';
// '+' and '*' could be the same selection
- bool clipoverwrite = (regname == '+' || regname == '*') && (cb_flags & CB_UNNAMEDMASK);
+ bool clipoverwrite = (regname == '+' || regname == '*')
+ && (cb_flags & (kOptCbFlagUnnamed | kOptCbFlagUnnamedplus));
if (regname == 0 || regname == '"' || clipoverwrite
|| ascii_isdigit(regname) || regname == '-') {
// The delete might overwrite the register we want to put, save it first
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index c100bc36b4..63c78936ba 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2187,7 +2187,7 @@ void op_insert(oparg_T *oap, int count1)
if (u_save_cursor() == FAIL) {
return;
}
- curwin->w_ve_flags = VE_ALL;
+ curwin->w_ve_flags = kOptVeFlagAll;
coladvance_force(oap->op_type == OP_APPEND
? oap->end_vcol + 1 : getviscol());
if (oap->op_type == OP_APPEND) {
@@ -2873,7 +2873,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
eol = (*(cursor_pos + utfc_ptr2len(cursor_pos)) == NUL);
}
- bool ve_allows = (cur_ve_flags == VE_ALL || cur_ve_flags == VE_ONEMORE);
+ bool ve_allows = (cur_ve_flags == kOptVeFlagAll || cur_ve_flags == kOptVeFlagOnemore);
bool eof = curbuf->b_ml.ml_line_count == curwin->w_cursor.lnum
&& one_past_line;
if (ve_allows || !(eol || eof)) {
@@ -3057,7 +3057,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
goto end;
}
- if (cur_ve_flags == VE_ALL && y_type == kMTCharWise) {
+ if (cur_ve_flags == kOptVeFlagAll && y_type == kMTCharWise) {
if (gchar_cursor() == TAB) {
int viscol = getviscol();
OptInt ts = curbuf->b_p_ts;
@@ -3086,7 +3086,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
colnr_T endcol2 = 0;
if (dir == FORWARD && c != NUL) {
- if (cur_ve_flags == VE_ALL) {
+ if (cur_ve_flags == kOptVeFlagAll) {
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
} else {
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
@@ -3100,7 +3100,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
}
col += curwin->w_cursor.coladd;
- if (cur_ve_flags == VE_ALL
+ if (cur_ve_flags == kOptVeFlagAll
&& (curwin->w_cursor.coladd > 0 || endcol2 == curwin->w_cursor.col)) {
if (dir == FORWARD && c == NUL) {
col++;
@@ -3560,7 +3560,7 @@ error:
// Make sure the cursor is not after the NUL.
int len = get_cursor_line_len();
if (curwin->w_cursor.col > len) {
- if (cur_ve_flags == VE_ALL) {
+ if (cur_ve_flags == kOptVeFlagAll) {
curwin->w_cursor.coladd = curwin->w_cursor.col - len;
}
curwin->w_cursor.col = len;
@@ -3592,7 +3592,7 @@ void adjust_cursor_eol(void)
const bool adj_cursor = (curwin->w_cursor.col > 0
&& gchar_cursor() == NUL
- && (cur_ve_flags & VE_ONEMORE) == 0
+ && (cur_ve_flags & kOptVeFlagOnemore) == 0
&& !(restart_edit || (State & MODE_INSERT)));
if (!adj_cursor) {
return;
@@ -3601,7 +3601,7 @@ void adjust_cursor_eol(void)
// Put the cursor on the last character in the line.
dec_cursor();
- if (cur_ve_flags == VE_ALL) {
+ if (cur_ve_flags == kOptVeFlagAll) {
colnr_T scol, ecol;
// Coladd is set to the width of the last character.
@@ -6076,7 +6076,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_DELETE:
VIsual_reselect = false; // don't reselect now
if (empty_region_error) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
CancelRedo();
} else {
op_delete(oap);
@@ -6092,7 +6092,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_YANK:
if (empty_region_error) {
if (!gui_yank) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
CancelRedo();
}
} else {
@@ -6106,7 +6106,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_CHANGE:
VIsual_reselect = false; // don't reselect now
if (empty_region_error) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
CancelRedo();
} else {
// This is a new edit command, not a restart. Need to
@@ -6169,7 +6169,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_LOWER:
case OP_ROT13:
if (empty_region_error) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
CancelRedo();
} else {
op_tilde(oap);
@@ -6211,7 +6211,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_APPEND:
VIsual_reselect = false; // don't reselect now
if (empty_region_error) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
CancelRedo();
} else {
// This is a new edit command, not a restart. Need to
@@ -6246,7 +6246,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_REPLACE:
VIsual_reselect = false; // don't reselect now
if (empty_region_error) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
CancelRedo();
} else {
// Restore linebreak, so that when the user edits it looks as before.
@@ -6284,7 +6284,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_NR_ADD:
case OP_NR_SUB:
if (empty_region_error) {
- vim_beep(BO_OPER);
+ vim_beep(kOptBoFlagOperator);
CancelRedo();
} else {
VIsual_active = true;
@@ -6344,7 +6344,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
yankreg_T *target = NULL;
bool explicit_cb_reg = (*name == '*' || *name == '+');
- bool implicit_cb_reg = (*name == NUL) && (cb_flags & CB_UNNAMEDMASK);
+ bool implicit_cb_reg = (*name == NUL) && (cb_flags & (kOptCbFlagUnnamed | kOptCbFlagUnnamedplus));
if (!explicit_cb_reg && !implicit_cb_reg) {
goto end;
}
@@ -6363,7 +6363,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
if (explicit_cb_reg) {
target = &y_regs[*name == '*' ? STAR_REGISTER : PLUS_REGISTER];
- if (writing && (cb_flags & (*name == '*' ? CB_UNNAMED : CB_UNNAMEDPLUS))) {
+ if (writing && (cb_flags & (*name == '*' ? kOptCbFlagUnnamed : kOptCbFlagUnnamedplus))) {
clipboard_needs_update = false;
}
goto end;
@@ -6377,8 +6377,8 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
goto end;
}
- if (cb_flags & CB_UNNAMEDPLUS) {
- *name = (cb_flags & CB_UNNAMED && writing) ? '"' : '+';
+ if (cb_flags & kOptCbFlagUnnamedplus) {
+ *name = (cb_flags & kOptCbFlagUnnamed && writing) ? '"' : '+';
target = &y_regs[PLUS_REGISTER];
} else {
*name = '*';
diff --git a/src/nvim/option.c b/src/nvim/option.c
index d3cbe9f056..669dac9773 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -6013,19 +6013,19 @@ int fill_culopt_flags(char *val, win_T *wp)
p = val;
}
while (*p != NUL) {
- // Note: Keep this in sync with p_culopt_values.
+ // Note: Keep this in sync with opt_culopt_values.
if (strncmp(p, "line", 4) == 0) {
p += 4;
- culopt_flags_new |= CULOPT_LINE;
+ culopt_flags_new |= kOptCuloptFlagLine;
} else if (strncmp(p, "both", 4) == 0) {
p += 4;
- culopt_flags_new |= CULOPT_LINE | CULOPT_NBR;
+ culopt_flags_new |= kOptCuloptFlagLine | kOptCuloptFlagNumber;
} else if (strncmp(p, "number", 6) == 0) {
p += 6;
- culopt_flags_new |= CULOPT_NBR;
+ culopt_flags_new |= kOptCuloptFlagNumber;
} else if (strncmp(p, "screenline", 10) == 0) {
p += 10;
- culopt_flags_new |= CULOPT_SCRLINE;
+ culopt_flags_new |= kOptCuloptFlagScreenline;
}
if (*p != ',' && *p != NUL) {
@@ -6037,7 +6037,7 @@ int fill_culopt_flags(char *val, win_T *wp)
}
// Can't have both "line" and "screenline".
- if ((culopt_flags_new & CULOPT_LINE) && (culopt_flags_new & CULOPT_SCRLINE)) {
+ if ((culopt_flags_new & kOptCuloptFlagLine) && (culopt_flags_new & kOptCuloptFlagScreenline)) {
return FAIL;
}
wp->w_p_culopt_flags = culopt_flags_new;
@@ -6147,7 +6147,8 @@ char *get_flp_value(buf_T *buf)
/// Get the local or global value of 'virtualedit' flags.
unsigned get_ve_flags(win_T *wp)
{
- return (wp->w_ve_flags ? wp->w_ve_flags : ve_flags) & ~(VE_NONE | VE_NONEU);
+ return (wp->w_ve_flags ? wp->w_ve_flags : ve_flags)
+ & ~(unsigned)(kOptVeFlagNone | kOptVeFlagNoneU);
}
/// Get the local or global value of 'showbreak'.
diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h
index e0a972f06c..3bb2035e7c 100644
--- a/src/nvim/option_vars.h
+++ b/src/nvim/option_vars.h
@@ -5,6 +5,10 @@
#include "nvim/sign_defs.h"
#include "nvim/types_defs.h"
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "option_vars.generated.h" // NOLINT(build/include_defs)
+#endif
+
// option_vars.h: definition of global variables for settable options
#define HIGHLIGHT_INIT \
@@ -264,12 +268,6 @@ enum {
STL_CLICK_FUNC, STL_TABPAGENR, STL_TABCLOSENR, STL_CLICK_FUNC, \
0, })
-// flags used for parsed 'wildmode'
-#define WIM_FULL 0x01
-#define WIM_LONGEST 0x02
-#define WIM_LIST 0x04
-#define WIM_BUFLASTUSED 0x08
-
// arguments for can_bs()
// each defined char should be unique over all values
// except for BS_START, that intentionally also matches BS_NOSTOP
@@ -280,11 +278,6 @@ enum {
#define BS_START 's' // "Start"
#define BS_NOSTOP 'p' // "nostoP
-// flags for the 'culopt' option
-#define CULOPT_LINE 0x01 // Highlight complete line
-#define CULOPT_SCRLINE 0x02 // Highlight screen line
-#define CULOPT_NBR 0x04 // Highlight Number column
-
#define LISPWORD_VALUE \
"defun,define,defmacro,set!,lambda,if,case,let,flet,let*,letrec,do,do*,define-syntax,let-syntax,letrec-syntax,destructuring-bind,defpackage,defparameter,defstruct,deftype,defvar,do-all-symbols,do-external-symbols,do-symbols,dolist,dotimes,ecase,etypecase,eval-when,labels,macrolet,multiple-value-bind,multiple-value-call,multiple-value-prog1,multiple-value-setq,prog1,progv,typecase,unless,unwind-protect,when,with-input-from-string,with-open-file,with-open-stream,with-output-to-string,with-package-iterator,define-condition,handler-bind,handler-case,restart-bind,restart-case,with-simple-restart,store-value,use-value,muffle-warning,abort,continue,with-slots,with-slots*,with-accessors,with-accessors*,defclass,defmethod,print-unreadable-object"
@@ -319,47 +312,17 @@ EXTERN char *p_bg; ///< 'background'
EXTERN int p_bk; ///< 'backup'
EXTERN char *p_bkc; ///< 'backupcopy'
EXTERN unsigned bkc_flags; ///< flags from 'backupcopy'
-#define BKC_YES 0x001
-#define BKC_AUTO 0x002
-#define BKC_NO 0x004
-#define BKC_BREAKSYMLINK 0x008
-#define BKC_BREAKHARDLINK 0x010
EXTERN char *p_bdir; ///< 'backupdir'
EXTERN char *p_bex; ///< 'backupext'
EXTERN char *p_bo; ///< 'belloff'
EXTERN char breakat_flags[256]; ///< which characters are in 'breakat'
EXTERN unsigned bo_flags;
-
-// values for the 'belloff' option
-#define BO_ALL 0x0001
-#define BO_BS 0x0002
-#define BO_CRSR 0x0004
-#define BO_COMPL 0x0008
-#define BO_COPY 0x0010
-#define BO_CTRLG 0x0020
-#define BO_ERROR 0x0040
-#define BO_ESC 0x0080
-#define BO_EX 0x0100
-#define BO_HANGUL 0x0200
-#define BO_IM 0x0400
-#define BO_LANG 0x0800
-#define BO_MESS 0x1000
-#define BO_MATCH 0x2000
-#define BO_OPER 0x4000
-#define BO_REG 0x8000
-#define BO_SH 0x10000
-#define BO_SPELL 0x20000
-#define BO_TERM 0x40000
-#define BO_WILD 0x80000
-
EXTERN char *p_bsk; ///< 'backupskip'
EXTERN char *p_breakat; ///< 'breakat'
EXTERN char *p_bh; ///< 'bufhidden'
EXTERN char *p_bt; ///< 'buftype'
EXTERN char *p_cmp; ///< 'casemap'
EXTERN unsigned cmp_flags;
-#define CMP_INTERNAL 0x001
-#define CMP_KEEPASCII 0x002
EXTERN char *p_enc; ///< 'encoding'
EXTERN int p_deco; ///< 'delcombine'
EXTERN char *p_ccv; ///< 'charconvert'
@@ -367,9 +330,6 @@ EXTERN char *p_cino; ///< 'cinoptions'
EXTERN char *p_cedit; ///< 'cedit'
EXTERN char *p_cb; ///< 'clipboard'
EXTERN unsigned cb_flags;
-#define CB_UNNAMED 0x001
-#define CB_UNNAMEDPLUS 0x002
-#define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS)
EXTERN OptInt p_cwh; ///< 'cmdwinheight'
EXTERN OptInt p_ch; ///< 'cmdheight'
EXTERN char *p_cms; ///< 'commentstring'
@@ -380,18 +340,6 @@ EXTERN char *p_cia; ///< 'completeitemalign'
EXTERN unsigned cia_flags; ///< order flags of 'completeitemalign'
EXTERN char *p_cot; ///< 'completeopt'
EXTERN unsigned cot_flags; ///< flags from 'completeopt'
-// Keep in sync with p_cot_values in optionstr.c
-#define COT_MENU 0x001
-#define COT_MENUONE 0x002
-#define COT_ANY_MENU 0x003 // combination of menu flags
-#define COT_LONGEST 0x004 // false: insert full match,
- // true: insert longest prefix
-#define COT_PREVIEW 0x008
-#define COT_POPUP 0x010
-#define COT_ANY_PREVIEW 0x018 // combination of preview flags
-#define COT_NOINSERT 0x020 // false: select & insert, true: noinsert
-#define COT_NOSELECT 0x040 // false: select & insert, true: noselect
-#define COT_FUZZY 0x080 // true: fuzzy match enabled
#ifdef BACKSLASH_IN_FILENAME
EXTERN char *p_csl; ///< 'completeslash'
#endif
@@ -410,11 +358,6 @@ EXTERN int p_dg; ///< 'digraph'
EXTERN char *p_dir; ///< 'directory'
EXTERN char *p_dy; ///< 'display'
EXTERN unsigned dy_flags;
-#define DY_LASTLINE 0x001
-#define DY_TRUNCATE 0x002
-#define DY_UHEX 0x004
-// legacy flag, not used
-#define DY_MSGSEP 0x008
EXTERN char *p_ead; ///< 'eadirection'
EXTERN int p_emoji; ///< 'emoji'
EXTERN int p_ea; ///< 'equalalways'
@@ -442,17 +385,6 @@ EXTERN char *p_fcl; ///< 'foldclose'
EXTERN OptInt p_fdls; ///< 'foldlevelstart'
EXTERN char *p_fdo; ///< 'foldopen'
EXTERN unsigned fdo_flags;
-#define FDO_ALL 0x001
-#define FDO_BLOCK 0x002
-#define FDO_HOR 0x004
-#define FDO_MARK 0x008
-#define FDO_PERCENT 0x010
-#define FDO_QUICKFIX 0x020
-#define FDO_SEARCH 0x040
-#define FDO_TAG 0x080
-#define FDO_INSERT 0x100
-#define FDO_UNDO 0x200
-#define FDO_JUMP 0x400
EXTERN char *p_fex; ///< 'formatexpr'
EXTERN char *p_flp; ///< 'formatlistpat'
EXTERN char *p_fo; ///< 'formatoptions'
@@ -488,9 +420,6 @@ EXTERN char *p_isp; ///< 'isprint'
EXTERN int p_js; ///< 'joinspaces'
EXTERN char *p_jop; ///< 'jumpooptions'
EXTERN unsigned jop_flags;
-#define JOP_STACK 0x01
-#define JOP_VIEW 0x02
-#define JOP_CLEAN 0x04
EXTERN char *p_keymap; ///< 'keymap'
EXTERN char *p_kp; ///< 'keywordprg'
EXTERN char *p_km; ///< 'keymodel'
@@ -506,7 +435,6 @@ EXTERN char *p_lispwords; ///< 'lispwords'
EXTERN OptInt p_ls; ///< 'laststatus'
EXTERN OptInt p_stal; ///< 'showtabline'
EXTERN char *p_lcs; ///< 'listchars'
-
EXTERN int p_lz; ///< 'lazyredraw'
EXTERN int p_lpl; ///< 'loadplugins'
EXTERN int p_magic; ///< 'magic'
@@ -551,14 +479,6 @@ EXTERN char *p_qe; ///< 'quoteescape'
EXTERN int p_ro; ///< 'readonly'
EXTERN char *p_rdb; ///< 'redrawdebug'
EXTERN unsigned rdb_flags;
-#define RDB_COMPOSITOR 0x001
-#define RDB_NOTHROTTLE 0x002
-#define RDB_INVALID 0x004
-#define RDB_NODELTA 0x008
-#define RDB_LINE 0x010
-#define RDB_FLUSH 0x020
-#define RDB_INTERSECT 0x040
-
EXTERN OptInt p_rdt; ///< 'redrawtime'
EXTERN OptInt p_re; ///< 'regexpengine'
EXTERN OptInt p_report; ///< 'report'
@@ -580,26 +500,6 @@ EXTERN char *p_sel; ///< 'selection'
EXTERN char *p_slm; ///< 'selectmode'
EXTERN char *p_ssop; ///< 'sessionoptions'
EXTERN unsigned ssop_flags;
-
-#define SSOP_BUFFERS 0x001
-#define SSOP_WINPOS 0x002
-#define SSOP_RESIZE 0x004
-#define SSOP_WINSIZE 0x008
-#define SSOP_LOCALOPTIONS 0x010
-#define SSOP_OPTIONS 0x020
-#define SSOP_HELP 0x040
-#define SSOP_BLANK 0x080
-#define SSOP_GLOBALS 0x100
-#define SSOP_SLASH 0x200 // Deprecated, always set.
-#define SSOP_UNIX 0x400 // Deprecated, always set.
-#define SSOP_SESDIR 0x800
-#define SSOP_CURDIR 0x1000
-#define SSOP_FOLDS 0x2000
-#define SSOP_CURSOR 0x4000
-#define SSOP_TABPAGES 0x8000
-#define SSOP_TERMINAL 0x10000
-#define SSOP_SKIP_RTP 0x20000
-
EXTERN char *p_sh; ///< 'shell'
EXTERN char *p_shcf; ///< 'shellcmdflag'
EXTERN char *p_sp; ///< 'shellpipe'
@@ -636,13 +536,6 @@ EXTERN OptInt p_tpm; ///< 'tabpagemax'
EXTERN char *p_tal; ///< 'tabline'
EXTERN char *p_tpf; ///< 'termpastefilter'
EXTERN unsigned tpf_flags; ///< flags from 'termpastefilter'
-#define TPF_BS 0x001
-#define TPF_HT 0x002
-#define TPF_FF 0x004
-#define TPF_ESC 0x008
-#define TPF_DEL 0x010
-#define TPF_C0 0x020
-#define TPF_C1 0x040
EXTERN char *p_tfu; ///< 'tagfunc'
EXTERN char *p_spc; ///< 'spellcapcheck'
EXTERN char *p_spf; ///< 'spellfile'
@@ -655,28 +548,14 @@ EXTERN int p_sol; ///< 'startofline'
EXTERN char *p_su; ///< 'suffixes'
EXTERN char *p_swb; ///< 'switchbuf'
EXTERN unsigned swb_flags;
-// Keep in sync with p_swb_values in optionstr.c
-#define SWB_USEOPEN 0x001
-#define SWB_USETAB 0x002
-#define SWB_SPLIT 0x004
-#define SWB_NEWTAB 0x008
-#define SWB_VSPLIT 0x010
-#define SWB_USELAST 0x020
EXTERN char *p_spk; ///< 'splitkeep'
EXTERN char *p_syn; ///< 'syntax'
EXTERN char *p_tcl; ///< 'tabclose'
EXTERN unsigned tcl_flags; ///< flags from 'tabclose'
-#define TCL_LEFT 0x001
-#define TCL_USELAST 0x002
EXTERN OptInt p_ts; ///< 'tabstop'
EXTERN int p_tbs; ///< 'tagbsearch'
EXTERN char *p_tc; ///< 'tagcase'
EXTERN unsigned tc_flags; ///< flags from 'tagcase'
-#define TC_FOLLOWIC 0x01
-#define TC_IGNORE 0x02
-#define TC_MATCH 0x04
-#define TC_FOLLOWSCS 0x08
-#define TC_SMART 0x10
EXTERN OptInt p_tl; ///< 'taglength'
EXTERN int p_tr; ///< 'tagrelative'
EXTERN char *p_tags; ///< 'tags'
@@ -707,16 +586,10 @@ EXTERN char *p_vsts; ///< 'varsofttabstop'
EXTERN char *p_vts; ///< 'vartabstop'
EXTERN char *p_vdir; ///< 'viewdir'
EXTERN char *p_vop; ///< 'viewoptions'
-EXTERN unsigned vop_flags; ///< uses SSOP_ flags
+EXTERN unsigned vop_flags; ///< uses OptSsopFlags
EXTERN int p_vb; ///< 'visualbell'
EXTERN char *p_ve; ///< 'virtualedit'
EXTERN unsigned ve_flags;
-#define VE_BLOCK 5U // includes "all"
-#define VE_INSERT 6U // includes "all"
-#define VE_ALL 4U
-#define VE_ONEMORE 8U
-#define VE_NONE 16U // "none"
-#define VE_NONEU 32U // "NONE"
EXTERN OptInt p_verbose; ///< 'verbose'
#ifdef IN_OPTION_C
char *p_vfile = empty_string_option; ///< used before options are initialized
@@ -726,9 +599,6 @@ extern char *p_vfile; ///< 'verbosefile'
EXTERN int p_warn; ///< 'warn'
EXTERN char *p_wop; ///< 'wildoptions'
EXTERN unsigned wop_flags;
-#define WOP_FUZZY 0x01
-#define WOP_TAGFILE 0x02
-#define WOP_PUM 0x04
EXTERN OptInt p_window; ///< 'window'
EXTERN char *p_wak; ///< 'winaltkeys'
EXTERN char *p_wig; ///< 'wildignore'
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index d61cba892b..2d712ee101 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -14,6 +14,8 @@
--- @field deny_duplicates? boolean
--- @field enable_if? string
--- @field defaults? vim.option_defaults
+--- @field values? vim.option_valid_values
+--- @field flags? true|table<string,integer>
--- @field secure? true
--- @field noglob? true
--- @field normal_fname_chars? true
@@ -43,6 +45,7 @@
--- @alias vim.option_scope 'global'|'buf'|'win'
--- @alias vim.option_type 'boolean'|'number'|'string'
--- @alias vim.option_value boolean|number|string
+--- @alias vim.option_valid_values (string|[string,vim.option_valid_values])[]
--- @alias vim.option_redraw
--- |'statuslines'
@@ -112,6 +115,7 @@ return {
abbreviation = 'ambw',
cb = 'did_set_ambiwidth',
defaults = { if_true = 'single' },
+ values = { 'single', 'double' },
desc = [=[
Tells Vim what to do with characters with East Asian Width Class
Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek
@@ -306,6 +310,7 @@ return {
abbreviation = 'bg',
cb = 'did_set_background',
defaults = { if_true = 'dark' },
+ values = { 'light', 'dark' },
desc = [=[
When set to "dark" or "light", adjusts the default color groups for
that background type. The |TUI| or other UI sets this on startup
@@ -341,6 +346,7 @@ return {
abbreviation = 'bs',
cb = 'did_set_backspace',
defaults = { if_true = 'indent,eol,start' },
+ values = { 'indent', 'eol', 'start', 'nostop' },
deny_duplicates = true,
desc = [=[
Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
@@ -390,6 +396,8 @@ return {
abbreviation = 'bkc',
cb = 'did_set_backupcopy',
defaults = { condition = 'UNIX', if_false = 'auto', if_true = 'auto' },
+ values = { 'yes', 'auto', 'no', 'breaksymlink', 'breakhardlink' },
+ flags = true,
deny_duplicates = true,
desc = [=[
When writing a file and a backup is made, this option tells how it's
@@ -587,6 +595,29 @@ return {
abbreviation = 'bo',
cb = 'did_set_belloff',
defaults = { if_true = 'all' },
+ values = {
+ 'all',
+ 'backspace',
+ 'cursor',
+ 'complete',
+ 'copy',
+ 'ctrlg',
+ 'error',
+ 'esc',
+ 'ex',
+ 'hangul',
+ 'insertmode',
+ 'lang',
+ 'mess',
+ 'showmatch',
+ 'operator',
+ 'register',
+ 'shell',
+ 'spell',
+ 'term',
+ 'wildmode',
+ },
+ flags = true,
deny_duplicates = true,
desc = [=[
Specifies for which events the bell will not be rung. It is a comma-
@@ -708,6 +739,7 @@ return {
if_true = ' \t!@*-+;:,./?',
doc = '" ^I!@*-+;:,./?"',
},
+ flags = true,
desc = [=[
This option lets you choose which characters might cause a line
break if 'linebreak' is on. Only works for ASCII characters.
@@ -738,6 +770,8 @@ return {
abbreviation = 'briopt',
cb = 'did_set_breakindentopt',
defaults = { if_true = '' },
+ -- Keep this in sync with briopt_check().
+ values = { 'shift:', 'min:', 'sbr', 'list:', 'column:' },
deny_duplicates = true,
desc = [=[
Settings for 'breakindent'. It can consist of the following optional
@@ -800,6 +834,7 @@ return {
abbreviation = 'bh',
cb = 'did_set_bufhidden',
defaults = { if_true = '' },
+ values = { 'hide', 'unload', 'delete', 'wipe' },
desc = [=[
This option specifies what happens when a buffer is no longer
displayed in a window:
@@ -852,6 +887,15 @@ return {
abbreviation = 'bt',
cb = 'did_set_buftype',
defaults = { if_true = '' },
+ values = {
+ 'nofile',
+ 'nowrite',
+ 'quickfix',
+ 'help',
+ 'acwrite',
+ 'terminal',
+ 'prompt',
+ },
desc = [=[
The value of this option specifies the type of a buffer:
<empty> normal buffer
@@ -911,6 +955,8 @@ return {
abbreviation = 'cmp',
cb = 'did_set_casemap',
defaults = { if_true = 'internal,keepascii' },
+ values = { 'internal', 'keepascii' },
+ flags = true,
deny_duplicates = true,
desc = [=[
Specifies details about changing the case of letters. It may contain
@@ -1175,6 +1221,8 @@ return {
abbreviation = 'cb',
cb = 'did_set_clipboard',
defaults = { if_true = '' },
+ values = { 'unnamed', 'unnamedplus' },
+ flags = true,
desc = [=[
This option is a list of comma-separated names.
These names are recognized:
@@ -1348,6 +1396,7 @@ return {
abbreviation = 'cpt',
cb = 'did_set_complete',
defaults = { if_true = '.,w,b,u,t' },
+ values = { '.', 'w', 'b', 'u', 'k', 'kspell', 's', 'i', 'd', ']', 't', 'U', 'f' },
deny_duplicates = true,
desc = [=[
This option specifies how keyword completion |ins-completion| works
@@ -1418,6 +1467,7 @@ return {
abbreviation = 'cia',
cb = 'did_set_completeitemalign',
defaults = { if_true = 'abbr,kind,menu' },
+ flags = true,
deny_duplicates = true,
desc = [=[
A comma-separated list of |complete-items| that controls the alignment
@@ -1438,6 +1488,17 @@ return {
abbreviation = 'cot',
cb = 'did_set_completeopt',
defaults = { if_true = 'menu,preview' },
+ values = {
+ 'menu',
+ 'menuone',
+ 'longest',
+ 'preview',
+ 'popup',
+ 'noinsert',
+ 'noselect',
+ 'fuzzy',
+ },
+ flags = true,
deny_duplicates = true,
desc = [=[
A comma-separated list of options for Insert mode completion
@@ -1493,6 +1554,7 @@ return {
abbreviation = 'csl',
cb = 'did_set_completeslash',
defaults = { if_true = '' },
+ values = { 'slash', 'backslash' },
desc = [=[
only modifiable in MS-Windows
When this option is set it overrules 'shellslash' for completion:
@@ -1908,6 +1970,13 @@ return {
abbreviation = 'culopt',
cb = 'did_set_cursorlineopt',
defaults = { if_true = 'both' },
+ -- Keep this in sync with fill_culopt_flags().
+ values = { 'line', 'screenline', 'number', 'both' },
+ flags = {
+ Line = 0x01,
+ Screenline = 0x02,
+ Number = 0x04,
+ },
deny_duplicates = true,
desc = [=[
Comma-separated list of settings for how 'cursorline' is displayed.
@@ -1935,6 +2004,7 @@ return {
{
cb = 'did_set_debug',
defaults = { if_true = '' },
+ values = { 'msg', 'throw', 'beep' },
desc = [=[
These values can be used:
msg Error messages that would otherwise be omitted will be given
@@ -2077,6 +2147,26 @@ return {
abbreviation = 'dip',
cb = 'did_set_diffopt',
defaults = { if_true = 'internal,filler,closeoff' },
+ -- Keep this in sync with diffopt_changed().
+ values = {
+ 'filler',
+ 'context:',
+ 'iblank',
+ 'icase',
+ 'iwhite',
+ 'iwhiteall',
+ 'iwhiteeol',
+ 'horizontal',
+ 'vertical',
+ 'closeoff',
+ 'hiddenoff',
+ 'foldcolumn:',
+ 'followwrap',
+ 'internal',
+ 'indent-heuristic',
+ 'linematch:',
+ { 'algorithm:', { 'myers', 'minimal', 'patience', 'histogram' } },
+ },
deny_duplicates = true,
desc = [=[
Option settings for diff mode. It can consist of the following items.
@@ -2269,6 +2359,8 @@ return {
abbreviation = 'dy',
cb = 'did_set_display',
defaults = { if_true = 'lastline' },
+ values = { 'lastline', 'truncate', 'uhex', 'msgsep' },
+ flags = true,
deny_duplicates = true,
desc = [=[
Change the way text is displayed. This is a comma-separated list of
@@ -2302,6 +2394,7 @@ return {
abbreviation = 'ead',
cb = 'did_set_eadirection',
defaults = { if_true = 'both' },
+ values = { 'both', 'ver', 'hor' },
desc = [=[
Tells when the 'equalalways' option applies:
ver vertically, width of windows is not affected
@@ -2689,6 +2782,7 @@ return {
if_false = 'unix',
doc = 'Windows: "dos", Unix: "unix"',
},
+ values = { 'unix', 'dos', 'mac' },
desc = [=[
This gives the <EOL> of the current buffer, which is used for
reading/writing the buffer from/to a file:
@@ -2993,6 +3087,7 @@ return {
abbreviation = 'fcl',
cb = 'did_set_foldclose',
defaults = { if_true = '' },
+ values = { 'all' },
deny_duplicates = true,
desc = [=[
When set to "all", a fold is closed when the cursor isn't in it and
@@ -3012,6 +3107,28 @@ return {
abbreviation = 'fdc',
cb = 'did_set_foldcolumn',
defaults = { if_true = '0' },
+ values = {
+ 'auto',
+ 'auto:1',
+ 'auto:2',
+ 'auto:3',
+ 'auto:4',
+ 'auto:5',
+ 'auto:6',
+ 'auto:7',
+ 'auto:8',
+ 'auto:9',
+ '0',
+ '1',
+ '2',
+ '3',
+ '4',
+ '5',
+ '6',
+ '7',
+ '8',
+ '9',
+ },
desc = [=[
When and how to draw the foldcolumn. Valid values are:
"auto": resize to the minimum amount of folds to display.
@@ -3148,6 +3265,7 @@ return {
abbreviation = 'fdm',
cb = 'did_set_foldmethod',
defaults = { if_true = 'manual' },
+ values = { 'manual', 'expr', 'marker', 'indent', 'syntax', 'diff' },
desc = [=[
The kind of folding used for the current window. Possible values:
|fold-manual| manual Folds are created manually.
@@ -3202,6 +3320,20 @@ return {
abbreviation = 'fdo',
cb = 'did_set_foldopen',
defaults = { if_true = 'block,hor,mark,percent,quickfix,search,tag,undo' },
+ values = {
+ 'all',
+ 'block',
+ 'hor',
+ 'mark',
+ 'percent',
+ 'quickfix',
+ 'search',
+ 'tag',
+ 'insert',
+ 'undo',
+ 'jump',
+ },
+ flags = true,
deny_duplicates = true,
desc = [=[
Specifies for which type of commands folds will be opened, if the
@@ -4163,6 +4295,7 @@ return {
abbreviation = 'icm',
cb = 'did_set_inccommand',
defaults = { if_true = 'nosplit' },
+ values = { 'nosplit', 'split' },
desc = [=[
When nonempty, shows the effects of |:substitute|, |:smagic|,
|:snomagic| and user commands with the |:command-preview| flag as you
@@ -4568,6 +4701,8 @@ return {
abbreviation = 'jop',
cb = 'did_set_jumpoptions',
defaults = { if_true = 'clean' },
+ values = { 'stack', 'view', 'clean' },
+ flags = true,
deny_duplicates = true,
desc = [=[
List of words that change the behavior of the |jumplist|.
@@ -4616,6 +4751,7 @@ return {
abbreviation = 'km',
cb = 'did_set_keymodel',
defaults = { if_true = '' },
+ values = { 'startsel', 'stopsel' },
deny_duplicates = true,
desc = [=[
List of comma-separated words, which enable special things that keys
@@ -4903,6 +5039,7 @@ return {
abbreviation = 'lop',
cb = 'did_set_lispoptions',
defaults = { if_true = '' },
+ values = { 'expr:0', 'expr:1' },
deny_duplicates = true,
desc = [=[
Comma-separated list of items that influence the Lisp indenting when
@@ -5559,6 +5696,7 @@ return {
abbreviation = 'mousem',
cb = 'did_set_mousemodel',
defaults = { if_true = 'popup_setpos' },
+ values = { 'extend', 'popup', 'popup_setpos', 'mac' },
desc = [=[
Sets the model to use for the mouse. The name mostly specifies what
the right mouse button is used for:
@@ -5635,6 +5773,7 @@ return {
{
cb = 'did_set_mousescroll',
defaults = { if_true = 'ver:3,hor:6' },
+ values = { 'hor:', 'ver:' },
desc = [=[
This option controls the number of lines / columns to scroll by when
scrolling with a mouse wheel (|scroll-mouse-wheel|). The option is
@@ -5770,6 +5909,7 @@ return {
abbreviation = 'nf',
cb = 'did_set_nrformats',
defaults = { if_true = 'bin,hex' },
+ values = { 'bin', 'octal', 'hex', 'alpha', 'unsigned', 'blank' },
deny_duplicates = true,
desc = [=[
This defines what bases Vim will consider for numbers when using the
@@ -6301,6 +6441,15 @@ return {
abbreviation = 'rdb',
cb = 'did_set_redrawdebug',
defaults = { if_true = '' },
+ values = {
+ 'compositor',
+ 'nothrottle',
+ 'invalid',
+ 'nodelta',
+ 'line',
+ 'flush',
+ },
+ flags = true,
desc = [=[
Flags to change the way redrawing works, for debugging purposes.
Most useful with 'writedelay' set to some reasonable value.
@@ -6473,6 +6622,7 @@ return {
abbreviation = 'rlc',
cb = 'did_set_rightleftcmd',
defaults = { if_true = 'search' },
+ values = { 'search' },
desc = [=[
Each word in this option enables the command line editing to work in
right-to-left mode for a group of commands:
@@ -6756,6 +6906,7 @@ return {
abbreviation = 'sbo',
cb = 'did_set_scrollopt',
defaults = { if_true = 'ver,jump' },
+ values = { 'ver', 'hor', 'jump' },
deny_duplicates = true,
desc = [=[
This is a comma-separated list of words that specifies how
@@ -6821,6 +6972,7 @@ return {
abbreviation = 'sel',
cb = 'did_set_selection',
defaults = { if_true = 'inclusive' },
+ values = { 'inclusive', 'exclusive', 'old' },
desc = [=[
This option defines the behavior of the selection. It is only used
in Visual and Select mode.
@@ -6851,6 +7003,7 @@ return {
abbreviation = 'slm',
cb = 'did_set_selectmode',
defaults = { if_true = '' },
+ values = { 'mouse', 'key', 'cmd' },
deny_duplicates = true,
desc = [=[
This is a comma-separated list of words, which specifies when to start
@@ -6873,6 +7026,28 @@ return {
abbreviation = 'ssop',
cb = 'did_set_sessionoptions',
defaults = { if_true = 'blank,buffers,curdir,folds,help,tabpages,winsize,terminal' },
+ -- Also used for 'viewoptions'.
+ values = {
+ 'buffers',
+ 'winpos',
+ 'resize',
+ 'winsize',
+ 'localoptions',
+ 'options',
+ 'help',
+ 'blank',
+ 'globals',
+ 'slash',
+ 'unix',
+ 'sesdir',
+ 'curdir',
+ 'folds',
+ 'cursor',
+ 'tabpages',
+ 'terminal',
+ 'skiprtp',
+ },
+ flags = true,
deny_duplicates = true,
desc = [=[
Changes the effect of the |:mksession| command. It is a comma-
@@ -7527,6 +7702,7 @@ return {
abbreviation = 'sloc',
cb = 'did_set_showcmdloc',
defaults = { if_true = 'last' },
+ values = { 'last', 'statusline', 'tabline' },
desc = [=[
This option can be used to display the (partially) entered command in
another location. Possible values are:
@@ -7678,6 +7854,30 @@ return {
abbreviation = 'scl',
cb = 'did_set_signcolumn',
defaults = { if_true = 'auto' },
+ values = {
+ 'yes',
+ 'no',
+ 'auto',
+ 'auto:1',
+ 'auto:2',
+ 'auto:3',
+ 'auto:4',
+ 'auto:5',
+ 'auto:6',
+ 'auto:7',
+ 'auto:8',
+ 'auto:9',
+ 'yes:1',
+ 'yes:2',
+ 'yes:3',
+ 'yes:4',
+ 'yes:5',
+ 'yes:6',
+ 'yes:7',
+ 'yes:8',
+ 'yes:9',
+ 'number',
+ },
desc = [=[
When and how to draw the signcolumn. Valid values are:
"auto" only when there is a sign to display
@@ -7944,6 +8144,8 @@ return {
abbreviation = 'spo',
cb = 'did_set_spelloptions',
defaults = { if_true = '' },
+ values = { 'camel', 'noplainbuffer' },
+ flags = true,
deny_duplicates = true,
desc = [=[
A comma-separated list of options for spell checking:
@@ -7969,6 +8171,8 @@ return {
abbreviation = 'sps',
cb = 'did_set_spellsuggest',
defaults = { if_true = 'best' },
+ -- Keep this in sync with spell_check_sps().
+ values = { 'best', 'fast', 'double', 'expr:', 'file:', 'timeout:' },
deny_duplicates = true,
desc = [=[
Methods used for spelling suggestions. Both for the |z=| command and
@@ -8064,6 +8268,7 @@ return {
abbreviation = 'spk',
cb = 'did_set_splitkeep',
defaults = { if_true = 'cursor' },
+ values = { 'cursor', 'screen', 'topline' },
desc = [=[
The value of this option determines the scroll behavior when opening,
closing or resizing horizontal splits.
@@ -8486,6 +8691,8 @@ return {
abbreviation = 'swb',
cb = 'did_set_switchbuf',
defaults = { if_true = 'uselast' },
+ values = { 'useopen', 'usetab', 'split', 'newtab', 'vsplit', 'uselast' },
+ flags = true,
deny_duplicates = true,
desc = [=[
This option controls the behavior when switching between buffers.
@@ -8583,6 +8790,8 @@ return {
abbreviation = 'tcl',
cb = 'did_set_tabclose',
defaults = { if_true = '' },
+ values = { 'left', 'uselast' },
+ flags = true,
deny_duplicates = true,
desc = [=[
This option controls the behavior when closing tab pages (e.g., using
@@ -8765,6 +8974,8 @@ return {
abbreviation = 'tc',
cb = 'did_set_tagcase',
defaults = { if_true = 'followic' },
+ values = { 'followic', 'ignore', 'match', 'followscs', 'smart' },
+ flags = true,
desc = [=[
This option specifies how case is handled when searching the tags
file:
@@ -8929,6 +9140,8 @@ return {
abbreviation = 'tpf',
cb = 'did_set_termpastefilter',
defaults = { if_true = 'BS,HT,ESC,DEL' },
+ values = { 'BS', 'HT', 'FF', 'ESC', 'DEL', 'C0', 'C1' },
+ flags = true,
deny_duplicates = true,
desc = [=[
A comma-separated list of options for specifying control characters
@@ -9506,6 +9719,7 @@ return {
abbreviation = 'vop',
cb = 'did_set_viewoptions',
defaults = { if_true = 'folds,cursor,curdir' },
+ flags = true,
deny_duplicates = true,
desc = [=[
Changes the effect of the |:mkview| command. It is a comma-separated
@@ -9533,6 +9747,15 @@ return {
abbreviation = 've',
cb = 'did_set_virtualedit',
defaults = { if_true = '' },
+ values = { 'block', 'insert', 'all', 'onemore', 'none', 'NONE' },
+ flags = {
+ Block = 5,
+ Insert = 6,
+ All = 4,
+ Onemore = 8,
+ None = 16,
+ NoneU = 32,
+ },
deny_duplicates = true,
desc = [=[
A comma-separated list of these words:
@@ -9777,6 +10000,9 @@ return {
abbreviation = 'wim',
cb = 'did_set_wildmode',
defaults = { if_true = 'full' },
+ -- Keep this in sync with check_opt_wim().
+ values = { 'full', 'longest', 'list', 'lastused' },
+ flags = true,
deny_duplicates = false,
desc = [=[
Completion mode that is used for the character specified with
@@ -9835,6 +10061,8 @@ return {
abbreviation = 'wop',
cb = 'did_set_wildoptions',
defaults = { if_true = 'pum,tagfile' },
+ values = { 'fuzzy', 'tagfile', 'pum' },
+ flags = true,
deny_duplicates = true,
desc = [=[
A list of words that change how |cmdline-completion| is done.
@@ -9867,6 +10095,7 @@ return {
abbreviation = 'wak',
cb = 'did_set_winaltkeys',
defaults = { if_true = 'menu' },
+ values = { 'yes', 'menu', 'no' },
desc = [=[
only used in Win32
Some GUI versions allow the access to menu entries by using the ALT
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index bfb26a0be6..b47517b1a2 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -68,84 +68,6 @@ static const char e_wrong_number_of_characters_for_field_str[]
static const char e_wrong_character_width_for_field_str[]
= N_("E1512: Wrong character width for field \"%s\"");
-static char *(p_ambw_values[]) = { "single", "double", NULL };
-static char *(p_bg_values[]) = { "light", "dark", NULL };
-static char *(p_bkc_values[]) = { "yes", "auto", "no", "breaksymlink", "breakhardlink", NULL };
-static char *(p_bo_values[]) = { "all", "backspace", "cursor", "complete", "copy", "ctrlg", "error",
- "esc", "ex", "hangul", "insertmode", "lang", "mess", "showmatch",
- "operator", "register", "shell", "spell", "term", "wildmode",
- NULL };
-// Note: Keep this in sync with briopt_check()
-static char *(p_briopt_values[]) = { "shift:", "min:", "sbr", "list:", "column:", NULL };
-// Note: Keep this in sync with diffopt_changed()
-static char *(p_dip_values[]) = { "filler", "context:", "iblank", "icase",
- "iwhite", "iwhiteall", "iwhiteeol", "horizontal", "vertical",
- "closeoff", "hiddenoff", "foldcolumn:", "followwrap", "internal",
- "indent-heuristic", "linematch:", "algorithm:", NULL };
-static char *(p_dip_algorithm_values[]) = { "myers", "minimal", "patience", "histogram", NULL };
-static char *(p_nf_values[]) = { "bin", "octal", "hex", "alpha", "unsigned", "blank", NULL };
-static char *(p_ff_values[]) = { "unix", "dos", "mac", NULL };
-static char *(p_cb_values[]) = { "unnamed", "unnamedplus", NULL };
-static char *(p_cmp_values[]) = { "internal", "keepascii", NULL };
-// Note: Keep this in sync with fill_culopt_flags()
-static char *(p_culopt_values[]) = { "line", "screenline", "number", "both", NULL };
-static char *(p_dy_values[]) = { "lastline", "truncate", "uhex", "msgsep", NULL };
-static char *(p_fdo_values[]) = { "all", "block", "hor", "mark", "percent", "quickfix", "search",
- "tag", "insert", "undo", "jump", NULL };
-// Note: Keep this in sync with spell_check_sps()
-static char *(p_sps_values[]) = { "best", "fast", "double", "expr:", "file:", "timeout:", NULL };
-/// Also used for 'viewoptions'! Keep in sync with SSOP_ flags.
-static char *(p_ssop_values[]) = { "buffers", "winpos", "resize", "winsize", "localoptions",
- "options", "help", "blank", "globals", "slash", "unix", "sesdir",
- "curdir", "folds", "cursor", "tabpages", "terminal", "skiprtp",
- NULL };
-// Keep in sync with SWB_ flags in option_vars.h
-static char *(p_swb_values[]) = { "useopen", "usetab", "split", "newtab", "vsplit", "uselast",
- NULL };
-static char *(p_spk_values[]) = { "cursor", "screen", "topline", NULL };
-static char *(p_tc_values[]) = { "followic", "ignore", "match", "followscs", "smart", NULL };
-// Keep in sync with TCL_ flags in option_vars.h
-static char *(p_tcl_values[]) = { "left", "uselast", NULL };
-static char *(p_ve_values[]) = { "block", "insert", "all", "onemore", "none", "NONE", NULL };
-// Note: Keep this in sync with check_opt_wim()
-static char *(p_wim_values[]) = { "full", "longest", "list", "lastused", NULL };
-static char *(p_wop_values[]) = { "fuzzy", "tagfile", "pum", NULL };
-static char *(p_wak_values[]) = { "yes", "menu", "no", NULL };
-static char *(p_mousem_values[]) = { "extend", "popup", "popup_setpos", "mac", NULL };
-static char *(p_sel_values[]) = { "inclusive", "exclusive", "old", NULL };
-static char *(p_slm_values[]) = { "mouse", "key", "cmd", NULL };
-static char *(p_km_values[]) = { "startsel", "stopsel", NULL };
-static char *(p_scbopt_values[]) = { "ver", "hor", "jump", NULL };
-static char *(p_debug_values[]) = { "msg", "throw", "beep", NULL };
-static char *(p_ead_values[]) = { "both", "ver", "hor", NULL };
-static char *(p_buftype_values[]) = { "nofile", "nowrite", "quickfix", "help", "acwrite",
- "terminal", "prompt", NULL };
-static char *(p_bufhidden_values[]) = { "hide", "unload", "delete", "wipe", NULL };
-static char *(p_bs_values[]) = { "indent", "eol", "start", "nostop", NULL };
-static char *(p_fdm_values[]) = { "manual", "expr", "marker", "indent",
- "syntax", "diff", NULL };
-static char *(p_fcl_values[]) = { "all", NULL };
-static char *(p_cot_values[]) = { "menu", "menuone", "longest", "preview", "popup",
- "noinsert", "noselect", "fuzzy", NULL };
-#ifdef BACKSLASH_IN_FILENAME
-static char *(p_csl_values[]) = { "slash", "backslash", NULL };
-#endif
-
-static char *(p_scl_values[]) = { "yes", "no", "auto", "auto:1", "auto:2", "auto:3", "auto:4",
- "auto:5", "auto:6", "auto:7", "auto:8", "auto:9", "yes:1",
- "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", "yes:7", "yes:8",
- "yes:9", "number", NULL };
-static char *(p_fdc_values[]) = { "auto", "auto:1", "auto:2", "auto:3", "auto:4", "auto:5",
- "auto:6", "auto:7", "auto:8", "auto:9", "0", "1", "2", "3", "4",
- "5", "6", "7", "8", "9", NULL };
-static char *(p_spo_values[]) = { "camel", "noplainbuffer", NULL };
-static char *(p_icm_values[]) = { "nosplit", "split", NULL };
-static char *(p_jop_values[]) = { "stack", "view", "clean", NULL };
-static char *(p_tpf_values[]) = { "BS", "HT", "FF", "ESC", "DEL", "C0", "C1", NULL };
-static char *(p_rdb_values[]) = { "compositor", "nothrottle", "invalid", "nodelta", "line",
- "flush", NULL };
-static char *(p_sloc_values[]) = { "last", "statusline", "tabline", NULL };
-
/// All possible flags for 'shm'.
/// the literal chars before 0 are removed flags. these are safely ignored
static char SHM_ALL[] = { SHM_RO, SHM_MOD, SHM_LINES,
@@ -158,23 +80,23 @@ static char SHM_ALL[] = { SHM_RO, SHM_MOD, SHM_LINES,
/// option values.
void didset_string_options(void)
{
- opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true);
- opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, true);
- opt_strings_flags(p_bo, p_bo_values, &bo_flags, true);
- opt_strings_flags(p_cot, p_cot_values, &cot_flags, true);
- opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true);
- opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true);
- opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true);
- opt_strings_flags(p_dy, p_dy_values, &dy_flags, true);
- opt_strings_flags(p_jop, p_jop_values, &jop_flags, true);
- opt_strings_flags(p_rdb, p_rdb_values, &rdb_flags, true);
- opt_strings_flags(p_tc, p_tc_values, &tc_flags, false);
- opt_strings_flags(p_tpf, p_tpf_values, &tpf_flags, true);
- opt_strings_flags(p_ve, p_ve_values, &ve_flags, true);
- opt_strings_flags(p_swb, p_swb_values, &swb_flags, true);
- opt_strings_flags(p_tcl, p_tcl_values, &tcl_flags, true);
- opt_strings_flags(p_wop, p_wop_values, &wop_flags, true);
- opt_strings_flags(p_cb, p_cb_values, &cb_flags, true);
+ opt_strings_flags(p_cmp, opt_cmp_values, &cmp_flags, true);
+ opt_strings_flags(p_bkc, opt_bkc_values, &bkc_flags, true);
+ opt_strings_flags(p_bo, opt_bo_values, &bo_flags, true);
+ opt_strings_flags(p_cot, opt_cot_values, &cot_flags, true);
+ opt_strings_flags(p_ssop, opt_ssop_values, &ssop_flags, true);
+ opt_strings_flags(p_vop, opt_ssop_values, &vop_flags, true);
+ opt_strings_flags(p_fdo, opt_fdo_values, &fdo_flags, true);
+ opt_strings_flags(p_dy, opt_dy_values, &dy_flags, true);
+ opt_strings_flags(p_jop, opt_jop_values, &jop_flags, true);
+ opt_strings_flags(p_rdb, opt_rdb_values, &rdb_flags, true);
+ opt_strings_flags(p_tc, opt_tc_values, &tc_flags, false);
+ opt_strings_flags(p_tpf, opt_tpf_values, &tpf_flags, true);
+ opt_strings_flags(p_ve, opt_ve_values, &ve_flags, true);
+ opt_strings_flags(p_swb, opt_swb_values, &swb_flags, true);
+ opt_strings_flags(p_tcl, opt_tcl_values, &tcl_flags, true);
+ opt_strings_flags(p_wop, opt_wop_values, &wop_flags, true);
+ opt_strings_flags(p_cb, opt_cb_values, &cb_flags, true);
}
char *illegal_char(char *errbuf, size_t errbuflen, int c)
@@ -300,7 +222,7 @@ int check_signcolumn(char *scl, win_T *wp)
return FAIL;
}
- if (check_opt_strings(val, p_scl_values, false) == OK) {
+ if (check_opt_strings(val, opt_scl_values, false) == OK) {
if (wp == NULL) {
return OK;
}
@@ -428,7 +350,7 @@ bool check_illegal_path_names(char *val, uint32_t flags)
/// An option that accepts a list of flags is changed.
/// e.g. 'viewoptions', 'switchbuf', 'casemap', etc.
-static const char *did_set_opt_flags(char *val, char **values, unsigned *flagp, bool list)
+static const char *did_set_opt_flags(char *val, const char **values, unsigned *flagp, bool list)
{
if (opt_strings_flags(val, values, flagp, list) != OK) {
return e_invarg;
@@ -438,7 +360,7 @@ static const char *did_set_opt_flags(char *val, char **values, unsigned *flagp,
/// An option that accepts a list of string values is changed.
/// e.g. 'nrformats', 'scrollopt', 'wildoptions', etc.
-static const char *did_set_opt_strings(char *val, char **values, bool list)
+static const char *did_set_opt_strings(char *val, const char **values, bool list)
{
return did_set_opt_flags(val, values, NULL, list);
}
@@ -456,7 +378,7 @@ static const char *did_set_option_listflag(char *val, char *flags, char *errbuf,
}
/// Expand an option that accepts a list of string values.
-static int expand_set_opt_string(optexpand_T *args, char **values, size_t numValues,
+static int expand_set_opt_string(optexpand_T *args, const char **values, size_t numValues,
int *numMatches, char ***matches)
{
regmatch_T *regmatch = args->oe_regmatch;
@@ -473,7 +395,7 @@ static int expand_set_opt_string(optexpand_T *args, char **values, size_t numVal
(*matches)[count++] = xstrdup(option_val);
}
- for (char **val = values; *val != NULL; val++) {
+ for (const char **val = values; *val != NULL; val++) {
if (include_orig_val && *option_val != NUL) {
if (strcmp(*val, option_val) == 0) {
continue;
@@ -568,7 +490,7 @@ static int expand_set_opt_listflag(optexpand_T *args, char *flags, int *numMatch
/// The 'ambiwidth' option is changed.
const char *did_set_ambiwidth(optset_T *args FUNC_ATTR_UNUSED)
{
- if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) {
+ if (check_opt_strings(p_ambw, opt_ambw_values, false) != OK) {
return e_invarg;
}
return check_chars_options();
@@ -577,8 +499,8 @@ const char *did_set_ambiwidth(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_ambiwidth(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_ambw_values,
- ARRAY_SIZE(p_ambw_values) - 1,
+ opt_ambw_values,
+ ARRAY_SIZE(opt_ambw_values) - 1,
numMatches,
matches);
}
@@ -586,7 +508,7 @@ int expand_set_ambiwidth(optexpand_T *args, int *numMatches, char ***matches)
/// The 'background' option is changed.
const char *did_set_background(optset_T *args)
{
- if (check_opt_strings(p_bg, p_bg_values, false) != OK) {
+ if (check_opt_strings(p_bg, opt_bg_values, false) != OK) {
return e_invarg;
}
@@ -615,8 +537,8 @@ const char *did_set_background(optset_T *args)
int expand_set_background(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_bg_values,
- ARRAY_SIZE(p_bg_values) - 1,
+ opt_bg_values,
+ ARRAY_SIZE(opt_bg_values) - 1,
numMatches,
matches);
}
@@ -628,7 +550,7 @@ const char *did_set_backspace(optset_T *args FUNC_ATTR_UNUSED)
if (*p_bs != '2') {
return e_invarg;
}
- } else if (check_opt_strings(p_bs, p_bs_values, true) != OK) {
+ } else if (check_opt_strings(p_bs, opt_bs_values, true) != OK) {
return e_invarg;
}
return NULL;
@@ -637,8 +559,8 @@ const char *did_set_backspace(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_backspace(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_bs_values,
- ARRAY_SIZE(p_bs_values) - 1,
+ opt_bs_values,
+ ARRAY_SIZE(opt_bs_values) - 1,
numMatches,
matches);
}
@@ -664,15 +586,15 @@ const char *did_set_backupcopy(optset_T *args)
// make the local value empty: use the global value
*flags = 0;
} else {
- if (opt_strings_flags(bkc, p_bkc_values, flags, true) != OK) {
+ if (opt_strings_flags(bkc, opt_bkc_values, flags, true) != OK) {
return e_invarg;
}
- if (((*flags & BKC_AUTO) != 0)
- + ((*flags & BKC_YES) != 0)
- + ((*flags & BKC_NO) != 0) != 1) {
+ if (((*flags & kOptBkcFlagAuto) != 0)
+ + ((*flags & kOptBkcFlagYes) != 0)
+ + ((*flags & kOptBkcFlagNo) != 0) != 1) {
// Must have exactly one of "auto", "yes" and "no".
- opt_strings_flags(oldval, p_bkc_values, flags, true);
+ opt_strings_flags(oldval, opt_bkc_values, flags, true);
return e_invarg;
}
}
@@ -683,8 +605,8 @@ const char *did_set_backupcopy(optset_T *args)
int expand_set_backupcopy(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_bkc_values,
- ARRAY_SIZE(p_bkc_values) - 1,
+ opt_bkc_values,
+ ARRAY_SIZE(opt_bkc_values) - 1,
numMatches,
matches);
}
@@ -703,14 +625,14 @@ const char *did_set_backupext_or_patchmode(optset_T *args FUNC_ATTR_UNUSED)
/// The 'belloff' option is changed.
const char *did_set_belloff(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_bo, p_bo_values, &bo_flags, true);
+ return did_set_opt_flags(p_bo, opt_bo_values, &bo_flags, true);
}
int expand_set_belloff(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_bo_values,
- ARRAY_SIZE(p_bo_values) - 1,
+ opt_bo_values,
+ ARRAY_SIZE(opt_bo_values) - 1,
numMatches,
matches);
}
@@ -752,8 +674,8 @@ const char *did_set_breakindentopt(optset_T *args)
int expand_set_breakindentopt(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_briopt_values,
- ARRAY_SIZE(p_briopt_values) - 1,
+ opt_briopt_values,
+ ARRAY_SIZE(opt_briopt_values) - 1,
numMatches,
matches);
}
@@ -762,14 +684,14 @@ int expand_set_breakindentopt(optexpand_T *args, int *numMatches, char ***matche
const char *did_set_bufhidden(optset_T *args)
{
buf_T *buf = (buf_T *)args->os_buf;
- return did_set_opt_strings(buf->b_p_bh, p_bufhidden_values, false);
+ return did_set_opt_strings(buf->b_p_bh, opt_bh_values, false);
}
int expand_set_bufhidden(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_bufhidden_values,
- ARRAY_SIZE(p_bufhidden_values) - 1,
+ opt_bh_values,
+ ARRAY_SIZE(opt_bh_values) - 1,
numMatches,
matches);
}
@@ -782,7 +704,7 @@ const char *did_set_buftype(optset_T *args)
// When 'buftype' is set, check for valid value.
if ((buf->terminal && buf->b_p_bt[0] != 't')
|| (!buf->terminal && buf->b_p_bt[0] == 't')
- || check_opt_strings(buf->b_p_bt, p_buftype_values, false) != OK) {
+ || check_opt_strings(buf->b_p_bt, opt_bt_values, false) != OK) {
return e_invarg;
}
if (win->w_status_height || global_stl_height()) {
@@ -797,8 +719,8 @@ const char *did_set_buftype(optset_T *args)
int expand_set_buftype(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_buftype_values,
- ARRAY_SIZE(p_buftype_values) - 1,
+ opt_bt_values,
+ ARRAY_SIZE(opt_bt_values) - 1,
numMatches,
matches);
}
@@ -806,14 +728,14 @@ int expand_set_buftype(optexpand_T *args, int *numMatches, char ***matches)
/// The 'casemap' option is changed.
const char *did_set_casemap(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, true);
+ return did_set_opt_flags(p_cmp, opt_cmp_values, &cmp_flags, true);
}
int expand_set_casemap(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_cmp_values,
- ARRAY_SIZE(p_cmp_values) - 1,
+ opt_cmp_values,
+ ARRAY_SIZE(opt_cmp_values) - 1,
numMatches,
matches);
}
@@ -904,14 +826,14 @@ const char *did_set_cinoptions(optset_T *args)
/// The 'clipboard' option is changed.
const char *did_set_clipboard(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_cb, p_cb_values, &cb_flags, true);
+ return did_set_opt_flags(p_cb, opt_cb_values, &cb_flags, true);
}
int expand_set_clipboard(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_cb_values,
- ARRAY_SIZE(p_cb_values) - 1,
+ opt_cb_values,
+ ARRAY_SIZE(opt_cb_values) - 1,
numMatches,
matches);
}
@@ -1009,12 +931,9 @@ const char *did_set_complete(optset_T *args)
int expand_set_complete(optexpand_T *args, int *numMatches, char ***matches)
{
- static char *(p_cpt_values[]) = {
- ".", "w", "b", "u", "k", "kspell", "s", "i", "d", "]", "t", "U", "f", NULL
- };
return expand_set_opt_string(args,
- p_cpt_values,
- ARRAY_SIZE(p_cpt_values) - 1,
+ opt_cpt_values,
+ ARRAY_SIZE(opt_cpt_values) - 1,
numMatches,
matches);
}
@@ -1079,11 +998,11 @@ const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED)
buf->b_cot_flags = 0;
}
- if (check_opt_strings(cot, p_cot_values, true) != OK) {
+ if (check_opt_strings(cot, opt_cot_values, true) != OK) {
return e_invarg;
}
- if (opt_strings_flags(cot, p_cot_values, flags, true) != OK) {
+ if (opt_strings_flags(cot, opt_cot_values, flags, true) != OK) {
return e_invarg;
}
@@ -1093,8 +1012,8 @@ const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_completeopt(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_cot_values,
- ARRAY_SIZE(p_cot_values) - 1,
+ opt_cot_values,
+ ARRAY_SIZE(opt_cot_values) - 1,
numMatches,
matches);
}
@@ -1104,8 +1023,8 @@ int expand_set_completeopt(optexpand_T *args, int *numMatches, char ***matches)
const char *did_set_completeslash(optset_T *args)
{
buf_T *buf = (buf_T *)args->os_buf;
- if (check_opt_strings(p_csl, p_csl_values, false) != OK
- || check_opt_strings(buf->b_p_csl, p_csl_values, false) != OK) {
+ if (check_opt_strings(p_csl, opt_csl_values, false) != OK
+ || check_opt_strings(buf->b_p_csl, opt_csl_values, false) != OK) {
return e_invarg;
}
return NULL;
@@ -1114,8 +1033,8 @@ const char *did_set_completeslash(optset_T *args)
int expand_set_completeslash(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_csl_values,
- ARRAY_SIZE(p_csl_values) - 1,
+ opt_csl_values,
+ ARRAY_SIZE(opt_csl_values) - 1,
numMatches,
matches);
}
@@ -1164,8 +1083,8 @@ const char *did_set_cursorlineopt(optset_T *args)
int expand_set_cursorlineopt(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_culopt_values,
- ARRAY_SIZE(p_culopt_values) - 1,
+ opt_culopt_values,
+ ARRAY_SIZE(opt_culopt_values) - 1,
numMatches,
matches);
}
@@ -1173,14 +1092,14 @@ int expand_set_cursorlineopt(optexpand_T *args, int *numMatches, char ***matches
/// The 'debug' option is changed.
const char *did_set_debug(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_debug, p_debug_values, false);
+ return did_set_opt_strings(p_debug, opt_debug_values, false);
}
int expand_set_debug(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_debug_values,
- ARRAY_SIZE(p_debug_values) - 1,
+ opt_debug_values,
+ ARRAY_SIZE(opt_debug_values) - 1,
numMatches,
matches);
}
@@ -1204,8 +1123,8 @@ int expand_set_diffopt(optexpand_T *args, int *numMatches, char ***matches)
if (xp->xp_pattern - args->oe_set_arg >= (int)algo_len
&& strncmp(xp->xp_pattern - algo_len, "algorithm:", algo_len) == 0) {
return expand_set_opt_string(args,
- p_dip_algorithm_values,
- ARRAY_SIZE(p_dip_algorithm_values) - 1,
+ opt_dip_algorithm_values,
+ ARRAY_SIZE(opt_dip_algorithm_values) - 1,
numMatches,
matches);
}
@@ -1213,8 +1132,8 @@ int expand_set_diffopt(optexpand_T *args, int *numMatches, char ***matches)
}
return expand_set_opt_string(args,
- p_dip_values,
- ARRAY_SIZE(p_dip_values) - 1,
+ opt_dip_values,
+ ARRAY_SIZE(opt_dip_values) - 1,
numMatches,
matches);
}
@@ -1222,7 +1141,7 @@ int expand_set_diffopt(optexpand_T *args, int *numMatches, char ***matches)
/// The 'display' option is changed.
const char *did_set_display(optset_T *args FUNC_ATTR_UNUSED)
{
- if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, true) != OK) {
+ if (opt_strings_flags(p_dy, opt_dy_values, &dy_flags, true) != OK) {
return e_invarg;
}
init_chartab();
@@ -1233,8 +1152,8 @@ const char *did_set_display(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_display(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_dy_values,
- ARRAY_SIZE(p_dy_values) - 1,
+ opt_dy_values,
+ ARRAY_SIZE(opt_dy_values) - 1,
numMatches,
matches);
}
@@ -1242,14 +1161,14 @@ int expand_set_display(optexpand_T *args, int *numMatches, char ***matches)
/// The 'eadirection' option is changed.
const char *did_set_eadirection(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_ead, p_ead_values, false);
+ return did_set_opt_strings(p_ead, opt_ead_values, false);
}
int expand_set_eadirection(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_ead_values,
- ARRAY_SIZE(p_ead_values) - 1,
+ opt_ead_values,
+ ARRAY_SIZE(opt_ead_values) - 1,
numMatches,
matches);
}
@@ -1334,7 +1253,7 @@ const char *did_set_fileformat(optset_T *args)
int opt_flags = args->os_flags;
if (!MODIFIABLE(buf) && !(opt_flags & OPT_GLOBAL)) {
return e_modifiable;
- } else if (check_opt_strings(*varp, p_ff_values, false) != OK) {
+ } else if (check_opt_strings(*varp, opt_ff_values, false) != OK) {
return e_invarg;
}
redraw_titles();
@@ -1351,8 +1270,8 @@ const char *did_set_fileformat(optset_T *args)
int expand_set_fileformat(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_ff_values,
- ARRAY_SIZE(p_ff_values) - 1,
+ opt_ff_values,
+ ARRAY_SIZE(opt_ff_values) - 1,
numMatches,
matches);
}
@@ -1361,17 +1280,17 @@ int expand_set_fileformat(optexpand_T *args, int *numMatches, char ***matches)
/// fileformat options.
char *get_fileformat_name(expand_T *xp FUNC_ATTR_UNUSED, int idx)
{
- if (idx >= (int)ARRAY_SIZE(p_ff_values)) {
+ if (idx >= (int)ARRAY_SIZE(opt_ff_values)) {
return NULL;
}
- return p_ff_values[idx];
+ return (char *)opt_ff_values[idx];
}
/// The 'fileformats' option is changed.
const char *did_set_fileformats(optset_T *args)
{
- return did_set_opt_strings(p_ffs, p_ff_values, true);
+ return did_set_opt_strings(p_ffs, opt_ff_values, true);
}
/// The 'filetype' or the 'syntax' option is changed.
@@ -1395,14 +1314,14 @@ const char *did_set_filetype_or_syntax(optset_T *args)
/// The 'foldclose' option is changed.
const char *did_set_foldclose(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_fcl, p_fcl_values, true);
+ return did_set_opt_strings(p_fcl, opt_fcl_values, true);
}
int expand_set_foldclose(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_fcl_values,
- ARRAY_SIZE(p_fcl_values) - 1,
+ opt_fcl_values,
+ ARRAY_SIZE(opt_fcl_values) - 1,
numMatches,
matches);
}
@@ -1411,7 +1330,7 @@ int expand_set_foldclose(optexpand_T *args, int *numMatches, char ***matches)
const char *did_set_foldcolumn(optset_T *args)
{
char **varp = (char **)args->os_varp;
- if (**varp == NUL || check_opt_strings(*varp, p_fdc_values, false) != OK) {
+ if (**varp == NUL || check_opt_strings(*varp, opt_fdc_values, false) != OK) {
return e_invarg;
}
return NULL;
@@ -1420,8 +1339,8 @@ const char *did_set_foldcolumn(optset_T *args)
int expand_set_foldcolumn(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_fdc_values,
- ARRAY_SIZE(p_fdc_values) - 1,
+ opt_fdc_values,
+ ARRAY_SIZE(opt_fdc_values) - 1,
numMatches,
matches);
}
@@ -1474,7 +1393,7 @@ const char *did_set_foldmethod(optset_T *args)
{
win_T *win = (win_T *)args->os_win;
char **varp = (char **)args->os_varp;
- if (check_opt_strings(*varp, p_fdm_values, false) != OK || **varp == NUL) {
+ if (check_opt_strings(*varp, opt_fdm_values, false) != OK || **varp == NUL) {
return e_invarg;
}
foldUpdateAll(win);
@@ -1487,8 +1406,8 @@ const char *did_set_foldmethod(optset_T *args)
int expand_set_foldmethod(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_fdm_values,
- ARRAY_SIZE(p_fdm_values) - 1,
+ opt_fdm_values,
+ ARRAY_SIZE(opt_fdm_values) - 1,
numMatches,
matches);
}
@@ -1496,14 +1415,14 @@ int expand_set_foldmethod(optexpand_T *args, int *numMatches, char ***matches)
/// The 'foldopen' option is changed.
const char *did_set_foldopen(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, true);
+ return did_set_opt_flags(p_fdo, opt_fdo_values, &fdo_flags, true);
}
int expand_set_foldopen(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_fdo_values,
- ARRAY_SIZE(p_fdo_values) - 1,
+ opt_fdo_values,
+ ARRAY_SIZE(opt_fdo_values) - 1,
numMatches,
matches);
}
@@ -1586,14 +1505,14 @@ const char *did_set_inccommand(optset_T *args FUNC_ATTR_UNUSED)
if (cmdpreview) {
return e_invarg;
}
- return did_set_opt_strings(p_icm, p_icm_values, false);
+ return did_set_opt_strings(p_icm, opt_icm_values, false);
}
int expand_set_inccommand(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_icm_values,
- ARRAY_SIZE(p_icm_values) - 1,
+ opt_icm_values,
+ ARRAY_SIZE(opt_icm_values) - 1,
numMatches,
matches);
}
@@ -1632,14 +1551,14 @@ const char *did_set_isopt(optset_T *args)
/// The 'jumpoptions' option is changed.
const char *did_set_jumpoptions(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_jop, p_jop_values, &jop_flags, true);
+ return did_set_opt_flags(p_jop, opt_jop_values, &jop_flags, true);
}
int expand_set_jumpoptions(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_jop_values,
- ARRAY_SIZE(p_jop_values) - 1,
+ opt_jop_values,
+ ARRAY_SIZE(opt_jop_values) - 1,
numMatches,
matches);
}
@@ -1699,7 +1618,7 @@ const char *did_set_keymap(optset_T *args)
/// The 'keymodel' option is changed.
const char *did_set_keymodel(optset_T *args FUNC_ATTR_UNUSED)
{
- if (check_opt_strings(p_km, p_km_values, true) != OK) {
+ if (check_opt_strings(p_km, opt_km_values, true) != OK) {
return e_invarg;
}
km_stopsel = (vim_strchr(p_km, 'o') != NULL);
@@ -1710,8 +1629,8 @@ const char *did_set_keymodel(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_keymodel(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_km_values,
- ARRAY_SIZE(p_km_values) - 1,
+ opt_km_values,
+ ARRAY_SIZE(opt_km_values) - 1,
numMatches,
matches);
}
@@ -1729,10 +1648,9 @@ const char *did_set_lispoptions(optset_T *args)
int expand_set_lispoptions(optexpand_T *args, int *numMatches, char ***matches)
{
- static char *(p_lop_values[]) = { "expr:0", "expr:1", NULL };
return expand_set_opt_string(args,
- p_lop_values,
- ARRAY_SIZE(p_lop_values) - 1,
+ opt_lop_values,
+ ARRAY_SIZE(opt_lop_values) - 1,
numMatches,
matches);
}
@@ -1789,14 +1707,14 @@ int expand_set_mouse(optexpand_T *args, int *numMatches, char ***matches)
/// The 'mousemodel' option is changed.
const char *did_set_mousemodel(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_mousem, p_mousem_values, false);
+ return did_set_opt_strings(p_mousem, opt_mousem_values, false);
}
int expand_set_mousemodel(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_mousem_values,
- ARRAY_SIZE(p_mousem_values) - 1,
+ opt_mousem_values,
+ ARRAY_SIZE(opt_mousem_values) - 1,
numMatches,
matches);
}
@@ -1868,10 +1786,9 @@ const char *did_set_mousescroll(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_mousescroll(optexpand_T *args, int *numMatches, char ***matches)
{
- static char *(p_mousescroll_values[]) = { "hor:", "ver:", NULL };
return expand_set_opt_string(args,
- p_mousescroll_values,
- ARRAY_SIZE(p_mousescroll_values) - 1,
+ opt_mousescroll_values,
+ ARRAY_SIZE(opt_mousescroll_values) - 1,
numMatches,
matches);
}
@@ -1881,14 +1798,14 @@ const char *did_set_nrformats(optset_T *args)
{
char **varp = (char **)args->os_varp;
- return did_set_opt_strings(*varp, p_nf_values, true);
+ return did_set_opt_strings(*varp, opt_nf_values, true);
}
int expand_set_nrformats(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_nf_values,
- ARRAY_SIZE(p_nf_values) - 1,
+ opt_nf_values,
+ ARRAY_SIZE(opt_nf_values) - 1,
numMatches,
matches);
}
@@ -1912,7 +1829,7 @@ const char *did_set_optexpr(optset_T *args)
/// The 'redrawdebug' option is changed.
const char *did_set_redrawdebug(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_rdb, p_rdb_values, &rdb_flags, true);
+ return did_set_opt_flags(p_rdb, opt_rdb_values, &rdb_flags, true);
}
/// The 'rightleftcmd' option is changed.
@@ -1930,10 +1847,9 @@ const char *did_set_rightleftcmd(optset_T *args)
int expand_set_rightleftcmd(optexpand_T *args, int *numMatches, char ***matches)
{
- static char *(p_rlc_values[]) = { "search", NULL };
return expand_set_opt_string(args,
- p_rlc_values,
- ARRAY_SIZE(p_rlc_values) - 1,
+ opt_rlc_values,
+ ARRAY_SIZE(opt_rlc_values) - 1,
numMatches,
matches);
}
@@ -1947,14 +1863,14 @@ const char *did_set_rulerformat(optset_T *args)
/// The 'scrollopt' option is changed.
const char *did_set_scrollopt(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_sbo, p_scbopt_values, true);
+ return did_set_opt_strings(p_sbo, opt_sbo_values, true);
}
int expand_set_scrollopt(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_scbopt_values,
- ARRAY_SIZE(p_scbopt_values) - 1,
+ opt_sbo_values,
+ ARRAY_SIZE(opt_sbo_values) - 1,
numMatches,
matches);
}
@@ -1962,7 +1878,7 @@ int expand_set_scrollopt(optexpand_T *args, int *numMatches, char ***matches)
/// The 'selection' option is changed.
const char *did_set_selection(optset_T *args FUNC_ATTR_UNUSED)
{
- if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, false) != OK) {
+ if (*p_sel == NUL || check_opt_strings(p_sel, opt_sel_values, false) != OK) {
return e_invarg;
}
if (VIsual_active) {
@@ -1975,8 +1891,8 @@ const char *did_set_selection(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_selection(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_sel_values,
- ARRAY_SIZE(p_sel_values) - 1,
+ opt_sel_values,
+ ARRAY_SIZE(opt_sel_values) - 1,
numMatches,
matches);
}
@@ -1984,14 +1900,14 @@ int expand_set_selection(optexpand_T *args, int *numMatches, char ***matches)
/// The 'selectmode' option is changed.
const char *did_set_selectmode(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_slm, p_slm_values, true);
+ return did_set_opt_strings(p_slm, opt_slm_values, true);
}
int expand_set_selectmode(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_slm_values,
- ARRAY_SIZE(p_slm_values) - 1,
+ opt_slm_values,
+ ARRAY_SIZE(opt_slm_values) - 1,
numMatches,
matches);
}
@@ -1999,13 +1915,13 @@ int expand_set_selectmode(optexpand_T *args, int *numMatches, char ***matches)
/// The 'sessionoptions' option is changed.
const char *did_set_sessionoptions(optset_T *args)
{
- if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true) != OK) {
+ if (opt_strings_flags(p_ssop, opt_ssop_values, &ssop_flags, true) != OK) {
return e_invarg;
}
- if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) {
+ if ((ssop_flags & kOptSsopFlagCurdir) && (ssop_flags & kOptSsopFlagSesdir)) {
// Don't allow both "sesdir" and "curdir".
const char *oldval = args->os_oldval.string.data;
- opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true);
+ opt_strings_flags(oldval, opt_ssop_values, &ssop_flags, true);
return e_invarg;
}
return NULL;
@@ -2014,8 +1930,8 @@ const char *did_set_sessionoptions(optset_T *args)
int expand_set_sessionoptions(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_ssop_values,
- ARRAY_SIZE(p_ssop_values) - 1,
+ opt_ssop_values,
+ ARRAY_SIZE(opt_ssop_values) - 1,
numMatches,
matches);
}
@@ -2099,7 +2015,7 @@ const char *did_set_showbreak(optset_T *args)
/// The 'showcmdloc' option is changed.
const char *did_set_showcmdloc(optset_T *args FUNC_ATTR_UNUSED)
{
- const char *errmsg = did_set_opt_strings(p_sloc, p_sloc_values, false);
+ const char *errmsg = did_set_opt_strings(p_sloc, opt_sloc_values, false);
if (errmsg == NULL) {
comp_col();
@@ -2111,8 +2027,8 @@ const char *did_set_showcmdloc(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_showcmdloc(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_sloc_values,
- ARRAY_SIZE(p_sloc_values) - 1,
+ opt_sloc_values,
+ ARRAY_SIZE(opt_sloc_values) - 1,
numMatches,
matches);
}
@@ -2137,8 +2053,8 @@ const char *did_set_signcolumn(optset_T *args)
int expand_set_signcolumn(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_scl_values,
- ARRAY_SIZE(p_scl_values) - 1,
+ opt_scl_values,
+ ARRAY_SIZE(opt_scl_values) - 1,
numMatches,
matches);
}
@@ -2185,11 +2101,11 @@ const char *did_set_spelloptions(optset_T *args)
const char *val = args->os_newval.string.data;
if (!(opt_flags & OPT_LOCAL)
- && opt_strings_flags(val, p_spo_values, &spo_flags, true) != OK) {
+ && opt_strings_flags(val, opt_spo_values, &spo_flags, true) != OK) {
return e_invarg;
}
if (!(opt_flags & OPT_GLOBAL)
- && opt_strings_flags(val, p_spo_values, &win->w_s->b_p_spo_flags, true) != OK) {
+ && opt_strings_flags(val, opt_spo_values, &win->w_s->b_p_spo_flags, true) != OK) {
return e_invarg;
}
return NULL;
@@ -2198,8 +2114,8 @@ const char *did_set_spelloptions(optset_T *args)
int expand_set_spelloptions(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_spo_values,
- ARRAY_SIZE(p_spo_values) - 1,
+ opt_spo_values,
+ ARRAY_SIZE(opt_spo_values) - 1,
numMatches,
matches);
}
@@ -2216,8 +2132,8 @@ const char *did_set_spellsuggest(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_spellsuggest(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_sps_values,
- ARRAY_SIZE(p_sps_values) - 1,
+ opt_sps_values,
+ ARRAY_SIZE(opt_sps_values) - 1,
numMatches,
matches);
}
@@ -2225,14 +2141,14 @@ int expand_set_spellsuggest(optexpand_T *args, int *numMatches, char ***matches)
/// The 'splitkeep' option is changed.
const char *did_set_splitkeep(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_spk, p_spk_values, false);
+ return did_set_opt_strings(p_spk, opt_spk_values, false);
}
int expand_set_splitkeep(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_spk_values,
- ARRAY_SIZE(p_spk_values) - 1,
+ opt_spk_values,
+ ARRAY_SIZE(opt_spk_values) - 1,
numMatches,
matches);
}
@@ -2291,14 +2207,14 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf
/// The 'switchbuf' option is changed.
const char *did_set_switchbuf(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, true);
+ return did_set_opt_flags(p_swb, opt_swb_values, &swb_flags, true);
}
int expand_set_switchbuf(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_swb_values,
- ARRAY_SIZE(p_swb_values) - 1,
+ opt_swb_values,
+ ARRAY_SIZE(opt_swb_values) - 1,
numMatches,
matches);
}
@@ -2306,14 +2222,14 @@ int expand_set_switchbuf(optexpand_T *args, int *numMatches, char ***matches)
/// The 'tabclose' option is changed.
const char *did_set_tabclose(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_tcl, p_tcl_values, &tcl_flags, true);
+ return did_set_opt_flags(p_tcl, opt_tcl_values, &tcl_flags, true);
}
int expand_set_tabclose(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_tcl_values,
- ARRAY_SIZE(p_tcl_values) - 1,
+ opt_tcl_values,
+ ARRAY_SIZE(opt_tcl_values) - 1,
numMatches,
matches);
}
@@ -2345,7 +2261,7 @@ const char *did_set_tagcase(optset_T *args)
// make the local value empty: use the global value
*flags = 0;
} else if (*p == NUL
- || opt_strings_flags(p, p_tc_values, flags, false) != OK) {
+ || opt_strings_flags(p, opt_tc_values, flags, false) != OK) {
return e_invarg;
}
return NULL;
@@ -2354,8 +2270,8 @@ const char *did_set_tagcase(optset_T *args)
int expand_set_tagcase(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_tc_values,
- ARRAY_SIZE(p_tc_values) - 1,
+ opt_tc_values,
+ ARRAY_SIZE(opt_tc_values) - 1,
numMatches,
matches);
}
@@ -2363,14 +2279,14 @@ int expand_set_tagcase(optexpand_T *args, int *numMatches, char ***matches)
/// The 'termpastefilter' option is changed.
const char *did_set_termpastefilter(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_tpf, p_tpf_values, &tpf_flags, true);
+ return did_set_opt_flags(p_tpf, opt_tpf_values, &tpf_flags, true);
}
int expand_set_termpastefilter(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_tpf_values,
- ARRAY_SIZE(p_tpf_values) - 1,
+ opt_tpf_values,
+ ARRAY_SIZE(opt_tpf_values) - 1,
numMatches,
matches);
}
@@ -2474,7 +2390,7 @@ const char *did_set_verbosefile(optset_T *args)
/// The 'viewoptions' option is changed.
const char *did_set_viewoptions(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, true);
+ return did_set_opt_flags(p_vop, opt_ssop_values, &vop_flags, true);
}
/// The 'virtualedit' option is changed.
@@ -2494,7 +2410,7 @@ const char *did_set_virtualedit(optset_T *args)
// make the local value empty: use the global value
*flags = 0;
} else {
- if (opt_strings_flags(ve, p_ve_values, flags, true) != OK) {
+ if (opt_strings_flags(ve, opt_ve_values, flags, true) != OK) {
return e_invarg;
} else if (strcmp(ve, args->os_oldval.string.data) != 0) {
// Recompute cursor position in case the new 've' setting
@@ -2509,8 +2425,8 @@ const char *did_set_virtualedit(optset_T *args)
int expand_set_virtualedit(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_ve_values,
- ARRAY_SIZE(p_ve_values) - 1,
+ opt_ve_values,
+ ARRAY_SIZE(opt_ve_values) - 1,
numMatches,
matches);
}
@@ -2542,8 +2458,8 @@ const char *did_set_wildmode(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_wildmode(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_wim_values,
- ARRAY_SIZE(p_wim_values) - 1,
+ opt_wim_values,
+ ARRAY_SIZE(opt_wim_values) - 1,
numMatches,
matches);
}
@@ -2551,14 +2467,14 @@ int expand_set_wildmode(optexpand_T *args, int *numMatches, char ***matches)
/// The 'wildoptions' option is changed.
const char *did_set_wildoptions(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_wop, p_wop_values, &wop_flags, true);
+ return did_set_opt_flags(p_wop, opt_wop_values, &wop_flags, true);
}
int expand_set_wildoptions(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_wop_values,
- ARRAY_SIZE(p_wop_values) - 1,
+ opt_wop_values,
+ ARRAY_SIZE(opt_wop_values) - 1,
numMatches,
matches);
}
@@ -2566,7 +2482,7 @@ int expand_set_wildoptions(optexpand_T *args, int *numMatches, char ***matches)
/// The 'winaltkeys' option is changed.
const char *did_set_winaltkeys(optset_T *args FUNC_ATTR_UNUSED)
{
- if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, false) != OK) {
+ if (*p_wak == NUL || check_opt_strings(p_wak, opt_wak_values, false) != OK) {
return e_invarg;
}
return NULL;
@@ -2575,8 +2491,8 @@ const char *did_set_winaltkeys(optset_T *args FUNC_ATTR_UNUSED)
int expand_set_winaltkeys(optexpand_T *args, int *numMatches, char ***matches)
{
return expand_set_opt_string(args,
- p_wak_values,
- ARRAY_SIZE(p_wak_values) - 1,
+ opt_wak_values,
+ ARRAY_SIZE(opt_wak_values) - 1,
numMatches,
matches);
}
@@ -2608,7 +2524,7 @@ int expand_set_winhighlight(optexpand_T *args, int *numMatches, char ***matches)
/// @param list when true: accept a list of values
///
/// @return OK for correct value, FAIL otherwise. Empty is always OK.
-static int check_opt_strings(char *val, char **values, int list)
+static int check_opt_strings(char *val, const char **values, int list)
{
return opt_strings_flags(val, values, NULL, list);
}
@@ -2621,7 +2537,7 @@ static int check_opt_strings(char *val, char **values, int list)
/// @param list when true: accept a list of values
///
/// @return OK for correct value, FAIL otherwise. Empty is always OK.
-static int opt_strings_flags(const char *val, char **values, unsigned *flagp, bool list)
+static int opt_strings_flags(const char *val, const char **values, unsigned *flagp, bool list)
{
unsigned new_flags = 0;
@@ -2651,7 +2567,7 @@ static int opt_strings_flags(const char *val, char **values, unsigned *flagp, bo
/// @return OK if "p" is a valid fileformat name, FAIL otherwise.
int check_ff_value(char *p)
{
- return check_opt_strings(p, p_ff_values, false);
+ return check_opt_strings(p, opt_ff_values, false);
}
static const char e_conflicts_with_value_of_listchars[]
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index d1951d4f96..953d2e75a6 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -456,7 +456,7 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf, int user_hlattr)
int *attrs = xmalloc(sizeof(int) * (size_t)vim_strsize(text));
bool in_fuzzy = State == MODE_CMDLINE ? cmdline_compl_is_fuzzy()
- : (get_cot_flags() & COT_FUZZY) != 0;
+ : (get_cot_flags() & kOptCotFlagFuzzy) != 0;
size_t leader_len = strlen(leader);
garray_T *ga = NULL;
@@ -844,7 +844,7 @@ static void pum_preview_set_text(buf_T *buf, char *info, linenr_T *lnum, int *ma
}
// delete the empty last line
ml_delete_buf(buf, buf->b_ml.ml_line_count, false);
- if (get_cot_flags() & COT_POPUP) {
+ if (get_cot_flags() & kOptCotFlagPopup) {
extmark_splice(buf, 1, 0, 1, 0, 0, buf->b_ml.ml_line_count, 0, inserted_bytes, kExtmarkNoUndo);
}
}
@@ -940,7 +940,7 @@ static bool pum_set_selected(int n, int repeat)
pum_selected = n;
unsigned cur_cot_flags = get_cot_flags();
- bool use_float = (cur_cot_flags & COT_POPUP) != 0;
+ bool use_float = (cur_cot_flags & kOptCotFlagPopup) != 0;
// when new leader add and info window is shown and no selected we still
// need use the first index item to update the info float window position.
bool force_select = use_float && pum_selected < 0 && win_float_find_preview();
@@ -1006,7 +1006,7 @@ static bool pum_set_selected(int n, int repeat)
if ((pum_array[pum_selected].pum_info != NULL)
&& (Rows > 10)
&& (repeat <= 1)
- && (cur_cot_flags & COT_ANY_PREVIEW)) {
+ && (cur_cot_flags & (kOptCotFlagPreview | kOptCotFlagPopup))) {
win_T *curwin_save = curwin;
tabpage_T *curtab_save = curtab;
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 6526b0d0bf..76c794b5a9 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2697,7 +2697,7 @@ static void qf_goto_win_with_qfl_file(int qf_fnum)
// Didn't find it, go to the window before the quickfix
// window, unless 'switchbuf' contains 'uselast': in this case we
// try to jump to the previously used window first.
- if ((swb_flags & SWB_USELAST) && win_valid(prevwin)
+ if ((swb_flags & kOptSwbFlagUselast) && win_valid(prevwin)
&& !prevwin->w_p_wfb) {
win = prevwin;
} else if (altwin != NULL) {
@@ -2754,7 +2754,7 @@ static int qf_jump_to_usable_window(int qf_fnum, bool newwin, bool *opened_windo
// If no usable window is found and 'switchbuf' contains "usetab"
// then search in other tabs.
- if (!usable_win && (swb_flags & SWB_USETAB)) {
+ if (!usable_win && (swb_flags & kOptSwbFlagUsetab)) {
usable_win = qf_goto_tabwin_with_file(qf_fnum);
}
@@ -3032,7 +3032,7 @@ static int qf_jump_to_buffer(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, int
qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol, qf_ptr->qf_pattern);
- if ((fdo_flags & FDO_QUICKFIX) && openfold) {
+ if ((fdo_flags & kOptFdoFlagQuickfix) && openfold) {
foldOpenCursor();
}
if (print_message) {
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 159ab35f6f..f06b679b0d 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1423,7 +1423,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, size_t patlen
cmdline_search_stat(dirc, &pos, &curwin->w_cursor,
show_top_bot_msg, msgbuf, msgbuflen,
(count != 1 || has_offset
- || (!(fdo_flags & FDO_SEARCH)
+ || (!(fdo_flags & kOptFdoFlagSearch)
&& hasFolding(curwin, curwin->w_cursor.lnum, NULL,
NULL))),
SEARCH_STAT_DEF_MAX_COUNT,
@@ -2350,7 +2350,7 @@ void showmatch(int c)
}
if ((lpos = findmatch(NULL, NUL)) == NULL) { // no match, so beep
- vim_beep(BO_MATCH);
+ vim_beep(kOptBoFlagShowmatch);
return;
}
@@ -2535,7 +2535,7 @@ int current_search(int count, bool forward)
}
}
- if (fdo_flags & FDO_SEARCH && KeyTyped) {
+ if (fdo_flags & kOptFdoFlagSearch && KeyTyped) {
foldOpenCursor();
}
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index a0fdd46b04..00e977710f 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -245,7 +245,7 @@ size_t spell_check(win_T *wp, char *ptr, hlf_T *attrp, int *capcol, bool docount
size_t nrlen = 0; // found a number first
size_t wrongcaplen = 0;
bool count_word = docount;
- bool use_camel_case = (wp->w_s->b_p_spo_flags & SPO_CAMEL) != 0;
+ bool use_camel_case = (wp->w_s->b_p_spo_flags & kOptSpoFlagCamel) != 0;
bool is_camel_case = false;
matchinf_T mi; // Most things are put in "mi" so that it can be passed to functions quickly.
@@ -1407,7 +1407,7 @@ size_t spell_move_to(win_T *wp, int dir, smt_T behaviour, bool curline, hlf_T *a
: p - buf) > wp->w_cursor.col)) {
colnr_T col = (colnr_T)(p - buf);
- bool no_plain_buffer = (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) != 0;
+ bool no_plain_buffer = (wp->w_s->b_p_spo_flags & kOptSpoFlagNoplainbuffer) != 0;
bool can_spell = !no_plain_buffer;
switch (decor_spell_nav_col(wp, lnum, &decor_lnum, col)) {
case kTrue:
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 0ddf4ffa38..3a985ab004 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -402,7 +402,7 @@ int spell_check_sps(void)
if (*s != NUL && !ascii_isdigit(*s)) {
f = -1;
}
- // Note: Keep this in sync with p_sps_values.
+ // Note: Keep this in sync with opt_sps_values.
} else if (strcmp(buf, "best") == 0) {
f = SPS_BEST;
} else if (strcmp(buf, "fast") == 0) {
@@ -464,7 +464,7 @@ void spell_suggest(int count)
// Use the Visually selected text as the bad word. But reject
// a multi-line selection.
if (curwin->w_cursor.lnum != VIsual.lnum) {
- vim_beep(BO_SPELL);
+ vim_beep(kOptBoFlagSpell);
return;
}
badlen = (int)curwin->w_cursor.col - (int)VIsual.col;
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 908f724792..32e2a8d652 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -146,9 +146,9 @@ bool virtual_active(win_T *wp)
if (virtual_op != kNone) {
return virtual_op;
}
- return cur_ve_flags == VE_ALL
- || ((cur_ve_flags & VE_BLOCK) && VIsual_active && VIsual_mode == Ctrl_V)
- || ((cur_ve_flags & VE_INSERT) && (State & MODE_INSERT));
+ return cur_ve_flags == kOptVeFlagAll
+ || ((cur_ve_flags & kOptVeFlagBlock) && VIsual_active && VIsual_mode == Ctrl_V)
+ || ((cur_ve_flags & kOptVeFlagInsert) && (State & MODE_INSERT));
}
/// MODE_VISUAL, MODE_SELECT and MODE_OP_PENDING State are never set, they are
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 3e0bb32391..5844d8d3f2 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -451,7 +451,7 @@ void do_tag(char *tag, int type, int count, int forceit, bool verbose)
curwin->w_cursor.col = saved_fmark.mark.col;
curwin->w_set_curswant = true;
check_cursor(curwin);
- if ((fdo_flags & FDO_TAG) && old_KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagTag) && old_KeyTyped) {
foldOpenCursor();
}
@@ -2294,17 +2294,17 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
// Change the value of 'ignorecase' according to 'tagcase' for the
// duration of this function.
switch (curbuf->b_tc_flags ? curbuf->b_tc_flags : tc_flags) {
- case TC_FOLLOWIC: break;
- case TC_IGNORE:
+ case kOptTcFlagFollowic: break;
+ case kOptTcFlagIgnore:
p_ic = true;
break;
- case TC_MATCH:
+ case kOptTcFlagMatch:
p_ic = false;
break;
- case TC_FOLLOWSCS:
+ case kOptTcFlagFollowscs:
p_ic = ignorecase(pat);
break;
- case TC_SMART:
+ case kOptTcFlagSmart:
p_ic = ignorecase_opt(pat, true, true);
break;
default:
@@ -2846,7 +2846,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, bool keep_help)
// If it was a CTRL-W CTRL-] command split window now. For ":tab tag"
// open a new tab page.
- if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB))) {
+ if (postponed_split && (swb_flags & (kOptSwbFlagUseopen | kOptSwbFlagUsetab))) {
buf_T *const existing_buf = buflist_findname_exp(fname);
if (existing_buf != NULL) {
@@ -3015,7 +3015,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, bool keep_help)
if (curbuf->b_help) {
set_topline(curwin, curwin->w_cursor.lnum);
}
- if ((fdo_flags & FDO_TAG) && old_KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagTag) && old_KeyTyped) {
foldOpenCursor();
}
}
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 5ff7f721ba..b4496d6758 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -598,12 +598,12 @@ bool terminal_enter(void)
int save_w_p_cuc = curwin->w_p_cuc;
OptInt save_w_p_so = curwin->w_p_so;
OptInt save_w_p_siso = curwin->w_p_siso;
- if (curwin->w_p_cul && curwin->w_p_culopt_flags & CULOPT_NBR) {
+ if (curwin->w_p_cul && curwin->w_p_culopt_flags & kOptCuloptFlagNumber) {
if (strcmp(curwin->w_p_culopt, "number") != 0) {
save_w_p_culopt = curwin->w_p_culopt;
curwin->w_p_culopt = xstrdup("number");
}
- curwin->w_p_culopt_flags = CULOPT_NBR;
+ curwin->w_p_culopt_flags = kOptCuloptFlagNumber;
} else {
curwin->w_p_cul = false;
}
@@ -868,28 +868,28 @@ static bool is_filter_char(int c)
unsigned flag = 0;
switch (c) {
case 0x08:
- flag = TPF_BS;
+ flag = kOptTpfFlagBS;
break;
case 0x09:
- flag = TPF_HT;
+ flag = kOptTpfFlagHT;
break;
case 0x0A:
case 0x0D:
break;
case 0x0C:
- flag = TPF_FF;
+ flag = kOptTpfFlagFF;
break;
case 0x1b:
- flag = TPF_ESC;
+ flag = kOptTpfFlagESC;
break;
case 0x7F:
- flag = TPF_DEL;
+ flag = kOptTpfFlagDEL;
break;
default:
if (c < ' ') {
- flag = TPF_C0;
+ flag = kOptTpfFlagC0;
} else if (c >= 0x80 && c <= 0x9F) {
- flag = TPF_C1;
+ flag = kOptTpfFlagC1;
}
}
return !!(tpf_flags & flag);
@@ -1181,7 +1181,7 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *data)
/// Called when the terminal wants to ring the system bell.
static int term_bell(void *data)
{
- vim_beep(BO_TERM);
+ vim_beep(kOptBoFlagTerm);
return 1;
}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index eba821a53d..f7b5f28cad 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -325,7 +325,7 @@ void ui_busy_stop(void)
/// Emit a bell or visualbell as a warning
///
-/// val is one of the BO_ values, e.g., BO_OPER
+/// val is one of the OptBoFlags values, e.g., kOptBoFlagOperator
void vim_beep(unsigned val)
{
called_vim_beep = true;
@@ -334,7 +334,7 @@ void vim_beep(unsigned val)
return;
}
- if (!((bo_flags & val) || (bo_flags & BO_ALL))) {
+ if (!((bo_flags & val) || (bo_flags & kOptBoFlagAll))) {
static int beeps = 0;
static uint64_t start_time = 0;
@@ -477,7 +477,7 @@ void ui_line(ScreenGrid *grid, int row, bool invalid_row, int startcol, int endc
(const sattr_T *)grid->attrs + off);
// 'writedelay': flush & delay each time.
- if (p_wd && (rdb_flags & RDB_LINE)) {
+ if (p_wd && (rdb_flags & kOptRdbFlagLine)) {
// If 'writedelay' is active, set the cursor to indicate what was drawn.
ui_call_grid_cursor_goto(grid->handle, row,
MIN(clearcol, (int)grid->cols - 1));
@@ -564,7 +564,7 @@ void ui_flush(void)
}
ui_call_flush();
- if (p_wd && (rdb_flags & RDB_FLUSH)) {
+ if (p_wd && (rdb_flags & kOptRdbFlagFlush)) {
os_sleep((uint64_t)llabs(p_wd));
}
}
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index e28e8d4da7..4cddc3dc82 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -425,7 +425,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag
for (int i = skipstart; i < (endcol - skipend) - startcol; i++) {
if (attrbuf[i] < 0) {
- if (rdb_flags & RDB_INVALID) {
+ if (rdb_flags & kOptRdbFlagInvalid) {
abort();
} else {
attrbuf[i] = 0;
@@ -441,7 +441,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag
static void compose_debug(Integer startrow, Integer endrow, Integer startcol, Integer endcol,
int syn_id, bool delay)
{
- if (!(rdb_flags & RDB_COMPOSITOR) || startcol >= endcol) {
+ if (!(rdb_flags & kOptRdbFlagCompositor) || startcol >= endcol) {
return;
}
@@ -637,7 +637,7 @@ void ui_comp_grid_scroll(Integer grid, Integer top, Integer bot, Integer left, I
}
} else {
ui_composed_call_grid_scroll(1, top, bot, left, right, rows, cols);
- if (rdb_flags & RDB_COMPOSITOR) {
+ if (rdb_flags & kOptRdbFlagCompositor) {
debug_delay(2);
}
}
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 0f8857a6bd..233e323f37 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -2528,7 +2528,7 @@ static void u_undoredo(bool undo, bool do_buf_event)
/// @param absolute used ":undo N"
static void u_undo_end(bool did_undo, bool absolute, bool quiet)
{
- if ((fdo_flags & FDO_UNDO) && KeyTyped) {
+ if ((fdo_flags & kOptFdoFlagUndo) && KeyTyped) {
foldOpenCursor();
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index c3f3e075f1..ac4c5a8e4a 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -186,13 +186,13 @@ win_T *swbuf_goto_win_with_buf(buf_T *buf)
// If 'switchbuf' contains "useopen": jump to first window in the current
// tab page containing "buf" if one exists.
- if (swb_flags & SWB_USEOPEN) {
+ if (swb_flags & kOptSwbFlagUseopen) {
wp = buf_jump_open_win(buf);
}
// If 'switchbuf' contains "usetab": jump to first window in any tab page
// containing "buf" if one exists.
- if (wp == NULL && (swb_flags & SWB_USETAB)) {
+ if (wp == NULL && (swb_flags & kOptSwbFlagUsetab)) {
wp = buf_jump_open_tab(buf);
}
@@ -583,7 +583,7 @@ wingotofile:
// If 'switchbuf' is set to 'useopen' or 'usetab' and the
// file is already opened in a window, then jump to it.
win_T *wp = NULL;
- if ((swb_flags & (SWB_USEOPEN | SWB_USETAB))
+ if ((swb_flags & (kOptSwbFlagUseopen | kOptSwbFlagUsetab))
&& cmdmod.cmod_tab == 0) {
wp = swbuf_goto_win_with_buf(buflist_findname_exp(ptr));
}
@@ -3448,13 +3448,13 @@ static frame_T *win_altframe(win_T *win, tabpage_T *tp)
static tabpage_T *alt_tabpage(void)
{
// Use the last accessed tab page, if possible.
- if ((tcl_flags & TCL_USELAST) && valid_tabpage(lastused_tabpage)) {
+ if ((tcl_flags & kOptTclFlagUselast) && valid_tabpage(lastused_tabpage)) {
return lastused_tabpage;
}
// Use the next tab page, if possible.
bool forward = curtab->tp_next != NULL
- && ((tcl_flags & TCL_LEFT) == 0 || curtab == first_tabpage);
+ && ((tcl_flags & kOptTclFlagLeft) == 0 || curtab == first_tabpage);
tabpage_T *tp;
if (forward) {