@@ -11,6 +11,9 @@ local Terminal = require("toggleterm.terminal").Terminal
1111
1212local M = {}
1313
14+ --- Create a new terminal and open it. If exit_on_action is true, focus it.
15+ --- @param prompt_bufnr number The buffer number of the telescope prompt.
16+ --- @param exit_on_action boolean Whether to exit the telescope buffer when the action executes.
1417function M .create_term (prompt_bufnr , exit_on_action )
1518 -- forward declare `term` so it can be used inside `on_open_terminal`.
1619 local term
@@ -44,6 +47,9 @@ function M.create_term(prompt_bufnr, exit_on_action)
4447 term :open ()
4548end
4649
50+ --- Create and name a new terminal and open it. If exit_on_action is true, focus it.
51+ --- @param prompt_bufnr number The buffer number of the telescope prompt.
52+ --- @param exit_on_action boolean Whether to exit the telescope buffer when the action executes.
4753function M .create_and_name_term (prompt_bufnr , exit_on_action )
4854 local prompt = " Name terminal: "
4955
@@ -80,6 +86,9 @@ function M.create_and_name_term(prompt_bufnr, exit_on_action)
8086 end )
8187end
8288
89+ --- Open a terminal. If exit_on_action is true, focus it.
90+ --- @param prompt_bufnr number The buffer number of the telescope prompt.
91+ --- @param exit_on_action boolean Whether to exit the telescope buffer when the action executes.
8392function M .open_term (prompt_bufnr , exit_on_action )
8493 local selection = actions_state .get_selected_entry ()
8594 if selection == nil then
@@ -105,6 +114,9 @@ function M.open_term(prompt_bufnr, exit_on_action)
105114 util .refresh_picker (prompt_bufnr , term )
106115end
107116
117+ --- Delete a buffer, with an option to force deletion.
118+ --- @param bufnr number The buffer number to delete.
119+ --- @param force boolean Whether to force deletion or not.
108120local function delete_buffer (bufnr , force )
109121 local ok , err = pcall (function ()
110122 vim .api .nvim_buf_delete (bufnr , { force = force })
@@ -116,6 +128,9 @@ local function delete_buffer(bufnr, force)
116128 end
117129end
118130
131+ --- Delete a terminal.
132+ --- @param prompt_bufnr number The buffer number of the telescope prompt.
133+ --- @param exit_on_action boolean Whether to exit the telescope buffer when the action executes.
119134function M .delete_term (prompt_bufnr , exit_on_action )
120135 local selection = actions_state .get_selected_entry ()
121136 if selection == nil then
@@ -154,6 +169,9 @@ function M.delete_term(prompt_bufnr, exit_on_action)
154169 util .refresh_picker (prompt_bufnr , selection , true )
155170end
156171
172+ --- Toggle a terminal open or closed. If toggling open and exit_on_action is true, focus it.
173+ --- @param prompt_bufnr number The buffer number of the telescope prompt.
174+ --- @param exit_on_action boolean Whether to exit the telescope buffer when the action executes.
157175function M .toggle_term (prompt_bufnr , exit_on_action )
158176 local current_picker = actions_state .get_current_picker (prompt_bufnr )
159177
@@ -182,6 +200,9 @@ function M.toggle_term(prompt_bufnr, exit_on_action)
182200 util .refresh_picker (prompt_bufnr , term )
183201end
184202
203+ --- Rename a terminal. If exit_on_action is true, focus it.
204+ --- @param prompt_bufnr number The buffer number of the telescope prompt.
205+ --- @param exit_on_action boolean Whether to exit the telescope buffer when the action executes.
185206function M .rename_term (prompt_bufnr , exit_on_action )
186207 local selection = actions_state .get_selected_entry ()
187208 if selection == nil then
0 commit comments