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 --- init.lua | 1 - lua/aotrix/plugins/telescope.lua | 47 ++++++++++++++++++++++++++++++++-- lua/aotrix/plugins/theme.lua | 5 +++- lua/aotrix/quickfix.lua | 55 ---------------------------------------- 4 files changed, 49 insertions(+), 59 deletions(-) delete mode 100644 lua/aotrix/quickfix.lua diff --git a/init.lua b/init.lua index 9dd82ab..df6bc5f 100644 --- a/init.lua +++ b/init.lua @@ -11,5 +11,4 @@ vim.opt.rtp:prepend(lazypath) require('aotrix.set') require('aotrix.remap') -require('aotrix.quickfix') require('lazy').setup('aotrix.plugins') 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') diff --git a/lua/aotrix/plugins/theme.lua b/lua/aotrix/plugins/theme.lua index 76e2df0..278222f 100644 --- a/lua/aotrix/plugins/theme.lua +++ b/lua/aotrix/plugins/theme.lua @@ -1,4 +1,7 @@ return { "rebelot/kanagawa.nvim", - config = function() vim.cmd("colorscheme kanagawa-wave") end + config = function() + -- vim.cmd("colorscheme kanagawa-wave") + vim.cmd("colorscheme default") + end } diff --git a/lua/aotrix/quickfix.lua b/lua/aotrix/quickfix.lua deleted file mode 100644 index 71a8677..0000000 --- a/lua/aotrix/quickfix.lua +++ /dev/null @@ -1,55 +0,0 @@ -local quickfix_is_open = false; -vim.api.nvim_create_autocmd('BufWinEnter', { - pattern = 'quickfix', - callback = function(args) quickfix_is_open = true end -}) -vim.api.nvim_create_autocmd('BufWinLeave', { - pattern = 'quickfix', - callback = function(args) quickfix_is_open = false end -}) -local nb_elements_quickfix = 0; -vim.api.nvim_create_autocmd('DiagnosticChanged', { - callback = function(args) - nb_elements_quickfix = #vim.diagnostic.get() - if quickfix_is_open then - if nb_elements_quickfix == 0 then - quickfix_is_open = false - vim.defer_fn(function() vim.cmd.cclose() end, 0) - else - vim.diagnostic.setqflist() - end - end - end -}) -local get_current_quickfix_index = function() - return tonumber(vim.fn.getqflist({idx = 0})['idx']) -end -vim.keymap.set("n", "q", function() - if #vim.diagnostic.get() > 0 then - if quickfix_is_open then - vim.cmd.cclose() - quickfix_is_open = false - else - vim.diagnostic.setqflist() - vim.cmd.cfirst() - end - end -end) -vim.keymap.set("n", "", function() - if #vim.diagnostic.get() > 0 and quickfix_is_open then - if get_current_quickfix_index() < nb_elements_quickfix then - vim.cmd.cnext() - else - vim.cmd.cfirst() - end - end -end) -vim.keymap.set("n", "", function() - if #vim.diagnostic.get() > 0 and quickfix_is_open then - if get_current_quickfix_index() > 1 then - vim.cmd.cprev() - else - vim.cmd.clast() - end - end -end) -- cgit v1.2.3