11return function ()
2+ local search_backend = require (" core.settings" ).search_backend
23 local builtin = require (" telescope.builtin" )
34 local extensions = require (" telescope" ).extensions
45 local vim_path = require (" core.global" ).vim_path
6+ local prompt_position = require (" telescope.config" ).values .layout_config .horizontal .prompt_position
7+ local fzf_opts = { fzf_opts = { [" --layout" ] = prompt_position == " top" and " reverse" or " default" } }
8+ local files = function ()
9+ if search_backend == " fzf" then
10+ return function ()
11+ local opts = {}
12+ local fzf = require (" fzf-lua" )
13+ opts = vim .tbl_deep_extend (" force" , opts , fzf_opts )
14+ if vim .fn .getcwd () == vim_path then
15+ fzf .files (vim .tbl_deep_extend (" force" , opts , { no_ignore = true }))
16+ elseif vim .fn .isdirectory (" .git" ) == 1 then
17+ fzf .git_files (opts )
18+ else
19+ fzf .files (opts )
20+ end
21+ end
22+ else
23+ return function (opts )
24+ opts = opts or {}
25+ if vim .fn .getcwd () == vim_path then
26+ builtin .find_files (vim .tbl_deep_extend (" force" , opts , { no_ignore = true }))
27+ elseif vim .fn .isdirectory (" .git" ) == 1 then
28+ builtin .git_files (opts )
29+ else
30+ builtin .find_files (opts )
31+ end
32+ end
33+ end
34+ end
35+
36+ local old_files = function ()
37+ if search_backend == " fzf" then
38+ return function ()
39+ local opts = {}
40+ local fzf = require (" fzf-lua" )
41+ opts = vim .tbl_deep_extend (" force" , opts , fzf_opts )
42+ fzf .oldfiles (opts )
43+ end
44+ else
45+ return function (opts )
46+ opts = opts or {}
47+ builtin .oldfiles (opts )
48+ end
49+ end
50+ end
51+
52+ local word_in_project = function ()
53+ if search_backend == " fzf" then
54+ return function ()
55+ local opts = {}
56+ local fzf = require (" fzf-lua" )
57+ opts = vim .tbl_deep_extend (" force" , opts , fzf_opts )
58+ if vim .fn .getcwd () == vim_path then
59+ opts = vim .tbl_deep_extend (" force" , opts , { no_ignore = true })
60+ end
61+ fzf .live_grep (opts )
62+ end
63+ else
64+ return function (opts )
65+ opts = opts or {}
66+ if vim .fn .getcwd () == vim_path then
67+ opts [" additional_args" ] = { " --no-ignore" }
68+ end
69+ extensions .live_grep_args .live_grep_args (opts )
70+ end
71+ end
72+ end
73+
74+ local word_under_cursor = function ()
75+ if search_backend == " fzf" then
76+ return function ()
77+ local opts = {}
78+ local fzf = require (" fzf-lua" )
79+ opts = vim .tbl_deep_extend (" force" , opts , fzf_opts )
80+ if vim .fn .getcwd () == vim_path then
81+ opts = vim .tbl_deep_extend (" force" , opts , { no_ignore = true })
82+ end
83+ fzf .grep_cword (opts )
84+ end
85+ else
86+ return function (opts )
87+ opts = opts or {}
88+ if vim .fn .getcwd () == vim_path then
89+ opts [" additional_args" ] = { " --no-ignore" }
90+ end
91+ builtin .grep_string (opts )
92+ end
93+ end
94+ end
595
696 require (" modules.utils" ).load_plugin (" search" , {
97+ prompt_position = prompt_position ,
798 collections = {
899 -- Search using filenames
9100 file = {
10101 initial_tab = 1 ,
11102 tabs = {
12103 {
13104 name = " Files" ,
14- tele_func = function (opts )
15- opts = opts or {}
16- if vim .fn .getcwd () == vim_path then
17- builtin .find_files (vim .tbl_deep_extend (" force" , opts , { no_ignore = true }))
18- elseif vim .fn .isdirectory (" .git" ) == 1 then
19- builtin .git_files (opts )
20- else
21- builtin .find_files (opts )
22- end
23- end ,
105+ tele_func = files (),
24106 },
25107 {
26108 name = " Frecency" ,
@@ -30,9 +112,7 @@ return function()
30112 },
31113 {
32114 name = " Oldfiles" ,
33- tele_func = function ()
34- builtin .oldfiles ()
35- end ,
115+ tele_func = old_files (),
36116 },
37117 {
38118 name = " Buffers" ,
@@ -48,27 +128,15 @@ return function()
48128 tabs = {
49129 {
50130 name = " Word in project" ,
51- tele_func = function ()
52- local opts = {}
53- if vim .fn .getcwd () == vim_path then
54- opts [" additional_args" ] = { " --no-ignore" }
55- end
56- extensions .live_grep_args .live_grep_args (opts )
57- end ,
131+ tele_func = word_in_project (),
58132 },
59133 {
60134 name = " Word under cursor" ,
61- tele_func = function (opts )
62- opts = opts or {}
63- if vim .fn .getcwd () == vim_path then
64- opts [" additional_args" ] = { " --no-ignore" }
65- end
66- builtin .grep_string (opts )
67- end ,
135+ tele_func = word_under_cursor (),
68136 },
69137 },
70138 },
71- -- Search by git (branches, commits)
139+ -- Search Git objects (branches, commits)
72140 git = {
73141 initial_tab = 1 ,
74142 tabs = {
@@ -114,6 +182,12 @@ return function()
114182 extensions .projects .projects ({})
115183 end ,
116184 },
185+ {
186+ name = " Zoxide" ,
187+ tele_func = function ()
188+ extensions .zoxide .list ()
189+ end ,
190+ },
117191 },
118192 },
119193 -- Miscellaneous
0 commit comments