From 21be6afac4df782b7a9d6b1d2856cb2b61ad94c7 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Tue, 18 Aug 2026 21:07:13 +0200 Subject: Remove quickfix and improve telescope buffers --- lua/aotrix/plugins/telescope.lua | 47 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'lua/aotrix/plugins/telescope.lua') 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', '', delete_multiple_buf) + map('i', '', delete_multiple_buf) + + return true + end + } +end + return { 'nvim-telescope/telescope.nvim', branch = 'master', @@ -19,7 +58,6 @@ return { -- map actions.which_key to (default: ) -- actions.which_key shows the mappings for your picker, -- e.g. git_{create, delete, ...}_branch for the git_branches picker - [""] = actions.close, [""] = actions.close, [""] = 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("pb", buffer_searcher, "[P]roject [B]uffers", {"n"}) + -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. map('rn', vim.lsp.buf.rename, '[R]e[n]ame') -- cgit v1.2.3