From 5897994cb75b5b64a34017873119c87a75c42375 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 28 Nov 2024 09:02:10 +0800 Subject: vim-patch:9.1.0890: %! item not allowed for 'rulerformat' (#31369) Problem: %! item not allowed for 'rulerformat' (yatinlala) Solution: also allow to use %! for rulerformat option (Yegappan Lakshmanan) fixes: vim/vim#16091 closes: vim/vim#16118 https://github.com/vim/vim/commit/ac023e8baae65584537aa3c11494dad6f71770af Co-authored-by: Yegappan Lakshmanan --- src/nvim/options.lua | 1 + src/nvim/optionstr.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/options.lua b/src/nvim/options.lua index bcb05b107b..84c90e44a7 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -8407,6 +8407,7 @@ return { All fields except the {item} are optional. A single percent sign can be given as "%%". + *stl-%!* When the option starts with "%!" then it is used as an expression, evaluated and the result is used as the option value. Example: >vim set statusline=%!MyStatusLine() diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index b47517b1a2..918443db9f 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -2191,7 +2191,11 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) { ru_wid = wid; } else { - errmsg = check_stl_option(p_ruf); + // 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); + } } } else if (rulerformat || s[0] != '%' || s[1] != '!') { // check 'statusline', 'winbar', 'tabline' or 'statuscolumn' -- cgit