Skip to content

Commit

Permalink
Open documentation on Enter
Browse files Browse the repository at this point in the history
Once again [0], the implementation details in fzf are completely bogus.

For some reason the maintainer believes so much in the Unix philosophy
that field index expressions are not allowed in the final returned
string [1], which means that the final string we get in the sink is some
bullshit like "std::string|/path/to/doc.html".  Apparently Unix nerds
will automatically jump to awk or cut to handle this stuff.

To troll the fzf maintainer, let's use VimScript instead of proper Unix
tools.

[0] 00022ad
[1] junegunn/fzf#1323
  • Loading branch information
vimpostor committed Aug 29, 2024
1 parent 00022ad commit 983e744
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autoload/clue/fzf.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
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, options: ['--delimiter', "\t", '--with-nth', '1', '--preview', 'pandoc -w plain -r html {2}']}))
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}']}))
endfunc

func clue#fzf#sink(s)
call clue#dash#open_external(strcharpart(a:s, stridx(a:s, "\t") + 1))
endfunc

0 comments on commit 983e744

Please sign in to comment.