From 8516c2dc1f301c439695629fff771227dbe00d30 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Sat, 23 Nov 2024 14:22:06 +0600 Subject: 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 --- src/nvim/tag.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/tag.c') 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(); } } -- cgit From 2a7d0ed6145bf3f8b139c2694563f460f829813a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Dec 2024 05:43:52 -0800 Subject: refactor: iwyu #31637 Result of `make iwyu` (after some "fixups"). --- src/nvim/tag.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 5844d8d3f2..cdce97fc01 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -34,7 +34,6 @@ #include "nvim/hashtab.h" #include "nvim/hashtab_defs.h" #include "nvim/help.h" -#include "nvim/highlight.h" #include "nvim/highlight_defs.h" #include "nvim/input.h" #include "nvim/insexpand.h" -- cgit From 6257270040bc5c61a489f7fb9d4102223c36cf89 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Fri, 8 Nov 2024 11:57:59 +0600 Subject: refactor(options): set option value for non-current context directly Problem: Currently, we use `switch_option_context` to temporarily switch the current option context before setting an option for a different buffer / window. This is not ideal because we already support getting and setting option values for non-current contexts in the underlying implementation. Solution: Set option value for non-current context by passing the context directly to the lower level functions. Also introduce a new `OptCtx` struct to store option context information, this will scale much better if we add more option scopes and other context information in the future. --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index cdce97fc01..dda77f8e1e 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -228,7 +228,7 @@ static Callback tfu_cb; // 'tagfunc' callback function /// a function (string), or function() or funcref() or a lambda. const char *did_set_tagfunc(optset_T *args) { - buf_T *buf = (buf_T *)args->os_buf; + buf_T *buf = args->os_ctx.buf; callback_free(&tfu_cb); callback_free(&buf->b_tfu_cb); -- cgit From 48e2a73610ca5639408f79b3d8eebd3e5f57a327 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Thu, 2 Jan 2025 14:51:03 +0100 Subject: feat(ui)!: emit prompt "messages" as cmdline events #31525 Problem: Prompts are emitted as messages events, where cmdline events are more appropriate. The user input is also emitted as message events in fast context, so cannot be displayed with vim.ui_attach(). Solution: Prompt for user input through cmdline prompts. --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index cdce97fc01..c676b00986 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -668,7 +668,7 @@ void do_tag(char *tag, int type, int count, int forceit, bool verbose) if (ask_for_selection) { // Ask to select a tag from the list. - int i = prompt_for_number(NULL); + int i = prompt_for_input(NULL, 0, false, NULL); if (i <= 0 || i > num_matches || got_int) { // no valid choice: don't change anything if (use_tagstack) { -- cgit From 19c9572d3626cde8503ee9061fa334b73f257b03 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Jan 2025 12:32:25 +0800 Subject: Revert "refactor(options): set option value for non-current context directly" (#31924) Reverts #31112 --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 9375629abc..c676b00986 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -228,7 +228,7 @@ static Callback tfu_cb; // 'tagfunc' callback function /// a function (string), or function() or funcref() or a lambda. const char *did_set_tagfunc(optset_T *args) { - buf_T *buf = args->os_ctx.buf; + buf_T *buf = (buf_T *)args->os_buf; callback_free(&tfu_cb); callback_free(&buf->b_tfu_cb); -- cgit