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.
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
# Ignore .git directory (mostly for tools like rg and fd)
|
||||||
|
/.git
|
||||||
|
|
||||||
# Ignore all compiled zsh-files
|
# Ignore all compiled zsh-files
|
||||||
*.zwc
|
*.zwc
|
||||||
|
|
||||||
|
|||||||
@@ -30,26 +30,3 @@ if (exists("g:loaded_tmux_navigator"))
|
|||||||
" Disable tmux navigator when zooming the Vim pane
|
" Disable tmux navigator when zooming the Vim pane
|
||||||
let g:tmux_navigator_disable_when_zoomed = 1
|
let g:tmux_navigator_disable_when_zoomed = 1
|
||||||
endif
|
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
|
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ FZF_DEFAULT_COMMAND_NO_RG+=" | cut -c3-"
|
|||||||
export FZF_DEFAULT_COMMAND_NO_RG
|
export FZF_DEFAULT_COMMAND_NO_RG
|
||||||
|
|
||||||
if (( $+commands[rg] )); then
|
if (( $+commands[rg] )); then
|
||||||
# Prune `.git/` and everything ignored by gitignore(5)
|
# Ignore gitignore(5)d files, see also $XDG_CONFIG_HOME/git/ignore
|
||||||
FZF_DEFAULT_COMMAND="rg -L --files -g '!.git'"
|
FZF_DEFAULT_COMMAND="rg -L --files"
|
||||||
else
|
else
|
||||||
# Fallback to hardcoding the most important paths to prune
|
# Fallback to hardcoding the most important paths to prune
|
||||||
FZF_DEFAULT_COMMAND="$FZF_DEFAULT_COMMAND_NO_RG"
|
FZF_DEFAULT_COMMAND="$FZF_DEFAULT_COMMAND_NO_RG"
|
||||||
|
|||||||
Reference in New Issue
Block a user