@@ -7,30 +7,40 @@ local neorg = require("neorg.core")
7
7
local module = neorg .modules .create (" core.integrations.telescope" )
8
8
9
9
module .setup = function ()
10
- return { success = true , requires = { " core.keybinds " , " core. dirman" } }
10
+ return { success = true , requires = { " core.dirman" } }
11
11
end
12
12
13
+ -- To add a new picker:
14
+ -- - Choose a name to add to this list (eg. <picker>)
15
+ -- - Create a file in `lua/telescope/_extensions/neorg/<picker>.lua`
16
+ -- - Add the picker to `lua/telescope/_extensions/neorg.lua`
17
+ -- - Add it to the list in the README
18
+
19
+ local pickers = {
20
+ " find_linkable" ,
21
+ " find_norg_files" ,
22
+ " insert_link" ,
23
+ " insert_file_link" ,
24
+ " search_headings" ,
25
+ " find_project_tasks" ,
26
+ " find_aof_project_tasks" ,
27
+ " find_aof_tasks" ,
28
+ " find_context_tasks" ,
29
+ " switch_workspace" ,
30
+ " backlinks.file_backlinks" ,
31
+ " backlinks.header_backlinks" ,
32
+ }
33
+
13
34
module .load = function ()
14
35
local telescope_loaded , telescope = pcall (require , " telescope" )
15
36
16
37
assert (telescope_loaded , telescope )
17
38
18
39
telescope .load_extension (" neorg" )
19
40
20
- module .required [" core.keybinds" ].register_keybinds (module .name , {
21
- " find_linkable" ,
22
- " find_norg_files" ,
23
- " insert_link" ,
24
- " insert_file_link" ,
25
- " search_headings" ,
26
- " find_project_tasks" ,
27
- " find_aof_project_tasks" ,
28
- " find_aof_tasks" ,
29
- " find_context_tasks" ,
30
- " switch_workspace" ,
31
- " find_backlinks" ,
32
- " find_header_backlinks" ,
33
- })
41
+ for _ , picker in ipairs (pickers ) do
42
+ vim .keymap .set (" " , (" <Plug>(neorg.telescope.%s)" ):format (picker ), module .public [picker ])
43
+ end
34
44
end
35
45
36
46
module .config .public = {
@@ -39,64 +49,10 @@ module.config.public = {
39
49
},
40
50
}
41
51
42
- module .public = {
43
- find_linkable = require (" telescope._extensions.neorg.find_linkable" ),
44
- find_norg_files = require (" telescope._extensions.neorg.find_norg_files" ),
45
- insert_link = require (" telescope._extensions.neorg.insert_link" ),
46
- insert_file_link = require (" telescope._extensions.neorg.insert_file_link" ),
47
- search_headings = require (" telescope._extensions.neorg.search_headings" ),
48
- find_project_tasks = require (" telescope._extensions.neorg.find_project_tasks" ),
49
- find_context_tasks = require (" telescope._extensions.neorg.find_context_tasks" ),
50
- find_aof_tasks = require (" telescope._extensions.neorg.find_aof_tasks" ),
51
- find_aof_project_tasks = require (" telescope._extensions.neorg.find_aof_project_tasks" ),
52
- switch_workspace = require (" telescope._extensions.neorg.switch_workspace" ),
53
- find_backlinks = require (" telescope._extensions.neorg.backlinks.file_backlinks" ),
54
- find_header_backlinks = require (" telescope._extensions.neorg.backlinks.header_backlinks" ),
55
- }
52
+ module .public = {}
56
53
57
- module .on_event = function (event )
58
- if event .split_type [2 ] == " core.integrations.telescope.find_linkable" then
59
- module .public .find_linkable ()
60
- elseif event .split_type [2 ] == " core.integrations.telescope.find_norg_files" then
61
- module .public .find_norg_files ()
62
- elseif event .split_type [2 ] == " core.integrations.telescope.insert_link" then
63
- module .public .insert_link ()
64
- elseif event .split_type [2 ] == " core.integrations.telescope.insert_file_link" then
65
- module .public .insert_file_link ()
66
- elseif event .split_type [2 ] == " core.integrations.telescope.search_headings" then
67
- module .public .search_headings ()
68
- elseif event .split_type [2 ] == " core.integrations.telescope.find_project_tasks" then
69
- module .public .find_project_tasks ()
70
- elseif event .split_type [2 ] == " core.integrations.telescope.find_aof_tasks" then
71
- module .public .find_aof_tasks ()
72
- elseif event .split_type [2 ] == " core.integrations.telescope.find_aof_project_tasks" then
73
- module .public .find_aof_project_tasks ()
74
- elseif event .split_type [2 ] == " core.integrations.telescope.find_context_tasks" then
75
- module .public .find_context_tasks ()
76
- elseif event .split_type [2 ] == " core.integrations.telescope.switch_workspace" then
77
- module .public .switch_workspace ()
78
- elseif event .split_type [2 ] == " core.integrations.telescope.find_backlinks" then
79
- module .public .find_backlinks ()
80
- elseif event .split_type [2 ] == " core.integrations.telescope.find_header_backlinks" then
81
- module .public .find_header_backlinks ()
82
- end
54
+ for _ , picker in ipairs (pickers ) do
55
+ module .public [picker ] = require ((" telescope._extensions.neorg.%s" ):format (picker ))
83
56
end
84
57
85
- module .events .subscribed = {
86
- [" core.keybinds" ] = {
87
- [" core.integrations.telescope.find_linkable" ] = true ,
88
- [" core.integrations.telescope.find_norg_files" ] = true ,
89
- [" core.integrations.telescope.insert_link" ] = true ,
90
- [" core.integrations.telescope.insert_file_link" ] = true ,
91
- [" core.integrations.telescope.search_headings" ] = true ,
92
- [" core.integrations.telescope.find_project_tasks" ] = true ,
93
- [" core.integrations.telescope.find_context_tasks" ] = true ,
94
- [" core.integrations.telescope.find_aof_tasks" ] = true ,
95
- [" core.integrations.telescope.find_aof_project_tasks" ] = true ,
96
- [" core.integrations.telescope.switch_workspace" ] = true ,
97
- [" core.integrations.telescope.find_backlinks" ] = true ,
98
- [" core.integrations.telescope.find_header_backlinks" ] = true ,
99
- },
100
- }
101
-
102
58
return module
0 commit comments