summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/aotrix/plugins/telescope.lua47
-rw-r--r--lua/aotrix/plugins/theme.lua5
-rw-r--r--lua/aotrix/quickfix.lua55
3 files changed, 49 insertions, 58 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')
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", "<leader>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", "<M-j>", 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", "<M-k>", 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)