diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 9a2cdbbba5..96c20ea290 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -44,7 +44,11 @@ DIAGNOSTICS OPTIONS -• todo +• When |ui2| is enabled, since the ruler is no longer a left-aligned box of + fixed width, there is no longer an inconsistent special handling of item + groups in 'rulerformat' to configure that fixed width. An old-style left- + aligned fixed-width ruler can now be achieved by using item groups exactly + as they are documented, e.g. `%-20.20(...%)`. TREESITTER diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d3a1923d6f..6612af2fbb 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5169,6 +5169,13 @@ A jump table for the options with a short description can be found at |Q_op|. Example: >vim set rulerformat=%15(%c%V\ %p%%%) < + This looks like an item group, but there are some differences in this + particular case. Most notably, the width is fixed and not a minimum, + and the ruler is left-aligned, whereas the alignment of item groups is + configurable and right-aligned by default. + + When |ui2| is enabled, the ruler no longer has a fixed width and the + item group syntax has no special meaning for 'rulerformat'. *'runtimepath'* *'rtp'* *vimfiles* 'runtimepath' 'rtp' string (default "$XDG_CONFIG_HOME/nvim, diff --git a/runtime/lua/vim/_meta/options.gen.lua b/runtime/lua/vim/_meta/options.gen.lua index e7296cea5d..7b76ddbdc4 100644 --- a/runtime/lua/vim/_meta/options.gen.lua +++ b/runtime/lua/vim/_meta/options.gen.lua @@ -5380,6 +5380,13 @@ vim.go.ru = vim.go.ruler --- set rulerformat=%15(%c%V\ %p%%%) --- ``` --- +--- This looks like an item group, but there are some differences in this +--- particular case. Most notably, the width is fixed and not a minimum, +--- and the ruler is left-aligned, whereas the alignment of item groups is +--- configurable and right-aligned by default. +--- +--- When `ui2` is enabled, the ruler no longer has a fixed width and the +--- item group syntax has no special meaning for 'rulerformat'. --- --- @type string vim.o.rulerformat = "" diff --git a/src/nvim/options.lua b/src/nvim/options.lua index ebd1e3048d..cd40fa02cc 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7073,6 +7073,13 @@ local options = { Example: >vim set rulerformat=%15(%c%V\ %p%%%) < + This looks like an item group, but there are some differences in this + particular case. Most notably, the width is fixed and not a minimum, + and the ruler is left-aligned, whereas the alignment of item groups is + configurable and right-aligned by default. + + When |ui2| is enabled, the ruler no longer has a fixed width and the + item group syntax has no special meaning for 'rulerformat'. ]=], full_name = 'rulerformat', modelineexpr = true, diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 3826f3a5b0..aef2f16eef 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -52,6 +52,7 @@ #include "nvim/tag.h" #include "nvim/terminal.h" #include "nvim/types_defs.h" +#include "nvim/ui.h" #include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" @@ -1917,7 +1918,7 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf win_config_float(win, win->w_config); } - if (rulerformat && *s == '%') { + if (rulerformat && !ui_has(kUIMessages) && *s == '%') { // set ru_wid if 'ruf' starts with "%99(" if (*++s == '-') { // ignore a '-' s++; @@ -1932,8 +1933,8 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf errmsg = check_stl_option(p_ruf); } } - } else if (rulerformat || s[0] != '%' || s[1] != '!') { - // check 'statusline', 'winbar', 'tabline' or 'statuscolumn' + } else if (s[0] != '%' || s[1] != '!') { + // check 'statusline', 'rulerformat', 'winbar', 'tabline' or 'statuscolumn' // only if it doesn't start with "%!" errmsg = check_stl_option(s); } diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 4913dc9a02..cc2a66cdca 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -308,7 +308,15 @@ static void win_redr_stl_expr(win_T *wp, bool draw_winbar, bool draw_ruler, bool wp->w_status_click_defs = stl_alloc_click_defs(wp->w_status_click_defs, maxwidth, &wp->w_status_click_defs_size); - if (draw_ruler) { + if (draw_ruler && ui_event) { + stl = p_ruf; + opt_idx = kOptRulerformat; + maxwidth = Columns / 2; + if (!in_status_line) { + fillchar = schar_from_ascii(' '); + group = HLF_MSG; + } + } else if (draw_ruler) { stl = p_ruf; opt_idx = kOptRulerformat; // advance past any leading group spec - implicit in ru_col