-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extended keybindings to the fzf dialog
By default on Enter we show the popup, so these bindings allow to open the docs with alternative sinks instead.
- Loading branch information
Showing
1 changed file
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |