Skip to content

Commit

Permalink
Update "fuzzy-snippets" bits-and-pieces.
Browse files Browse the repository at this point in the history
  • Loading branch information
damiendart committed Jul 18, 2024
1 parent 103b46c commit 7581820
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 6 additions & 3 deletions .vim/plugin/fuzzy-finders.vim
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function! s:FuzzyGrepSelection(visualmode)
endtry
endfunction

function! s:FuzzySnippets() abort
function! s:FuzzySnippets(...) abort
function! Handler(input) closure
if a:input[0] ==? 'f1'
execute 'h :FS'
Expand Down Expand Up @@ -163,7 +163,10 @@ function! s:FuzzySnippets() abort
endtry
endfunction

call s:Fuzzy('fuzzy-snippets --vim', funcref('Handler'))
let l:arguments = copy(a:000)
let l:query = len(l:arguments) > 0 ? join(l:arguments, ' ') : ''

call s:Fuzzy('fuzzy-snippets --vim -- ' . shellescape(l:query), funcref('Handler'))
endfunction

function! s:ToQuickfix(line)
Expand All @@ -184,7 +187,7 @@ autocmd FileType fuzzyfinder let b:laststatus = &laststatus
\| autocmd WinLeave <buffer> close!

command! -bang -nargs=* FG call s:FuzzyGrep(<bang>0, <f-args>)
command! FS call s:FuzzySnippets()
command! -nargs=* FS call s:FuzzySnippets(<f-args>)

nnoremap <silent> <leader>fg :<C-U>call <SID>FuzzyGrepSelection('n')<CR>
vnoremap <silent> <leader>fg :<C-U>call <SID>FuzzyGrepSelection('v')<CR>
3 changes: 1 addition & 2 deletions bin/fuzzy-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ while :; do
;;
--vim)
VIM_MODE=1
shift
;;
--)
shift
Expand Down Expand Up @@ -138,7 +137,7 @@ fi
FZF_EXPECT='ctrl-p,f1'
FZF_LABEL='ENTER: Copy snippet ╱ CTRL+P: Print snippet ╱ F1: Help'
IFS=' '
INITIAL_QUERY="$*"
INITIAL_QUERY="${*:-}"

if [ "$VIM_MODE" = 1 ]; then
FZF_EXPECT='ctrl-y,f1'
Expand Down

0 comments on commit 7581820

Please sign in to comment.