Skip to content

Commit

Permalink
fix: cd to plugins dir
Browse files Browse the repository at this point in the history
refactor: config

feat: preview dirent
  • Loading branch information
phanen committed Mar 21, 2024
1 parent 947a152 commit 8a7d2e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
7 changes: 7 additions & 0 deletions lua/fzf-lua-overlay/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local default = {
plugins_dir = vim.fn.stdpath 'data' .. '/lazy',
notes_dir = '~/notes',
notes_history = vim.fn.stdpath 'state' .. '/fzf_notes_history',
}

return default
23 changes: 16 additions & 7 deletions lua/fzf-lua-overlay/overlay.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
local notes_actions = require 'fzf-lua-overlay.actions'
local cfg = require 'fzf-lua-overlay.config'

local overlay = setmetatable({
find_dots = { 'files', { cwd = '~' } },
grep_dots = { 'live_grep_native', { cwd = '~' } },
grep_notes = { 'live_grep_native', { cwd = '~/notes' } },
grep_notes = { 'live_grep_native', { cwd = cfg.notes_dir } },
todo_comment = { 'grep', { search = 'TODO|HACK|PERF|NOTE|FIX', no_esc = true } },
lsp_references = {
'lsp_references',
Expand All @@ -12,10 +13,10 @@ local overlay = setmetatable({
find_notes = {
'files',
{
cwd = '~/notes',
cwd = cfg.notes_dir,
actions = notes_actions,
fzf_opts = {
['--history'] = vim.fn.stdpath 'state' .. '/fzf_notes_history',
['--history'] = cfg.notes_history,
},
file_icons = false,
git_icons = false,
Expand All @@ -24,9 +25,13 @@ local overlay = setmetatable({
zoxide = {
'fzf_exec',
{
prompt = 'zoxide>',
prompt = 'zoxide> ',
preview = 'ls --color {2}',
actions = {
['default'] = function(selected)
if not selected or not selected[1] then
return
end
local path = selected[1]:match '/.+'
vim.system { 'zoxide', 'add', path }
vim.api.nvim_set_current_dir(path)
Expand All @@ -38,16 +43,20 @@ local overlay = setmetatable({
plugins = {
'fzf_exec',
{
prompt = 'zoxide>',
prompt = 'plugins> ',
preview = ('ls --color %s/{1}'):format(cfg.plugins_dir),
actions = {
['default'] = function(selected)
local path = selected[1]:match '/.+'
if not selected or not selected[1] then
return
end
local path = ('%s/%s'):format(cfg.plugins_dir, selected[1])
vim.system { 'zoxide', 'add', path }
vim.api.nvim_set_current_dir(path)
end,
},
},
('ls %s'):format(vim.fn.stdpath 'data' .. '/lazy'),
('ls %s'):format(cfg.plugins_dir, cfg.plugins_dir),
},
}, { -- other static opts lazy to write
__index = function(t, k)
Expand Down

0 comments on commit 8a7d2e3

Please sign in to comment.