From 5ec3e6623d319f91a19b89bc9fa242fa108a0b06 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 8 Feb 2025 21:30:14 +0100 Subject: [PATCH] switch to snacks picker --- lua/plugins/fzf-lua.lua | 1 + lua/plugins/lspconfig.lua | 11 ---- lua/plugins/snacks.lua | 105 ++++++++++++++++++++++++------------- lua/plugins/trouble.lua | 5 -- lua/plugins/workspaces.lua | 1 + lua/themes/bamboo.lua | 4 -- 6 files changed, 70 insertions(+), 57 deletions(-) diff --git a/lua/plugins/fzf-lua.lua b/lua/plugins/fzf-lua.lua index 0ff216d..7f093ff 100644 --- a/lua/plugins/fzf-lua.lua +++ b/lua/plugins/fzf-lua.lua @@ -123,4 +123,5 @@ return { desc = 'Fuzzy complete path', }, }, + enabled = false } diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index cd68b92..bdce254 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,13 +1,9 @@ local lspKeys = function(client, bufnr) - local fzf = require('fzf-lua') local options = { noremap = true, silent = false, buffer = bufnr } vim.keymap.set('n', ',', vim.diagnostic.goto_prev, vim.tbl_extend('error', options, { desc = 'Diag prev' })) vim.keymap.set('n', ';', vim.diagnostic.goto_next, vim.tbl_extend('error', options, { desc = 'Diag next' })) vim.keymap.set({ 'n', 'x' }, 'a', vim.lsp.buf.code_action, vim.tbl_extend('error', options, { desc = 'Code action' })) - vim.keymap.set('n', 'd', function() - fzf.lsp_definitions({ jump_to_single_result = true }) - end, vim.tbl_extend('error', options, { desc = 'Definition' })) vim.keymap.set('n', 'e', vim.lsp.buf.declaration, vim.tbl_extend('error', options, { desc = 'Declaration' })) vim.keymap.set('n', 'h', function() require('pretty_hover').hover() @@ -17,19 +13,12 @@ local lspKeys = function(client, bufnr) vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, vim.tbl_extend('error', options, { desc = 'Incoming calls' })) vim.keymap.set('n', 'm', vim.lsp.buf.rename, vim.tbl_extend('error', options, { desc = 'Rename' })) - vim.keymap.set('n', '', fzf.lsp_live_workspace_symbols, - vim.tbl_extend('error', options, { desc = 'Workspace symbols' })) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, vim.tbl_extend('error', options, { desc = 'Type definition' })) vim.keymap.set({ 'n', 'i', 'x' }, '', vim.lsp.buf.signature_help, vim.tbl_extend('error', options, { desc = 'Signature help' })) - vim.keymap.set('n', 'r', fzf.lsp_references, vim.tbl_extend('error', options, { desc = 'References' })) - vim.keymap.set('n', '', fzf.lsp_document_symbols, vim.tbl_extend('error', options, { desc = 'Document symbols' })) - vim.keymap.set('n', 'w', fzf.lsp_live_workspace_symbols, - vim.tbl_extend('error', options, { desc = 'Workspace symbols' })) vim.keymap.set('n', 'v', vim.diagnostic.open_float, vim.tbl_extend('error', options, { desc = 'Diagnostics Float' })) - vim.keymap.set('n', 'V', fzf.diagnostics_document, vim.tbl_extend('error', options, { desc = 'Diagnostics' })) vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', vim.tbl_extend('error', options, { desc = 'Switch Source/Header' })) diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua index 15fc112..087168e 100644 --- a/lua/plugins/snacks.lua +++ b/lua/plugins/snacks.lua @@ -35,44 +35,75 @@ return { { section = 'startup' }, }, }, + picker = { + matcher = { + frecency = true + } + } }, keys = { - { - 'g', - function() - Snacks.lazygit() - end, - desc = 'Lazygit', - }, - { - 'gf', - function() - Snacks.lazygit.log_file() - end, - desc = 'Lazygit Current File History', - }, - { - 'gl', - function() - Snacks.lazygit.log() - end, - desc = 'Lazygit Log (cwd)', - }, - { - 'm', - function() - Snacks.words.jump(vim.v.count1) - end, - desc = 'Next Reference', - mode = { 'n' }, - }, - { - '', - function() - Snacks.words.jump(-vim.v.count1) - end, - desc = 'Prev Reference', - mode = { 'n' }, - }, + { 'g', function() Snacks.lazygit() end, desc = 'Lazygit', }, + { 'gf', function() Snacks.lazygit.log_file() end, desc = 'Lazygit Current File History', }, + { 'gl', function() Snacks.lazygit.log() end, desc = 'Lazygit Log (cwd)', }, + { 'm', function() Snacks.words.jump(vim.v.count1) end, desc = 'Next Reference', mode = { 'n' }, }, + { '', function() Snacks.words.jump(-vim.v.count1) end, desc = 'Prev Reference', mode = { 'n' }, }, + -- Top Pickers & Explorer + { '', function() Snacks.picker.smart() end, desc = 'Smart Find Files' }, + { 'b', function() Snacks.picker.buffers() end, desc = 'Buffers' }, + { 'l', function() Snacks.picker.grep() end, desc = 'Grep' }, + { ':', function() Snacks.picker.command_history() end, desc = 'Command History' }, + { 'n', function() Snacks.picker.notifications() end, desc = 'Notification History' }, + { 'e', function() Snacks.explorer() end, desc = 'File Explorer' }, + -- find + -- { "fb", function() Snacks.picker.buffers() end, desc = "Buffers" }, + -- { "f", function() Snacks.picker.files({ cwd = vim.fn.stdpath("config") }) end, desc = "Find Config File" }, + { 'f', function() Snacks.picker.files() end, desc = 'Find Files' }, + { 'g', function() Snacks.picker.git_files() end, desc = 'Find Git Files' }, + { 'p', function() Snacks.picker.projects() end, desc = 'Projects' }, + { 'o', function() Snacks.picker.recent() end, desc = 'Recent' }, + { 'i', function() Snacks.picker.recent({ filter = { cwd = true } }) end, desc = 'Recent in cwd' }, + -- git + -- { "gb", function() Snacks.picker.git_branches() end, desc = "Git Branches" }, + -- { "gl", function() Snacks.picker.git_log() end, desc = "Git Log" }, + -- { "gL", function() Snacks.picker.git_log_line() end, desc = "Git Log Line" }, + -- { "gs", function() Snacks.picker.git_status() end, desc = "Git Status" }, + -- { "gS", function() Snacks.picker.git_stash() end, desc = "Git Stash" }, + -- { "gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (Hunks)" }, + -- { "gf", function() Snacks.picker.git_log_file() end, desc = "Git Log File" }, + -- Grep + { 'sb', function() Snacks.picker.lines() end, desc = 'Buffer Lines' }, + { 'sB', function() Snacks.picker.grep_buffers() end, desc = 'Grep Open Buffers' }, + -- { "sg", function() Snacks.picker.grep() end, desc = "Grep" }, + { 'd', function() Snacks.picker.grep_word() end, desc = 'Visual selection or word', mode = { 'n', 'x' } }, + -- search + -- { 's"', function() Snacks.picker.registers() end, desc = "Registers" }, + -- { 's/', function() Snacks.picker.search_history() end, desc = "Search History" }, + -- { "sa", function() Snacks.picker.autocmds() end, desc = "Autocmds" }, + -- { "sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" }, + -- { "sc", function() Snacks.picker.command_history() end, desc = "Command History" }, + -- { "sC", function() Snacks.picker.commands() end, desc = "Commands" }, + -- { "v", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, + { 'V', function() Snacks.picker.diagnostics_buffer() end, desc = 'Buffer Diagnostics' }, + { 'sh', function() Snacks.picker.help() end, desc = 'Help Pages' }, + { 'sH', function() Snacks.picker.highlights() end, desc = 'Highlights' }, + { 'si', function() Snacks.picker.icons() end, desc = 'Icons' }, + { 'j', function() Snacks.picker.jumps() end, desc = 'Jumps' }, + -- { "sk", function() Snacks.picker.keymaps() end, desc = "Keymaps" }, + -- { "sl", function() Snacks.picker.loclist() end, desc = "Location List" }, + -- { "sm", function() Snacks.picker.marks() end, desc = "Marks" }, + -- { "sM", function() Snacks.picker.man() end, desc = "Man Pages" }, + -- { "sp", function() Snacks.picker.lazy() end, desc = "Search for Plugin Spec" }, + -- { "sq", function() Snacks.picker.qflist() end, desc = "Quickfix List" }, + -- { "sR", function() Snacks.picker.resume() end, desc = "Resume" }, + -- { "su", function() Snacks.picker.undo() end, desc = "Undo History" }, + -- { "uC", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" }, + -- LSP + { 'd', function() Snacks.picker.lsp_definitions() end, desc = 'Goto Definition' }, + { 'D', function() Snacks.picker.lsp_declarations() end, desc = 'Goto Declaration' }, + { 'r', function() Snacks.picker.lsp_references() end, nowait = true, desc = 'References' }, + { 'I', function() Snacks.picker.lsp_implementations() end, desc = 'Goto Implementation' }, + { 'e', function() Snacks.picker.lsp_type_definitions() end, desc = 'Goto T[y]pe Definition' }, + { '', function() Snacks.picker.lsp_symbols() end, desc = 'LSP Symbols' }, + { 'sS', function() Snacks.picker.lsp_workspace_symbols() end, desc = 'LSP Workspace Symbols' }, }, } diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index 1feed92..4200a5b 100644 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -13,11 +13,6 @@ return { 'Trouble diagnostics toggle filter.buf=0', desc = 'Buffer Diagnostics (Trouble)', }, - { - 's', - 'Trouble symbols focus', - desc = 'Symbols (Trouble)', - }, { 'cl', 'Trouble lsp toggle focus=false win.position=right', diff --git a/lua/plugins/workspaces.lua b/lua/plugins/workspaces.lua index 601dfb2..9fbd5e9 100644 --- a/lua/plugins/workspaces.lua +++ b/lua/plugins/workspaces.lua @@ -41,4 +41,5 @@ return { end, }, }, + enabled = false } diff --git a/lua/themes/bamboo.lua b/lua/themes/bamboo.lua index 391c01c..aab1af3 100644 --- a/lua/themes/bamboo.lua +++ b/lua/themes/bamboo.lua @@ -30,10 +30,6 @@ return { ['LspReferenceRead'] = { bg = colors.vulgaris.green, fg = colors.vulgaris.bg1, fmt = 'nocombine' }, ['LspReferenceWrite'] = { bg = colors.vulgaris.red, fg = colors.vulgaris.bg1, fmt = 'nocombine' }, ['LspReferenceText'] = { bg = colors.vulgaris.cyan, fg = colors.vulgaris.bg1, fmt = 'nocombine' }, - ['Delimiter'] = { fg = colors.vulgaris.fg }, - ['NormalFloat'] = { bg = colors.vulgaris.bg3 }, - ['FloatNormal'] = { bg = colors.vulgaris.bg3 }, - ['PmenuSel'] = { bg = colors.vulgaris.grey }, }, }) require('bamboo').load()