Skip to content

Commit 2834f98

Browse files
committed
feat: poor man http
1 parent 3bc5ff4 commit 2834f98

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1+
local c
12
---@class fle.config.Cmd: fzf-lua.config.Base
23
local __DEFAULT__ = {
34
allow = {
45
journalctl = true,
6+
curl = true,
57
},
68
fzf_opts = {
79
['--raw'] = true,
810
},
11+
preview = {
12+
fn = function(...) return c(...) end,
13+
type = 'cmd',
14+
field_index = '{q}',
15+
},
916
}
17+
18+
c = function(s, opts)
19+
-- TODO: callback should have way to access cmd
20+
opts = type(opts) == 'table' and opts or __DEFAULT__
21+
local q = s[1]
22+
local cmd = q:match('^%s*(%S+)')
23+
if not cmd or not opts.allow[cmd] then return vim.tbl_keys(opts.allow) end
24+
return q
25+
end
1026
return function(opts)
1127
assert(__DEFAULT__)
12-
FzfLua.fzf_live(function(s)
13-
local q = s[1]
14-
local cmd = q:match('^%s*(%S+)')
15-
if not cmd or not opts.allow[cmd] then return vim.tbl_keys(opts.allow) end
16-
return q
17-
end, opts)
28+
FzfLua.fzf_live(c, opts)
1829
end

0 commit comments

Comments
 (0)