From b80f86d085e05395f68fbaf2c1f449916f618a06 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 23 Jun 2023 16:23:12 +0200 Subject: [PATCH] vim:plugins: Do not hardcode quotes in Rg redef. They redefinition would fail if fzf.vim would ever change the quotes used. --- .config/vim/vimrc.d/20-plugins.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.config/vim/vimrc.d/20-plugins.vim b/.config/vim/vimrc.d/20-plugins.vim index d3ce0a3..0f5b06c 100644 --- a/.config/vim/vimrc.d/20-plugins.vim +++ b/.config/vim/vimrc.d/20-plugins.vim @@ -33,10 +33,14 @@ endif if (get(g:, 'loaded_fzf')) " Redefine :Rg to ignore the .git directory - let s:rg_to_add = " -g '!.git' " + let s:rg_to_add = " -g ['\"]!.git['\"] " let s:rg_desc = get(nvim_get_commands({}), 'Rg', {}) if get(s:rg_desc, 'definition', s:rg_to_add) !~ s:rg_to_add + " Adjust quotes depending on the definition + let s:rg_quote = s:rg_desc['definition'] =~ '^[^(]*("' ? "'" : '"' + let s:rg_to_add = substitute(s:rg_to_add, "\\V['\"]", s:rg_quote, 'g') + let s:rg_definition = substitute(s:rg_desc['definition'], ' -- ', \ s:rg_to_add .. '-- ', '') " See :h command-attributes