diff options
-rw-r--r-- | runtime/doc/options.txt | 27 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/options.lua | 16 | ||||
-rw-r--r-- | src/nvim/popupmnu.c | 38 |
4 files changed, 37 insertions, 46 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 65981ceff5..4b832a8606 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -4524,20 +4524,6 @@ A jump table for the options with a short description can be found at |Q_op|. global When on a ":" prompt is used in Ex mode. - *'pumheight'* *'ph'* -'pumheight' 'ph' number (default 0) - global - Determines the maximum number of items to show in the popup menu for - Insert mode completion. When zero as much space as available is used. - |ins-completion-menu|. - - *'pumwidth'* *'pw'* -'pumwidth' 'pw' number (default 0) - global - Determines the minium width to use for the popup menu for Insert mode - completion. When zero the default of 15 screen cells is used. - |ins-completion-menu|. - *'pumblend'* *'pb'* 'pumblend' 'pb' number (default 0) global @@ -4554,6 +4540,19 @@ A jump table for the options with a short description can be found at |Q_op|. < UI-dependent. Works best with RGB colors. 'termguicolors' + *'pumheight'* *'ph'* +'pumheight' 'ph' number (default 0) + global + Determines the maximum number of items to show in the popup menu for + Insert mode completion. When zero as much space as available is used. + |ins-completion-menu|. + + *'pumwidth'* *'pw'* +'pumwidth' 'pw' number (default 15) + global + Determines the minium width to use for the popup menu for Insert mode + completion. |ins-completion-menu|. + *'pyxversion'* *'pyx'* 'pyxversion' 'pyx' number (default depends on the build) global diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index b03342b387..fcad6836bf 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -371,9 +371,9 @@ EXTERN long p_columns; // 'columns' EXTERN int p_confirm; // 'confirm' EXTERN int p_cp; // 'compatible' EXTERN char_u *p_cot; // 'completeopt' +EXTERN long p_pb; // 'pumblend' EXTERN long p_ph; // 'pumheight' EXTERN long p_pw; // 'pumwidth' -EXTERN long p_pb; // 'pumblend' EXTERN char_u *p_cpo; // 'cpoptions' EXTERN char_u *p_csprg; // 'cscopeprg' EXTERN int p_csre; // 'cscoperelative' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index e80d8e4cc2..7d080b8d56 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1816,26 +1816,26 @@ return { defaults={if_true={vi=true}} }, { - full_name='pumheight', abbreviation='ph', + full_name='pumblend', abbreviation='pb', type='number', scope={'global'}, vi_def=true, - varname='p_ph', + redraw={'ui_option'}, + varname='p_pb', defaults={if_true={vi=0}} }, { - full_name='pumwidth', abbreviation='pw', + full_name='pumheight', abbreviation='ph', type='number', scope={'global'}, vi_def=true, - varname='p_pw', + varname='p_ph', defaults={if_true={vi=0}} }, { - full_name='pumblend', abbreviation='pb', + full_name='pumwidth', abbreviation='pw', type='number', scope={'global'}, vi_def=true, - redraw={'ui_option'}, - varname='p_pb', - defaults={if_true={vi=0}} + varname='p_pw', + defaults={if_true={vi=15}} }, { full_name='pyxversion', abbreviation='pyx', diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index be585b78de..2ea55c0710 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -82,13 +82,6 @@ static void pum_compute_size(void) } } -// Return the minimum width of the popup menu. -static int pum_get_width(void) - FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT -{ - return p_pw == 0 ? PUM_DEF_WIDTH : (int)p_pw; -} - /// Show the popup menu with items "array[size]". /// "array" must remain valid until pum_undisplay() is called! /// When possible the leftmost character is aligned with screen column "col". @@ -104,7 +97,6 @@ static int pum_get_width(void) void pum_display(pumitem_T *array, int size, int selected, bool array_changed, int cmd_startcol) { - int def_width; int context_lines; int above_row; int below_row; @@ -168,7 +160,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, } } - def_width = pum_get_width(); + int def_width = (int)p_pw; win_T *pvwin = NULL; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { @@ -284,9 +276,9 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, def_width = max_width; } - if ((((col < Columns - pum_get_width()) || (col < Columns - max_width)) + if ((((col < Columns - p_pw) || (col < Columns - max_width)) && !curwin->w_p_rl) - || (curwin->w_p_rl && ((col > pum_get_width()) || (col > max_width)))) { + || (curwin->w_p_rl && ((col > p_pw) || (col > max_width)))) { // align pum column with "col" pum_col = col; @@ -300,18 +292,18 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, } if ((pum_width > max_width + pum_kind_width + pum_extra_width + 1) - && (pum_width > pum_get_width())) { + && (pum_width > p_pw)) { // the width is too much, make it narrower pum_width = max_width + pum_kind_width + pum_extra_width + 1; - if (pum_width < pum_get_width()) { - pum_width = pum_get_width(); + if (pum_width < p_pw) { + pum_width = (int)p_pw; } } - } else if (((col > pum_get_width() || col > max_width) + } else if (((col > p_pw || col > max_width) && !curwin->w_p_rl) || (curwin->w_p_rl - && (col < Columns - pum_get_width() + && (col < Columns - p_pw || col < Columns - max_width))) { // align right pum edge with "col" if (curwin->w_p_rl) { @@ -332,8 +324,8 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, pum_width = pum_col - pum_scrollbar; } - if (pum_width < pum_get_width()) { - pum_width = pum_get_width(); + if (pum_width < p_pw) { + pum_width = (int)p_pw; if (curwin->w_p_rl) { if (pum_width > pum_col) { pum_width = pum_col; @@ -344,10 +336,10 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, } } } else if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 - && pum_width > pum_get_width()) { + && pum_width > p_pw) { pum_width = max_width + pum_kind_width + pum_extra_width + 1; - if (pum_width < pum_get_width()) { - pum_width = pum_get_width(); + if (pum_width < p_pw) { + pum_width = (int)p_pw; } } } else if (Columns < def_width) { @@ -361,9 +353,9 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, assert(Columns - 1 >= INT_MIN); pum_width = (int)(Columns - 1); } else { - if (max_width > pum_get_width()) { + if (max_width > p_pw) { // truncate - max_width = pum_get_width(); + max_width = (int)p_pw; } if (curwin->w_p_rl) { |