-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
121 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
return require("telescope").register_extension({ | ||
exports = { | ||
find_linkable = require("neorg.modules.core.integrations.telescope.module").public.find_linkable, | ||
insert_link = require("neorg.modules.core.integrations.telescope.module").public.insert_link, | ||
insert_file_link = require("neorg.modules.core.integrations.telescope.module").public.insert_file_link, | ||
search_headings = require("neorg.modules.core.integrations.telescope.module").public.search_headings, | ||
}, | ||
exports = { | ||
find_linkable = require("neorg.modules.core.integrations.telescope.module").public.find_linkable, | ||
insert_link = require("neorg.modules.core.integrations.telescope.module").public.insert_link, | ||
insert_file_link = require("neorg.modules.core.integrations.telescope.module").public.insert_file_link, | ||
search_headings = require("neorg.modules.core.integrations.telescope.module").public.search_headings, | ||
find_project_tasks = require("neorg.modules.core.integrations.telescope.module").public.find_project_tasks, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
local actions = require("telescope.actions") | ||
local actions_set = require("telescope.actions.set") | ||
local state = require("telescope.actions.state") | ||
local finders = require("telescope.finders") | ||
local pickers = require("telescope.pickers") | ||
local conf = require("telescope.config").values | ||
|
||
local neorg_loaded, _ = pcall(require, "neorg.modules") | ||
|
||
assert(neorg_loaded, "Neorg is not loaded - please make sure to load Neorg first") | ||
|
||
local function get_project_tasks() | ||
local tasks_raw = neorg.modules.get_module("core.gtd.queries").get("tasks") -- or "tasks" | ||
tasks_raw = neorg.modules.get_module("core.gtd.queries").add_metadata(tasks_raw, "task") | ||
local projects_tasks = neorg.modules.get_module("core.gtd.queries").sort_by("project_uuid", tasks_raw) | ||
return projects_tasks | ||
end | ||
|
||
local function get_projects() | ||
local projects_raw = neorg.modules.get_module("core.gtd.queries").get("projects") -- or "projects" | ||
projects_raw = neorg.modules.get_module("core.gtd.queries").add_metadata(projects_raw, "project") | ||
return projects_raw | ||
end | ||
|
||
local function pick_tasks(project) | ||
local project_tasks = get_project_tasks() | ||
local tasks = project_tasks[project.uuid] | ||
local opts = {} | ||
|
||
pickers.new(opts, { | ||
prompt_title = "Picker Project Tasks:" .. project.content, | ||
results_title = "Tasks", | ||
finder = finders.new_table({ | ||
results = tasks, | ||
entry_maker = function(entry) | ||
return { | ||
value = entry, | ||
display = entry.content, | ||
ordinal = entry.content, | ||
} | ||
end, | ||
}), | ||
previewer = nil, | ||
sorter = conf.generic_sorter(opts), | ||
attach_mappings = function(prompt_bufnr) | ||
actions_set.select:replace(function() | ||
local entry = state.get_selected_entry() | ||
actions.close(prompt_bufnr) | ||
dump(entry.value) | ||
end) | ||
return true | ||
end, | ||
}):find() | ||
end | ||
|
||
return function(opts) | ||
opts = opts or {} | ||
|
||
pickers.new(opts, { | ||
prompt_title = "Pick Neorg Gtd Projects", | ||
results_title = "Projects", | ||
finder = finders.new_table({ | ||
results = get_projects(), | ||
entry_maker = function(entry) | ||
return { | ||
value = entry, | ||
display = entry.content, | ||
ordinal = entry.content, | ||
} | ||
end, | ||
}), | ||
previewer = nil, | ||
sorter = conf.generic_sorter(opts), | ||
attach_mappings = function(prompt_bufnr) | ||
actions_set.select:replace(function() | ||
local entry = state.get_selected_entry() | ||
actions.close(prompt_bufnr) | ||
pick_tasks(entry.value) | ||
end) | ||
return true | ||
end, | ||
}):find() | ||
end |