diff options
author | glepnir <glephunter@gmail.com> | 2024-10-03 06:45:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-03 06:45:01 +0800 |
commit | 6a2f8958e832aebc20cf42d8ade4cb58fe33df9e (patch) | |
tree | e2d5750f75a126a32cc7128ab9c5d1e869b5437a /src/nvim/optionstr.c | |
parent | d3b4772ddcd4c890dc5bc38e1f1b36a08aed0c04 (diff) | |
download | rneovim-6a2f8958e832aebc20cf42d8ade4cb58fe33df9e.tar.gz rneovim-6a2f8958e832aebc20cf42d8ade4cb58fe33df9e.tar.bz2 rneovim-6a2f8958e832aebc20cf42d8ade4cb58fe33df9e.zip |
vim-patch:9.1.0754: fixed order of items in insert-mode completion menu (#30619)
Problem: fixed order of items in insert-mode completion menu
Solution: Introduce the 'completeitemalign' option with default
value "abbr,kind,menu" (glepnir).
Adding an new option `completeitemalign` abbr is `cia` to custom
the complete-item order in popupmenu.
closes: vim/vim#14006
closes: vim/vim#15760
https://github.com/vim/vim/commit/6a89c94a9eeee53481ced1a1260a177bffde4c0f
Diffstat (limited to 'src/nvim/optionstr.c')
-rw-r--r-- | src/nvim/optionstr.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index a9651084b7..c8f19d7ccf 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -995,6 +995,51 @@ int expand_set_complete(optexpand_T *args, int *numMatches, char ***matches) matches); } +/// The 'completeitemalign' option is changed. +const char *did_set_completeitemalign(optset_T *args) +{ + char *p = p_cia; + unsigned new_cia_flags = 0; + bool seen[3] = { false, false, false }; + int count = 0; + char buf[10]; + while (*p) { + copy_option_part(&p, buf, sizeof(buf), ","); + if (count >= 3) { + return e_invarg; + } + if (strequal(buf, "abbr")) { + if (seen[CPT_ABBR]) { + return e_invarg; + } + new_cia_flags = new_cia_flags * 10 + CPT_ABBR; + seen[CPT_ABBR] = true; + count++; + } else if (strequal(buf, "kind")) { + if (seen[CPT_KIND]) { + return e_invarg; + } + new_cia_flags = new_cia_flags * 10 + CPT_KIND; + seen[CPT_KIND] = true; + count++; + } else if (strequal(buf, "menu")) { + if (seen[CPT_MENU]) { + return e_invarg; + } + new_cia_flags = new_cia_flags * 10 + CPT_MENU; + seen[CPT_MENU] = true; + count++; + } else { + return e_invarg; + } + } + if (new_cia_flags == 0 || count != 3) { + return e_invarg; + } + cia_flags = new_cia_flags; + return NULL; +} + /// The 'completeopt' option is changed. const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED) { |