-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE]: Allow starting the finder from a custom root item group #390
Comments
I'll need to think about how to implement this exactly. When you add keymaps to legendary, there is a parse step, so that means that when you would pass items to the finder as a custom "root" we would need to figure out:
@towry how would you feel about the API just accepting a group name as a string, and then legendary would look up the group by name? So, you could do something like: require('legendary').find({ itemgroup = 'My item group' }) |
Yes, I had randomly tried this API, I think it is intuitive. |
@mrjones2014 It works. |
My current usage is a bit tedious because I have to manage many temporary variables. I am not sure if I am overusing the legendary functions API, but it seems to work well with various plugins as popup menus (or context menus). Otherwise, I would have to use other plugins to meet my needs, which would greatly improve my workflow in a monorepo codebase. Thanks for the work, much appreciate. local M = {}
local cwd = nil
local legendary_registered = false
local item_group_name = 'folder_actions'
function M.enter(new_cwd)
cwd = new_cwd
return M
end
local get_current_cwd = function() return cwd end
function M.then_folder_action()
local lg = require('legendary')
local select_prompt = 'Folder action under: ' .. require('userlib.runtime.path').home_to_tilde(cwd)
if not cwd then return end
if legendary_registered then
lg.find({
select_prompt = select_prompt,
itemgroup = item_group_name,
})
return
end
legendary_registered = true
lg.funcs({
itemgroup = 'folder_actions',
description = 'Folder actions',
funcs = {
{
description = 'Open with mini.files',
function()
end,
},
{
description = 'Open with NVimTree',
function()
end,
},
{
description = 'Find files with telescope',
function()
require('userlib.telescope.pickers').project_files({
cwd = get_current_cwd(),
use_all_files = true,
})
end,
},
{
description = 'Recent files',
function()
require('userlib.telescope.pickers').project_files({
oldfiles = true,
cwd_only = true,
cwd = get_current_cwd(),
})
end,
},
{
description = 'Search content',
function()
require('userlib.telescope.live_grep_call')({
cwd = get_current_cwd(),
})
end,
},
}
})
lg.find({
select_prompt = select_prompt,
itemgroup = item_group_name,
})
end
return M |
Instead of function M.enter(new_cwd)
cwd = new_cwd
return M
end
local get_current_cwd = function() return cwd end You can just use As far as keeping track of |
Discussed in #389
Originally posted by towry July 6, 2023
I want to use legendary as folder action select, so I can select folder from telescope and use legendary.
So I write the script as following:
how to write the filters so that only everything under 'Folder action' item group shown?
I have looked over the docs, nothing found.
The text was updated successfully, but these errors were encountered: