Skip to content

Commit aa93f4d

Browse files
committed
Switch telescope for snacks.nvim
1 parent a788d7f commit aa93f4d

File tree

1 file changed

+48
-105
lines changed

1 file changed

+48
-105
lines changed

init.lua

Lines changed: 48 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -347,108 +347,52 @@ require('lazy').setup({
347347
-- Use the `dependencies` key to specify the dependencies of a particular plugin
348348

349349
{ -- Fuzzy Finder (files, lsp, etc)
350-
'nvim-telescope/telescope.nvim',
351-
event = 'VimEnter',
350+
'folke/snacks.nvim',
351+
priority = 1000,
352+
lazy = false,
352353
dependencies = {
353-
'nvim-lua/plenary.nvim',
354-
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
355-
'nvim-telescope/telescope-fzf-native.nvim',
356-
357-
-- `build` is used to run some command when the plugin is installed/updated.
358-
-- This is only run then, not every time Neovim starts up.
359-
build = 'make',
360-
361-
-- `cond` is a condition used to determine whether this plugin should be
362-
-- installed and loaded.
363-
cond = function() return vim.fn.executable 'make' == 1 end,
364-
},
365-
{ 'nvim-telescope/telescope-ui-select.nvim' },
366-
367354
-- Useful for getting pretty icons, but requires a Nerd Font.
368355
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
369356
},
370-
config = function()
371-
-- Telescope is a fuzzy finder that comes with a lot of different things that
372-
-- it can fuzzy find! It's more than just a "file finder", it can search
373-
-- many different aspects of Neovim, your workspace, LSP, and more!
374-
--
375-
-- The easiest way to use Telescope, is to start by doing something like:
376-
-- :Telescope help_tags
377-
--
378-
-- After running this command, a window will open up and you're able to
379-
-- type in the prompt window. You'll see a list of `help_tags` options and
380-
-- a corresponding preview of the help.
381-
--
382-
-- Two important keymaps to use while in Telescope are:
383-
-- - Insert mode: <c-/>
384-
-- - Normal mode: ?
385-
--
386-
-- This opens a window that shows you all of the keymaps for the current
387-
-- Telescope picker. This is really useful to discover what Telescope can
388-
-- do as well as how to actually do it!
389-
390-
-- [[ Configure Telescope ]]
391-
-- See `:help telescope` and `:help telescope.setup()`
392-
require('telescope').setup {
393-
-- You can put your default mappings / updates / etc. in here
394-
-- All the info you're looking for is in `:help telescope.setup()`
395-
--
396-
-- defaults = {
397-
-- mappings = {
398-
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
399-
-- },
400-
-- },
401-
-- pickers = {}
402-
extensions = {
403-
['ui-select'] = {
404-
require('telescope.themes').get_dropdown(),
405-
},
406-
},
407-
}
408357

409-
-- Enable Telescope extensions if they are installed
410-
pcall(require('telescope').load_extension, 'fzf')
411-
pcall(require('telescope').load_extension, 'ui-select')
412-
413-
-- See `:help telescope.builtin`
414-
local builtin = require 'telescope.builtin'
415-
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
416-
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
417-
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
418-
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
419-
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
420-
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
421-
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
422-
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
423-
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
424-
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
425-
426-
-- Slightly advanced example of overriding default behavior and theme
427-
vim.keymap.set('n', '<leader>/', function()
428-
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
429-
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
430-
winblend = 10,
431-
previewer = false,
432-
})
433-
end, { desc = '[/] Fuzzily search in current buffer' })
434-
435-
-- It's also possible to pass additional configuration options.
436-
-- See `:help telescope.builtin.live_grep()` for information about particular keys
437-
vim.keymap.set(
438-
'n',
439-
'<leader>s/',
440-
function()
441-
builtin.live_grep {
442-
grep_open_files = true,
443-
prompt_title = 'Live Grep in Open Files',
444-
}
445-
end,
446-
{ desc = '[S]earch [/] in Open Files' }
447-
)
358+
-- snacks.nvim is a plugin that contains a collection of QoL improvements.
359+
-- One of those plugins is called snacks-picker
360+
-- It is a fuzzy finder, inspired by Telescope, that comes with a lot of different
361+
-- things that it can fuzzy find! It's more than just a "file finder", it can search
362+
-- many different aspects of Neovim, your workspace, LSP, and more!
363+
--
364+
-- Two important keymaps to use while in a picker are:
365+
-- - Insert mode: <c-/>
366+
-- - Normal mode: ?
367+
--
368+
-- This opens a window that shows you all of the keymaps for the current
369+
-- Snacks picker. This is really useful to discover what nacks-picker can
370+
-- do as well as how to actually do it!
371+
372+
-- [[ Configure Snacks Pickers ]]
373+
-- See `:help snacks-picker` and `:help snacks-picker-setup`
374+
---@type snacks.Config
375+
opts = {
376+
picker = {},
377+
},
448378

379+
-- See `:help snacks-pickers-sources`
380+
keys = {
381+
{ '<leader>sh', function() Snacks.picker.help() end, desc = '[S]earch [H]elp' },
382+
{ '<leader>sk', function() Snacks.picker.keymaps() end, desc = '[S]earch [K]eymaps' },
383+
{ '<leader>sf', function() Snacks.picker.smart() end, desc = '[S]earch [F]iles' },
384+
{ '<leader>ss', function() Snacks.picker.pickers() end, desc = '[S]earch [S]elect Snacks' },
385+
{ '<leader>sw', function() Snacks.picker.grep_word() end, desc = '[S]earch current [W]ord', mode = { 'n', 'x' } },
386+
{ '<leader>sg', function() Snacks.picker.grep() end, desc = '[S]earch by [G]rep' },
387+
{ '<leader>sd', function() Snacks.picker.diagnostics() end, desc = '[S]earch [D]iagnostics' },
388+
{ '<leader>sr', function() Snacks.picker.resume() end, desc = '[S]earch [R]esume' },
389+
{ '<leader>s.', function() Snacks.picker.recent() end, desc = '[S]earch Recent Files ("." for repeat)' },
390+
{ '<leader><leader>', function() Snacks.picker.buffers() end, desc = '[ ] Find existing buffers' },
391+
{ '<leader>/', function() Snacks.picker.lines {} end, desc = '[/] Fuzzily search in current buffer' },
392+
{ '<leader>s/', function() Snacks.picker.grep_buffers() end, desc = '[S]earch [/] in Open Files' },
449393
-- Shortcut for searching your Neovim configuration files
450-
vim.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' })
451-
end,
394+
{ '<leader>sn', function() Snacks.picker.files { cwd = vim.fn.stdpath 'config' } end, desc = '[S]earch [N]eovim files' },
395+
},
452396
},
453397

454398
-- LSP Plugins
@@ -533,33 +477,32 @@ require('lazy').setup({
533477
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
534478

535479
-- Find references for the word under your cursor.
536-
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
537-
480+
map('grr', require('snacks').picker.lsp_references, '[G]oto [R]eferences')
538481
-- Jump to the implementation of the word under your cursor.
539482
-- Useful when your language has ways of declaring types without an actual implementation.
540-
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
483+
map('gri', require('snacks').picker.lsp_implementations, '[G]oto [I]mplementation')
541484

542485
-- Jump to the definition of the word under your cursor.
543486
-- This is where a variable was first declared, or where a function is defined, etc.
544487
-- To jump back, press <C-t>.
545-
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
488+
map('grd', require('snacks').picker.lsp_definitions, '[G]oto [D]efinition')
546489

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

551494
-- Fuzzy find all the symbols in your current document.
552495
-- Symbols are things like variables, functions, types, etc.
553-
map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
496+
map('gO', require('snacks').picker.lsp_symbols, 'Open Document Symbols')
554497

555498
-- Fuzzy find all the symbols in your current workspace.
556499
-- Similar to document symbols, except searches over your entire project.
557-
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
500+
map('gW', require('snacks').picker.lsp_workspace_symbols, 'Open Workspace Symbols')
558501

559502
-- Jump to the type of the word under your cursor.
560503
-- Useful when you're not sure what type a variable is and you want to see
561504
-- the definition of its *type*, not where it was *defined*.
562-
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
505+
map('grt', require('snacks').picker.lsp_type_definitions, '[G]oto [T]ype Definition')
563506

564507
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
565508
---@param client vim.lsp.Client
@@ -865,7 +808,7 @@ require('lazy').setup({
865808
-- Change the name of the colorscheme plugin below, and then
866809
-- change the command in the config to whatever the name of that colorscheme is.
867810
--
868-
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
811+
-- If you want to see what colorschemes are already installed, you can use `:lua Snacks.picker.colorschemes()`.
869812
'folke/tokyonight.nvim',
870813
priority = 1000, -- Make sure to load this before all the other start plugins.
871814
config = function()
@@ -970,9 +913,9 @@ require('lazy').setup({
970913
-- { import = 'custom.plugins' },
971914
--
972915
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
973-
-- Or use telescope!
916+
-- Or use the "help" snacks-picker!
974917
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
975-
-- you can continue same window with `<space>sr` which resumes last telescope search
918+
-- you can continue same window with `<space>sr` which resumes last snacks-picker search
976919
}, {
977920
ui = {
978921
-- If you are using a Nerd Font: set icons to an empty table which will use the

0 commit comments

Comments
 (0)