From f06af5e66981095f3244f67d1587ce7e9853eb4c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 08:13:58 +0800 Subject: vim-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=` 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: vim/vim#13182 https://github.com/vim/vim/commit/900894b09a95398dfc75599e9f0aa2ea25723384 Co-authored-by: Yee Cheng Chin --- src/nvim/optionstr.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/optionstr.h') diff --git a/src/nvim/optionstr.h b/src/nvim/optionstr.h index 3520cc2061..0993b67c9a 100644 --- a/src/nvim/optionstr.h +++ b/src/nvim/optionstr.h @@ -2,6 +2,7 @@ #define NVIM_OPTIONSTR_H #include "nvim/buffer_defs.h" +#include "nvim/cmdexpand.h" #include "nvim/option_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From 09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 2 Oct 2023 10:45:33 +0800 Subject: refactor: move cmdline completion types to cmdexpand_defs.h (#25465) --- src/nvim/optionstr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/optionstr.h') diff --git a/src/nvim/optionstr.h b/src/nvim/optionstr.h index 0993b67c9a..a481ed1d07 100644 --- a/src/nvim/optionstr.h +++ b/src/nvim/optionstr.h @@ -2,7 +2,7 @@ #define NVIM_OPTIONSTR_H #include "nvim/buffer_defs.h" -#include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/option_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/optionstr.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/optionstr.h') diff --git a/src/nvim/optionstr.h b/src/nvim/optionstr.h index a481ed1d07..03d6f840b4 100644 --- a/src/nvim/optionstr.h +++ b/src/nvim/optionstr.h @@ -1,5 +1,4 @@ -#ifndef NVIM_OPTIONSTR_H -#define NVIM_OPTIONSTR_H +#pragma once #include "nvim/buffer_defs.h" #include "nvim/cmdexpand_defs.h" @@ -8,4 +7,3 @@ #ifdef INCLUDE_GENERATED_DECLARATIONS # include "optionstr.h.generated.h" #endif -#endif // NVIM_OPTIONSTR_H -- cgit From 574d25642fc9ca65b396633aeab6e2d32778b642 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 17:21:58 +0800 Subject: refactor: move Arena and ArenaMem to memory_defs.h (#26240) --- src/nvim/optionstr.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim/optionstr.h') diff --git a/src/nvim/optionstr.h b/src/nvim/optionstr.h index 03d6f840b4..b317e55b7e 100644 --- a/src/nvim/optionstr.h +++ b/src/nvim/optionstr.h @@ -1,8 +1,10 @@ #pragma once -#include "nvim/buffer_defs.h" -#include "nvim/cmdexpand_defs.h" -#include "nvim/option_defs.h" +#include // IWYU pragma: keep + +#include "nvim/buffer_defs.h" // IWYU pragma: keep +#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep +#include "nvim/option_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "optionstr.h.generated.h" -- cgit