@@ -2,7 +2,7 @@ local actions = require("telescope.actions")
22local actions_state = require (" telescope.actions.state" )
33local toggleterm_ui = require (" toggleterm.ui" )
44local toggleterm_config = require (" toggleterm.config" )
5- local util = require (" util " )
5+ local utils = require (" lib.utils " )
66local Terminal = require (" toggleterm.terminal" ).Terminal
77
88local M = {}
@@ -23,8 +23,8 @@ function M.create_term(prompt_bufnr, exit_on_action)
2323 -- set origin window to current term before switching back to telescope
2424 -- this ensures the cursor is moved to the correct term window after closing a term
2525 toggleterm_ui .set_origin_window ()
26- util .focus_on_telescope (prompt_bufnr )
27- util .refresh_picker (prompt_bufnr , term )
26+ utils .focus_on_telescope (prompt_bufnr )
27+ utils .refresh_picker (prompt_bufnr , term )
2828 -- remove the on_open callback to avoid potential side effects in future actions.
2929 term .on_open = nil
3030 end )
@@ -37,7 +37,7 @@ function M.create_term(prompt_bufnr, exit_on_action)
3737 -- the autocommand setup in telescope/init.lua that starts insert mode on leaving the telescope buffer
3838 -- won't work here since the cursor may move to a non-toggleterm buftype for a brief moment while the
3939 -- toggleterm buffer is being created
40- util .start_insert_mode ()
40+ utils .start_insert_mode ()
4141 end
4242
4343 term = Terminal :new ({ hidden = float , on_open = on_open_terminal })
@@ -46,11 +46,11 @@ function M.create_term(prompt_bufnr, exit_on_action)
4646 term :open ()
4747 elseif float then
4848 term :spawn ()
49- util .refresh_picker (prompt_bufnr , term )
49+ utils .refresh_picker (prompt_bufnr , term )
5050 -- remove the on_open callback to avoid potential side effects in future actions.
5151 term .on_open = nil
5252 else
53- util .focus_on_origin_win ()
53+ utils .focus_on_origin_win ()
5454 term :open ()
5555 end
5656end
@@ -64,7 +64,7 @@ function M.create_and_name_term(prompt_bufnr, exit_on_action)
6464 local prompt = " Name terminal: "
6565
6666 vim .ui .input ({ prompt = prompt }, function (name )
67- util .clear_command_line ()
67+ utils .clear_command_line ()
6868 if name and # name > 0 then
6969 local term
7070 local function on_open_terminal ()
@@ -73,8 +73,8 @@ function M.create_and_name_term(prompt_bufnr, exit_on_action)
7373 -- set origin window to current term before switching back to telescope
7474 -- this ensures the cursor is moved to the correct term window after closing a term
7575 toggleterm_ui .set_origin_window ()
76- util .focus_on_telescope (prompt_bufnr )
77- util .refresh_picker (prompt_bufnr , term )
76+ utils .focus_on_telescope (prompt_bufnr )
77+ utils .refresh_picker (prompt_bufnr , term )
7878 -- remove the on_open callback to avoid potential side effects in future actions.
7979 term .on_open = nil
8080 end )
@@ -87,7 +87,7 @@ function M.create_and_name_term(prompt_bufnr, exit_on_action)
8787 -- the autocommand setup in telescope/init.lua that starts insert mode on leaving the telescope buffer
8888 -- won't work here since the cursor may move to a non-toggleterm buftype for a brief moment while the
8989 -- toggleterm buffer is being created
90- util .start_insert_mode ()
90+ utils .start_insert_mode ()
9191 end
9292
9393 term = Terminal :new ({ display_name = name , hidden = float , on_open = on_open_terminal })
@@ -96,11 +96,11 @@ function M.create_and_name_term(prompt_bufnr, exit_on_action)
9696 term :open ()
9797 elseif float then
9898 term :spawn ()
99- util .refresh_picker (prompt_bufnr , term )
99+ utils .refresh_picker (prompt_bufnr , term )
100100 -- remove the on_open callback to avoid potential side effects in future actions.
101101 term .on_open = nil
102102 else
103- util .focus_on_origin_win ()
103+ utils .focus_on_origin_win ()
104104 term :open ()
105105 end
106106 end
@@ -120,7 +120,7 @@ function M.rename_term(prompt_bufnr, exit_on_action)
120120
121121 local prompt = string.format (" Rename terminal %s: " , selection .term_name )
122122 vim .ui .input ({ prompt = prompt }, function (name )
123- util .clear_command_line ()
123+ utils .clear_command_line ()
124124 if name and # name > 0 then
125125 -- rename terminal within toggleterm
126126 term .display_name = name
@@ -130,10 +130,10 @@ function M.rename_term(prompt_bufnr, exit_on_action)
130130 term :focus ()
131131 else
132132 local current_picker = actions_state .get_current_picker (prompt_bufnr )
133- local finder , new_row_number = util .create_finder (term .id )
133+ local finder , new_row_number = utils .create_finder (term .id )
134134 current_picker :refresh (finder , { reset_prompt = false })
135135
136- util .set_selection_row (current_picker , new_row_number )
136+ utils .set_selection_row (current_picker , new_row_number )
137137 end
138138 end
139139 end )
@@ -156,17 +156,17 @@ function M.open_term(prompt_bufnr, exit_on_action)
156156 term :open ()
157157 end
158158 term :focus ()
159- util .start_insert_mode ()
159+ utils .start_insert_mode ()
160160 return
161161 end
162162
163- util .focus_on_origin_win ()
163+ utils .focus_on_origin_win ()
164164 if not term :is_open () then
165165 term :open ()
166166 end
167167
168- util .focus_on_telescope (prompt_bufnr )
169- util .refresh_picker (prompt_bufnr , term )
168+ utils .focus_on_telescope (prompt_bufnr )
169+ utils .refresh_picker (prompt_bufnr , term )
170170end
171171
172172--- Toggle a terminal open or closed. If toggling open and exit_on_action is true, focus it.
@@ -185,11 +185,11 @@ function M.toggle_term(prompt_bufnr, exit_on_action)
185185 if exit_on_action then
186186 actions .close (prompt_bufnr )
187187 term :toggle ()
188- util .start_insert_mode ()
188+ utils .start_insert_mode ()
189189 return
190190 end
191191
192- util .focus_on_origin_win ()
192+ utils .focus_on_origin_win ()
193193 if term :is_open () then
194194 term :close ()
195195 current_picker .original_win_id = toggleterm_ui .get_origin_window ()
@@ -198,8 +198,8 @@ function M.toggle_term(prompt_bufnr, exit_on_action)
198198 current_picker .original_win_id = term .window
199199 end
200200
201- util .focus_on_telescope (prompt_bufnr )
202- util .refresh_picker (prompt_bufnr , term )
201+ utils .focus_on_telescope (prompt_bufnr )
202+ utils .refresh_picker (prompt_bufnr , term )
203203end
204204
205205--- Delete a terminal.
@@ -226,17 +226,17 @@ function M.delete_term(prompt_bufnr, exit_on_action)
226226 -- and causes telescope to exit. See toggleterm's terminal.lua:__handle_exit and ui.lua:close_split.
227227 term .close_on_exit = false
228228
229- util .focus_on_origin_win ()
229+ utils .focus_on_origin_win ()
230230
231231 local force = vim .api .nvim_buf_get_option (selection .bufnr , " buftype" ) == " terminal"
232232
233- util .delete_buffer (selection .bufnr , force )
233+ utils .delete_buffer (selection .bufnr , force )
234234
235235 toggleterm_ui .set_origin_window ()
236236
237- util .focus_on_telescope (prompt_bufnr )
237+ utils .focus_on_telescope (prompt_bufnr )
238238
239- util .refresh_picker (prompt_bufnr , selection , true )
239+ utils .refresh_picker (prompt_bufnr , selection , true )
240240end
241241
242242return M
0 commit comments