Skip to content

Commit

Permalink
Migrate fzf-lua to Snacks.picker
Browse files Browse the repository at this point in the history
  • Loading branch information
mau-mauricelim committed Feb 5, 2025
1 parent e50c026 commit 787367d
Show file tree
Hide file tree
Showing 10 changed files with 447 additions and 59 deletions.
36 changes: 17 additions & 19 deletions .config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,39 @@
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"blink.cmp": { "branch": "main", "commit": "b6f11a0aa33e601c469a126e3ed6e35208fe3ea3" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" },
"cellular-automaton.nvim": { "branch": "main", "commit": "1606e9d5d04ff254023c3f3c62842d065708d6d3" },
"conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" },
"duck.nvim": { "branch": "main", "commit": "d8a6b08af440e5a0e2b3b357e2f78bb1883272cd" },
"fidget.nvim": { "branch": "main", "commit": "a0abbf18084b77d28bc70e24752e4f4fd54aea17" },
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"fidget.nvim": { "branch": "main", "commit": "3fa10de61546fd0a98faac3084a6c0db612adaf8" },
"flash.nvim": { "branch": "main", "commit": "f899265876ecdcf7352dbc9f0adf87068cedefbb" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"fzf-lua": { "branch": "main", "commit": "7a83b844423c6ec55c445f1de9ad51fe038f5df5" },
"gitsigns.nvim": { "branch": "main", "commit": "d8918f06624dd53b9a82bd0e29c31bcfd541b40d" },
"grug-far.nvim": { "branch": "main", "commit": "635e69adf3a714621bd0a289314bc23c5848babb" },
"gitsigns.nvim": { "branch": "main", "commit": "0883d0f67c1b728713deeddfcec4aabf71410801" },
"grug-far.nvim": { "branch": "main", "commit": "3a8690461afac34c0e5bacb0f7b4bc3066aab665" },
"harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" },
"incline.nvim": { "branch": "main", "commit": "16fc9c073e3ea4175b66ad94375df6d73fc114c0" },
"indent-blankline.nvim": { "branch": "master", "commit": "e10626f7fcd51ccd56d7ffc00883ba7e0aa28f78" },
"lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" },
"lazy.nvim": { "branch": "main", "commit": "7527af40ddd4a93a02911be570b32609b9d4ea53" },
"lazydev.nvim": { "branch": "main", "commit": "a1b78b2ac6f978c72e76ea90ae92a94edf380cfc" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "f75e877f5266e87523eb5a18fcde2081820d087b" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "374c78d3ebb5c53f43ea6bd906b6587b5e899b9e" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.nvim": { "branch": "main", "commit": "7a75a970d0bae09ef579e41dbb20551bdf596f31" },
"noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" },
"mini.nvim": { "branch": "main", "commit": "87fc38a8a2b8d498cecb021d057a38ea2e9f5a79" },
"noice.nvim": { "branch": "main", "commit": "e3c68a4d2275a01268a52e2931bfccfbfb693d15" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-lspconfig": { "branch": "master", "commit": "e5bf88e5ea1c4cea5ea96b1e970cb264f7a401a1" },
"nvim-tree.lua": { "branch": "master", "commit": "d529a99f88e0dff02e0aa275db2f595cd252a2c8" },
"nvim-treesitter": { "branch": "master", "commit": "61a385d74f822dcd1d223f42f1267d1317aaa2d0" },
"nvim-web-devicons": { "branch": "master", "commit": "1c9136332840edee0c593f2f4f89598c8ed97f5f" },
"nvim-lspconfig": { "branch": "master", "commit": "66bc018936c6ff76beb75f89d986af6442db4001" },
"nvim-treesitter": { "branch": "master", "commit": "9e0b5e7f0d148963d6ec71c48cec1a3f8607d619" },
"nvim-web-devicons": { "branch": "master", "commit": "402377242b04be3f4f0f3720bd952df86e946c30" },
"onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" },
"plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" },
"snacks.nvim": { "branch": "main", "commit": "b96bd540f785c725289f9f15f0147b1b2dac5a35" },
"snacks.nvim": { "branch": "main", "commit": "09349ecd44040666db9d4835994a378a9ff53e8c" },
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
"trouble.nvim": { "branch": "main", "commit": "50481f414bd3c1a40122c1d759d7e424d5fafe84" },
"trouble.nvim": { "branch": "main", "commit": "6f380b8826fb819c752c8fd7daaee9ef96d4c689" },
"undotree": { "branch": "master", "commit": "2556c6800b210b2096b55b66e74b4cc1d9ebbe4f" },
"vim-fugitive": { "branch": "master", "commit": "d74a7cff4cfcf84f83cc7eccfa365488f3bbabc2" },
"vim-fugitive": { "branch": "master", "commit": "b068eaf1e6cbe35d1ac100d435cd7f7b74a5c87d" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
"vim-tmux-navigator": { "branch": "master", "commit": "d847ea942a5bb4d4fab6efebc9f30d787fd96e65" },
"vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" },
"which-key.nvim": { "branch": "main", "commit": "6cebd86917df559a88de0f806b2989799c6e6423" }
"which-key.nvim": { "branch": "main", "commit": "0e76a87ac51772569aec678dc74baa8e2a86100c" }
}
4 changes: 2 additions & 2 deletions .config/nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ vim.keymap.set('v', '<', '<gv')
vim.keymap.set('v', '>', '>gv')

-- Sentence case word
vim.keymap.set('n', '<Leader>gs', 'guiwv~', { desc = '[S]entence case word' })
vim.keymap.set('n', '<Leader>gS', 'guiwv~', { desc = '[S]entence case word' })

-- Visual block mode (Default Ctrl-V)
-- Ctrl-V is bound to paste in Windows Terminal, use Ctrl-Q instead
Expand All @@ -148,7 +148,7 @@ vim.keymap.set('n', '<Leader>xl', '<cmd>exec "lua ".getline(".")<CR>', { desc =
vim.keymap.set('n', '<Leader>xp', '<cmd>exec "lua P(".getline(".").")"<CR>', { desc = 'E[X]ecute current line in Lua print()' })

-- Add -- stylua: ignore above current line
vim.keymap.set('n', '<Leader>si', 'yyP^d$a-- stylua: ignore<Esc>', { desc = 'Add [S]tylua [I]gnore above current line' })
vim.keymap.set('n', '<Leader>li', 'yyP^d$a-- stylua: ignore<Esc>', { desc = 'Add [L]ua [I]gnore above current line' })

-- Change all
vim.keymap.set('n', 'cA', 'ggdGi', { desc = '[C]hange [A]ll lines' })
Expand Down
File renamed without changes.
File renamed without changes.
41 changes: 39 additions & 2 deletions .config/nvim/lua/plugins/flash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,50 @@ return {
[motion:lower()] = 'next',
[motion:upper()] = 'prev',
-- jump2d style: same case goes next, opposite case goes prev
-- [motion] = "next",
-- [motion:match("%l") and motion:upper() or motion:lower()] = "prev",
-- [motion] = 'next',
-- [motion:match('%l') and motion:upper() or motion:lower()] = 'prev',
}
end,
},
},
},
specs = {
{
'folke/snacks.nvim',
opts = {
picker = {
win = {
input = {
keys = {
['<C-f>'] = { 'flash', mode = { 'n', 'i' } },
-- ['s'] = { 'flash' },
},
},
},
actions = {
flash = function(picker)
require('flash').jump({
pattern = '^',
label = { after = { 0, 0 } },
search = {
mode = 'search',
exclude = {
function(win)
return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= 'snacks_picker_list'
end,
},
},
action = function(match)
local idx = picker.list:row2idx(match.pos[1])
picker.list:_move(idx, true, true)
end,
})
end,
},
},
},
},
},
-- stylua: ignore
keys = {
{ '<C-f>', mode = { 'n', 'x', 'o' }, function() require('flash').jump() end, desc = 'Flash' },
Expand Down
6 changes: 3 additions & 3 deletions .config/nvim/lua/plugins/grug-far.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ return { -- Find And Replace plugin for neovim
'MagicDuck/grug-far.nvim',
keys = {
{
'<Leader>fr',
'<Leader>fR',
mode = { 'n' },
function()
require('grug-far').open({ prefills = { paths = vim.fn.expand('%') } })
end,
desc = '[F]ind and [R]eplace in current file',
},
{
'<Leader>gfw',
'<Leader>fW',
mode = { 'n' },
function()
require('grug-far').open({ prefills = { search = vim.fn.expand('<cword>') } })
end,
desc = '[G]rug-[F]ar search current [W]ord under the cursor',
},
{
'<Leader>gfv',
'<Leader>fV',
mode = { 'v' },
[[:<C-u>lua require('grug-far').with_visual_selection({ prefills = { paths = vim.fn.expand("%") } })<CR>]],
desc = '[G]rug-[F]ar search current visual selection in current file',
Expand Down
32 changes: 0 additions & 32 deletions .config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,6 @@ return { -- LSP Configuration & Plugins
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end

local fzf_lua = require('fzf-lua')
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-T>.
-- https://github.com/ibhagwan/fzf-lua/wiki#lsp-single-result
map('gd', function() fzf_lua.lsp_definitions({ jump_to_single_result=true, ignore_current_line=true }) end, '[G]oto [D]efinition')

-- Find references for the word under your cursor.
-- `gr` is used by mini-operators
map('gR', fzf_lua.lsp_references, '[G]oto [R]eferences')

-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
map('gI', fzf_lua.lsp_implementations, '[G]oto [I]mplementation')

-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
map('<Leader>D', fzf_lua.lsp_typedefs, 'Type [D]efinition')

-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map('<Leader>ds', fzf_lua.lsp_document_symbols, '[D]ocument [S]ymbols')

-- Fuzzy find all the symbols in your current workspace
-- Similar to document symbols, except searches over your whole project.
map('<Leader>ws', fzf_lua.lsp_workspace_symbols, '[W]orkspace [S]ymbols')

-- Rename the variable under your cursor
-- Most Language Servers support renaming across files, etc.
map('<Leader>rv', vim.lsp.buf.rename, '[R]ename [V]ariable')
Expand All @@ -101,10 +73,6 @@ return { -- LSP Configuration & Plugins
-- See `:help K` for why this keymap
map('K', vim.lsp.buf.hover, 'Hover Documentation')

-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')

-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
Expand Down
Loading

0 comments on commit 787367d

Please sign in to comment.