Skip to content

Commit

Permalink
Add extended keybindings to the fzf dialog
Browse files Browse the repository at this point in the history
By default on Enter we show the popup, so these bindings allow to open
the docs with alternative sinks instead.
  • Loading branch information
vimpostor committed Aug 30, 2024
1 parent 983e744 commit 46d41c3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions autoload/clue/fzf.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
let s:actions = ["ctrl-b", "ctrl-d", "ctrl-z"]

func clue#fzf#show(doc)
let l = clue#dash#get_all(a:doc)
let a = map(l, {_, v -> v.name . "\t" . clue#dash#html_absolute_path(a:doc, clue#dash#sanitize_sqlite_path(v.path))})
call fzf#run(fzf#wrap(#{source: a, sink: function('clue#fzf#sink'), options: ['--delimiter', "\t", '--with-nth', '1', '--preview', 'pandoc -w plain -r html {2}']}))
call fzf#run(fzf#wrap(#{source: a, sinklist: function('clue#fzf#sink'), options: ['--delimiter', "\t", '--with-nth', '1', '--preview', 'pandoc -w plain -r html {2}', '--expect', join(s:actions, ',')]}))
endfunc

func clue#fzf#sink(s)
call clue#dash#open_external(strcharpart(a:s, stridx(a:s, "\t") + 1))
func clue#fzf#sink(l)
let k = strcharpart(a:l[0], 5)
let t = stridx(a:l[1], "\t")
let q = strcharpart(a:l[1], 0, t)
let p = strcharpart(a:l[1], t + 1)
if k == "b"
call clue#dash#open_external(p)
elseif k == "d" || k == "z"
call clue#dash#query_external(q)
else
call clue#dash#show_pandoc(p)
endif
endfunc

0 comments on commit 46d41c3

Please sign in to comment.