summaryrefslogtreecommitdiff
path: root/lua/aotrix/plugins/telescope.lua
diff options
context:
space:
mode:
authorAotrix <[email protected]>2026-08-18 21:07:13 +0200
committerAotrix <[email protected]>2026-08-18 21:07:13 +0200
commit21be6afac4df782b7a9d6b1d2856cb2b61ad94c7 (patch)
tree076c756e1eecc8e1dfd36ee5754ae23a362fe003 /lua/aotrix/plugins/telescope.lua
parent2b9c63e75de26a8cbb35a0d3157c7ee7e41de75c (diff)
Remove quickfix and improve telescope buffers
Diffstat (limited to 'lua/aotrix/plugins/telescope.lua')
-rw-r--r--lua/aotrix/plugins/telescope.lua47
1 files changed, 45 insertions, 2 deletions
diff --git a/lua/aotrix/plugins/telescope.lua b/lua/aotrix/plugins/telescope.lua
index e7c11aa..6345f45 100644
--- a/lua/aotrix/plugins/telescope.lua
+++ b/lua/aotrix/plugins/telescope.lua
@@ -1,3 +1,42 @@
+local builtin = require('telescope.builtin')
+local action_state = require('telescope.actions.state')
+local actions = require('telescope.actions')
+
+buffer_searcher = function()
+ builtin.buffers {
+ sort_mru = true,
+ ignore_current_buffer = true,
+ show_all_buffers = false,
+ attach_mappings = function(prompt_bufnr, map)
+ local refresh_buffer_searcher = function()
+ actions.close(prompt_bufnr)
+ vim.schedule(buffer_searcher)
+ end
+
+ local delete_buf = function()
+ local selection = action_state.get_selected_entry()
+ vim.api.nvim_buf_delete(selection.bufnr, {force = true})
+ refresh_buffer_searcher()
+ end
+
+ local delete_multiple_buf = function()
+ local picker = action_state.get_current_picker(prompt_bufnr)
+ local selection = picker:get_multi_selection()
+ for _, entry in ipairs(selection) do
+ vim.api.nvim_buf_delete(entry.bufnr, {force = true})
+ end
+ refresh_buffer_searcher()
+ end
+
+ map('n', 'dd', delete_buf)
+ map('n', '<C-d>', delete_multiple_buf)
+ map('i', '<C-d>', delete_multiple_buf)
+
+ return true
+ end
+ }
+end
+
return {
'nvim-telescope/telescope.nvim',
branch = 'master',
@@ -19,7 +58,6 @@ return {
-- map actions.which_key to <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
- ["<esc>"] = actions.close,
["<C-c>"] = actions.close,
["<CR>"] = actions.select_default
}
@@ -38,7 +76,10 @@ return {
scroll_strategy = "limit",
file_ignore_patterns = {".git/[^h]"}
},
- pickers = {find_files = {hidden = true}},
+ pickers = {
+ find_files = {hidden = true},
+ buffers = {initial_mode = "normal"}
+ },
extensions = {fzf = {}}
})
@@ -106,6 +147,8 @@ return {
require('telescope.builtin').lsp_dynamic_workspace_symbols,
'[W]orkspace [S]ymbols')
+ map("<leader>pb", buffer_searcher, "[P]roject [B]uffers", {"n"})
+
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')