Skip to content

Commit a59f078

Browse files
committed
chore: switch from telescope to snacks.picker
Based on nvim-lua#1481
1 parent c194520 commit a59f078

File tree

3 files changed

+167
-190
lines changed

3 files changed

+167
-190
lines changed

init.lua

Lines changed: 11 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -378,152 +378,6 @@ require('lazy').setup({
378378
--
379379
-- Use the `dependencies` key to specify the dependencies of a particular plugin
380380

381-
{ -- Fuzzy Finder (files, lsp, etc)
382-
'nvim-telescope/telescope.nvim',
383-
event = 'VimEnter',
384-
dependencies = {
385-
'nvim-lua/plenary.nvim',
386-
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
387-
'nvim-telescope/telescope-fzf-native.nvim',
388-
389-
-- `build` is used to run some command when the plugin is installed/updated.
390-
-- This is only run then, not every time Neovim starts up.
391-
build = 'make',
392-
393-
-- `cond` is a condition used to determine whether this plugin should be
394-
-- installed and loaded.
395-
cond = function()
396-
return vim.fn.executable 'make' == 1
397-
end,
398-
},
399-
{ 'nvim-telescope/telescope-ui-select.nvim' },
400-
{
401-
'nvim-telescope/telescope-live-grep-args.nvim',
402-
-- This will not install any breaking changes.
403-
-- For major updates, this must be adjusted manually.
404-
version = '^1.0.0',
405-
},
406-
407-
-- Useful for getting pretty icons, but requires a Nerd Font.
408-
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
409-
},
410-
config = function()
411-
-- Telescope is a fuzzy finder that comes with a lot of different things that
412-
-- it can fuzzy find! It's more than just a "file finder", it can search
413-
-- many different aspects of Neovim, your workspace, LSP, and more!
414-
--
415-
-- The easiest way to use Telescope, is to start by doing something like:
416-
-- :Telescope help_tags
417-
--
418-
-- After running this command, a window will open up and you're able to
419-
-- type in the prompt window. You'll see a list of `help_tags` options and
420-
-- a corresponding preview of the help.
421-
--
422-
-- Two important keymaps to use while in Telescope are:
423-
-- - Insert mode: <c-/>
424-
-- - Normal mode: ?
425-
--
426-
-- This opens a window that shows you all of the keymaps for the current
427-
-- Telescope picker. This is really useful to discover what Telescope can
428-
-- do as well as how to actually do it!
429-
430-
local lga_actions = require 'telescope-live-grep-args.actions'
431-
432-
-- [[ Configure Telescope ]]
433-
-- See `:help telescope` and `:help telescope.setup()`
434-
require('telescope').setup {
435-
-- You can put your default mappings / updates / etc. in here
436-
-- All the info you're looking for is in `:help telescope.setup()`
437-
--
438-
defaults = {
439-
mappings = {
440-
i = {
441-
['<C-q>'] = require('telescope.actions').smart_send_to_qflist + require('telescope.actions').open_qflist,
442-
['<CR>'] = require('telescope.actions').select_default + require('telescope.actions').center,
443-
['<C-n>'] = require('telescope.actions').cycle_history_next,
444-
['<C-p>'] = require('telescope.actions').cycle_history_prev,
445-
},
446-
},
447-
},
448-
pickers = {
449-
find_files = {
450-
file_ignore_patterns = { 'node_modules', '.git' },
451-
hidden = true,
452-
theme = 'ivy',
453-
},
454-
-- live_grep = {
455-
-- file_ignore_patterns = { 'node_modules', '.git' },
456-
-- additional_args = { '--hidden' },
457-
-- },
458-
marks = {
459-
theme = 'ivy',
460-
},
461-
},
462-
extensions = {
463-
['ui-select'] = {
464-
require('telescope.themes').get_dropdown(),
465-
},
466-
live_grep_args = {
467-
auto_quoting = true, -- enable/disable auto-quoting
468-
-- define mappings, e.g.
469-
mappings = { -- extend mappings
470-
i = {
471-
['<C-k>'] = lga_actions.quote_prompt(),
472-
['<C-i>'] = lga_actions.quote_prompt { postfix = ' --iglob ' },
473-
-- freeze the current list and start a fuzzy search in the frozen list
474-
['<C-space>'] = lga_actions.to_fuzzy_refine,
475-
},
476-
},
477-
theme = 'ivy',
478-
},
479-
},
480-
}
481-
482-
-- Enable Telescope extensions if they are installed
483-
pcall(require('telescope').load_extension, 'fzf')
484-
pcall(require('telescope').load_extension, 'ui-select')
485-
pcall(require('telescope').load_extension, 'live_grep_args')
486-
487-
-- See `:help telescope.builtin`
488-
local builtin = require 'telescope.builtin'
489-
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
490-
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
491-
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
492-
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
493-
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
494-
-- vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
495-
vim.keymap.set('n', '<leader>sg', ":lua require('telescope').extensions.live_grep_args.live_grep_args()<CR>", { desc = '[S]earch by [G]rep' })
496-
vim.keymap.set('n', '<leader>sm', builtin.marks, { desc = '[S]earch [M]arks' })
497-
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
498-
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
499-
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
500-
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
501-
502-
-- Slightly advanced example of overriding default behavior and theme
503-
vim.keymap.set('n', '<leader>/', function()
504-
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
505-
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
506-
winblend = 10,
507-
previewer = false,
508-
})
509-
end, { desc = '[/] Fuzzily search in current buffer' })
510-
511-
-- It's also possible to pass additional configuration options.
512-
-- See `:help telescope.builtin.live_grep()` for information about particular keys
513-
vim.keymap.set('n', '<leader>s/', function()
514-
builtin.live_grep {
515-
grep_open_files = true,
516-
prompt_title = 'Live Grep in Open Files',
517-
}
518-
end, { desc = '[S]earch [/] in Open Files' })
519-
520-
-- Shortcut for searching your Neovim configuration files
521-
vim.keymap.set('n', '<leader>sn', function()
522-
builtin.find_files { cwd = vim.fn.stdpath 'config' }
523-
end, { desc = '[S]earch [N]eovim files' })
524-
end,
525-
},
526-
527381
-- LSP Plugins
528382
{
529383
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
@@ -534,6 +388,7 @@ require('lazy').setup({
534388
library = {
535389
-- Load luvit types when the `vim.uv` word is found
536390
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
391+
{ path = 'snacks.nvim', words = { 'Snacks' } },
537392
},
538393
},
539394
},
@@ -597,35 +452,26 @@ require('lazy').setup({
597452
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
598453
end
599454

600-
-- NOTE:
601-
-- With Neovim v0.11 `gr` is a prefix for a bunch of code actions
602-
-- https://github.com/nvim-lua/kickstart.nvim/pull/1427
603-
-- Commented out the old mapping, let's see how it evolves..
604-
605455
-- Jump to the definition of the word under your cursor.
606456
-- This is where a variable was first declared, or where a function is defined, etc.
607457
-- To jump back, press <C-t>.
608-
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
609-
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
458+
map('gd', require('snacks').picker.lsp_definitions, '[G]oto [D]efinition')
459+
map('grd', require('snacks').picker.lsp_definitions, '[G]oto [D]efinition')
610460

611461
-- Rename the variable under your cursor.
612462
-- Most Language Servers support renaming across files, etc.
613-
-- map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
614463
map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
615464

616465
-- Execute a code action, usually your cursor needs to be on top of an error
617466
-- or a suggestion from your LSP for this to activate.
618-
-- map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
619467
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
620468

621469
-- Find references for the word under your cursor.
622-
-- map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
623-
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
470+
map('grr', require('snacks').picker.lsp_references, '[G]oto [R]eferences')
624471

625472
-- Jump to the implementation of the word under your cursor.
626473
-- Useful when your language has ways of declaring types without an actual implementation.
627-
-- map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
628-
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
474+
map('gri', require('snacks').picker.lsp_implementations, '[G]oto [I]mplementation')
629475

630476
-- WARN: This is not Goto Definition, this is Goto Declaration.
631477
-- For example, in C this would take you to the header.
@@ -635,18 +481,15 @@ require('lazy').setup({
635481
-- Jump to the type of the word under your cursor.
636482
-- Useful when you're not sure what type a variable is and you want to see
637483
-- the definition of its *type*, not where it was *defined*.
638-
-- map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
639-
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
484+
map('grt', require('snacks').picker.lsp_type_definitions, '[G]oto [T]ype Definition')
640485

641486
-- Fuzzy find all the symbols in your current document.
642487
-- Symbols are things like variables, functions, types, etc.
643-
-- map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
644-
map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
488+
map('gO', require('snacks').picker.lsp_symbols, 'Open Document Symbols')
645489

646490
-- Fuzzy find all the symbols in your current workspace.
647491
-- Similar to document symbols, except searches over your entire project.
648-
-- map('<leader>Ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
649-
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
492+
map('gW', require('snacks').picker.lsp_workspace_symbols, 'Open Workspace Symbols')
650493

651494
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
652495
---@param client vim.lsp.Client
@@ -977,7 +820,7 @@ require('lazy').setup({
977820
-- Change the name of the colorscheme plugin below, and then
978821
-- change the command in the config to whatever the name of that colorscheme is.
979822
--
980-
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
823+
-- If you want to see what colorschemes are already installed, you can use `:lua Snacks.picker.colorschemes()`.
981824
'catppuccin/nvim',
982825
name = 'catppuccin',
983826
priority = 1000, -- Make sure to load this before all the other start plugins.
@@ -1078,9 +921,9 @@ require('lazy').setup({
1078921
{ import = 'custom.plugins' },
1079922
--
1080923
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
1081-
-- Or use telescope!
924+
-- Or use hte "help" snacks-picker!
1082925
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
1083-
-- you can continue same window with `<space>sr` which resumes last telescope search
926+
-- you can continue same window with `<space>sr` which resumes last snacks-picker search
1084927
}, {
1085928
ui = {
1086929
-- If you are using a Nerd Font: set icons to an empty table which will use the

lua/custom/plugins/copilot-chat.lua

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,10 @@ return {
1313
opts = {
1414
-- See Configuration section for options
1515
model = 'claude-3.7-sonnet',
16-
contexts = {
17-
-- Open a file picker to select a file
18-
-- https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/690#issuecomment-2551162017
19-
-- file = {
20-
-- input = function(callback)
21-
-- local telescope = require 'telescope.builtin'
22-
-- local actions = require 'telescope.actions'
23-
-- local action_state = require 'telescope.actions.state'
24-
-- telescope.find_files {
25-
-- attach_mappings = function(prompt_bufnr)
26-
-- actions.select_default:replace(function()
27-
-- actions.close(prompt_bufnr)
28-
-- local selection = action_state.get_selected_entry()
29-
-- callback(selection[1])
30-
-- end)
31-
-- return true
32-
-- end,
33-
-- }
34-
-- end,
35-
-- },
36-
},
3716
},
3817
keys = {
3918
{
19+
-- TODO: find a new keymap for this after upgrading to Neovim v11
4020
'<leader>ccq',
4121
function()
4222
-- Create floating window

0 commit comments

Comments
 (0)