From 0c4dfbf363218a7b57e1f955f6c61deee7776439 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 23 Jun 2023 17:03:29 +0200 Subject: [PATCH] git:ignore: Add /.git Ignore the .git directory globally instead of ignoring it manually in tools like fd and ripgrep. I feel very dumb for putting all this time into the redefinition of :Rg, especially since I am currently **much** procrastinating writing my bachelor thesis. --- .config/git/ignore | 3 +++ .config/vim/vimrc.d/20-plugins.vim | 23 ----------------------- .config/zsh/.zprofile | 4 ++-- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/.config/git/ignore b/.config/git/ignore index 381ee79..db769e2 100644 --- a/.config/git/ignore +++ b/.config/git/ignore @@ -1,3 +1,6 @@ +# Ignore .git directory (mostly for tools like rg and fd) +/.git + # Ignore all compiled zsh-files *.zwc diff --git a/.config/vim/vimrc.d/20-plugins.vim b/.config/vim/vimrc.d/20-plugins.vim index 0f5b06c..d54acd9 100644 --- a/.config/vim/vimrc.d/20-plugins.vim +++ b/.config/vim/vimrc.d/20-plugins.vim @@ -30,26 +30,3 @@ if (exists("g:loaded_tmux_navigator")) " Disable tmux navigator when zooming the Vim pane let g:tmux_navigator_disable_when_zoomed = 1 endif - -if (get(g:, 'loaded_fzf')) - " Redefine :Rg to ignore the .git directory - 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 - " TODO: what is complete_arg? - let s:opts = filter(copy(s:rg_desc), - \ {key, val -> -1 < index(['nargs', 'complete', 'range', 'count', - \ 'addr', 'bang', 'bar', 'register', - \ 'keepscript'], key) - \ }) - call nvim_create_user_command('Rg', s:rg_definition, s:opts) - endif -endif diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index d2f96df..383d97a 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -106,8 +106,8 @@ FZF_DEFAULT_COMMAND_NO_RG+=" | cut -c3-" export FZF_DEFAULT_COMMAND_NO_RG if (( $+commands[rg] )); then - # Prune `.git/` and everything ignored by gitignore(5) - FZF_DEFAULT_COMMAND="rg -L --files -g '!.git'" + # Ignore gitignore(5)d files, see also $XDG_CONFIG_HOME/git/ignore + FZF_DEFAULT_COMMAND="rg -L --files" else # Fallback to hardcoding the most important paths to prune FZF_DEFAULT_COMMAND="$FZF_DEFAULT_COMMAND_NO_RG"