From d0f06687d1680ce76a923953d5e1ec6d32b4c5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofus=20Albert=20H=C3=B8gsbro=20Rose?= Date: Fri, 14 Feb 2025 10:10:32 +0100 Subject: [PATCH] feat: switched to snacks picker from fzf-lua --- lua/autocmds/lsp.lua | 59 ++++----- lua/plugins.lua | 3 +- lua/plugins/editing/treesitter.lua | 4 +- lua/plugins/langs/md_quarto/molten-nvim.lua | 11 +- lua/plugins/snacks.lua | 138 +++++++++++++++++++- lua/plugins/workflow/projections.lua | 52 ++++++-- 6 files changed, 217 insertions(+), 50 deletions(-) diff --git a/lua/autocmds/lsp.lua b/lua/autocmds/lsp.lua index 38909d2..666928e 100644 --- a/lua/autocmds/lsp.lua +++ b/lua/autocmds/lsp.lua @@ -26,12 +26,9 @@ vim.api.nvim_create_autocmd('LspAttach', { -- LSP: Diagnostics if lsp_client:supports_method('textDocument/diagnostic') then - vim.keymap.set( - 'n', - 'le', - require('fzf-lua').diagnostics_document, - { buffer = buf, desc = '[L]SP [E]rrors' } - ) + vim.keymap.set('n', 'le', function() + require('snacks').picker.diagnostics_buffer() + end, { buffer = buf, desc = '[L]SP [E]rrors' }) end -- LSP: Diagnostics @@ -48,20 +45,6 @@ vim.api.nvim_create_autocmd('LspAttach', { id = lsp_client.id, }) end, { buffer = buf, desc = '[L]SP [F]ormat' }) - - -- Format the current buffer on save - --- TODO: Only on filetypes w/fast formatters? - --vim.api.nvim_create_autocmd('BufWritePre', { - -- buffer = buf, - -- callback = function() - -- require('conform').format({ - -- async = true, - -- bufnr = buf, - -- id = lsp_client.id, - -- }) - -- --vim.lsp.buf.format({ bufnr = buf, id = lsp_client.id }) - -- end - --}) end -- LSP Action: Inlay Hint @@ -80,12 +63,9 @@ vim.api.nvim_create_autocmd('LspAttach', { -- LSP Action: Code Actions if lsp_client:supports_method('textDocument/codeAction') then - vim.keymap.set( - 'n', - 'li', - require('fzf-lua').lsp_code_actions, - { buffer = buf, desc = '[L]SP F[I]xes' } - ) + vim.keymap.set('n', 'li', function() + vim.lsp.buf.code_action() + end, { buffer = buf, desc = '[L]SP F[I]xes' }) end -- LSP Action: Rename @@ -104,17 +84,30 @@ vim.api.nvim_create_autocmd('LspAttach', { or lsp_client:supports_method('textDocument/typeDefinition') or lsp_client:supports_method('textDocument/definition') then - vim.keymap.set('n', 'ld', require('fzf-lua').lsp_finder, { buffer = buf, desc = '[L]SP Fin[D]er' }) + vim.keymap.set('n', 'ld', function() + require('snacks').picker.smart({ + multi = { + 'lsp_definitions', + 'lsp_references', + 'lsp_implementations', + 'lsp_type_definitions', + }, + format = 'file', + matcher = { + cwd_bonus = true, + frecency = false, + sort_empty = true, + }, + transform = 'unique_file', + }) + end, { buffer = buf, desc = '[L]SP Fin[D]er' }) end -- LSP Action: List Buffer Symbols if lsp_client:supports_method('textDocument/documentSymbol') then - vim.keymap.set( - 'n', - 'ls', - require('fzf-lua').lsp_document_symbols, - { buffer = buf, desc = '[L]SP [S]ymbols' } - ) + vim.keymap.set('n', 'ls', function() + require('snacks').lsp_symbols() + end, { buffer = buf, desc = '[L]SP [S]ymbols' }) end end, }) diff --git a/lua/plugins.lua b/lua/plugins.lua index bb7bbf8..b3e3684 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -36,7 +36,7 @@ require('lazy').setup({ -- Search: telescope (for now) --- Keys: s - require('plugins/search/fzf-lua'), + --require('plugins/search/fzf-lua'), -- Version Control: git ---- Keys: g @@ -76,7 +76,6 @@ require('lazy').setup({ -- Workflow require('plugins/workflow/projections'), - require('plugins/workflow/mini-files'), --require('plugins/workflow/git-dev'), --require('plugins/workflow/sad'), diff --git a/lua/plugins/editing/treesitter.lua b/lua/plugins/editing/treesitter.lua index fb6583b..4b600f1 100644 --- a/lua/plugins/editing/treesitter.lua +++ b/lua/plugins/editing/treesitter.lua @@ -249,7 +249,9 @@ return { -- Use Treesitter as the Folding Method --vim.opt.foldmethod = "expr" --vim.opt.foldexpr = "nvim_treesitter#foldexpr()" - -- + + -- Suppress Concealment of ``` + --- See https://github.com/nvim-treesitter/nvim-treesitter/issues/5751 require('vim.treesitter.query').set( 'markdown', 'highlights', diff --git a/lua/plugins/langs/md_quarto/molten-nvim.lua b/lua/plugins/langs/md_quarto/molten-nvim.lua index 0da2399..f475ae4 100644 --- a/lua/plugins/langs/md_quarto/molten-nvim.lua +++ b/lua/plugins/langs/md_quarto/molten-nvim.lua @@ -38,6 +38,7 @@ return { prompt = 'Enter Jupyter Server URL:', }, function(input) if input then + vim.print(input) vim.cmd(':MoltenInit ' .. input) end end) @@ -61,17 +62,17 @@ return { init = function() -- Configuration if vim.g.neovide then - vim.g.molten_image_provider = 'image.nvim' - else vim.g.molten_image_provider = 'none' + else + vim.g.molten_image_provider = 'image.nvim' + vim.g.molten_image_location = 'float' end vim.g.molten_output_win_max_height = 12 - --vim.g.molten_auto_open_output = false + vim.g.molten_auto_open_output = false vim.g.molten_auto_init_behavior = 'raise' vim.g.molten_virt_text_output = true - vim.g.molten_image_location = 'float' + vim.g.molten_virt_lines_off_by_1 = true --vim.g.molten_output_show_more = true - vim.g.molten_output_virt_lines = false vim.g.molten_use_border_highlights = true end, } diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua index f7ce281..726bb72 100644 --- a/lua/plugins/snacks.lua +++ b/lua/plugins/snacks.lua @@ -5,6 +5,7 @@ return { priority = 1000, keys = { + -- Buffer Management { 'd', function() @@ -13,7 +14,7 @@ return { desc = 'Delete Current Buffer', }, - -- UX + -- UX: Zen Mode --- u { 'ud', @@ -36,6 +37,131 @@ return { end, desc = '[U]I [Z]en Mode', }, + + -- Picker + --- Accessibility + { + 's?', + function() + require('snacks').picker.pickers() + end, + 'n', + desc = '[S]earch Pickers', + }, + { + 'sh', + function() + require('snacks').picker.help() + end, + 'n', + desc = '[S]earch [H]elp Tags', + }, + { + 'sk', + function() + require('snacks').picker.keymaps() + end, + 'n', + desc = '[S]earch [K]eymaps', + }, + { + 'sc', + function() + require('snacks').picker.commands() + end, + 'n', + desc = '[S]earch [C]ommands', + }, + { + 'sm', + function() + require('snacks').picker.man() + end, + 'n', + desc = '[S]earch [M]anpages', + }, + + --- Grep + { + 'sg', + function() + require('snacks').picker.grep() + end, + 'n', + desc = '[S]earch w/[G]rep', + }, + + --- Buffer / File Search + { + 'sb', + function() + require('snacks').picker.buffers() + end, + 'n', + desc = '[S]earch [B]uffers', + }, + { + 'sf', + function() + require('snacks').picker.files() + end, + 'n', + desc = '[S]earch [F]iles', + }, + { + 'st', + function() + require('snacks').explorer() + end, + 'n', + desc = '[S]earch File[T]ree', + }, + + --- Git: "VCS" -> "v" + { + 'svd', + function() + require('snacks').picker.git_diff() + end, + 'n', + desc = '[S]earch Git [L]og', + }, + { + 'svl', + function() + require('snacks').picker.git_log_file() + end, + 'n', + desc = '[S]earch Git [L]og', + }, + { + 'svs', + function() + require('snacks').picker.git_status() + end, + 'n', + desc = '[S]earch Git [S]tatus', + }, + + --- Debug + { + 'sd', + function() + require('snacks').picker.diagnostics_buffer() + end, + 'n', + desc = '[S]earch [D]iagnostics', + }, + + --- Vim + { + "s'", + function() + require('snacks').picker.registers() + end, + 'n', + desc = '[S]earch Vim Registers', + }, }, opts = { @@ -48,6 +174,16 @@ return { -- Dim: Focus on the Active Scope dim = {}, + -- Picker + picker = { + --sources = { + -- ['projections'] = { + -- preview = 'preview', + -- format = "text", + -- }, + --}, + }, + -- Indent: Indentation Guides indent = { animate = { diff --git a/lua/plugins/workflow/projections.lua b/lua/plugins/workflow/projections.lua index af29077..cbb7f9d 100644 --- a/lua/plugins/workflow/projections.lua +++ b/lua/plugins/workflow/projections.lua @@ -12,26 +12,62 @@ local function store_session() end end +local function get_projects_table() + local workspaces = require('projections.workspace').get_workspaces() + + local projects = {} + for _, ws in ipairs(workspaces) do + for _, project in ipairs(ws:projects()) do + table.insert(projects, { + text = tostring(project.name), + project_name = tostring(project.name), + project_path = tostring(project:path()), + }) + end + end + + return projects +end + -- Plugin return { 'gnikdroy/projections.nvim', commit = '889914169fa1f5c00fb8659653b5a8330fb223e6', lazy = true, - dependencies = { - { - 'nyngwang/fzf-lua-projections.nvim', - commit = '411672ab6f7c38d3a4a51916fda1a01c1618ae04', - }, - }, + --dependencies = { + -- { + -- 'nyngwang/fzf-lua-projections.nvim', + -- commit = '411672ab6f7c38d3a4a51916fda1a01c1618ae04', + -- }, + --}, keys = { { 'sp', function() - require('fzf-lua-p').projects() + require('snacks.picker.core.picker').new({ + title = 'Projects', + items = get_projects_table(), + preview = 'preview', + layout = { + preview = false, + --preset = 'select', + }, + format = 'text', + confirm = function(picker, item) + picker:close() + + if item then + vim.schedule(function() + store_session() + require('projections.switcher').switch(item.project_path) + end) + end + end, + }) end, - 'n', + desc = '[S]earch [P]rojects', }, },