Skip to content

Commit 2976f50

Browse files
fzf ripgrep integration (#1159)
Nushell has fuzzy autocompletion but in many areas fzf is still king and has lot's of resources available. This pr adds Ripgrep fzf integration, it basically reimplements the bash version from [junegunn's blog](https://junegunn.github.io/fzf/tips/ripgrep-integration/#wrap-up) for nushell.
1 parent 3ece6a9 commit 2976f50

File tree

1 file changed

+23
-1
lines changed
  • custom-completions/auto-generate/completions

1 file changed

+23
-1
lines changed

custom-completions/auto-generate/completions/fzf.nu

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,26 @@ extern "fzf +s" [
2626
extern "fzf +m" [
2727

2828
...args
29-
]
29+
]
30+
31+
# ripgrep->fzf->vim [QUERY] https://junegunn.github.io/fzf/tips/ripgrep-integration/#wrap-up
32+
export def rg-fzf-nvim [] {
33+
let RELOAD = 'rg --column --color=always --smart-case {q}'
34+
let OPENER = '
35+
if $env.FZF_SELECT_COUNT == 0 {
36+
nvim {1} +{2} # No selection. Open the current line in Vim.
37+
} else {
38+
nvim +cw -q {+f} # Build quickfix list for the selected items.
39+
}
40+
'
41+
( fzf --disabled --ansi --multi
42+
--bind $"start:reload:($RELOAD)" --bind $"change:reload:($RELOAD)"
43+
--bind $"enter:become:($OPENER)" --bind $"ctrl-o:execute:($OPENER)"
44+
--bind 'ctrl-a:select-all,ctrl-d:deselect-all,ctrl-/:toggle-preview'
45+
--delimiter ':'
46+
--preview 'bat --style=full --color=always --highlight-line {2} {1}'
47+
--preview-window '~4,+{2}+4/3,<80(up)'
48+
--query "$*" )
49+
}
50+
# ripgrep->fzf->vim [QUERY]
51+
export alias rfv = rg-fzf-nvim

0 commit comments

Comments
 (0)