Skip to content

Commit

Permalink
feat: picker for scriptnames
Browse files Browse the repository at this point in the history
  • Loading branch information
phanen committed Mar 25, 2024
1 parent a02bdae commit 9d7f842
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# fzf-lua-overlay
[![CI](https://github.com/phanen/fzf-lua-overlay/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/phanen/fzf-lua-overlay/actions/workflows/ci.yml)

An overlay on fzf-lua to provide powerful default.
Strong defaults and new pickers for fzf-lua.

## features
new pickers
* zoxide
* plugins
* notes/journals
* scriptnames
* ...

## usage
Feel free to copy to dotfiles, refer to:
Expand Down
8 changes: 4 additions & 4 deletions lua/fzf-lua-overlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ end
return setmetatable({}, {
__index = function(_, k)
return function()
local opts, ropts, key, cmd
key, opts, cmd = unpack(require('fzf-lua-overlay.overlay')[k])
local opts, ropts, key, fzf_exec_arg
key, opts, fzf_exec_arg = unpack(require('fzf-lua-overlay.overlay')[k])
ropts = opts_fn(k)
opts = vim.tbl_deep_extend('force', opts, ropts or {})
if cmd then
require('fzf-lua').fzf_exec(cmd, opts)
if fzf_exec_arg then
require('fzf-lua').fzf_exec(fzf_exec_arg, opts)
else
require('fzf-lua')[key](opts)
end
Expand Down
26 changes: 23 additions & 3 deletions lua/fzf-lua-overlay/overlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,35 @@ local overlay = setmetatable({
},
('ls %s'):format(cfg.plugins_dir, cfg.plugins_dir),
},
scriptnames = {
'fzf_exec',
{
prompt = 'scriptnames> ',
previewer = 'builtin',
},
function(fzf_cb)
coroutine.wrap(function()
local co = coroutine.running()
local scripts = vim.fn.getscriptinfo()
for _, script in ipairs(scripts) do
vim.print(script)
fzf_cb(script.name, function()
coroutine.resume(co)
end)
coroutine.yield()
end
fzf_cb()
end)()
end,
},
}, { -- other static opts lazy to write
__index = function(t, k)
local opts = {}
if k:match 'lsp' then
opts.jump_to_single_result = true
end
local v = { k, opts }
t[k] = v
return v
t[k] = { k, opts }
return t[k]
end,
})

Expand Down

0 comments on commit 9d7f842

Please sign in to comment.