2019-09-16 21:06:21 +02:00
|
|
|
/* vi:set ts=8 sts=4 sw=4 noet:
|
|
|
|
*
|
|
|
|
* VIM - Vi IMproved by Bram Moolenaar
|
|
|
|
*
|
|
|
|
* Do ":help uganda" in Vim to read copying and usage conditions.
|
|
|
|
* Do ":help credits" in Vim to see a list of people who contributed.
|
|
|
|
* See README.txt for an overview of the Vim source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* optionstr.c: Functions related to string options
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "vim.h"
|
|
|
|
|
2022-12-16 16:41:23 +00:00
|
|
|
static char_u shm_buf[SHM_LEN];
|
|
|
|
static int set_shm_recursive = 0;
|
|
|
|
|
2019-09-16 21:06:21 +02:00
|
|
|
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",
|
2022-04-13 11:47:25 +01:00
|
|
|
"spell", "term", "wildmode", NULL};
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
#if defined(FEAT_LINEBREAK)
|
|
|
|
// Note: Keep this in sync with briopt_check()
|
|
|
|
static char *(p_briopt_values[]) = {"shift:", "min:", "sbr", "list:", "column:", NULL};
|
|
|
|
#endif
|
|
|
|
#if defined(FEAT_DIFF)
|
|
|
|
// Note: Keep this in sync with diffopt_changed()
|
2025-01-16 19:03:40 +01:00
|
|
|
static char *(p_dip_values[]) = {"filler", "context:", "iblank", "icase", "iwhite", "iwhiteall", "iwhiteeol", "horizontal", "vertical", "closeoff", "hiddenoff", "foldcolumn:", "followwrap", "internal", "indent-heuristic", "algorithm:", "linematch:", NULL};
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
static char *(p_dip_algorithm_values[]) = {"myers", "minimal", "patience", "histogram", NULL};
|
|
|
|
#endif
|
2024-07-06 17:50:09 +02:00
|
|
|
static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", "unsigned", "blank", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
#ifdef FEAT_CLIPBOARD
|
|
|
|
// Note: Keep this in sync with did_set_clipboard()
|
|
|
|
static char *(p_cb_values[]) = {"unnamed", "unnamedplus", "autoselect", "autoselectplus", "autoselectml", "html", "exclude:", NULL};
|
|
|
|
#endif
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_CRYPT
|
2021-06-20 14:02:16 +02:00
|
|
|
static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2",
|
|
|
|
# ifdef FEAT_SODIUM
|
2023-04-23 17:50:22 +01:00
|
|
|
"xchacha20", "xchacha20v2",
|
2021-06-20 14:02:16 +02:00
|
|
|
# endif
|
|
|
|
NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
|
|
|
static char *(p_cmp_values[]) = {"internal", "keepascii", NULL};
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
#ifdef FEAT_SYN_HL
|
|
|
|
// Note: Keep this in sync with fill_culopt_flags()
|
|
|
|
static char *(p_culopt_values[]) = {"line", "screenline", "number", "both", NULL};
|
|
|
|
#endif
|
2019-09-16 21:06:21 +02:00
|
|
|
static char *(p_dy_values[]) = {"lastline", "truncate", "uhex", NULL};
|
2023-09-20 20:20:04 +02:00
|
|
|
static char *(p_jop_values[]) = {"stack", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_FOLDING
|
|
|
|
static char *(p_fdo_values[]) = {"all", "block", "hor", "mark", "percent",
|
|
|
|
"quickfix", "search", "tag", "insert",
|
|
|
|
"undo", "jump", NULL};
|
|
|
|
#endif
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
// Note: Keep this in sync with match_keyprotocol()
|
|
|
|
static char *(p_kpc_protocol_values[]) = {"none", "mok2", "kitty", NULL};
|
|
|
|
#ifdef FEAT_PROP_POPUP
|
|
|
|
// Note: Keep this in sync with parse_popup_option()
|
|
|
|
static char *(p_popup_option_values[]) = {"height:", "width:", "highlight:", "border:", "align:", NULL};
|
|
|
|
static char *(p_popup_option_border_values[]) = {"on", "off", NULL};
|
|
|
|
static char *(p_popup_option_align_values[]) = {"item", "menu", NULL};
|
|
|
|
#endif
|
|
|
|
#if defined(FEAT_SPELL)
|
|
|
|
// Note: Keep this in sync with spell_check_sps()
|
|
|
|
static char *(p_sps_values[]) = {"best", "fast", "double", "expr:", "file:", "timeout:", NULL};
|
|
|
|
#endif
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_SESSION
|
2021-04-16 19:58:22 +02:00
|
|
|
// Also used for 'viewoptions'! Keep in sync with SSOP_ flags.
|
2019-09-16 21:06:21 +02:00
|
|
|
static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize",
|
|
|
|
"localoptions", "options", "help", "blank", "globals", "slash", "unix",
|
2021-04-16 19:58:22 +02:00
|
|
|
"sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", "skiprtp",
|
|
|
|
NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
2019-11-17 18:09:38 +01:00
|
|
|
// Keep in sync with SWB_ flags in option.h
|
|
|
|
static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", "vsplit", "uselast", NULL};
|
2022-10-03 15:28:08 +01:00
|
|
|
static char *(p_spk_values[]) = {"cursor", "screen", "topline", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
static char *(p_tc_values[]) = {"followic", "ignore", "match", "followscs", "smart", NULL};
|
2024-07-12 19:30:58 +02:00
|
|
|
// Keep in sync with TCL_ flags in option.h
|
|
|
|
static char *(p_tcl_values[]) = {"left", "uselast", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
|
|
|
|
static char *(p_toolbar_values[]) = {"text", "icons", "tooltips", "horiz", NULL};
|
|
|
|
#endif
|
|
|
|
#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
|
|
|
|
static char *(p_tbis_values[]) = {"tiny", "small", "medium", "large", "huge", "giant", NULL};
|
|
|
|
#endif
|
2019-10-17 23:00:07 +02:00
|
|
|
#if defined(UNIX) || defined(VMS)
|
2019-09-16 21:06:21 +02:00
|
|
|
static char *(p_ttym_values[]) = {"xterm", "xterm2", "dec", "netterm", "jsbterm", "pterm", "urxvt", "sgr", NULL};
|
|
|
|
#endif
|
2021-07-26 22:19:10 +02:00
|
|
|
static char *(p_ve_values[]) = {"block", "insert", "all", "onemore", "none", "NONE", NULL};
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
// Note: Keep this in sync with check_opt_wim()
|
patch 9.1.1166: command-line auto-completion hard with wildmenu
Problem: command-line auto-completion hard with wildmenu
Solution: implement "noselect" wildoption value (Girish Palya)
When `noselect` is present in `wildmode` and 'wildmenu' is enabled, the
completion menu appears without pre-selecting the first item.
This change makes it easier to implement command-line auto-completion,
where the menu dynamically appears as characters are typed, and `<Tab>`
can be used to manually select an item. This can be achieved by
leveraging the `CmdlineChanged` event to insert `wildchar(m)`,
triggering completion menu.
Without this change, auto-completion using the 'wildmenu' mechanism is
not feasible, as it automatically inserts the first match, preventing
dynamic selection.
The following Vimscript snippet demonstrates how to configure
auto-completion using `noselect`:
```vim
vim9script
set wim=noselect:lastused,full wop=pum wcm=<C-@> wmnu
autocmd CmdlineChanged : timer_start(0, function(CmdComplete, [getcmdline()]))
def CmdComplete(cur_cmdline: string, timer: number)
var [cmdline, curpos] = [getcmdline(), getcmdpos()]
if cur_cmdline ==# cmdline # Avoid completing each character in keymaps and pasted text
&& !pumvisible() && curpos == cmdline->len() + 1
if cmdline[curpos - 2] =~ '[\w*/:]' # Reduce noise by completing only selected characters
feedkeys("\<C-@>", "ti")
set eventignore+=CmdlineChanged # Suppress redundant completion attempts
timer_start(0, (_) => {
getcmdline()->substitute('\%x00$', '', '')->setcmdline() # Remove <C-@> if no completion items exist
set eventignore-=CmdlineChanged
})
endif
endif
enddef
```
fixes: #16551
closes: #16759
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-03-02 22:55:57 +01:00
|
|
|
static char *(p_wim_values[]) = {"full", "longest", "list", "lastused", "noselect", NULL};
|
2022-02-24 13:28:41 +00:00
|
|
|
static char *(p_wop_values[]) = {"fuzzy", "tagfile", "pum", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_WAK
|
|
|
|
static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
|
|
|
|
#endif
|
|
|
|
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};
|
|
|
|
#ifdef FEAT_BROWSE
|
|
|
|
static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
|
|
|
|
#endif
|
|
|
|
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", "terminal", "acwrite", "prompt", "popup", NULL};
|
|
|
|
static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
|
2020-04-17 19:41:21 +02:00
|
|
|
static char *(p_bs_values[]) = {"indent", "eol", "start", "nostop", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_FOLDING
|
|
|
|
static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
|
|
|
|
# ifdef FEAT_DIFF
|
|
|
|
"diff",
|
|
|
|
# endif
|
|
|
|
NULL};
|
|
|
|
static char *(p_fcl_values[]) = {"all", NULL};
|
|
|
|
#endif
|
2025-03-06 21:59:13 +01:00
|
|
|
static char *(p_cfc_values[]) = {"keyword", "files", "whole_line", NULL};
|
2025-01-29 18:53:51 +01:00
|
|
|
static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "popup", "popuphidden", "noinsert", "noselect", "fuzzy", "nosort", "preinsert", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef BACKSLASH_IN_FILENAME
|
|
|
|
static char *(p_csl_values[]) = {"slash", "backslash", NULL};
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_SIGNS
|
|
|
|
static char *(p_scl_values[]) = {"yes", "no", "auto", "number", NULL};
|
|
|
|
#endif
|
|
|
|
#if defined(MSWIN) && defined(FEAT_TERMINAL)
|
|
|
|
static char *(p_twt_values[]) = {"winpty", "conpty", "", NULL};
|
|
|
|
#endif
|
2022-12-15 13:15:39 +00:00
|
|
|
static char *(p_sloc_values[]) = {"last", "statusline", "tabline", NULL};
|
2023-02-27 12:47:47 +00:00
|
|
|
static char *(p_sws_values[]) = {"fsync", "sync", NULL};
|
2019-09-16 21:06:21 +02:00
|
|
|
|
|
|
|
static int check_opt_strings(char_u *val, char **values, int list);
|
|
|
|
static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* After setting various option values: recompute variables that depend on
|
|
|
|
* option values.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
didset_string_options(void)
|
|
|
|
{
|
|
|
|
(void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
|
|
|
|
(void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
|
|
|
|
(void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
|
2025-03-06 21:59:13 +01:00
|
|
|
(void)opt_strings_flags(p_cfc, p_cfc_values, &cfc_flags, TRUE);
|
2024-06-05 20:27:06 +02:00
|
|
|
(void)opt_strings_flags(p_cot, p_cot_values, &cot_flags, TRUE);
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_SESSION
|
|
|
|
(void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
|
|
|
|
(void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_FOLDING
|
|
|
|
(void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
|
|
|
|
#endif
|
|
|
|
(void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
|
2023-09-20 20:20:04 +02:00
|
|
|
(void)opt_strings_flags(p_jop, p_jop_values, &jop_flags, TRUE);
|
2019-09-16 21:06:21 +02:00
|
|
|
(void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
|
|
|
|
(void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
|
2019-10-17 23:00:07 +02:00
|
|
|
#if defined(UNIX) || defined(VMS)
|
2019-09-16 21:06:21 +02:00
|
|
|
(void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
|
|
|
|
#endif
|
|
|
|
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
|
|
|
|
(void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
|
|
|
|
#endif
|
|
|
|
#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
|
|
|
|
(void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
|
|
|
|
#endif
|
2022-05-12 17:44:29 +01:00
|
|
|
(void)opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE);
|
2024-07-12 19:30:58 +02:00
|
|
|
(void)opt_strings_flags(p_tcl, p_tcl_values, &tcl_flags, TRUE);
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
|
|
|
|
2023-05-11 15:02:56 +01:00
|
|
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
2019-09-16 21:06:21 +02:00
|
|
|
/*
|
|
|
|
* Trigger the OptionSet autocommand.
|
|
|
|
* "opt_idx" is the index of the option being set.
|
|
|
|
* "opt_flags" can be OPT_LOCAL etc.
|
|
|
|
* "oldval" the old value
|
|
|
|
* "oldval_l" the old local value (only non-NULL if global and local value
|
|
|
|
* are set)
|
|
|
|
* "oldval_g" the old global value (only non-NULL if global and local value
|
|
|
|
* are set)
|
|
|
|
* "newval" the new value
|
|
|
|
*/
|
|
|
|
void
|
2022-11-28 11:36:50 +00:00
|
|
|
trigger_optionset_string(
|
2019-09-16 21:06:21 +02:00
|
|
|
int opt_idx,
|
|
|
|
int opt_flags,
|
|
|
|
char_u *oldval,
|
|
|
|
char_u *oldval_l,
|
|
|
|
char_u *oldval_g,
|
|
|
|
char_u *newval)
|
|
|
|
{
|
|
|
|
// Don't do this recursively.
|
2023-01-16 18:19:05 +00:00
|
|
|
if (oldval == NULL || newval == NULL
|
|
|
|
|| *get_vim_var_str(VV_OPTION_TYPE) != NUL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char_u buf_type[7];
|
2019-09-16 21:06:21 +02:00
|
|
|
|
2023-01-16 18:19:05 +00:00
|
|
|
sprintf((char *)buf_type, "%s",
|
2019-09-16 21:06:21 +02:00
|
|
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
2023-01-16 18:19:05 +00:00
|
|
|
set_vim_var_string(VV_OPTION_OLD, oldval, -1);
|
|
|
|
set_vim_var_string(VV_OPTION_NEW, newval, -1);
|
|
|
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
|
|
|
if (opt_flags & OPT_LOCAL)
|
|
|
|
{
|
|
|
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
|
|
|
|
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
|
|
|
|
}
|
|
|
|
if (opt_flags & OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
|
|
|
|
set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
|
|
|
|
}
|
|
|
|
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
|
|
{
|
|
|
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
|
|
|
|
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
|
|
|
|
set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
2023-01-16 18:19:05 +00:00
|
|
|
if (opt_flags & OPT_MODELINE)
|
|
|
|
{
|
|
|
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
|
|
|
|
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
|
|
|
|
}
|
|
|
|
apply_autocmds(EVENT_OPTIONSET,
|
|
|
|
get_option_fullname(opt_idx), NULL, FALSE,
|
|
|
|
NULL);
|
|
|
|
reset_v_option_vars();
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static char *
|
2023-12-05 15:36:06 +01:00
|
|
|
illegal_char(char *errbuf, size_t errbuflen, int c)
|
2019-09-16 21:06:21 +02:00
|
|
|
{
|
|
|
|
if (errbuf == NULL)
|
|
|
|
return "";
|
2024-01-17 20:54:49 +01:00
|
|
|
vim_snprintf(errbuf, errbuflen, _(e_illegal_character_str),
|
2023-11-29 11:34:05 +01:00
|
|
|
(char *)transchar(c));
|
2019-09-16 21:06:21 +02:00
|
|
|
return errbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check string options in a buffer for NULL value.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
check_buf_options(buf_T *buf)
|
|
|
|
{
|
|
|
|
check_string_option(&buf->b_p_bh);
|
|
|
|
check_string_option(&buf->b_p_bt);
|
|
|
|
check_string_option(&buf->b_p_fenc);
|
|
|
|
check_string_option(&buf->b_p_ff);
|
|
|
|
#ifdef FEAT_FIND_ID
|
|
|
|
check_string_option(&buf->b_p_def);
|
|
|
|
check_string_option(&buf->b_p_inc);
|
|
|
|
# ifdef FEAT_EVAL
|
|
|
|
check_string_option(&buf->b_p_inex);
|
|
|
|
# endif
|
|
|
|
#endif
|
2022-05-21 20:17:31 +01:00
|
|
|
#if defined(FEAT_EVAL)
|
2019-09-16 21:06:21 +02:00
|
|
|
check_string_option(&buf->b_p_inde);
|
|
|
|
check_string_option(&buf->b_p_indk);
|
|
|
|
#endif
|
|
|
|
#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
|
|
|
|
check_string_option(&buf->b_p_bexpr);
|
|
|
|
#endif
|
|
|
|
#if defined(FEAT_CRYPT)
|
|
|
|
check_string_option(&buf->b_p_cm);
|
|
|
|
#endif
|
|
|
|
check_string_option(&buf->b_p_fp);
|
|
|
|
#if defined(FEAT_EVAL)
|
|
|
|
check_string_option(&buf->b_p_fex);
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_CRYPT
|
|
|
|
check_string_option(&buf->b_p_key);
|
|
|
|
#endif
|
|
|
|
check_string_option(&buf->b_p_kp);
|
|
|
|
check_string_option(&buf->b_p_mps);
|
|
|
|
check_string_option(&buf->b_p_fo);
|
|
|
|
check_string_option(&buf->b_p_flp);
|
|
|
|
check_string_option(&buf->b_p_isk);
|
|
|
|
check_string_option(&buf->b_p_com);
|
|
|
|
#ifdef FEAT_FOLDING
|
|
|
|
check_string_option(&buf->b_p_cms);
|
|
|
|
#endif
|
|
|
|
check_string_option(&buf->b_p_nf);
|
|
|
|
check_string_option(&buf->b_p_qe);
|
|
|
|
#ifdef FEAT_SYN_HL
|
|
|
|
check_string_option(&buf->b_p_syn);
|
|
|
|
check_string_option(&buf->b_s.b_syn_isk);
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_SPELL
|
|
|
|
check_string_option(&buf->b_s.b_p_spc);
|
|
|
|
check_string_option(&buf->b_s.b_p_spf);
|
|
|
|
check_string_option(&buf->b_s.b_p_spl);
|
2020-06-10 21:47:00 +02:00
|
|
|
check_string_option(&buf->b_s.b_p_spo);
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
|
|
|
check_string_option(&buf->b_p_sua);
|
|
|
|
check_string_option(&buf->b_p_cink);
|
|
|
|
check_string_option(&buf->b_p_cino);
|
2022-04-07 12:39:08 +01:00
|
|
|
check_string_option(&buf->b_p_cinsd);
|
2019-09-16 21:06:21 +02:00
|
|
|
parse_cino(buf);
|
2022-10-15 16:05:33 +01:00
|
|
|
check_string_option(&buf->b_p_lop);
|
2019-09-16 21:06:21 +02:00
|
|
|
check_string_option(&buf->b_p_ft);
|
|
|
|
check_string_option(&buf->b_p_cinw);
|
2024-06-05 20:27:06 +02:00
|
|
|
check_string_option(&buf->b_p_cot);
|
2019-09-16 21:06:21 +02:00
|
|
|
check_string_option(&buf->b_p_cpt);
|
|
|
|
#ifdef FEAT_COMPL_FUNC
|
|
|
|
check_string_option(&buf->b_p_cfu);
|
|
|
|
check_string_option(&buf->b_p_ofu);
|
2021-10-16 21:14:11 +01:00
|
|
|
check_string_option(&buf->b_p_tsrfu);
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FEAT_EVAL
|
2024-11-02 18:40:10 +01:00
|
|
|
check_string_option(&buf->b_p_ffu);
|
2019-09-16 21:06:21 +02:00
|
|
|
check_string_option(&buf->b_p_tfu);
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_KEYMAP
|
|
|
|
check_string_option(&buf->b_p_keymap);
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_QUICKFIX
|
|
|
|
check_string_option(&buf->b_p_gp);
|
|
|
|
check_string_option(&buf->b_p_mp);
|
|
|
|
check_string_option(&buf->b_p_efm);
|
|
|
|
#endif
|
|
|
|
check_string_option(&buf->b_p_ep);
|
|
|
|
check_string_option(&buf->b_p_path);
|
|
|
|
check_string_option(&buf->b_p_tags);
|
|
|
|
check_string_option(&buf->b_p_tc);
|
|
|
|
check_string_option(&buf->b_p_dict);
|
|
|
|
check_string_option(&buf->b_p_tsr);
|
|
|
|
check_string_option(&buf->b_p_lw);
|
|
|
|
check_string_option(&buf->b_p_bkc);
|
|
|
|
check_string_option(&buf->b_p_menc);
|
|
|
|
#ifdef FEAT_VARTABS
|
|
|
|
check_string_option(&buf->b_p_vsts);
|
|
|
|
check_string_option(&buf->b_p_vts);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the string allocated for an option.
|
|
|
|
* Checks for the string being empty_option. This may happen if we're out of
|
|
|
|
* memory, vim_strsave() returned NULL, which was replaced by empty_option by
|
|
|
|
* check_options().
|
|
|
|
* Does NOT check for P_ALLOCED flag!
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
free_string_option(char_u *p)
|
|
|
|
{
|
|
|
|
if (p != empty_option)
|
|
|
|
vim_free(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
clear_string_option(char_u **pp)
|
|
|
|
{
|
|
|
|
if (*pp != empty_option)
|
|
|
|
vim_free(*pp);
|
|
|
|
*pp = empty_option;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
check_string_option(char_u **pp)
|
|
|
|
{
|
|
|
|
if (*pp == NULL)
|
|
|
|
*pp = empty_option;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set global value for string option when it's a local option.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
set_string_option_global(
|
|
|
|
int opt_idx, // option index
|
|
|
|
char_u **varp) // pointer to option variable
|
|
|
|
{
|
|
|
|
char_u **p, *s;
|
|
|
|
|
|
|
|
// the global value is always allocated
|
|
|
|
if (is_window_local_option(opt_idx))
|
|
|
|
p = (char_u **)GLOBAL_WO(varp);
|
|
|
|
else
|
|
|
|
p = (char_u **)get_option_var(opt_idx);
|
|
|
|
if (!is_global_option(opt_idx)
|
|
|
|
&& p != varp
|
|
|
|
&& (s = vim_strsave(*varp)) != NULL)
|
|
|
|
{
|
|
|
|
free_string_option(*p);
|
|
|
|
*p = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a string option to a new value (without checking the effect).
|
|
|
|
* The string is copied into allocated memory.
|
|
|
|
* if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
|
|
|
|
* When "set_sid" is zero set the scriptID to current_sctx.sc_sid. When
|
|
|
|
* "set_sid" is SID_NONE don't set the scriptID. Otherwise set the scriptID to
|
|
|
|
* "set_sid".
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
set_string_option_direct(
|
|
|
|
char_u *name,
|
|
|
|
int opt_idx,
|
|
|
|
char_u *val,
|
|
|
|
int opt_flags, // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
|
|
|
|
int set_sid UNUSED)
|
|
|
|
{
|
|
|
|
char_u *s;
|
|
|
|
char_u **varp;
|
|
|
|
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
|
|
|
|
int idx = opt_idx;
|
|
|
|
|
|
|
|
if (idx == -1) // use name
|
|
|
|
{
|
|
|
|
idx = findoption(name);
|
|
|
|
if (idx < 0) // not found (should not happen)
|
|
|
|
{
|
2022-01-01 14:19:49 +00:00
|
|
|
semsg(_(e_internal_error_str), "set_string_option_direct()");
|
2023-05-31 17:12:14 +01:00
|
|
|
siemsg("For option %s", name);
|
2019-09-16 21:06:21 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_hidden_option(idx)) // can't set hidden option
|
|
|
|
return;
|
|
|
|
|
|
|
|
s = vim_strsave(val);
|
2023-01-16 18:19:05 +00:00
|
|
|
if (s == NULL)
|
|
|
|
return;
|
2019-09-16 21:06:21 +02:00
|
|
|
|
2023-01-16 18:19:05 +00:00
|
|
|
varp = (char_u **)get_option_varp_scope(idx,
|
|
|
|
both ? OPT_LOCAL : opt_flags);
|
|
|
|
if ((opt_flags & OPT_FREE) && (get_option_flags(idx) & P_ALLOCED))
|
|
|
|
free_string_option(*varp);
|
|
|
|
*varp = s;
|
2019-09-16 21:06:21 +02:00
|
|
|
|
2023-01-16 18:19:05 +00:00
|
|
|
// For buffer/window local option may also set the global value.
|
|
|
|
if (both)
|
|
|
|
set_string_option_global(idx, varp);
|
2019-09-16 21:06:21 +02:00
|
|
|
|
2023-01-16 18:19:05 +00:00
|
|
|
set_option_flag(idx, P_ALLOCED);
|
|
|
|
|
|
|
|
// When setting both values of a global option with a local value,
|
|
|
|
// make the local value empty, so that the global value is used.
|
|
|
|
if (is_global_local_option(idx) && both)
|
|
|
|
{
|
|
|
|
free_string_option(*varp);
|
|
|
|
*varp = empty_option;
|
|
|
|
}
|
2019-09-16 21:06:21 +02:00
|
|
|
# ifdef FEAT_EVAL
|
2023-01-16 18:19:05 +00:00
|
|
|
if (set_sid != SID_NONE)
|
|
|
|
{
|
|
|
|
sctx_T script_ctx;
|
|
|
|
|
|
|
|
if (set_sid == 0)
|
|
|
|
script_ctx = current_sctx;
|
|
|
|
else
|
2019-09-16 21:06:21 +02:00
|
|
|
{
|
2023-01-16 18:19:05 +00:00
|
|
|
script_ctx.sc_sid = set_sid;
|
|
|
|
script_ctx.sc_seq = 0;
|
|
|
|
script_ctx.sc_lnum = 0;
|
|
|
|
script_ctx.sc_version = 1;
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
2023-01-16 18:19:05 +00:00
|
|
|
set_option_sctx_idx(idx, opt_flags, script_ctx);
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
2023-01-16 18:19:05 +00:00
|
|
|
# endif
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 21:20:59 +00:00
|
|
|
#if defined(FEAT_PROP_POPUP) || \
|
|
|
|
(defined(FEAT_DIFF) && defined(FEAT_FOLDING)) || defined(PROTO)
|
2019-09-16 21:06:21 +02:00
|
|
|
/*
|
|
|
|
* Like set_string_option_direct(), but for a window-local option in "wp".
|
|
|
|
* Blocks autocommands to avoid the old curwin becoming invalid.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
set_string_option_direct_in_win(
|
|
|
|
win_T *wp,
|
|
|
|
char_u *name,
|
|
|
|
int opt_idx,
|
|
|
|
char_u *val,
|
|
|
|
int opt_flags,
|
|
|
|
int set_sid)
|
|
|
|
{
|
|
|
|
win_T *save_curwin = curwin;
|
|
|
|
|
|
|
|
block_autocmds();
|
|
|
|
curwin = wp;
|
|
|
|
curbuf = curwin->w_buffer;
|
|
|
|
set_string_option_direct(name, opt_idx, val, opt_flags, set_sid);
|
|
|
|
curwin = save_curwin;
|
|
|
|
curbuf = curwin->w_buffer;
|
|
|
|
unblock_autocmds();
|
|
|
|
}
|
2023-03-12 21:20:59 +00:00
|
|
|
#endif
|
2019-09-16 21:06:21 +02:00
|
|
|
|
2022-01-08 12:41:16 +00:00
|
|
|
#if defined(FEAT_PROP_POPUP) || defined(PROTO)
|
2019-09-16 21:06:21 +02:00
|
|
|
/*
|
|
|
|
* Like set_string_option_direct(), but for a buffer-local option in "buf".
|
|
|
|
* Blocks autocommands to avoid the old curbuf becoming invalid.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
set_string_option_direct_in_buf(
|
|
|
|
buf_T *buf,
|
|
|
|
char_u *name,
|
|
|
|
int opt_idx,
|
|
|
|
char_u *val,
|
|
|
|
int opt_flags,
|
|
|
|
int set_sid)
|
|
|
|
{
|
|
|
|
buf_T *save_curbuf = curbuf;
|
|
|
|
|
|
|
|
block_autocmds();
|
|
|
|
curbuf = buf;
|
|
|
|
curwin->w_buffer = curbuf;
|
|
|
|
set_string_option_direct(name, opt_idx, val, opt_flags, set_sid);
|
|
|
|
curbuf = save_curbuf;
|
|
|
|
curwin->w_buffer = curbuf;
|
|
|
|
unblock_autocmds();
|
|
|
|
}
|
2022-01-08 12:41:16 +00:00
|
|
|
#endif
|
2019-09-16 21:06:21 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a string option to a new value, and handle the effects.
|
|
|
|
*
|
2022-04-15 13:53:33 +01:00
|
|
|
* Returns NULL on success or an untranslated error message on error.
|
2019-09-16 21:06:21 +02:00
|
|
|
*/
|
|
|
|
char *
|
|
|
|
set_string_option(
|
|
|
|
int opt_idx,
|
|
|
|
char_u *value,
|
2023-02-13 16:10:04 +00:00
|
|
|
int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL
|
2023-11-29 11:34:05 +01:00
|
|
|
char *errbuf,
|
2023-12-05 15:36:06 +01:00
|
|
|
size_t errbuflen)
|
2019-09-16 21:06:21 +02:00
|
|
|
{
|
|
|
|
char_u *s;
|
|
|
|
char_u **varp;
|
|
|
|
char_u *oldval;
|
|
|
|
#if defined(FEAT_EVAL)
|
|
|
|
char_u *oldval_l = NULL;
|
|
|
|
char_u *oldval_g = NULL;
|
|
|
|
char_u *saved_oldval = NULL;
|
|
|
|
char_u *saved_oldval_l = NULL;
|
|
|
|
char_u *saved_oldval_g = NULL;
|
|
|
|
char_u *saved_newval = NULL;
|
|
|
|
#endif
|
2022-04-15 13:53:33 +01:00
|
|
|
char *errmsg = NULL;
|
2019-09-16 21:06:21 +02:00
|
|
|
int value_checked = FALSE;
|
|
|
|
|
|
|
|
if (is_hidden_option(opt_idx)) // don't set hidden option
|
|
|
|
return NULL;
|
|
|
|
|
2020-03-16 20:27:38 +01:00
|
|
|
s = vim_strsave(value == NULL ? (char_u *)"" : value);
|
2023-01-16 18:19:05 +00:00
|
|
|
if (s == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
varp = (char_u **)get_option_varp_scope(opt_idx,
|
|
|
|
(opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
|
|
? (is_global_local_option(opt_idx)
|
|
|
|
? OPT_GLOBAL : OPT_LOCAL)
|
|
|
|
: opt_flags);
|
|
|
|
oldval = *varp;
|
2019-09-16 21:06:21 +02:00
|
|
|
#if defined(FEAT_EVAL)
|
2023-01-16 18:19:05 +00:00
|
|
|
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
|
|
{
|
|
|
|
oldval_l = *(char_u **)get_option_varp_scope(opt_idx, OPT_LOCAL);
|
|
|
|
oldval_g = *(char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
|
|
|
|
}
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
2023-01-16 18:19:05 +00:00
|
|
|
*varp = s;
|
2019-09-16 21:06:21 +02:00
|
|
|
|
|
|
|
#if defined(FEAT_EVAL)
|
2023-01-16 18:19:05 +00:00
|
|
|
if (!starting
|
2019-09-16 21:06:21 +02:00
|
|
|
# ifdef FEAT_CRYPT
|
2023-01-16 18:19:05 +00:00
|
|
|
&& !is_crypt_key_option(opt_idx)
|
2019-09-16 21:06:21 +02:00
|
|
|
# endif
|
2023-01-16 18:19:05 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if (oldval_l != NULL)
|
|
|
|
saved_oldval_l = vim_strsave(oldval_l);
|
|
|
|
if (oldval_g != NULL)
|
|
|
|
saved_oldval_g = vim_strsave(oldval_g);
|
|
|
|
saved_oldval = vim_strsave(oldval);
|
|
|
|
saved_newval = vim_strsave(s);
|
|
|
|
}
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
2023-02-20 12:16:39 +00:00
|
|
|
if ((errmsg = did_set_string_option(opt_idx, varp, oldval, value, errbuf,
|
2023-11-29 11:34:05 +01:00
|
|
|
errbuflen, opt_flags, OP_NONE, &value_checked)) == NULL)
|
2023-01-16 18:19:05 +00:00
|
|
|
did_set_option(opt_idx, opt_flags, TRUE, value_checked);
|
2019-09-16 21:06:21 +02:00
|
|
|
|
|
|
|
#if defined(FEAT_EVAL)
|
2023-01-16 18:19:05 +00:00
|
|
|
// call autocommand after handling side effects
|
|
|
|
if (errmsg == NULL)
|
|
|
|
trigger_optionset_string(opt_idx, opt_flags,
|
|
|
|
saved_oldval, saved_oldval_l,
|
|
|
|
saved_oldval_g, saved_newval);
|
|
|
|
vim_free(saved_oldval);
|
|
|
|
vim_free(saved_oldval_l);
|
|
|
|
vim_free(saved_oldval_g);
|
|
|
|
vim_free(saved_newval);
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
2022-04-15 13:53:33 +01:00
|
|
|
return errmsg;
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return TRUE if "val" is a valid 'filetype' name.
|
|
|
|
* Also used for 'syntax' and 'keymap'.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
valid_filetype(char_u *val)
|
|
|
|
{
|
|
|
|
return valid_name(val, ".-_");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef FEAT_STL_OPT
|
|
|
|
/*
|
|
|
|
* Check validity of options with the 'statusline' format.
|
2022-04-15 13:17:57 +01:00
|
|
|
* Return an untranslated error message or NULL.
|
2019-09-16 21:06:21 +02:00
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
check_stl_option(char_u *s)
|
|
|
|
{
|
|
|
|
int groupdepth = 0;
|
2023-11-29 11:34:05 +01:00
|
|
|
static char errbuf[ERR_BUFLEN];
|
|
|
|
int errbuflen = ERR_BUFLEN;
|
2019-09-16 21:06:21 +02:00
|
|
|
|
2020-10-26 21:05:27 +01:00
|
|
|
while (*s)
|
2019-09-16 21:06:21 +02:00
|
|
|
{
|
|
|
|
// Check for valid keys after % sequences
|
|
|
|
while (*s && *s != '%')
|
|
|
|
s++;
|
|
|
|
if (!*s)
|
|
|
|
break;
|
|
|
|
s++;
|
2023-02-11 11:15:25 +00:00
|
|
|
if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_SEPARATE)
|
2019-09-16 21:06:21 +02:00
|
|
|
{
|
|
|
|
s++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (*s == ')')
|
|
|
|
{
|
|
|
|
s++;
|
|
|
|
if (--groupdepth < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (*s == '-')
|
|
|
|
s++;
|
|
|
|
while (VIM_ISDIGIT(*s))
|
|
|
|
s++;
|
|
|
|
if (*s == STL_USER_HL)
|
|
|
|
continue;
|
|
|
|
if (*s == '.')
|
|
|
|
{
|
|
|
|
s++;
|
|
|
|
while (*s && VIM_ISDIGIT(*s))
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
if (*s == '(')
|
|
|
|
{
|
|
|
|
groupdepth++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (vim_strchr(STL_ALL, *s) == NULL)
|
|
|
|
{
|
2023-11-29 11:34:05 +01:00
|
|
|
return illegal_char(errbuf, errbuflen, *s);
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
|
|
|
if (*s == '{')
|
|
|
|
{
|
2022-04-15 13:17:57 +01:00
|
|
|
int reevaluate = (*++s == '%');
|
2021-05-15 17:23:28 +02:00
|
|
|
|
2022-04-15 13:17:57 +01:00
|
|
|
if (reevaluate && *++s == '}')
|
|
|
|
// "}" is not allowed immediately after "%{%"
|
2023-11-29 11:34:05 +01:00
|
|
|
return illegal_char(errbuf, errbuflen, '}');
|
2021-05-15 17:23:28 +02:00
|
|
|
while ((*s != '}' || (reevaluate && s[-1] != '%')) && *s)
|
2019-09-16 21:06:21 +02:00
|
|
|
s++;
|
|
|
|
if (*s != '}')
|
2022-04-15 13:17:57 +01:00
|
|
|
return e_unclosed_expression_sequence;
|
2019-09-16 21:06:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (groupdepth != 0)
|
2022-04-15 13:17:57 +01:00
|
|
|
return e_unbalanced_groups;
|
2019-09-16 21:06:21 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-01-31 13:25:58 +00:00
|
|
|
/*
|
|
|
|
* Check for a "normal" directory or file name in some options. Disallow a
|
|
|
|
* path separator (slash and/or backslash), wildcards and characters that are
|
|
|
|
* often illegal in a file name. Be more permissive if "secure" is off.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
check_illegal_path_names(int opt_idx, char_u **varp)
|
|
|
|
{
|
|
|
|
return (((get_option_flags(opt_idx) & P_NFNAME)
|
|
|
|
&& vim_strpbrk(*varp, (char_u *)(secure
|
|
|
|
? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
|
|
|
|
|| ((get_option_flags(opt_idx) & P_NDNAME)
|
|
|
|
&& vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL));
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* An option that accepts a list of flags is changed.
|
|
|
|
* e.g. 'viewoptions', 'switchbuf', 'casemap', etc.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
|
|
|
static char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_opt_flags(char_u *val, char **values, unsigned *flagp, int list)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (opt_strings_flags(val, values, flagp, list) == FAIL)
|
|
|
|
return e_invalid_argument;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An option that accepts a list of string values is changed.
|
|
|
|
* e.g. 'nrformats', 'scrollopt', 'wildoptions', etc.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
did_set_opt_strings(char_u *val, char **values, int list)
|
|
|
|
{
|
|
|
|
return did_set_opt_flags(val, values, NULL, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An option which is a list of flags is set. Valid values are in 'flags'.
|
|
|
|
*/
|
|
|
|
static char *
|
2023-11-29 11:34:05 +01:00
|
|
|
did_set_option_listflag(
|
|
|
|
char_u *val,
|
|
|
|
char_u *flags,
|
|
|
|
char *errbuf,
|
2023-12-05 15:36:06 +01:00
|
|
|
size_t errbuflen)
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
|
|
|
char_u *s;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
for (s = val; *s; ++s)
|
2023-03-01 12:44:06 +00:00
|
|
|
if (vim_strchr(flags, *s) == NULL)
|
2023-11-29 11:34:05 +01:00
|
|
|
return illegal_char(errbuf, errbuflen, *s);
|
2023-03-01 12:44:06 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
/*
|
2023-10-05 20:54:21 +02:00
|
|
|
* Expand an option that accepts a list of fixed string values with known
|
|
|
|
* number of items.
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
*/
|
patch 9.0.1960: Make CI checks more strict
Problem: Make CI checks more strict
Solution: Add -Wstrict-prototypes -Wmissing-prototypes to CI,
fix uncovered problems
Add -Wstrict-prototypes -Wmissing-prototypes warnings check to CI
Add two new warnings to CI, silence some Perl related build-warnings:
- `strict-prototypes` helps prevent declaring a function with an empty
argument list, e.g. `int func()`. In C++, that's equivalent to `int
func(void)`, but in C, that means a function that can take any number
of arguments which is rarely what we want.
- `missing-prototypes` makes sure we use `static` for file-only internal
functions. Non-static functions should have been declared on a
prototype file.
- Add `no-compound-token-split-by-macro` to the perl cflags, since it
throws out a bunch of perl-related warnings that make the CI log
unnecessary verbose and hard to read. This seems to happen only with
clang 12 and above.
When applying those changes, it already uncovered a few warnings, so fix
up the code as well (fix prototypes, make the code static, remove
shadowed var declaration)
GTK header needs to have #pragma warning suppressiong because GTK2
headers will warn on `-Wstrict-prototypes`, and it's included by gui.h
and so we can't just turn off the warning in a couple files.
closes: #13223
closes: #13226
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-30 12:28:50 +02:00
|
|
|
static int
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
expand_set_opt_string(
|
|
|
|
optexpand_T *args,
|
|
|
|
char **values,
|
2023-10-02 21:38:39 +02:00
|
|
|
size_t numValues,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int *numMatches,
|
|
|
|
char_u ***matches)
|
|
|
|
{
|
|
|
|
char_u *p;
|
|
|
|
regmatch_T *regmatch = args->oe_regmatch;
|
|
|
|
int include_orig_val = args->oe_include_orig_val;
|
|
|
|
char_u *option_val = args->oe_opt_value;
|
|
|
|
|
|
|
|
// Assume numValues is small since they are fixed enums, so just allocate
|
|
|
|
// upfront instead of needing two passes to calculate output size.
|
|
|
|
*matches = ALLOC_MULT(char_u *, numValues + 1);
|
|
|
|
if (*matches == NULL)
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (include_orig_val && *option_val != NUL)
|
|
|
|
{
|
|
|
|
p = vim_strsave(option_val);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
(*matches)[count++] = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (char **val = values; *val != NULL; val++)
|
|
|
|
{
|
|
|
|
if (include_orig_val && *option_val != NUL)
|
|
|
|
{
|
|
|
|
if (STRCMP((char_u*)*val, option_val) == 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (vim_regexec(regmatch, (char_u*)(*val), (colnr_T)0))
|
|
|
|
{
|
|
|
|
p = vim_strsave((char_u*)*val);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
(*matches)[count++] = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
*numMatches = count;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char_u *set_opt_callback_orig_option = NULL;
|
|
|
|
static char_u *((*set_opt_callback_func)(expand_T *, int));
|
|
|
|
|
|
|
|
/*
|
2023-10-05 20:54:21 +02:00
|
|
|
* Callback used by expand_set_opt_generic to also include the original value
|
|
|
|
* as the first item.
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
*/
|
|
|
|
static char_u *
|
2023-10-05 20:54:21 +02:00
|
|
|
expand_set_opt_generic_cb(expand_T *xp, int idx)
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
{
|
|
|
|
if (idx == 0)
|
|
|
|
{
|
|
|
|
if (set_opt_callback_orig_option != NULL)
|
|
|
|
return set_opt_callback_orig_option;
|
|
|
|
else
|
|
|
|
return (char_u *)""; // empty strings are ignored
|
|
|
|
}
|
|
|
|
return set_opt_callback_func(xp, idx - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-10-05 20:54:21 +02:00
|
|
|
* Expand an option with a callback that iterates through a list of possible
|
|
|
|
* names using an index.
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
*/
|
patch 9.0.1960: Make CI checks more strict
Problem: Make CI checks more strict
Solution: Add -Wstrict-prototypes -Wmissing-prototypes to CI,
fix uncovered problems
Add -Wstrict-prototypes -Wmissing-prototypes warnings check to CI
Add two new warnings to CI, silence some Perl related build-warnings:
- `strict-prototypes` helps prevent declaring a function with an empty
argument list, e.g. `int func()`. In C++, that's equivalent to `int
func(void)`, but in C, that means a function that can take any number
of arguments which is rarely what we want.
- `missing-prototypes` makes sure we use `static` for file-only internal
functions. Non-static functions should have been declared on a
prototype file.
- Add `no-compound-token-split-by-macro` to the perl cflags, since it
throws out a bunch of perl-related warnings that make the CI log
unnecessary verbose and hard to read. This seems to happen only with
clang 12 and above.
When applying those changes, it already uncovered a few warnings, so fix
up the code as well (fix prototypes, make the code static, remove
shadowed var declaration)
GTK header needs to have #pragma warning suppressiong because GTK2
headers will warn on `-Wstrict-prototypes`, and it's included by gui.h
and so we can't just turn off the warning in a couple files.
closes: #13223
closes: #13226
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-30 12:28:50 +02:00
|
|
|
static int
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
expand_set_opt_generic(
|
|
|
|
optexpand_T *args,
|
|
|
|
char_u *((*func)(expand_T *, int)),
|
|
|
|
int *numMatches,
|
|
|
|
char_u ***matches)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
set_opt_callback_orig_option = args->oe_include_orig_val ?
|
|
|
|
args->oe_opt_value : NULL;
|
|
|
|
set_opt_callback_func = func;
|
|
|
|
|
|
|
|
ret = ExpandGeneric(
|
|
|
|
(char_u*)"", // not using fuzzy as currently EXPAND_STRING_SETTING doesn't use it
|
|
|
|
args->oe_xp,
|
|
|
|
args->oe_regmatch,
|
|
|
|
matches,
|
|
|
|
numMatches,
|
2023-10-05 20:54:21 +02:00
|
|
|
expand_set_opt_generic_cb,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
FALSE);
|
|
|
|
|
|
|
|
set_opt_callback_orig_option = NULL;
|
|
|
|
set_opt_callback_func = NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-10-05 22:17:09 +02:00
|
|
|
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)
|
2023-10-05 20:54:21 +02:00
|
|
|
static garray_T *expand_cb_ga;
|
|
|
|
static optexpand_T *expand_cb_args;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback provided to a function in expand_set_opt_callback. Will perform
|
|
|
|
* regex matching against the value and add to the list.
|
|
|
|
*
|
|
|
|
* Returns OK usually. Returns FAIL if it failed to allocate memory, and the
|
|
|
|
* caller should terminate the enumeration.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
expand_set_opt_callback_cb(char_u *val)
|
|
|
|
{
|
|
|
|
regmatch_T *regmatch = expand_cb_args->oe_regmatch;
|
|
|
|
expand_T *xp = expand_cb_args->oe_xp;
|
|
|
|
garray_T *ga = expand_cb_ga;
|
|
|
|
char_u *str;
|
|
|
|
|
|
|
|
if (val == NULL || *val == NUL)
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
if (xp->xp_pattern[0] != NUL &&
|
|
|
|
!vim_regexec(regmatch, val, (colnr_T)0))
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
str = vim_strsave_escaped(val, (char_u *)" \t\\");
|
|
|
|
|
|
|
|
if (str == NULL)
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
if (ga_grow(ga, 1) == FAIL)
|
|
|
|
{
|
|
|
|
vim_free(str);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
((char_u **)ga->ga_data)[ga->ga_len] = str;
|
|
|
|
++ga->ga_len;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expand an option with a provided function that takes a callback. The
|
|
|
|
* function will enumerate through all options and call the callback to add it
|
|
|
|
* to the list.
|
|
|
|
*
|
|
|
|
* "func" is the enumerator function that will generate the list of options.
|
|
|
|
* "func_params" is a single parameter that will be passed to func.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
expand_set_opt_callback(
|
|
|
|
optexpand_T *args,
|
|
|
|
void (*func)(optexpand_T *, void* params, int (*cb)(char_u *val)),
|
|
|
|
void *func_params,
|
|
|
|
int *numMatches,
|
|
|
|
char_u ***matches)
|
|
|
|
{
|
|
|
|
garray_T ga;
|
|
|
|
int include_orig_val = args->oe_include_orig_val;
|
|
|
|
char_u *option_val = args->oe_opt_value;
|
|
|
|
|
|
|
|
ga_init2(&ga, sizeof(char *), 30);
|
|
|
|
|
|
|
|
if (include_orig_val && *option_val != NUL)
|
|
|
|
{
|
|
|
|
char_u *p = vim_strsave(option_val);
|
|
|
|
if (p == NULL)
|
|
|
|
return FAIL;
|
|
|
|
if (ga_grow(&ga, 1) == FAIL)
|
|
|
|
{
|
|
|
|
vim_free(p);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
((char_u **)ga.ga_data)[ga.ga_len] = p;
|
|
|
|
++ga.ga_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
expand_cb_ga = &ga;
|
|
|
|
expand_cb_args = args;
|
|
|
|
|
|
|
|
func(args, func_params, expand_set_opt_callback_cb);
|
|
|
|
|
|
|
|
expand_cb_ga = NULL;
|
|
|
|
expand_cb_args = NULL;
|
|
|
|
|
|
|
|
*matches = ga.ga_data;
|
|
|
|
*numMatches = ga.ga_len;
|
|
|
|
return OK;
|
|
|
|
}
|
2023-10-05 22:17:09 +02:00
|
|
|
#endif
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Expand an option which is a list of flags.
|
|
|
|
*/
|
patch 9.0.1960: Make CI checks more strict
Problem: Make CI checks more strict
Solution: Add -Wstrict-prototypes -Wmissing-prototypes to CI,
fix uncovered problems
Add -Wstrict-prototypes -Wmissing-prototypes warnings check to CI
Add two new warnings to CI, silence some Perl related build-warnings:
- `strict-prototypes` helps prevent declaring a function with an empty
argument list, e.g. `int func()`. In C++, that's equivalent to `int
func(void)`, but in C, that means a function that can take any number
of arguments which is rarely what we want.
- `missing-prototypes` makes sure we use `static` for file-only internal
functions. Non-static functions should have been declared on a
prototype file.
- Add `no-compound-token-split-by-macro` to the perl cflags, since it
throws out a bunch of perl-related warnings that make the CI log
unnecessary verbose and hard to read. This seems to happen only with
clang 12 and above.
When applying those changes, it already uncovered a few warnings, so fix
up the code as well (fix prototypes, make the code static, remove
shadowed var declaration)
GTK header needs to have #pragma warning suppressiong because GTK2
headers will warn on `-Wstrict-prototypes`, and it's included by gui.h
and so we can't just turn off the warning in a couple files.
closes: #13223
closes: #13226
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-30 12:28:50 +02:00
|
|
|
static int
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
expand_set_opt_listflag(
|
|
|
|
optexpand_T *args,
|
|
|
|
char_u *flags,
|
|
|
|
int *numMatches,
|
|
|
|
char_u ***matches)
|
|
|
|
{
|
|
|
|
char_u *p;
|
|
|
|
char_u *option_val = args->oe_opt_value;
|
|
|
|
char_u *cmdline_val = args->oe_set_arg;
|
|
|
|
int append = args->oe_append;
|
|
|
|
int include_orig_val = args->oe_include_orig_val && (*option_val != NUL);
|
|
|
|
|
2023-10-02 21:38:39 +02:00
|
|
|
size_t num_flags = STRLEN(flags);
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
// Assume we only have small number of flags, so just allocate max size.
|
|
|
|
*matches = ALLOC_MULT(char_u *, num_flags + 1);
|
|
|
|
if (*matches == NULL)
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (include_orig_val)
|
|
|
|
{
|
|
|
|
p = vim_strsave(option_val);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
(*matches)[count++] = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (char_u *flag = flags; *flag != NUL; flag++)
|
|
|
|
{
|
|
|
|
if (append && vim_strchr(option_val, *flag) != NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (vim_strchr(cmdline_val, *flag) == NULL)
|
|
|
|
{
|
|
|
|
if (include_orig_val
|
|
|
|
&& option_val[1] == NUL
|
|
|
|
&& *flag == option_val[0])
|
|
|
|
{
|
|
|
|
// This value is already used as the first choice as it's the
|
|
|
|
// existing flag. Just skip it to avoid duplicate.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
p = vim_strnsave(flag, 1);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
(*matches)[count++] = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
*numMatches = count;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'ambiwidth' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_ambiwidth(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return check_chars_options();
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_ambiwidth(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_ambw_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_ambw_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'background' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
2024-01-03 19:48:51 +01:00
|
|
|
did_set_background(optset_T *args)
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
|
|
|
if (check_opt_strings(p_bg, p_bg_values, FALSE) == FAIL)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
2024-01-03 19:48:51 +01:00
|
|
|
if (args->os_oldval.string != NULL && args->os_oldval.string[0] == *p_bg)
|
|
|
|
// Value was not changed
|
|
|
|
return NULL;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#ifdef FEAT_EVAL
|
|
|
|
int dark = (*p_bg == 'd');
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
2023-03-01 12:44:06 +00:00
|
|
|
|
|
|
|
init_highlight(FALSE, FALSE);
|
|
|
|
|
|
|
|
#ifdef FEAT_EVAL
|
|
|
|
if (dark != (*p_bg == 'd')
|
|
|
|
&& get_var_value((char_u *)"g:colors_name") != NULL)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
// The color scheme must have set 'background' back to another
|
|
|
|
// value, that's not what we want here. Disable the color
|
|
|
|
// scheme and set the colors again.
|
|
|
|
do_unlet((char_u *)"g:colors_name", TRUE);
|
|
|
|
free_string_option(p_bg);
|
|
|
|
p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
|
|
|
|
check_string_option(&p_bg);
|
|
|
|
init_highlight(FALSE, FALSE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_TERMINAL
|
|
|
|
term_update_colors_all();
|
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_background(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_bg_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_bg_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'backspace' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_backspace(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
if (VIM_ISDIGIT(*p_bs))
|
|
|
|
{
|
|
|
|
if (*p_bs > '3' || p_bs[1] != NUL)
|
|
|
|
return e_invalid_argument;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
|
|
|
|
return e_invalid_argument;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_backspace(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_bs_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_bs_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'backupcopy' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_backupcopy(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
char_u *bkc = p_bkc;
|
|
|
|
unsigned int *flags = &bkc_flags;
|
|
|
|
char *errmsg = NULL;
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
if (args->os_flags & OPT_LOCAL)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
bkc = curbuf->b_p_bkc;
|
|
|
|
flags = &curbuf->b_bkc_flags;
|
|
|
|
}
|
2024-11-03 09:10:50 +01:00
|
|
|
else if (!(args->os_flags & OPT_GLOBAL))
|
|
|
|
// When using :set, clear the local flags.
|
|
|
|
curbuf->b_bkc_flags = 0;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
if ((args->os_flags & OPT_LOCAL) && *bkc == NUL)
|
2023-01-30 13:04:42 +00:00
|
|
|
// make the local value empty: use the global value
|
|
|
|
*flags = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
|
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
if ((((int)*flags & BKC_AUTO) != 0)
|
|
|
|
+ (((int)*flags & BKC_YES) != 0)
|
|
|
|
+ (((int)*flags & BKC_NO) != 0) != 1)
|
|
|
|
{
|
|
|
|
// Must have exactly one of "auto", "yes" and "no".
|
2023-02-20 12:16:39 +00:00
|
|
|
(void)opt_strings_flags(args->os_oldval.string, p_bkc_values,
|
|
|
|
flags, TRUE);
|
2023-01-30 13:04:42 +00:00
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_backupcopy(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_bkc_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_bkc_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'backupext' or the 'patchmode' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_backupext_or_patchmode(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
|
|
|
|
*p_pm == '.' ? p_pm + 1 : p_pm) == 0)
|
|
|
|
return e_backupext_and_patchmode_are_equal;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'belloff' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_belloff(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
return did_set_opt_flags(p_bo, p_bo_values, &bo_flags, TRUE);
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_belloff(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_bo_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_bo_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
#if defined(FEAT_LINEBREAK) || defined(PROTO)
|
2024-02-03 18:08:09 +01:00
|
|
|
/*
|
|
|
|
* The 'breakat' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_breakat(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
char_u *p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
breakat_flags[i] = FALSE;
|
|
|
|
|
|
|
|
if (p_breakat != NULL)
|
|
|
|
for (p = p_breakat; *p; p++)
|
|
|
|
breakat_flags[*p] = TRUE;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'breakindentopt' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2024-10-22 22:59:39 +02:00
|
|
|
did_set_breakindentopt(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2024-10-22 22:59:39 +02:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (briopt_check(*varp, varp == &curwin->w_p_briopt ? curwin : NULL)
|
|
|
|
== FAIL)
|
|
|
|
return e_invalid_argument;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
// list setting requires a redraw
|
2024-10-22 22:59:39 +02:00
|
|
|
if (varp == &curwin->w_p_briopt && curwin->w_briopt_list)
|
2023-01-30 13:04:42 +00:00
|
|
|
redraw_all_later(UPD_NOT_VALID);
|
|
|
|
|
2024-10-22 22:59:39 +02:00
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_breakindentopt(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_briopt_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_briopt_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_BROWSE) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'browsedir' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-27 12:47:47 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_browsedir(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
|
|
|
|
&& !mch_isdir(p_bsdir))
|
|
|
|
return e_invalid_argument;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_browsedir(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_bsdir_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_bsdir_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'bufhidden' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_bufhidden(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE);
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_bufhidden(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_bufhidden_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_bufhidden_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'buftype' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_buftype(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
if (curwin->w_status_height)
|
|
|
|
{
|
|
|
|
curwin->w_redr_status = TRUE;
|
|
|
|
redraw_later(UPD_VALID);
|
|
|
|
}
|
|
|
|
curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
|
|
|
|
redraw_titles();
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_buftype(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_buftype_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_buftype_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'casemap' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_casemap(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_casemap(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_cmp_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_cmp_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(FEAT_CLIPBOARD) || defined(PROTO)
|
|
|
|
int
|
|
|
|
expand_set_clipboard(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_cb_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_cb_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-02 14:46:48 +00:00
|
|
|
/*
|
|
|
|
* The global 'listchars' or 'fillchars' option is changed.
|
|
|
|
*/
|
|
|
|
static char *
|
2024-01-17 20:54:49 +01:00
|
|
|
did_set_global_listfillchars(char_u *val, int opt_lcs, int opt_flags,
|
|
|
|
char *errbuf, size_t errbuflen)
|
2023-03-02 14:46:48 +00:00
|
|
|
{
|
|
|
|
char *errmsg = NULL;
|
|
|
|
char_u **local_ptr = opt_lcs ? &curwin->w_p_lcs : &curwin->w_p_fcs;
|
|
|
|
|
|
|
|
// only apply the global value to "curwin" when it does not have a
|
|
|
|
// local value
|
|
|
|
if (opt_lcs)
|
|
|
|
errmsg = set_listchars_option(curwin, val,
|
2024-01-17 20:54:49 +01:00
|
|
|
**local_ptr == NUL || !(opt_flags & OPT_GLOBAL),
|
|
|
|
errbuf, errbuflen);
|
2023-03-02 14:46:48 +00:00
|
|
|
else
|
|
|
|
errmsg = set_fillchars_option(curwin, val,
|
2024-01-17 20:54:49 +01:00
|
|
|
**local_ptr == NUL || !(opt_flags & OPT_GLOBAL),
|
|
|
|
errbuf, errbuflen);
|
2023-03-02 14:46:48 +00:00
|
|
|
if (errmsg != NULL)
|
|
|
|
return errmsg;
|
|
|
|
|
|
|
|
tabpage_T *tp;
|
|
|
|
win_T *wp;
|
|
|
|
|
|
|
|
// If the current window is set to use the global
|
|
|
|
// 'listchars'/'fillchars' value, clear the window-local value.
|
|
|
|
if (!(opt_flags & OPT_GLOBAL))
|
|
|
|
clear_string_option(local_ptr);
|
|
|
|
FOR_ALL_TAB_WINDOWS(tp, wp)
|
|
|
|
{
|
|
|
|
// If the current window has a local value need to apply it
|
|
|
|
// again, it was changed when setting the global value.
|
|
|
|
// If no error was returned above, we don't expect an error
|
|
|
|
// here, so ignore the return value.
|
|
|
|
if (opt_lcs)
|
|
|
|
{
|
|
|
|
if (*wp->w_p_lcs == NUL)
|
2024-01-17 20:54:49 +01:00
|
|
|
(void)set_listchars_option(wp, wp->w_p_lcs, TRUE, NULL, 0);
|
2023-03-02 14:46:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*wp->w_p_fcs == NUL)
|
2024-01-17 20:54:49 +01:00
|
|
|
(void)set_fillchars_option(wp, wp->w_p_fcs, TRUE, NULL, 0);
|
2023-03-02 14:46:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw_all_later(UPD_NOT_VALID);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 'fillchars' option or the 'listchars' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_chars_option(optset_T *args)
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-02 14:46:48 +00:00
|
|
|
char *errmsg = NULL;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
if ( varp == &p_lcs // global 'listchars'
|
|
|
|
|| varp == &p_fcs) // global 'fillchars'
|
|
|
|
errmsg = did_set_global_listfillchars(*varp, varp == &p_lcs,
|
2024-01-17 20:54:49 +01:00
|
|
|
args->os_flags, args->os_errbuf, args->os_errbuflen);
|
2023-03-03 12:26:15 +00:00
|
|
|
else if (varp == &curwin->w_p_lcs) // local 'listchars'
|
2024-01-17 20:54:49 +01:00
|
|
|
errmsg = set_listchars_option(curwin, *varp, TRUE,
|
|
|
|
args->os_errbuf, args->os_errbuflen);
|
2023-03-03 12:26:15 +00:00
|
|
|
else if (varp == &curwin->w_p_fcs) // local 'fillchars'
|
2024-01-17 20:54:49 +01:00
|
|
|
errmsg = set_fillchars_option(curwin, *varp, TRUE,
|
|
|
|
args->os_errbuf, args->os_errbuflen);
|
2023-03-02 14:46:48 +00:00
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
/*
|
|
|
|
* Expand 'fillchars' or 'listchars' option value.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
expand_set_chars_option(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
char_u **varp = (char_u **)args->oe_varp;
|
|
|
|
int is_lcs = (varp == &p_lcs || varp == &curwin->w_p_lcs);
|
|
|
|
return expand_set_opt_generic(
|
|
|
|
args,
|
|
|
|
is_lcs ? get_listchars_name : get_fillchars_name,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'cinoptions' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-23 15:05:22 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_cinoptions(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
// TODO: recognize errors
|
|
|
|
parse_cino(curbuf);
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
|
|
|
|
#if defined(FEAT_SYN_HL) || defined(PROTO)
|
|
|
|
/*
|
|
|
|
* The 'colorcolumn' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
2024-10-22 22:43:01 +02:00
|
|
|
did_set_colorcolumn(optset_T *args)
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
2024-10-22 22:43:01 +02:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
return check_colorcolumn(*varp, varp == &curwin->w_p_cc ? curwin : NULL);
|
2023-03-01 12:44:06 +00:00
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'comments' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_comments(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *s;
|
|
|
|
char *errmsg = NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
for (s = *varp; *s; )
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
while (*s && *s != ':')
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (vim_strchr((char_u *)COM_ALL, *s) == NULL
|
|
|
|
&& !VIM_ISDIGIT(*s) && *s != '-')
|
|
|
|
{
|
2023-11-29 11:34:05 +01:00
|
|
|
errmsg = illegal_char(args->os_errbuf, args->os_errbuflen, *s);
|
2023-03-01 12:44:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++s;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
if (*s++ == NUL)
|
|
|
|
errmsg = e_missing_colon;
|
|
|
|
else if (*s == ',' || *s == NUL)
|
|
|
|
errmsg = e_zero_length_string;
|
|
|
|
if (errmsg != NULL)
|
2023-01-30 13:04:42 +00:00
|
|
|
break;
|
2023-03-01 12:44:06 +00:00
|
|
|
while (*s && *s != ',')
|
|
|
|
{
|
|
|
|
if (*s == '\\' && s[1] != NUL)
|
|
|
|
++s;
|
|
|
|
++s;
|
|
|
|
}
|
|
|
|
s = skip_to_option_part(s);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_FOLDING) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'commentstring' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_commentstring(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
|
2023-03-01 12:44:06 +00:00
|
|
|
return e_commentstring_must_be_empty_or_contain_str;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'complete' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-03-01 12:44:06 +00:00
|
|
|
char *
|
|
|
|
did_set_complete(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *s;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// check if it is a valid value for 'complete' -- Acevedo
|
2023-03-03 12:26:15 +00:00
|
|
|
for (s = *varp; *s;)
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
|
|
|
while (*s == ',' || *s == ' ')
|
|
|
|
s++;
|
|
|
|
if (!*s)
|
|
|
|
break;
|
|
|
|
if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
|
2023-11-29 11:34:05 +01:00
|
|
|
return illegal_char(args->os_errbuf, args->os_errbuflen, *s);
|
2023-03-01 12:44:06 +00:00
|
|
|
if (*++s != NUL && *s != ',' && *s != ' ')
|
|
|
|
{
|
|
|
|
if (s[-1] == 'k' || s[-1] == 's')
|
|
|
|
{
|
|
|
|
// skip optional filename after 'k' and 's'
|
|
|
|
while (*s && *s != ',' && *s != ' ')
|
|
|
|
{
|
|
|
|
if (*s == '\\' && s[1] != NUL)
|
|
|
|
++s;
|
|
|
|
++s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (args->os_errbuf != NULL)
|
|
|
|
{
|
2023-12-05 16:04:23 +01:00
|
|
|
vim_snprintf((char *)args->os_errbuf, args->os_errbuflen,
|
2023-03-01 12:44:06 +00:00
|
|
|
_(e_illegal_character_after_chr), *--s);
|
|
|
|
return args->os_errbuf;
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_complete(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
static char *(p_cpt_values[]) = {
|
|
|
|
".", "w", "b", "u", "k", "kspell", "s", "i", "d", "]", "t", "U",
|
|
|
|
NULL};
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_cpt_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_cpt_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'completeopt' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_completeopt(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2024-06-05 20:27:06 +02:00
|
|
|
char_u *cot = p_cot;
|
|
|
|
unsigned *flags = &cot_flags;
|
|
|
|
|
|
|
|
if (args->os_flags & OPT_LOCAL)
|
|
|
|
{
|
|
|
|
cot = curbuf->b_p_cot;
|
|
|
|
flags = &curbuf->b_cot_flags;
|
|
|
|
}
|
2024-11-03 09:10:50 +01:00
|
|
|
else if (!(args->os_flags & OPT_GLOBAL))
|
|
|
|
// When using :set, clear the local flags.
|
|
|
|
curbuf->b_cot_flags = 0;
|
2024-06-05 20:27:06 +02:00
|
|
|
|
|
|
|
if (check_opt_strings(cot, p_cot_values, TRUE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
if (opt_strings_flags(cot, p_cot_values, flags, TRUE) != OK)
|
2023-03-01 12:44:06 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_completeopt(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_cot_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_cot_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2025-03-06 21:59:13 +01:00
|
|
|
/*
|
|
|
|
* The 'completefuzzycollect' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_completefuzzycollect(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
if (opt_strings_flags(p_cfc, p_cfc_values, &cfc_flags, TRUE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2025-03-07 19:09:09 +01:00
|
|
|
int
|
|
|
|
expand_set_completefuzzycollect(
|
|
|
|
optexpand_T *args,
|
|
|
|
int *numMatches,
|
|
|
|
char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_cfc_values,
|
|
|
|
ARRAY_LENGTH(p_cfc_values) - 1,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2024-10-01 20:32:12 +02:00
|
|
|
/*
|
|
|
|
* The 'completeitemalign' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_completeitemalign(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
char_u *p = p_cia;
|
|
|
|
unsigned new_cia_flags = 0;
|
|
|
|
int seen[3] = { FALSE, FALSE, FALSE };
|
|
|
|
int count = 0;
|
|
|
|
char_u buf[10];
|
|
|
|
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
copy_option_part(&p, buf, sizeof(buf), ",");
|
|
|
|
if (count >= 3)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
if (STRCMP(buf, "abbr") == 0)
|
|
|
|
{
|
|
|
|
if (seen[CPT_ABBR])
|
|
|
|
return e_invalid_argument;
|
|
|
|
new_cia_flags = new_cia_flags * 10 + CPT_ABBR;
|
|
|
|
seen[CPT_ABBR] = TRUE;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
else if (STRCMP(buf, "kind") == 0)
|
|
|
|
{
|
|
|
|
if (seen[CPT_KIND])
|
|
|
|
return e_invalid_argument;
|
|
|
|
new_cia_flags = new_cia_flags * 10 + CPT_KIND;
|
|
|
|
seen[CPT_KIND] = TRUE;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
else if (STRCMP(buf, "menu") == 0)
|
|
|
|
{
|
|
|
|
if (seen[CPT_MENU])
|
|
|
|
return e_invalid_argument;
|
|
|
|
new_cia_flags = new_cia_flags * 10 + CPT_MENU;
|
|
|
|
seen[CPT_MENU] = TRUE;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return e_invalid_argument;
|
|
|
|
}
|
|
|
|
if (new_cia_flags == 0 || count != 3)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
cia_flags = new_cia_flags;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if (defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'completepopup' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_completepopup(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (parse_completepopup(NULL) == FAIL)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
popup_close_info();
|
|
|
|
return NULL;
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-23 15:05:22 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'completeslash' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_completeslash(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (check_opt_strings(p_csl, p_csl_values, FALSE) != OK
|
|
|
|
|| check_opt_strings(curbuf->b_p_csl, p_csl_values, FALSE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_completeslash(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_csl_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_csl_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-23 15:05:22 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_CONCEAL) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'concealcursor' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_concealcursor(optset_T *args)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-11-29 11:34:05 +01:00
|
|
|
return did_set_option_listflag(*varp, (char_u *)COCU_ALL, args->os_errbuf,
|
|
|
|
args->os_errbuflen);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_concealcursor(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_listflag(args, (char_u*)COCU_ALL, numMatches, matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-23 15:05:22 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'cpoptions' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_cpoptions(optset_T *args)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-11-29 11:34:05 +01:00
|
|
|
return did_set_option_listflag(*varp, (char_u *)CPO_ALL, args->os_errbuf,
|
|
|
|
args->os_errbuflen);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_cpoptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_listflag(args, (char_u*)CPO_ALL, numMatches, matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_CRYPT) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'cryptkey' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_cryptkey(optset_T *args)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
// Make sure the ":set" command doesn't show the new value in the
|
|
|
|
// history.
|
|
|
|
remove_key_from_history();
|
|
|
|
|
2023-10-01 09:13:22 +02:00
|
|
|
if (args->os_op != OP_NONE)
|
|
|
|
// Don't allow set+=/-=/^= as they can allow for substring guessing
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
if (STRCMP(curbuf->b_p_key, args->os_oldval.string) != 0)
|
|
|
|
{
|
|
|
|
// Need to update the swapfile.
|
|
|
|
ml_set_crypt_key(curbuf, args->os_oldval.string,
|
|
|
|
*curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
|
|
|
|
changed_internal();
|
|
|
|
}
|
2023-06-27 18:57:10 +01:00
|
|
|
# ifdef FEAT_SODIUM
|
|
|
|
if (crypt_method_is_sodium(crypt_get_method_nr(curbuf)))
|
|
|
|
crypt_sodium_lock_key(args->os_newval.string);
|
|
|
|
# endif
|
2023-03-01 12:44:06 +00:00
|
|
|
|
|
|
|
return NULL;
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
2023-02-27 12:47:47 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'cryptmethod' option is changed.
|
2023-02-27 12:47:47 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_cryptmethod(optset_T *args)
|
2023-02-27 12:47:47 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *p;
|
|
|
|
char_u *s;
|
|
|
|
|
|
|
|
if (args->os_flags & OPT_LOCAL)
|
|
|
|
p = curbuf->b_p_cm;
|
|
|
|
else
|
|
|
|
p = p_cm;
|
|
|
|
if (check_opt_strings(p, p_cm_values, TRUE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
else if (crypt_self_test() == FAIL)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
// When setting the global value to empty, make it "zip".
|
|
|
|
if (*p_cm == NUL)
|
|
|
|
{
|
|
|
|
free_string_option(p_cm);
|
|
|
|
p_cm = vim_strsave((char_u *)"zip");
|
|
|
|
}
|
|
|
|
// When using ":set cm=name" the local value is going to be empty.
|
|
|
|
// Do that here, otherwise the crypt functions will still use the
|
|
|
|
// local value.
|
|
|
|
if ((args->os_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
|
|
{
|
|
|
|
free_string_option(curbuf->b_p_cm);
|
|
|
|
curbuf->b_p_cm = empty_option;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to update the swapfile when the effective method changed.
|
|
|
|
// Set "s" to the effective old value, "p" to the effective new
|
|
|
|
// method and compare.
|
|
|
|
if ((args->os_flags & OPT_LOCAL) && *args->os_oldval.string == NUL)
|
|
|
|
s = p_cm; // was previously using the global value
|
|
|
|
else
|
|
|
|
s = args->os_oldval.string;
|
|
|
|
if (*curbuf->b_p_cm == NUL)
|
|
|
|
p = p_cm; // is now using the global value
|
|
|
|
else
|
|
|
|
p = curbuf->b_p_cm;
|
|
|
|
if (STRCMP(s, p) != 0)
|
|
|
|
ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
|
|
|
|
|
|
|
|
// If the global value changes need to update the swapfile for all
|
|
|
|
// buffers using that value.
|
|
|
|
if ((args->os_flags & OPT_GLOBAL)
|
|
|
|
&& STRCMP(p_cm, args->os_oldval.string) != 0)
|
|
|
|
{
|
|
|
|
buf_T *buf;
|
|
|
|
|
|
|
|
FOR_ALL_BUFFERS(buf)
|
|
|
|
if (buf != curbuf && *buf->b_p_cm == NUL)
|
|
|
|
ml_set_crypt_key(buf, buf->b_p_key, args->os_oldval.string);
|
|
|
|
}
|
|
|
|
return NULL;
|
2023-02-27 12:47:47 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_cryptmethod(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_cm_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_cm_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-27 12:47:47 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if (defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'cscopequickfix' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_cscopequickfix(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *p;
|
|
|
|
|
|
|
|
if (p_csqf == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
p = p_csqf;
|
|
|
|
while (*p != NUL)
|
|
|
|
{
|
|
|
|
if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
|
|
|
|
|| p[1] == NUL
|
|
|
|
|| vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
|
|
|
|
|| (p[2] != NUL && p[2] != ','))
|
|
|
|
return e_invalid_argument;
|
|
|
|
else if (p[2] == NUL)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
p += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-23 15:05:22 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_SYN_HL) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'cursorlineopt' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_cursorlineopt(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
// This could be changed to use opt_strings_flags() instead.
|
2023-03-03 12:26:15 +00:00
|
|
|
if (**varp == NUL || fill_culopt_flags(*varp, curwin) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_cursorlineopt(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_culopt_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_culopt_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-23 15:05:22 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'debug' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_debug(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(p_debug, p_debug_values, TRUE);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_debug(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_debug_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_debug_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_DIFF) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'diffopt' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_diffopt(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (diffopt_changed() == FAIL)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_diffopt(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
expand_T *xp = args->oe_xp;
|
|
|
|
|
|
|
|
if (xp->xp_pattern > args->oe_set_arg && *(xp->xp_pattern-1) == ':')
|
|
|
|
{
|
|
|
|
// Within "algorithm:", we have a subgroup of possible options.
|
2023-10-02 21:38:39 +02:00
|
|
|
int algo_len = (int)STRLEN("algorithm:");
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
if (xp->xp_pattern - args->oe_set_arg >= algo_len &&
|
|
|
|
STRNCMP(xp->xp_pattern - algo_len, "algorithm:", algo_len) == 0)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_dip_algorithm_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_dip_algorithm_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_dip_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_dip_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'display' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_display(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
(void)init_chartab();
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_display(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_dy_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_dy_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'eadirection' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_eadirection(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
return did_set_opt_strings(p_ead, p_ead_values, FALSE);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_eadirection(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_ead_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_ead_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* One of the 'encoding', 'fileencoding', 'termencoding' or 'makeencoding'
|
|
|
|
* options is changed.
|
|
|
|
*/
|
2023-03-03 12:26:15 +00:00
|
|
|
char *
|
|
|
|
did_set_encoding(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
char_u **gvarp;
|
2023-01-30 13:04:42 +00:00
|
|
|
char *errmsg = NULL;
|
|
|
|
char_u *p;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
// Get the global option to compare with, otherwise we would have to check
|
|
|
|
// two values for all local options.
|
|
|
|
gvarp = (char_u **)get_option_varp_scope(args->os_idx, OPT_GLOBAL);
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
if (gvarp == &p_fenc)
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
if (!curbuf->b_p_ma && args->os_flags != OPT_GLOBAL)
|
2023-01-30 13:04:42 +00:00
|
|
|
errmsg = e_cannot_make_changes_modifiable_is_off;
|
|
|
|
else if (vim_strchr(*varp, ',') != NULL)
|
|
|
|
// No comma allowed in 'fileencoding'; catches confusing it
|
|
|
|
// with 'fileencodings'.
|
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// May show a "+" in the title now.
|
|
|
|
redraw_titles();
|
|
|
|
// Add 'fileencoding' to the swap file.
|
|
|
|
ml_setflags(curbuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (errmsg == NULL)
|
|
|
|
{
|
|
|
|
// canonize the value, so that STRCMP() can be used on it
|
|
|
|
p = enc_canonize(*varp);
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
|
|
|
vim_free(*varp);
|
|
|
|
*varp = p;
|
|
|
|
}
|
|
|
|
if (varp == &p_enc)
|
|
|
|
{
|
|
|
|
errmsg = mb_init();
|
|
|
|
redraw_titles();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(FEAT_GUI_GTK)
|
|
|
|
if (errmsg == NULL && varp == &p_tenc && gui.in_use)
|
|
|
|
{
|
|
|
|
// GTK uses only a single encoding, and that is UTF-8.
|
|
|
|
if (STRCMP(p_tenc, "utf-8") != 0)
|
|
|
|
errmsg = e_cannot_be_changed_in_gtk_GUI;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (errmsg == NULL)
|
|
|
|
{
|
|
|
|
#ifdef FEAT_KEYMAP
|
|
|
|
// When 'keymap' is used and 'encoding' changes, reload the keymap
|
|
|
|
// (with another encoding).
|
|
|
|
if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
|
|
|
|
(void)keymap_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// When 'termencoding' is not empty and 'encoding' changes or when
|
|
|
|
// 'termencoding' changes, need to setup for keyboard input and
|
|
|
|
// display output conversion.
|
|
|
|
if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
|
|
|
|
{
|
|
|
|
if (convert_setup(&input_conv, p_tenc, p_enc) == FAIL
|
|
|
|
|| convert_setup(&output_conv, p_enc, p_tenc) == FAIL)
|
|
|
|
{
|
|
|
|
semsg(_(e_cannot_convert_between_str_and_str),
|
|
|
|
p_tenc, p_enc);
|
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(MSWIN)
|
2023-02-15 19:13:43 +00:00
|
|
|
// $HOME, $VIM and $VIMRUNTIME may have characters in active code page.
|
2023-01-30 13:04:42 +00:00
|
|
|
if (varp == &p_enc)
|
2023-02-15 19:13:43 +00:00
|
|
|
{
|
2023-01-30 13:04:42 +00:00
|
|
|
init_homedir();
|
2023-02-15 19:13:43 +00:00
|
|
|
init_vimdir();
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_encoding(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_generic(
|
|
|
|
args,
|
|
|
|
get_encoding_name,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2025-02-08 18:52:39 +01:00
|
|
|
* The 'eventignore(win)' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2025-02-08 18:52:39 +01:00
|
|
|
did_set_eventignore(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2025-02-08 18:52:39 +01:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (check_ei(*varp) == FAIL)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2025-02-08 18:52:39 +01:00
|
|
|
static int expand_eiw = FALSE;
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
static char_u *
|
|
|
|
get_eventignore_name(expand_T *xp, int idx)
|
|
|
|
{
|
2025-02-08 18:52:39 +01:00
|
|
|
// 'eventignore(win)' allows special keyword "all" in addition to
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
// all event names.
|
|
|
|
if (idx == 0)
|
|
|
|
return (char_u *)"all";
|
2025-02-08 18:52:39 +01:00
|
|
|
return get_event_name_no_group(xp, idx - 1, expand_eiw);
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_eventignore(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
2025-02-08 18:52:39 +01:00
|
|
|
expand_eiw = args->oe_varp != (char_u *)&p_ei;
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
return expand_set_opt_generic(
|
|
|
|
args,
|
|
|
|
get_eventignore_name,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'fileformat' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_fileformat(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
if (!curbuf->b_p_ma && !(args->os_flags & OPT_GLOBAL))
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_cannot_make_changes_modifiable_is_off;
|
2023-03-03 12:26:15 +00:00
|
|
|
else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
// may also change 'textmode'
|
|
|
|
if (get_fileformat(curbuf) == EOL_DOS)
|
|
|
|
curbuf->b_p_tx = TRUE;
|
|
|
|
else
|
|
|
|
curbuf->b_p_tx = FALSE;
|
|
|
|
redraw_titles();
|
|
|
|
// update flag in swap file
|
|
|
|
ml_setflags(curbuf);
|
|
|
|
// Redraw needed when switching to/from "mac": a CR in the text
|
|
|
|
// will be displayed differently.
|
2023-02-20 12:16:39 +00:00
|
|
|
if (get_fileformat(curbuf) == EOL_MAC || *args->os_oldval.string == 'm')
|
2023-01-30 13:04:42 +00:00
|
|
|
redraw_curbuf_later(UPD_NOT_VALID);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_fileformat(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_ff_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_ff_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-10-14 11:46:51 +02:00
|
|
|
/*
|
|
|
|
* Function given to ExpandGeneric() to obtain the possible arguments of the
|
|
|
|
* fileformat options.
|
|
|
|
*/
|
|
|
|
char_u *
|
|
|
|
get_fileformat_name(expand_T *xp UNUSED, int idx)
|
|
|
|
{
|
|
|
|
if (idx >= (int)ARRAY_LENGTH(p_ff_values))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (char_u*)p_ff_values[idx];
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'fileformats' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_fileformats(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
// also change 'textauto'
|
|
|
|
if (*p_ffs == NUL)
|
|
|
|
p_ta = FALSE;
|
|
|
|
else
|
|
|
|
p_ta = TRUE;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'filetype' or the 'syntax' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_filetype_or_syntax(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (!valid_filetype(*varp))
|
2023-03-01 12:44:06 +00:00
|
|
|
return e_invalid_argument;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
args->os_value_changed = STRCMP(args->os_oldval.string, *varp) != 0;
|
2023-03-01 12:44:06 +00:00
|
|
|
|
|
|
|
// Since we check the value, there is no need to set P_INSECURE,
|
|
|
|
// even when the value comes from a modeline.
|
|
|
|
args->os_value_checked = TRUE;
|
2023-02-20 12:16:39 +00:00
|
|
|
|
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_FOLDING) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'foldclose' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_foldclose(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(p_fcl, p_fcl_values, TRUE);
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_foldclose(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_fcl_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_fcl_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if (defined(FEAT_EVAL) && defined(FEAT_FOLDING)) || defined(PROTO)
|
|
|
|
/*
|
|
|
|
* The 'foldexpr' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_foldexpr(optset_T *args)
|
|
|
|
{
|
|
|
|
(void)did_set_optexpr(args);
|
|
|
|
if (foldmethodIsExpr(curwin))
|
|
|
|
foldUpdateAll(curwin);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_FOLDING) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'foldignore' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_foldignore(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (foldmethodIsIndent(curwin))
|
|
|
|
foldUpdateAll(curwin);
|
2023-01-30 13:04:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'foldmarker' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-25 11:59:33 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_foldmarker(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *p;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
p = vim_strchr(*varp, ',');
|
2023-03-01 12:44:06 +00:00
|
|
|
if (p == NULL)
|
|
|
|
return e_comma_required;
|
2023-03-03 12:26:15 +00:00
|
|
|
else if (p == *varp || p[1] == NUL)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
2023-03-01 12:44:06 +00:00
|
|
|
else if (foldmethodIsMarker(curwin))
|
|
|
|
foldUpdateAll(curwin);
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'foldmethod' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-25 11:59:33 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_foldmethod(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2024-10-22 22:11:51 +02:00
|
|
|
if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK || **varp == NUL)
|
2023-03-01 12:44:06 +00:00
|
|
|
return e_invalid_argument;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
foldUpdateAll(curwin);
|
|
|
|
if (foldmethodIsDiff(curwin))
|
|
|
|
newFoldLevel();
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_foldmethod(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_fdm_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_fdm_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'foldopen' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_foldopen(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_foldopen(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_fdo_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_fdo_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'formatoptions' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_formatoptions(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-11-29 11:34:05 +01:00
|
|
|
return did_set_option_listflag(*varp, (char_u *)FO_ALL, args->os_errbuf,
|
|
|
|
args->os_errbuflen);
|
2023-03-01 12:44:06 +00:00
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_formatoptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_listflag(args, (char_u*)FO_ALL, numMatches, matches);
|
|
|
|
}
|
|
|
|
|
2023-02-25 11:59:33 +00:00
|
|
|
#if defined(CURSOR_SHAPE) || defined(PROTO)
|
|
|
|
/*
|
|
|
|
* The 'guicursor' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_guicursor(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
return parse_shape_opt(SHAPE_CURSOR);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
#if defined(FEAT_GUI) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'guifont' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_guifont(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
char_u *p;
|
|
|
|
char *errmsg = NULL;
|
|
|
|
|
|
|
|
if (gui.in_use)
|
|
|
|
{
|
|
|
|
p = p_guifont;
|
|
|
|
# if defined(FEAT_GUI_GTK)
|
|
|
|
// Put up a font dialog and let the user select a new value.
|
|
|
|
// If this is cancelled go back to the old value but don't
|
|
|
|
// give an error message.
|
|
|
|
if (STRCMP(p, "*") == 0)
|
|
|
|
{
|
2023-02-20 12:16:39 +00:00
|
|
|
p = gui_mch_font_dialog(args->os_oldval.string);
|
2023-01-30 13:04:42 +00:00
|
|
|
free_string_option(p_guifont);
|
2023-02-20 12:16:39 +00:00
|
|
|
p_guifont = (p != NULL) ? p : vim_strsave(args->os_oldval.string);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
|
|
|
|
{
|
|
|
|
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
|
|
|
|
if (STRCMP(p_guifont, "*") == 0)
|
|
|
|
{
|
|
|
|
// Dialog was cancelled: Keep the old value without giving
|
|
|
|
// an error message.
|
|
|
|
free_string_option(p_guifont);
|
2023-02-20 12:16:39 +00:00
|
|
|
p_guifont = vim_strsave(args->os_oldval.string);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
errmsg = e_invalid_fonts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
|
2023-10-05 20:54:21 +02:00
|
|
|
/*
|
|
|
|
* Expand the 'guifont' option. Only when GUI is being used. Each platform has
|
|
|
|
* specific behaviors.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
expand_set_guifont(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
if (!gui.in_use)
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)
|
|
|
|
char_u **varp = (char_u **)args->oe_varp;
|
|
|
|
int wide = (varp == &p_guifontwide);
|
|
|
|
|
|
|
|
return expand_set_opt_callback(
|
|
|
|
args, gui_mch_expand_font, &wide, numMatches, matches);
|
|
|
|
# else
|
|
|
|
return FAIL;
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
# if defined(FEAT_XFONTSET) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'guifontset' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_guifontset(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
char *errmsg = NULL;
|
|
|
|
|
|
|
|
if (STRCMP(p_guifontset, "*") == 0)
|
|
|
|
errmsg = e_cant_select_fontset;
|
|
|
|
else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
|
|
|
|
errmsg = e_invalid_fontset;
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 'guifontwide' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_guifontwide(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
char *errmsg = NULL;
|
|
|
|
|
|
|
|
if (STRCMP(p_guifontwide, "*") == 0)
|
|
|
|
errmsg = e_cant_select_wide_font;
|
|
|
|
else if (gui_get_wide_font() == FAIL)
|
|
|
|
errmsg = e_invalid_wide_font;
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-02-24 14:26:52 +01:00
|
|
|
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) || defined(PROTO)
|
2023-02-20 12:16:39 +00:00
|
|
|
/*
|
|
|
|
* The 'guiligatures' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_guiligatures(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
gui_set_ligatures();
|
2023-02-20 12:16:39 +00:00
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_GUI) || defined(PROTO)
|
|
|
|
/*
|
|
|
|
* The 'guioptions' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_guioptions(optset_T *args)
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-01 12:44:06 +00:00
|
|
|
char *errmsg;
|
|
|
|
|
2023-11-29 11:34:05 +01:00
|
|
|
errmsg = did_set_option_listflag(*varp, (char_u *)GO_ALL, args->os_errbuf,
|
|
|
|
args->os_errbuflen);
|
2023-03-01 12:44:06 +00:00
|
|
|
if (errmsg != NULL)
|
|
|
|
return errmsg;
|
|
|
|
|
|
|
|
gui_init_which_components(args->os_oldval.string);
|
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_guioptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_listflag(args, (char_u*)GO_ALL, numMatches, matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(FEAT_GUI_TABLINE) || defined(PROTO)
|
|
|
|
/*
|
|
|
|
* The 'guitablabel' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_guitablabel(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
redraw_tabline = TRUE;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 'helpfile' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_helpfile(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
// May compute new values for $VIM and $VIMRUNTIME
|
|
|
|
if (didset_vim)
|
|
|
|
vim_unsetenv_ext((char_u *)"VIM");
|
|
|
|
if (didset_vimruntime)
|
|
|
|
vim_unsetenv_ext((char_u *)"VIMRUNTIME");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(FEAT_MULTI_LANG) || defined(PROTO)
|
|
|
|
/*
|
|
|
|
* The 'helplang' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_helplang(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
char *errmsg = NULL;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// Check for "", "ab", "ab,cd", etc.
|
|
|
|
for (char_u *s = p_hlg; *s != NUL; s += 3)
|
|
|
|
{
|
|
|
|
if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
|
|
|
|
{
|
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (s[2] == NUL)
|
|
|
|
break;
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
/*
|
|
|
|
* The 'highlight' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_highlight(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
if (highlight_changed() == FAIL)
|
|
|
|
return e_invalid_argument; // invalid flags
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
/*
|
|
|
|
* Expand 'highlight' option.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
expand_set_highlight(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
char_u *p;
|
|
|
|
expand_T *xp = args->oe_xp;
|
|
|
|
static char_u hl_flags[HLF_COUNT] = HL_FLAGS;
|
2023-10-02 23:21:11 +02:00
|
|
|
size_t i;
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (xp->xp_pattern > args->oe_set_arg && *(xp->xp_pattern-1) == ':')
|
|
|
|
{
|
|
|
|
// Right after a ':', meaning we just return all highlight names.
|
|
|
|
return expand_set_opt_generic(
|
|
|
|
args,
|
|
|
|
get_highlight_name,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*xp->xp_pattern == NUL)
|
|
|
|
{
|
|
|
|
// At beginning of a comma-separated list. Return the specific list of
|
|
|
|
// supported occasions.
|
|
|
|
*matches = ALLOC_MULT(char_u *, HLF_COUNT + 1);
|
|
|
|
if (*matches == NULL)
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
// We still want to return the full option if it's requested.
|
|
|
|
if (args->oe_include_orig_val)
|
|
|
|
{
|
|
|
|
p = vim_strsave(args->oe_opt_value);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
(*matches)[count++] = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < HLF_COUNT; i++)
|
|
|
|
{
|
|
|
|
p = vim_strnsave(&hl_flags[i], 1);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
(*matches)[count++] = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
*numMatches = count;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We are after the initial character (which indicates the occasion). We
|
|
|
|
// already made sure we are not matching after a ':' above, so now we want
|
|
|
|
// to match against display mode modifiers.
|
|
|
|
// Since the xp_pattern starts from the beginning, we need to include it in
|
|
|
|
// the returned match.
|
|
|
|
|
|
|
|
// Note: Keep this in sync with highlight_changed()
|
2023-10-02 21:38:39 +02:00
|
|
|
static char_u p_hl_mode_values[] =
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
{':', 'b', 'i', '-', 'n', 'r', 's', 'u', 'c', '2', 'd', '=', 't'};
|
2023-10-02 21:38:39 +02:00
|
|
|
size_t num_hl_modes = ARRAY_LENGTH(p_hl_mode_values);
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
*matches = ALLOC_MULT(char_u *, num_hl_modes);
|
|
|
|
if (*matches == NULL)
|
|
|
|
return FAIL;
|
|
|
|
|
2023-10-17 10:56:25 +02:00
|
|
|
int pattern_len = xp->xp_pattern_len;
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
for (i = 0; i < num_hl_modes; i++)
|
|
|
|
{
|
|
|
|
// Don't allow duplicates as these are unique flags
|
2023-10-17 10:56:25 +02:00
|
|
|
char_u *dup = vim_strchr(xp->xp_pattern + 1, p_hl_mode_values[i]);
|
|
|
|
if (dup != NULL && (int)(dup - xp->xp_pattern) < pattern_len)
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// ':' only works by itself, not with other flags.
|
|
|
|
if (pattern_len > 1 && p_hl_mode_values[i] == ':')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
p = vim_strnsave(xp->xp_pattern, pattern_len + 1);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p[pattern_len] = p_hl_mode_values[i];
|
|
|
|
p[pattern_len + 1] = NUL;
|
|
|
|
(*matches)[count++] = p;
|
|
|
|
}
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
VIM_CLEAR(*matches);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
*numMatches = count;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'titlestring' or the 'iconstring' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
static char *
|
2023-03-01 12:44:06 +00:00
|
|
|
parse_titleiconstring(optset_T *args UNUSED, int flagval UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
#ifdef FEAT_STL_OPT
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
// NULL => statusline syntax
|
2023-03-03 12:26:15 +00:00
|
|
|
if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
|
2023-01-30 13:04:42 +00:00
|
|
|
stl_syntax |= flagval;
|
|
|
|
else
|
|
|
|
stl_syntax &= ~flagval;
|
|
|
|
#endif
|
|
|
|
did_set_title();
|
2023-02-20 12:16:39 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 'iconstring' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_iconstring(optset_T *args)
|
|
|
|
{
|
|
|
|
int flagval = 0;
|
|
|
|
|
|
|
|
#ifdef FEAT_STL_OPT
|
|
|
|
flagval = STL_IN_ICON;
|
|
|
|
#endif
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
return parse_titleiconstring(args, flagval);
|
2023-02-25 11:59:33 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'imactivatekey' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_imactivatekey(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (!im_xim_isvalid_imactivate())
|
|
|
|
return e_invalid_argument;
|
2023-02-20 12:16:39 +00:00
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-10-22 22:27:19 +02:00
|
|
|
/*
|
|
|
|
* The 'iskeyword' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_iskeyword(optset_T *args)
|
|
|
|
{
|
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (varp == &p_isk) // only check for global-value
|
|
|
|
{
|
|
|
|
if (check_isopt(*varp) == FAIL)
|
|
|
|
return e_invalid_argument;
|
|
|
|
}
|
|
|
|
else // fallthrough for local-value
|
|
|
|
return did_set_isopt(args);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'isident' or the 'iskeyword' or the 'isprint' or the 'isfname' option is
|
|
|
|
* changed.
|
2023-02-20 12:16:39 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_isopt(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2024-10-22 22:27:19 +02:00
|
|
|
// 'isident', 'iskeyword', 'isprint' or 'isfname' option: refill g_chartab[]
|
2023-03-01 12:44:06 +00:00
|
|
|
// If the new option is invalid, use old value.
|
|
|
|
// 'lisp' option: refill g_chartab[] for '-' char.
|
|
|
|
if (init_chartab() == FAIL)
|
|
|
|
{
|
|
|
|
args->os_restore_chartab = TRUE;// need to restore the chartab.
|
|
|
|
return e_invalid_argument; // error in value
|
|
|
|
}
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
2023-09-20 20:20:04 +02:00
|
|
|
/*
|
|
|
|
* The 'jumpoptions' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
2023-09-21 16:36:28 +02:00
|
|
|
did_set_jumpoptions(optset_T *args UNUSED)
|
2023-09-20 20:20:04 +02:00
|
|
|
{
|
|
|
|
if (opt_strings_flags(p_jop, p_jop_values, &jop_flags, TRUE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_jumpoptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_jop_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_jop_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_KEYMAP) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'keymap' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_keymap(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-01-30 13:04:42 +00:00
|
|
|
char *errmsg = NULL;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
if (!valid_filetype(*varp))
|
2023-01-30 13:04:42 +00:00
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
else
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
|
|
|
int secure_save = secure;
|
|
|
|
|
|
|
|
// Reset the secure flag, since the value of 'keymap' has
|
|
|
|
// been checked to be safe.
|
|
|
|
secure = 0;
|
|
|
|
|
|
|
|
// load or unload key mapping tables
|
|
|
|
errmsg = keymap_init();
|
|
|
|
|
|
|
|
secure = secure_save;
|
|
|
|
|
|
|
|
// Since we check the value, there is no need to set P_INSECURE,
|
|
|
|
// even when the value comes from a modeline.
|
|
|
|
args->os_value_checked = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errmsg == NULL)
|
|
|
|
{
|
|
|
|
if (*curbuf->b_p_keymap != NUL)
|
|
|
|
{
|
|
|
|
// Installed a new keymap, switch on using it.
|
|
|
|
curbuf->b_p_iminsert = B_IMODE_LMAP;
|
|
|
|
if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
|
|
|
|
curbuf->b_p_imsearch = B_IMODE_LMAP;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Cleared the keymap, may reset 'iminsert' and 'imsearch'.
|
|
|
|
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
|
|
|
|
curbuf->b_p_iminsert = B_IMODE_NONE;
|
|
|
|
if (curbuf->b_p_imsearch == B_IMODE_LMAP)
|
|
|
|
curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
|
|
|
|
}
|
|
|
|
if ((args->os_flags & OPT_LOCAL) == 0)
|
|
|
|
{
|
|
|
|
set_iminsert_global();
|
|
|
|
set_imsearch_global();
|
|
|
|
}
|
|
|
|
status_redraw_curbuf();
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'keymodel' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_keymodel(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
km_stopsel = (vim_strchr(p_km, 'o') != NULL);
|
|
|
|
km_startsel = (vim_strchr(p_km, 'a') != NULL);
|
2023-01-30 13:04:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_keymodel(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_km_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_km_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'keyprotocol' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_keyprotocol(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-09-29 20:17:20 +02:00
|
|
|
char_u *term = T_NAME;
|
|
|
|
keyprot_T kpc = match_keyprotocol(term);
|
|
|
|
if (kpc == KEYPROTOCOL_FAIL)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-09-29 20:17:20 +02:00
|
|
|
apply_keyprotocol(term, kpc);
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_keyprotocol(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
expand_T *xp = args->oe_xp;
|
|
|
|
if (xp->xp_pattern > args->oe_set_arg && *(xp->xp_pattern-1) == ':')
|
|
|
|
{
|
|
|
|
// 'keyprotocol' only has well-defined terms for completion for the
|
|
|
|
// protocol part after the colon.
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_kpc_protocol_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_kpc_protocol_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
// Use expand_set_opt_string instead of returning FAIL so that we can
|
|
|
|
// include the original value if args->oe_include_orig_val is set.
|
|
|
|
static char *(empty[]) = {NULL};
|
|
|
|
return expand_set_opt_string(args, empty, 0, numMatches, matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'lispoptions' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_lispoptions(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (**varp != NUL
|
|
|
|
&& STRCMP(*varp, "expr:0") != 0
|
|
|
|
&& STRCMP(*varp, "expr:1") != 0)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_lispoptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
static char *(p_lop_values[]) = {"expr:0", "expr:1", NULL};
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_lop_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_lop_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'matchpairs' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_matchpairs(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *p;
|
|
|
|
|
|
|
|
if (has_mbyte)
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
for (p = *varp; *p != NUL; ++p)
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
|
|
|
int x2 = -1;
|
|
|
|
int x3 = -1;
|
|
|
|
|
|
|
|
p += mb_ptr2len(p);
|
|
|
|
if (*p != NUL)
|
|
|
|
x2 = *p++;
|
|
|
|
if (*p != NUL)
|
|
|
|
{
|
|
|
|
x3 = mb_ptr2char(p);
|
|
|
|
p += mb_ptr2len(p);
|
|
|
|
}
|
|
|
|
if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
|
|
|
|
return e_invalid_argument;
|
|
|
|
if (*p == NUL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Check for "x:y,x:y"
|
2023-03-03 12:26:15 +00:00
|
|
|
for (p = *varp; *p != NUL; p += 4)
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
|
|
|
if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
|
|
|
|
return e_invalid_argument;
|
|
|
|
if (p[3] == NUL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-12-06 17:26:25 +01:00
|
|
|
/*
|
|
|
|
* Process the updated 'messagesopt' option value.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_messagesopt(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
if (messagesopt_changed() == FAIL)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_messagesopt(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
2024-12-07 16:09:08 +01:00
|
|
|
static char *(p_mopt_values[]) = {"hit-enter", "wait:", "history:", NULL};
|
2024-12-06 17:26:25 +01:00
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
2024-12-07 16:09:08 +01:00
|
|
|
p_mopt_values,
|
|
|
|
ARRAY_LENGTH(p_mopt_values) - 1,
|
2024-12-06 17:26:25 +01:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_SPELL) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'mkspellmem' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_mkspellmem(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (spell_check_msm() != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'mouse' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_mouse(optset_T *args)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-11-29 11:34:05 +01:00
|
|
|
return did_set_option_listflag(*varp, (char_u *)MOUSE_ALL, args->os_errbuf,
|
|
|
|
args->os_errbuflen);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_mouse(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_listflag(args, (char_u*)MOUSE_ALL, numMatches, matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'mousemodel' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_mousemodel(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
|
2023-12-19 20:12:29 +01:00
|
|
|
else if (*p_mousem != *args->os_oldval.string)
|
2023-03-01 12:44:06 +00:00
|
|
|
// Changed from "extend" to "popup" or "popup_setpos" or vv: need
|
|
|
|
// to create or delete the popup menus.
|
|
|
|
gui_motif_update_mousemodel(root_menu);
|
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_mousemodel(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_mousem_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_mousem_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_MOUSESHAPE) || defined(PROTO)
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_mouseshape(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char *errmsg = NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
errmsg = parse_shape_opt(SHAPE_MOUSE);
|
|
|
|
update_mouseshape(-1);
|
|
|
|
|
|
|
|
return errmsg;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'nrformats' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_nrformats(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
return did_set_opt_strings(*varp, p_nf_values, TRUE);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_nrformats(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_nf_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_nf_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* One of the '*expr' options is changed: 'balloonexpr', 'diffexpr',
|
2024-11-02 18:40:10 +01:00
|
|
|
* 'foldexpr', 'foldtext', 'formatexpr', 'includeexpr', 'indentexpr',
|
|
|
|
* 'patchexpr', 'printexpr' and 'charconvert'.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_optexpr(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// If the option value starts with <SID> or s:, then replace that with
|
|
|
|
// the script identifier.
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u *name = get_scriptlocal_funcname(*varp);
|
2023-03-01 12:44:06 +00:00
|
|
|
if (name != NULL)
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
free_string_option(*varp);
|
|
|
|
*varp = name;
|
2023-03-01 12:44:06 +00:00
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'pastetoggle' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_pastetoggle(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *p;
|
|
|
|
|
|
|
|
// translate key codes like in a mapping
|
|
|
|
if (*p_pt)
|
|
|
|
{
|
2023-08-11 23:15:38 +02:00
|
|
|
(void)replace_termcodes(p_pt, &p, 0,
|
2023-03-01 12:44:06 +00:00
|
|
|
REPTERM_FROM_PART | REPTERM_DO_LT, NULL);
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
|
|
|
free_string_option(p_pt);
|
|
|
|
p_pt = p;
|
|
|
|
}
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_PROP_POPUP) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'previewpopup' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_previewpopup(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (parse_previewpopup(NULL) == FAIL)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_popupoption(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
expand_T *xp = args->oe_xp;
|
|
|
|
|
|
|
|
if (xp->xp_pattern > args->oe_set_arg && *(xp->xp_pattern-1) == ':')
|
|
|
|
{
|
|
|
|
// Within "highlight:"/"border:"/"align:", we have a subgroup of possible options.
|
2023-10-02 21:38:39 +02:00
|
|
|
int border_len = (int)STRLEN("border:");
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
if (xp->xp_pattern - args->oe_set_arg >= border_len &&
|
|
|
|
STRNCMP(xp->xp_pattern - border_len, "border:", border_len) == 0)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_popup_option_border_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_popup_option_border_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-10-02 21:38:39 +02:00
|
|
|
int align_len = (int)STRLEN("align:");
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
if (xp->xp_pattern - args->oe_set_arg >= align_len &&
|
|
|
|
STRNCMP(xp->xp_pattern - align_len, "align:", align_len) == 0)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_popup_option_align_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_popup_option_align_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-10-02 21:38:39 +02:00
|
|
|
int highlight_len = (int)STRLEN("highlight:");
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
if (xp->xp_pattern - args->oe_set_arg >= highlight_len &&
|
|
|
|
STRNCMP(xp->xp_pattern - highlight_len, "highlight:", highlight_len) == 0)
|
|
|
|
{
|
|
|
|
// Return the list of all highlight names
|
|
|
|
return expand_set_opt_generic(
|
|
|
|
args,
|
|
|
|
get_highlight_name,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_popup_option_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_popup_option_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_POSTSCRIPT) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'printencoding' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_printencoding(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *s, *p;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// Canonize 'printencoding' if VIM standard one
|
|
|
|
p = enc_canonize(p_penc);
|
|
|
|
if (p != NULL)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
vim_free(p_penc);
|
|
|
|
p_penc = p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Ensure lower case and '-' for '_'
|
|
|
|
for (s = p_penc; *s != NUL; s++)
|
|
|
|
{
|
|
|
|
if (*s == '_')
|
|
|
|
*s = '-';
|
|
|
|
else
|
|
|
|
*s = TOLOWER_ASC(*s);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
#if defined(FEAT_PRINTER) || defined(PROTO)
|
|
|
|
|
|
|
|
static char_u *
|
|
|
|
get_printoptions_names(expand_T *xp UNUSED, int idx)
|
|
|
|
{
|
2023-10-02 21:38:39 +02:00
|
|
|
if (idx >= (int)ARRAY_LENGTH(printer_opts))
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
return NULL;
|
|
|
|
return (char_u*)printer_opts[idx].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expand 'printoptions' option
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
expand_set_printoptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_generic(
|
|
|
|
args,
|
|
|
|
get_printoptions_names,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-02-25 11:59:33 +00:00
|
|
|
#if defined(FEAT_STL_OPT) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'statusline' or the 'tabline' or the 'rulerformat' option is changed.
|
2023-02-20 12:16:39 +00:00
|
|
|
* "rulerformat" is TRUE if the 'rulerformat' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
|
|
|
static char *
|
2023-03-01 12:44:06 +00:00
|
|
|
parse_statustabline_rulerformat(optset_T *args, int rulerformat)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-01-30 13:04:42 +00:00
|
|
|
char_u *s;
|
|
|
|
char *errmsg = NULL;
|
|
|
|
int wid;
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
if (rulerformat) // reset ru_wid first
|
2023-01-30 13:04:42 +00:00
|
|
|
ru_wid = 0;
|
2023-03-03 12:26:15 +00:00
|
|
|
s = *varp;
|
2023-02-20 12:16:39 +00:00
|
|
|
if (rulerformat && *s == '%')
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
// set ru_wid if 'ruf' starts with "%99("
|
|
|
|
if (*++s == '-') // ignore a '-'
|
|
|
|
s++;
|
|
|
|
wid = getdigits(&s);
|
|
|
|
if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
|
|
|
|
ru_wid = wid;
|
|
|
|
else
|
2024-11-27 20:55:45 +01:00
|
|
|
{
|
|
|
|
// Validate the flags in 'rulerformat' only if it doesn't point to
|
|
|
|
// a custom function ("%!" flag).
|
|
|
|
if ((*varp)[1] != '!')
|
|
|
|
errmsg = check_stl_option(p_ruf);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
// check 'statusline' or 'tabline' only if it doesn't start with "%!"
|
2023-02-20 12:16:39 +00:00
|
|
|
else if (rulerformat || s[0] != '%' || s[1] != '!')
|
2023-01-30 13:04:42 +00:00
|
|
|
errmsg = check_stl_option(s);
|
2023-02-20 12:16:39 +00:00
|
|
|
if (rulerformat && errmsg == NULL)
|
2023-01-30 13:04:42 +00:00
|
|
|
comp_col();
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-20 12:16:39 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_RENDER_OPTIONS) || defined(PROTO)
|
2023-02-20 12:16:39 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'renderoptions' option is changed.
|
2023-02-20 12:16:39 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_renderoptions(optset_T *args UNUSED)
|
2023-02-20 12:16:39 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (!gui_mch_set_rendering_options(p_rop))
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
2023-02-20 12:16:39 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-20 12:16:39 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_RIGHTLEFT) || defined(PROTO)
|
2023-02-20 12:16:39 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'rightleftcmd' option is changed.
|
2023-02-20 12:16:39 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_rightleftcmd(optset_T *args)
|
2023-02-20 12:16:39 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// Currently only "search" is a supported value.
|
2023-03-03 12:26:15 +00:00
|
|
|
if (**varp != NUL && STRCMP(*varp, "search") != 0)
|
2023-03-01 12:44:06 +00:00
|
|
|
return e_invalid_argument;
|
2023-02-20 12:16:39 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_rightleftcmd(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
static char *(p_rlc_values[]) = {"search", NULL};
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_rlc_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_rlc_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-20 12:16:39 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_STL_OPT) || defined(PROTO)
|
2023-02-20 12:16:39 +00:00
|
|
|
/*
|
|
|
|
* The 'rulerformat' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_rulerformat(optset_T *args)
|
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return parse_statustabline_rulerformat(args, TRUE);
|
2023-02-20 12:16:39 +00:00
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'scrollopt' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-25 11:59:33 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_scrollopt(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(p_sbo, p_scbopt_values, TRUE);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_scrollopt(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_scbopt_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_scbopt_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'selection' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_selection(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-04 19:57:32 +00:00
|
|
|
if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_selection(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_sel_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_sel_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-31 13:25:58 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'selectmode' option is changed.
|
2023-01-31 13:25:58 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_selectmode(optset_T *args UNUSED)
|
2023-01-31 13:25:58 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(p_slm, p_slm_values, TRUE);
|
2023-01-31 13:25:58 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_selectmode(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_slm_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_slm_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_SESSION) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'sessionoptions' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_sessionoptions(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
2023-03-01 12:44:06 +00:00
|
|
|
if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
|
|
|
|
{
|
|
|
|
// Don't allow both "sesdir" and "curdir".
|
|
|
|
(void)opt_strings_flags(args->os_oldval.string, p_ssop_values,
|
|
|
|
&ssop_flags, TRUE);
|
|
|
|
return e_invalid_argument;
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_sessionoptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_ssop_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_ssop_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'shortmess' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_shortmess(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-11-29 11:34:05 +01:00
|
|
|
return did_set_option_listflag(*varp, (char_u *)SHM_ALL, args->os_errbuf,
|
|
|
|
args->os_errbuflen);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_shortmess(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_listflag(args, (char_u*)SHM_ALL, numMatches, matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_LINEBREAK) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'showbreak' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_showbreak(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *s;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
for (s = *varp; *s; )
|
2023-03-01 12:44:06 +00:00
|
|
|
{
|
|
|
|
if (ptr2cells(s) != 1)
|
|
|
|
return e_showbreak_contains_unprintable_or_wide_character;
|
|
|
|
MB_PTR_ADV(s);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'showcmdloc' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_showcmdloc(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2024-03-01 23:01:43 +01:00
|
|
|
char *errmsg = did_set_opt_strings(p_sloc, p_sloc_values, FALSE);
|
|
|
|
|
|
|
|
if (errmsg == NULL)
|
|
|
|
comp_col();
|
|
|
|
|
|
|
|
return errmsg;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_showcmdloc(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_sloc_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_sloc_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_SIGNS) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'signcolumn' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_signcolumn(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
2023-03-01 12:44:06 +00:00
|
|
|
// When changing the 'signcolumn' to or from 'number', recompute the
|
|
|
|
// width of the number column if 'number' or 'relativenumber' is set.
|
|
|
|
if (((*args->os_oldval.string == 'n' && args->os_oldval.string[1] == 'u')
|
|
|
|
|| (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) =='u'))
|
|
|
|
&& (curwin->w_p_nu || curwin->w_p_rnu))
|
|
|
|
curwin->w_nrwidth_line_count = 0;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_signcolumn(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_scl_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_scl_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_SPELL) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'spellcapcheck' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_spellcapcheck(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
// compile the regexp program.
|
|
|
|
return compile_cap_prog(curwin->w_s);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'spellfile' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_spellfile(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (!valid_spellfile(*varp))
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// If there is a window for this buffer in which 'spell' is set load the
|
|
|
|
// wordlists.
|
2024-10-14 20:21:48 +02:00
|
|
|
return did_set_spell_option();
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'spell' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_spelllang(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (!valid_spelllang(*varp))
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// If there is a window for this buffer in which 'spell' is set load the
|
|
|
|
// wordlists.
|
2024-10-14 20:21:48 +02:00
|
|
|
return did_set_spell_option();
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'spelloptions' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_spelloptions(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
2023-03-04 19:57:32 +00:00
|
|
|
if (**varp != NUL && STRCMP(*varp, "camel") != 0)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_spelloptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
static char *(p_spo_values[]) = {"camel", NULL};
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_spo_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_spo_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'spellsuggest' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_spellsuggest(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (spell_check_sps() != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_spellsuggest(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_sps_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_sps_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 'splitkeep' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_splitkeep(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
return did_set_opt_strings(p_spk, p_spk_values, FALSE);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_splitkeep(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_spk_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_spk_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_STL_OPT) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'statusline' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_statusline(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return parse_statustabline_rulerformat(args, FALSE);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'swapsync' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_swapsync(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(p_sws, p_sws_values, FALSE);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
2023-02-23 15:05:22 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_swapsync(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_sws_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_sws_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'switchbuf' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_switchbuf(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, TRUE);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_switchbuf(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_swb_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_swb_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2024-07-12 19:30:58 +02:00
|
|
|
/*
|
|
|
|
* The 'tabclose' option is changed.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_tabclose(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
return did_set_opt_flags(p_tcl, p_tcl_values, &tcl_flags, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_tabclose(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_tcl_values,
|
|
|
|
ARRAY_LENGTH(p_tcl_values) - 1,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_STL_OPT) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'tabline' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_tabline(optset_T *args)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return parse_statustabline_rulerformat(args, FALSE);
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'tagcase' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_tagcase(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
unsigned int *flags;
|
|
|
|
char_u *p;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
if (args->os_flags & OPT_LOCAL)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
p = curbuf->b_p_tc;
|
|
|
|
flags = &curbuf->b_tc_flags;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
p = p_tc;
|
|
|
|
flags = &tc_flags;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
if ((args->os_flags & OPT_LOCAL) && *p == NUL)
|
|
|
|
// 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)
|
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_tagcase(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_tc_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_tc_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'term' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-03-04 19:57:32 +00:00
|
|
|
char *
|
|
|
|
did_set_term(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (T_NAME[0] == NUL)
|
2023-03-04 19:57:32 +00:00
|
|
|
return e_cannot_set_term_to_empty_string;
|
2023-03-01 12:44:06 +00:00
|
|
|
#ifdef FEAT_GUI
|
2023-03-04 19:57:32 +00:00
|
|
|
if (gui.in_use)
|
|
|
|
return e_cannot_change_term_in_GUI;
|
|
|
|
if (term_is_gui(T_NAME))
|
|
|
|
return e_use_gui_to_start_GUI;
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-03-04 19:57:32 +00:00
|
|
|
if (set_termname(T_NAME) == FAIL)
|
|
|
|
return e_not_found_in_termcap;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-04 19:57:32 +00:00
|
|
|
// Screen colors may have changed.
|
|
|
|
redraw_later_clear();
|
|
|
|
|
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* Some terminal option (t_xxx) is changed
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-03-03 12:26:15 +00:00
|
|
|
char *
|
|
|
|
did_set_term_option(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if (!full_screen)
|
|
|
|
return NULL;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// ":set t_Co=0" and ":set t_Co=1" do ":set t_Co="
|
|
|
|
if (varp == &T_CCO)
|
|
|
|
{
|
|
|
|
int colors = atoi((char *)T_CCO);
|
2023-02-20 12:16:39 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
// Only reinitialize colors if t_Co value has really changed to
|
|
|
|
// avoid expensive reload of colorscheme if t_Co is set to the
|
|
|
|
// same value multiple times.
|
|
|
|
if (colors != t_colors)
|
|
|
|
{
|
|
|
|
t_colors = colors;
|
|
|
|
if (t_colors <= 1)
|
|
|
|
{
|
|
|
|
vim_free(T_CCO);
|
|
|
|
T_CCO = empty_option;
|
|
|
|
}
|
|
|
|
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
|
|
|
|
if (is_term_win32())
|
|
|
|
{
|
|
|
|
swap_tcap();
|
2023-03-03 12:26:15 +00:00
|
|
|
args->os_did_swaptcap = TRUE;
|
2023-03-01 12:44:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// We now have a different color setup, initialize it again.
|
|
|
|
init_highlight(TRUE, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ttest(FALSE);
|
|
|
|
if (varp == &T_ME)
|
|
|
|
{
|
|
|
|
out_str(T_ME);
|
|
|
|
redraw_later(UPD_CLEAR);
|
|
|
|
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
|
|
|
|
// Since t_me has been set, this probably means that the user
|
|
|
|
// wants to use this as default colors. Need to reset default
|
|
|
|
// background/foreground colors.
|
|
|
|
# ifdef VIMDLL
|
|
|
|
if (!gui.in_use && !gui.starting)
|
|
|
|
# endif
|
|
|
|
mch_set_normal_colors();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if (varp == &T_BE && termcap_active)
|
|
|
|
{
|
|
|
|
MAY_WANT_TO_LOG_THIS;
|
|
|
|
|
|
|
|
if (*T_BE == NUL)
|
|
|
|
// When clearing t_BE we assume the user no longer wants
|
|
|
|
// bracketed paste, thus disable it by writing t_BD.
|
|
|
|
out_str(T_BD);
|
|
|
|
else
|
|
|
|
out_str(T_BE);
|
|
|
|
}
|
2023-03-03 12:26:15 +00:00
|
|
|
|
|
|
|
return NULL;
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_TERMINAL) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'termwinkey' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2024-10-22 22:07:52 +02:00
|
|
|
did_set_termwinkey(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2024-10-22 22:07:52 +02:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
|
|
|
if ((*varp)[0] != NUL && string_to_key(*varp, TRUE) == 0)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'termwinsize' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2024-10-22 22:01:46 +02:00
|
|
|
did_set_termwinsize(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2024-10-22 22:01:46 +02:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *p;
|
|
|
|
|
2024-10-22 22:01:46 +02:00
|
|
|
if ((*varp)[0] == NUL)
|
2023-03-01 12:44:06 +00:00
|
|
|
return NULL;
|
|
|
|
|
2024-10-22 22:01:46 +02:00
|
|
|
p = skipdigits(*varp);
|
|
|
|
if (p == *varp || (*p != 'x' && *p != '*') || *skipdigits(p + 1) != NUL)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
# if defined(MSWIN) || defined(PROTO)
|
2023-02-27 12:47:47 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'termwintype' option is changed.
|
2023-02-27 12:47:47 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_termwintype(optset_T *args UNUSED)
|
2023-02-27 12:47:47 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(p_twt, p_twt_values, FALSE);
|
2023-02-27 12:47:47 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_termwintype(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_twt_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_twt_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
# endif
|
2023-02-27 12:47:47 +00:00
|
|
|
#endif
|
|
|
|
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'titlestring' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-27 12:47:47 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_titlestring(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
int flagval = 0;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#ifdef FEAT_STL_OPT
|
|
|
|
flagval = STL_IN_TITLE;
|
|
|
|
#endif
|
|
|
|
return parse_titleiconstring(args, flagval);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if (defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'toolbar' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_toolbar(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-04 19:57:32 +00:00
|
|
|
if (opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags,
|
|
|
|
TRUE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
out_flush();
|
|
|
|
gui_mch_show_toolbar((toolbar_flags &
|
|
|
|
(TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
|
2023-01-30 13:04:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_toolbar(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_toolbar_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_toolbar_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if (defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'toolbariconsize' option is changed. GTK+ 2 only.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-03-01 12:44:06 +00:00
|
|
|
char *
|
|
|
|
did_set_toolbariconsize(optset_T *args UNUSED)
|
|
|
|
{
|
|
|
|
if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
out_flush();
|
|
|
|
gui_mch_show_toolbar((toolbar_flags &
|
|
|
|
(TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
|
2023-01-30 13:04:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_toolbariconsize(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_tbis_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_tbis_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-23 15:05:22 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(UNIX) || defined(VMS) || defined(PROTO)
|
2023-02-23 15:05:22 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'ttymouse' option is changed.
|
2023-02-23 15:05:22 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_ttymouse(optset_T *args UNUSED)
|
2023-02-23 15:05:22 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char *errmsg = NULL;
|
|
|
|
|
|
|
|
// Switch the mouse off before changing the escape sequences used for
|
|
|
|
// that.
|
|
|
|
mch_setmouse(FALSE);
|
|
|
|
if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
|
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
else
|
|
|
|
check_mouse_termcode();
|
|
|
|
if (termcap_active)
|
|
|
|
setmouse(); // may switch it on again
|
|
|
|
|
|
|
|
return errmsg;
|
2023-02-23 15:05:22 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_ttymouse(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_ttym_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_ttym_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
2023-02-20 12:16:39 +00:00
|
|
|
#if defined(FEAT_VARTABS) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
|
|
|
* The 'varsofttabstop' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_varsofttabstop(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-01-30 13:04:42 +00:00
|
|
|
char_u *cp;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
if (!((*varp)[0]) || ((*varp)[0] == '0' && !((*varp)[1])))
|
2023-03-07 17:45:11 +00:00
|
|
|
VIM_CLEAR(curbuf->b_p_vsts_array);
|
2023-01-30 13:04:42 +00:00
|
|
|
else
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
for (cp = *varp; *cp; ++cp)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
if (vim_isdigit(*cp))
|
|
|
|
continue;
|
2023-03-03 12:26:15 +00:00
|
|
|
if (*cp == ',' && cp > *varp && *(cp-1) != ',')
|
2023-01-30 13:04:42 +00:00
|
|
|
continue;
|
|
|
|
return e_invalid_argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
int *oldarray = curbuf->b_p_vsts_array;
|
2023-03-03 12:26:15 +00:00
|
|
|
if (tabstop_set(*varp, &(curbuf->b_p_vsts_array)) == OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
if (oldarray)
|
|
|
|
vim_free(oldarray);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return e_invalid_argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 'vartabstop' option is changed.
|
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
|
|
|
did_set_vartabstop(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
2023-01-30 13:04:42 +00:00
|
|
|
char_u *cp;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
if (!((*varp)[0]) || ((*varp)[0] == '0' && !((*varp)[1])))
|
2023-03-07 17:45:11 +00:00
|
|
|
VIM_CLEAR(curbuf->b_p_vts_array);
|
2023-01-30 13:04:42 +00:00
|
|
|
else
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
for (cp = *varp; *cp; ++cp)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
if (vim_isdigit(*cp))
|
|
|
|
continue;
|
2023-03-03 12:26:15 +00:00
|
|
|
if (*cp == ',' && cp > *varp && *(cp-1) != ',')
|
2023-01-30 13:04:42 +00:00
|
|
|
continue;
|
|
|
|
return e_invalid_argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
int *oldarray = curbuf->b_p_vts_array;
|
|
|
|
|
2023-03-03 12:26:15 +00:00
|
|
|
if (tabstop_set(*varp, &(curbuf->b_p_vts_array)) == OK)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
|
|
|
vim_free(oldarray);
|
|
|
|
# ifdef FEAT_FOLDING
|
|
|
|
if (foldmethodIsIndent(curwin))
|
|
|
|
foldUpdateAll(curwin);
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return e_invalid_argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'verbosefile' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_verbosefile(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
verbose_stop();
|
|
|
|
if (*p_vfile != NUL && verbose_open() == FAIL)
|
2023-01-30 13:04:42 +00:00
|
|
|
return e_invalid_argument;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_SESSION) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'viewoptions' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-20 12:16:39 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_viewoptions(optset_T *args UNUSED)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_VIMINFO) || defined(PROTO)
|
2023-01-30 13:04:42 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'viminfo' option is changed.
|
2023-01-30 13:04:42 +00:00
|
|
|
*/
|
2023-02-25 11:59:33 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_viminfo(optset_T *args)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *s;
|
|
|
|
char *errmsg = NULL;
|
|
|
|
|
|
|
|
for (s = p_viminfo; *s;)
|
2023-01-30 13:04:42 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
// Check it's a valid character
|
|
|
|
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
|
|
|
|
{
|
2023-11-29 11:34:05 +01:00
|
|
|
errmsg = illegal_char(args->os_errbuf, args->os_errbuflen, *s);
|
2023-03-01 12:44:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*s == 'n') // name is always last one
|
|
|
|
break;
|
|
|
|
else if (*s == 'r') // skip until next ','
|
|
|
|
{
|
|
|
|
while (*++s && *s != ',')
|
|
|
|
;
|
|
|
|
}
|
|
|
|
else if (*s == '%')
|
|
|
|
{
|
|
|
|
// optional number
|
|
|
|
while (vim_isdigit(*++s))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
else if (*s == '!' || *s == 'h' || *s == 'c')
|
|
|
|
++s; // no extra chars
|
|
|
|
else // must have a number
|
|
|
|
{
|
|
|
|
while (vim_isdigit(*++s))
|
|
|
|
;
|
|
|
|
|
|
|
|
if (!VIM_ISDIGIT(*(s - 1)))
|
|
|
|
{
|
|
|
|
if (args->os_errbuf != NULL)
|
|
|
|
{
|
2023-12-05 16:04:23 +01:00
|
|
|
vim_snprintf(args->os_errbuf, args->os_errbuflen,
|
2023-03-01 12:44:06 +00:00
|
|
|
_(e_missing_number_after_angle_str_angle),
|
|
|
|
transchar_byte(*(s - 1)));
|
|
|
|
errmsg = args->os_errbuf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
errmsg = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*s == ',')
|
|
|
|
++s;
|
|
|
|
else if (*s)
|
|
|
|
{
|
|
|
|
if (args->os_errbuf != NULL)
|
|
|
|
errmsg = e_missing_comma;
|
|
|
|
else
|
|
|
|
errmsg = "";
|
|
|
|
break;
|
|
|
|
}
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
|
|
|
|
errmsg = e_must_specify_a_value;
|
2023-01-30 13:04:42 +00:00
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
return errmsg;
|
2023-02-25 11:59:33 +00:00
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-25 11:59:33 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'virtualedit' option is changed.
|
2023-02-25 11:59:33 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_virtualedit(optset_T *args)
|
2023-02-25 11:59:33 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char_u *ve = p_ve;
|
|
|
|
unsigned int *flags = &ve_flags;
|
|
|
|
|
|
|
|
if (args->os_flags & OPT_LOCAL)
|
|
|
|
{
|
|
|
|
ve = curwin->w_p_ve;
|
|
|
|
flags = &curwin->w_ve_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((args->os_flags & OPT_LOCAL) && *ve == NUL)
|
|
|
|
// make the local value empty: use the global value
|
|
|
|
*flags = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (opt_strings_flags(ve, p_ve_values, flags, TRUE) != OK)
|
|
|
|
return e_invalid_argument;
|
|
|
|
else if (STRCMP(ve, args->os_oldval.string) != 0)
|
|
|
|
{
|
|
|
|
// Recompute cursor position in case the new 've' setting
|
|
|
|
// changes something.
|
|
|
|
validate_virtcol();
|
|
|
|
coladvance(curwin->w_virtcol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-25 11:59:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_virtualedit(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_ve_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_ve_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-02-25 11:59:33 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'whichwrap' option is changed.
|
2023-02-25 11:59:33 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_whichwrap(optset_T *args)
|
2023-02-25 11:59:33 +00:00
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
char_u **varp = (char_u **)args->os_varp;
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
// Add ',' to the list flags because 'whichwrap' is a flag
|
|
|
|
// list that is comma-separated.
|
2023-11-29 11:34:05 +01:00
|
|
|
return did_set_option_listflag(*varp, (char_u *)(WW_ALL ","),
|
|
|
|
args->os_errbuf, args->os_errbuflen);
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_whichwrap(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_listflag(args, (char_u*)WW_ALL, numMatches, matches);
|
2023-01-30 13:04:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-31 13:25:58 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'wildmode' option is changed.
|
2023-01-31 13:25:58 +00:00
|
|
|
*/
|
2023-02-25 11:59:33 +00:00
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_wildmode(optset_T *args UNUSED)
|
2023-01-31 13:25:58 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
if (check_opt_wim() == FAIL)
|
|
|
|
return e_invalid_argument;
|
|
|
|
return NULL;
|
2023-02-25 11:59:33 +00:00
|
|
|
}
|
2023-01-31 13:25:58 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_wildmode(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_wim_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_wim_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-02-25 11:59:33 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'wildoptions' option is changed.
|
2023-02-25 11:59:33 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_wildoptions(optset_T *args UNUSED)
|
2023-02-25 11:59:33 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
return did_set_opt_strings(p_wop, p_wop_values, TRUE);
|
2023-02-25 11:59:33 +00:00
|
|
|
}
|
2023-01-31 13:25:58 +00:00
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_wildoptions(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_wop_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_wop_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:44:06 +00:00
|
|
|
#if defined(FEAT_WAK) || defined(PROTO)
|
2023-02-25 11:59:33 +00:00
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'winaltkeys' option is changed.
|
2023-02-25 11:59:33 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_winaltkeys(optset_T *args UNUSED)
|
2023-02-25 11:59:33 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
char *errmsg = NULL;
|
2023-02-25 11:59:33 +00:00
|
|
|
|
2023-03-04 19:57:32 +00:00
|
|
|
if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
|
2023-03-01 12:44:06 +00:00
|
|
|
errmsg = e_invalid_argument;
|
|
|
|
# ifdef FEAT_MENU
|
|
|
|
# if defined(FEAT_GUI_MOTIF)
|
|
|
|
else if (gui.in_use)
|
|
|
|
gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
|
|
|
|
# elif defined(FEAT_GUI_GTK)
|
|
|
|
else if (gui.in_use)
|
|
|
|
gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
return errmsg;
|
2023-02-25 11:59:33 +00:00
|
|
|
}
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
expand_set_winaltkeys(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_string(
|
|
|
|
args,
|
|
|
|
p_wak_values,
|
2023-10-02 21:38:39 +02:00
|
|
|
ARRAY_LENGTH(p_wak_values) - 1,
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
2023-03-01 12:44:06 +00:00
|
|
|
#endif
|
2023-02-25 11:59:33 +00:00
|
|
|
|
|
|
|
/*
|
2023-03-01 12:44:06 +00:00
|
|
|
* The 'wincolor' option is changed.
|
2023-02-25 11:59:33 +00:00
|
|
|
*/
|
|
|
|
char *
|
2023-03-01 12:44:06 +00:00
|
|
|
did_set_wincolor(optset_T *args UNUSED)
|
2023-02-25 11:59:33 +00:00
|
|
|
{
|
2023-03-01 12:44:06 +00:00
|
|
|
#ifdef FEAT_TERMINAL
|
|
|
|
term_update_wincolor(curwin);
|
|
|
|
#endif
|
|
|
|
return NULL;
|
2023-01-31 13:25:58 +00:00
|
|
|
}
|
|
|
|
|
patch 9.0.1958: cannot complete option values
Problem: cannot complete option values
Solution: Add completion functions for several options
Add cmdline tab-completion for setting string options
Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).
The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.
For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.
For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.
For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.
Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.
closes: #13182
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29 20:42:32 +02:00
|
|
|
int
|
|
|
|
expand_set_wincolor(optexpand_T *args, int *numMatches, char_u ***matches)
|
|
|
|
{
|
|
|
|
return expand_set_opt_generic(
|
|
|
|
args,
|
|
|
|
get_highlight_name,
|
|
|
|
numMatches,
|
|
|
|
matches);
|
|
|
|
}
|
|
|
|
|
2023-01-31 13:25:58 +00:00
|
|
|
#ifdef FEAT_SYN_HL
|
|
|
|
/*
|
|
|
|
* When the 'syntax' option is set, load the syntax of that name.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
do_syntax_autocmd(int value_changed)
|
|
|
|
{
|
|
|
|
static int syn_recursive = 0;
|
|
|
|
|
|
|
|
++syn_recursive;
|
|
|
|
// Only pass TRUE for "force" when the value changed or not used
|
|
|
|
// recursively, to avoid endless recurrence.
|
|
|
|
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
|
|
|
|
value_changed || syn_recursive == 1, curbuf);
|
|
|
|
curbuf->b_flags |= BF_SYN_SET;
|
|
|
|
--syn_recursive;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When the 'filetype' option is set, trigger the FileType autocommand.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
do_filetype_autocmd(char_u **varp, int opt_flags, int value_changed)
|
|
|
|
{
|
|
|
|
// Skip this when called from a modeline and the filetype was already set
|
|
|
|
// to this value.
|
|
|
|
if ((opt_flags & OPT_MODELINE) && !value_changed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
static int ft_recursive = 0;
|
|
|
|
int secure_save = secure;
|
|
|
|
|
|
|
|
// Reset the secure flag, since the value of 'filetype' has
|
|
|
|
// been checked to be safe.
|
|
|
|
secure = 0;
|
|
|
|
|
|
|
|
++ft_recursive;
|
2024-03-31 18:41:27 +02:00
|
|
|
curbuf->b_did_filetype = TRUE;
|
2023-01-31 13:25:58 +00:00
|
|
|
// Only pass TRUE for "force" when the value changed or not
|
|
|
|
// used recursively, to avoid endless recurrence.
|
|
|
|
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname,
|
|
|
|
value_changed || ft_recursive == 1, curbuf);
|
|
|
|
--ft_recursive;
|
|
|
|
// Just in case the old "curbuf" is now invalid.
|
|
|
|
if (varp != &(curbuf->b_p_ft))
|
|
|
|
varp = NULL;
|
|
|
|
|
|
|
|
secure = secure_save;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef FEAT_SPELL
|
|
|
|
/*
|
|
|
|
* When the 'spelllang' option is set, source the spell/LANG.vim file in
|
|
|
|
* 'runtimepath'.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
do_spelllang_source(void)
|
|
|
|
{
|
|
|
|
char_u fname[200];
|
|
|
|
char_u *p;
|
|
|
|
char_u *q = curwin->w_s->b_p_spl;
|
|
|
|
|
|
|
|
// Skip the first name if it is "cjk".
|
|
|
|
if (STRNCMP(q, "cjk,", 4) == 0)
|
|
|
|
q += 4;
|
|
|
|
|
|
|
|
// They could set 'spellcapcheck' depending on the language. Use the first
|
|
|
|
// name in 'spelllang' up to '_region' or '.encoding'.
|
|
|
|
for (p = q; *p != NUL; ++p)
|
|
|
|
if (!ASCII_ISALNUM(*p) && *p != '-')
|
|
|
|
break;
|
|
|
|
if (p > q)
|
|
|
|
{
|
|
|
|
vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
|
|
|
|
(int)(p - q), q);
|
|
|
|
source_runtime(fname, DIP_ALL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-16 21:06:21 +02:00
|
|
|
/*
|
|
|
|
* Handle string options that need some action to perform when changed.
|
2022-07-27 18:26:03 +01:00
|
|
|
* The new value must be allocated.
|
2023-01-31 13:25:58 +00:00
|
|
|
* Returns NULL for success, or an untranslated error message for an error.
|
2019-09-16 21:06:21 +02:00
|
|
|
*/
|
|
|
|
char *
|
|
|
|
did_set_string_option(
|
|
|
|
int opt_idx, // index in options[] table
|
|
|
|
char_u **varp, // pointer to the option variable
|
|
|
|
char_u *oldval, // previous value of the option
|
2023-02-20 12:16:39 +00:00
|
|
|
char_u *value, // new value of the option
|
2019-09-16 21:06:21 +02:00
|
|
|
char *errbuf, // buffer for errors, or NULL
|
2023-12-05 15:36:06 +01:00
|
|
|
size_t errbuflen, // length of error buffer
|
2019-09-16 21:06:21 +02:00
|
|
|
int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL
|
2023-10-01 09:13:22 +02:00
|
|
|
set_op_T op, // OP_ADDING/OP_PREPENDING/OP_REMOVING
|
2023-01-31 13:25:58 +00:00
|
|
|
int *value_checked) // value was checked to be safe, no
|
2019-09-16 21:06:21 +02:00
|
|
|
// need to set P_INSECURE
|
|
|
|
{
|
|
|
|
char *errmsg = NULL;
|
|
|
|
long_u free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
|
2023-02-20 12:16:39 +00:00
|
|
|
opt_did_set_cb_T did_set_cb = get_option_did_set_cb(opt_idx);
|
2023-03-04 19:57:32 +00:00
|
|
|
optset_T args;
|
|
|
|
|
|
|
|
// 'ttytype' is an alias for 'term'. Both 'term' and 'ttytype' point to
|
|
|
|
// T_NAME. If 'term' or 'ttytype' is modified, then use the index for the
|
|
|
|
// 'term' option. Only set the P_ALLOCED flag on 'term'.
|
|
|
|
if (varp == &T_NAME)
|
|
|
|
{
|
|
|
|
opt_idx = findoption((char_u *)"term");
|
|
|
|
if (opt_idx >= 0)
|
|
|
|
{
|
|
|
|
free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
|
|
|
|
did_set_cb = get_option_did_set_cb(opt_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CLEAR_FIELD(args);
|
2019-09-16 21:06:21 +02:00
|
|
|
|
|
|
|
// Disallow changing some options from secure mode
|
|
|
|
if ((secure
|
|
|
|
#ifdef HAVE_SANDBOX
|
|
|
|
|| sandbox != 0
|
|
|
|
#endif
|
|
|
|
) && (get_option_flags(opt_idx) & P_SECURE))
|
2022-01-01 15:58:22 +00:00
|
|
|
errmsg = e_not_allowed_here;
|
2023-01-31 13:25:58 +00:00
|
|
|
// Check for a "normal" directory or file name in some options.
|
|
|
|
else if (check_illegal_path_names(opt_idx, varp))
|
2021-12-31 22:49:24 +00:00
|
|
|
errmsg = e_invalid_argument;
|
2023-02-20 12:16:39 +00:00
|
|
|
else if (did_set_cb != NULL)
|
|
|
|
{
|
2023-03-03 12:26:15 +00:00
|
|
|
args.os_varp = (char_u *)varp;
|
|
|
|
args.os_idx = opt_idx;
|
2023-02-20 12:16:39 +00:00
|
|
|
args.os_flags = opt_flags;
|
2023-10-01 09:13:22 +02:00
|
|
|
args.os_op = op;
|
2023-02-20 12:16:39 +00:00
|
|
|
args.os_oldval.string = oldval;
|
|
|
|
args.os_newval.string = value;
|
2023-02-25 11:59:33 +00:00
|
|
|
args.os_errbuf = errbuf;
|
2023-11-29 11:34:05 +01:00
|
|
|
args.os_errbuflen = errbuflen;
|
2023-02-27 12:47:47 +00:00
|
|
|
// Invoke the option specific callback function to validate and apply
|
|
|
|
// the new option value.
|
2023-02-20 12:16:39 +00:00
|
|
|
errmsg = did_set_cb(&args);
|
2023-02-27 12:47:47 +00:00
|
|
|
|
|
|
|
// The 'keymap', 'filetype' and 'syntax' option callback functions
|
|
|
|
// may change the os_value_checked field.
|
|
|
|
*value_checked = args.os_value_checked;
|
2023-02-20 12:16:39 +00:00
|
|
|
}
|
2019-09-16 21:06:21 +02:00
|
|
|
|
2023-01-31 13:25:58 +00:00
|
|
|
// If an error is detected, restore the previous value.
|
2019-09-16 21:06:21 +02:00
|
|
|
if (errmsg != NULL)
|
|
|
|
{
|
2022-07-27 18:26:03 +01:00
|
|
|
free_string_option(*varp);
|
2019-09-16 21:06:21 +02:00
|
|
|
*varp = oldval;
|
|
|
|
// When resetting some values, need to act on it.
|
2023-03-04 19:57:32 +00:00
|
|
|
if (args.os_restore_chartab)
|
2019-09-16 21:06:21 +02:00
|
|
|
(void)init_chartab();
|
|
|
|
if (varp == &p_hl)
|
|
|
|
(void)highlight_changed();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef FEAT_EVAL
|
|
|
|
// Remember where the option was set.
|
|
|
|
set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
|
|
|
|
#endif
|
|
|
|
// Free string options that are in allocated memory.
|
|
|
|
// Use "free_oldval", because recursiveness may change the flags under
|
|
|
|
// our fingers (esp. init_highlight()).
|
|
|
|
if (free_oldval)
|
|
|
|
free_string_option(oldval);
|
2022-07-27 18:26:03 +01:00
|
|
|
set_option_flag(opt_idx, P_ALLOCED);
|
2019-09-16 21:06:21 +02:00
|
|
|
|
|
|
|
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
|
|
&& is_global_local_option(opt_idx))
|
|
|
|
{
|
|
|
|
// global option with local value set to use global value; free
|
|
|
|
// the local value and make it empty
|
2023-01-31 13:25:58 +00:00
|
|
|
char_u *p = get_option_varp_scope(opt_idx, OPT_LOCAL);
|
2019-09-16 21:06:21 +02:00
|
|
|
free_string_option(*(char_u **)p);
|
|
|
|
*(char_u **)p = empty_option;
|
|
|
|
}
|
|
|
|
|
|
|
|
// May set global value for local option.
|
|
|
|
else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
|
|
|
|
set_string_option_global(opt_idx, varp);
|
|
|
|
|
|
|
|
// Trigger the autocommand only after setting the flags.
|
|
|
|
#ifdef FEAT_SYN_HL
|
|
|
|
if (varp == &(curbuf->b_p_syn))
|
2023-03-04 19:57:32 +00:00
|
|
|
do_syntax_autocmd(args.os_value_changed);
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
|
|
|
else if (varp == &(curbuf->b_p_ft))
|
2023-03-04 19:57:32 +00:00
|
|
|
do_filetype_autocmd(varp, opt_flags, args.os_value_changed);
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_SPELL
|
|
|
|
if (varp == &(curwin->w_s->b_p_spl))
|
2023-01-31 13:25:58 +00:00
|
|
|
do_spelllang_source();
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (varp == &p_mouse)
|
|
|
|
{
|
|
|
|
if (*p_mouse == NUL)
|
|
|
|
mch_setmouse(FALSE); // switch mouse off
|
|
|
|
else
|
|
|
|
setmouse(); // in case 'mouse' changed
|
|
|
|
}
|
|
|
|
|
2020-05-31 14:08:12 +02:00
|
|
|
if (varp == &p_rtp)
|
2025-02-28 17:34:46 +01:00
|
|
|
{
|
|
|
|
export_myvimdir();
|
|
|
|
#if defined(FEAT_LUA) || defined(PROTO)
|
2020-05-31 14:08:12 +02:00
|
|
|
update_package_paths_in_lua();
|
|
|
|
#endif
|
2025-02-28 17:34:46 +01:00
|
|
|
}
|
2020-05-31 14:08:12 +02:00
|
|
|
|
2022-01-07 16:55:32 +00:00
|
|
|
#if defined(FEAT_LINEBREAK)
|
|
|
|
// Changing Formatlistpattern when briopt includes the list setting:
|
|
|
|
// redraw
|
|
|
|
if ((varp == &p_flp || varp == &(curbuf->b_p_flp))
|
|
|
|
&& curwin->w_briopt_list)
|
2022-08-14 14:17:45 +01:00
|
|
|
redraw_all_later(UPD_NOT_VALID);
|
2022-01-07 16:55:32 +00:00
|
|
|
#endif
|
|
|
|
|
2019-09-16 21:06:21 +02:00
|
|
|
if (curwin->w_curswant != MAXCOL
|
2024-02-18 09:33:54 +01:00
|
|
|
&& (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0
|
|
|
|
&& (get_option_flags(opt_idx) & P_HLONLY) == 0)
|
2019-09-16 21:06:21 +02:00
|
|
|
curwin->w_set_curswant = TRUE;
|
|
|
|
|
2021-03-10 13:40:08 +01:00
|
|
|
if ((opt_flags & OPT_NO_REDRAW) == 0)
|
|
|
|
{
|
2019-09-16 21:06:21 +02:00
|
|
|
#ifdef FEAT_GUI
|
2023-02-20 12:16:39 +00:00
|
|
|
// set when changing an option that only requires a redraw in the GUI
|
|
|
|
int redraw_gui_only = FALSE;
|
|
|
|
|
|
|
|
if (varp == &p_go // 'guioptions'
|
|
|
|
|| varp == &p_guifont // 'guifont'
|
|
|
|
# ifdef FEAT_GUI_TABLINE
|
|
|
|
|| varp == &p_gtl // 'guitablabel'
|
|
|
|
|| varp == &p_gtt // 'guitabtooltip'
|
|
|
|
# endif
|
|
|
|
# ifdef FEAT_XFONTSET
|
|
|
|
|| varp == &p_guifontset // 'guifontset'
|
|
|
|
# endif
|
|
|
|
|| varp == &p_guifontwide // 'guifontwide'
|
2024-02-26 22:23:05 +01:00
|
|
|
# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)
|
2023-02-20 12:16:39 +00:00
|
|
|
|| varp == &p_guiligatures // 'guiligatures'
|
|
|
|
# endif
|
|
|
|
)
|
|
|
|
redraw_gui_only = TRUE;
|
|
|
|
|
2021-03-10 13:40:08 +01:00
|
|
|
// check redraw when it's not a GUI option or the GUI is active.
|
|
|
|
if (!redraw_gui_only || gui.in_use)
|
2019-09-16 21:06:21 +02:00
|
|
|
#endif
|
2021-03-10 13:40:08 +01:00
|
|
|
check_redraw(get_option_flags(opt_idx));
|
|
|
|
}
|
2019-09-16 21:06:21 +02:00
|
|
|
|
|
|
|
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
|
2023-03-04 19:57:32 +00:00
|
|
|
if (args.os_did_swaptcap)
|
2019-09-16 21:06:21 +02:00
|
|
|
{
|
|
|
|
set_termname((char_u *)"win32");
|
|
|
|
init_highlight(TRUE, FALSE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return errmsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check an option that can be a range of string values.
|
|
|
|
*
|
|
|
|
* Return OK for correct value, FAIL otherwise.
|
|
|
|
* Empty is always OK.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
check_opt_strings(
|
|
|
|
char_u *val,
|
|
|
|
char **values,
|
|
|
|
int list) // when TRUE: accept a list of values
|
|
|
|
{
|
|
|
|
return opt_strings_flags(val, values, NULL, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle an option that can be a range of string values.
|
|
|
|
* Set a flag in "*flagp" for each string present.
|
|
|
|
*
|
|
|
|
* Return OK for correct value, FAIL otherwise.
|
|
|
|
* Empty is always OK.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
opt_strings_flags(
|
|
|
|
char_u *val, // new value
|
|
|
|
char **values, // array of valid string values
|
|
|
|
unsigned *flagp,
|
|
|
|
int list) // when TRUE: accept a list of values
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
unsigned new_flags = 0;
|
|
|
|
|
|
|
|
while (*val)
|
|
|
|
{
|
|
|
|
for (i = 0; ; ++i)
|
|
|
|
{
|
|
|
|
if (values[i] == NULL) // val not found in values[]
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
len = (int)STRLEN(values[i]);
|
|
|
|
if (STRNCMP(values[i], val, len) == 0
|
|
|
|
&& ((list && val[len] == ',') || val[len] == NUL))
|
|
|
|
{
|
|
|
|
val += len + (val[len] == ',');
|
|
|
|
new_flags |= (1 << i);
|
|
|
|
break; // check next item in val list
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flagp != NULL)
|
|
|
|
*flagp = new_flags;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* return OK if "p" is a valid fileformat name, FAIL otherwise.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
check_ff_value(char_u *p)
|
|
|
|
{
|
|
|
|
return check_opt_strings(p, p_ff_values, FALSE);
|
|
|
|
}
|
2022-12-16 16:41:23 +00:00
|
|
|
|
|
|
|
/*
|
2023-02-20 12:16:39 +00:00
|
|
|
* Save the actual shortmess Flags and clear them temporarily to avoid that
|
|
|
|
* file messages overwrites any output from the following commands.
|
2022-12-16 16:41:23 +00:00
|
|
|
*
|
|
|
|
* Caller must make sure to first call save_clear_shm_value() and then
|
|
|
|
* restore_shm_value() exactly the same number of times.
|
|
|
|
*/
|
|
|
|
void
|
2023-02-21 14:27:41 +00:00
|
|
|
save_clear_shm_value(void)
|
2022-12-16 16:41:23 +00:00
|
|
|
{
|
|
|
|
if (STRLEN(p_shm) >= SHM_LEN)
|
|
|
|
{
|
|
|
|
iemsg(e_internal_error_shortmess_too_long);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (++set_shm_recursive == 1)
|
|
|
|
{
|
|
|
|
STRCPY(shm_buf, p_shm);
|
|
|
|
set_option_value_give_err((char_u *)"shm", 0L, (char_u *)"", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore the shortmess Flags set from the save_clear_shm_value() function.
|
|
|
|
*/
|
|
|
|
void
|
2023-02-21 14:27:41 +00:00
|
|
|
restore_shm_value(void)
|
2022-12-16 16:41:23 +00:00
|
|
|
{
|
|
|
|
if (--set_shm_recursive == 0)
|
|
|
|
{
|
|
|
|
set_option_value_give_err((char_u *)"shm", 0L, shm_buf, 0);
|
|
|
|
vim_memset(shm_buf, 0, SHM_LEN);
|
|
|
|
}
|
|
|
|
}
|
2025-02-28 17:34:46 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Export the environment variable $MYVIMDIR to the first item in runtimepath
|
|
|
|
*/
|
2025-03-01 16:30:33 +01:00
|
|
|
void
|
2025-02-28 17:34:46 +01:00
|
|
|
export_myvimdir()
|
|
|
|
{
|
|
|
|
int dofree = FALSE;
|
|
|
|
char_u *p;
|
|
|
|
char_u *q = p_rtp;
|
|
|
|
char_u *buf = alloc(MAXPATHL);
|
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
(void)copy_option_part(&q, buf, MAXPATHL, ",");
|
|
|
|
|
|
|
|
p = vim_getenv((char_u *)"MYVIMDIR", &dofree);
|
|
|
|
|
|
|
|
if (p == NULL || STRCMP(p, buf) != 0)
|
|
|
|
{
|
|
|
|
add_pathsep(buf);
|
|
|
|
#ifdef MSWIN
|
|
|
|
// normalize path separators
|
|
|
|
for (q = buf; *q != NUL; q++)
|
|
|
|
if (*q == '/')
|
|
|
|
*q = '\\';
|
|
|
|
#endif
|
|
|
|
vim_setenv((char_u *)"MYVIMDIR", buf);
|
|
|
|
}
|
|
|
|
if (dofree)
|
|
|
|
vim_free(p);
|
|
|
|
vim_free(buf);
|
|
|
|
}
|