Skip to content

Commit 3f23f17

Browse files
committed
feat(snacks): use snacks.nvim
1 parent d8ecfda commit 3f23f17

6 files changed

Lines changed: 187 additions & 150 deletions

File tree

lua/custom/plugins/lazygit.lua

Lines changed: 0 additions & 21 deletions
This file was deleted.

lua/custom/plugins/rust.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
return {
22
{
33
'mrcjkb/rustaceanvim',
4-
version = '^6', -- Recommended
54
ft = { 'rust' },
65
config = function()
76
vim.api.nvim_create_autocmd('LspAttach', {
87
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
98
callback = function(args)
109
vim.keymap.set('n', '<localleader>lc', '<cmd>RustLsp openCargo<cr>', { desc = 'Open current Cargo.toml' })
1110
vim.keymap.set('n', '<localleader>ld', '<cmd>RustLsp openDocs<cr>', { desc = 'View symbol at docs.rs' })
12-
vim.keymap.set('n', '<localleader>le', '<cmd>RustLsp explainError<cr>', { desc = 'Explain error on this line' })
11+
vim.keymap.set('n', '<localleader>le', '<cmd>RustLsp explainError current<cr>', { desc = 'Explain error on this line' })
1312
vim.keymap.set('n', '<localleader>lE', '<cmd>RustLsp expandMacro<cr>', { desc = 'Expand Rust macro' })
1413
vim.keymap.set('n', '<localleader>lr', '<cmd>RustLsp runnables<cr>', { desc = 'View current runnables' })
1514
vim.keymap.set('n', '<localleader>lt', '<cmd>RustTest<cr>', { desc = 'Run test under cursor' })
15+
16+
local bufnr = vim.api.nvim_get_current_buf()
17+
vim.keymap.set('n', 'K', function()
18+
vim.cmd.RustLsp { 'hover', 'actions' }
19+
end, { silent = true, buffer = bufnr })
1620
end,
1721
})
1822
vim.g.rustaceanvim = {

lua/kickstart/plugins/lspconfig.lua

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,33 @@ return {
77
opts = {
88
library = {
99
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
10+
{ path = 'snacks.nvim', words = { 'Snacks' } },
1011
},
1112
},
1213
},
1314
{
1415
'folke/trouble.nvim',
1516
opts = {},
17+
specs = {
18+
'folke/snacks.nvim',
19+
opts = function(_, opts)
20+
return vim.tbl_deep_extend('force', opts or {}, {
21+
picker = {
22+
actions = require('trouble.sources.snacks').actions,
23+
win = {
24+
input = {
25+
keys = {
26+
['<c-t>'] = {
27+
'trouble_open',
28+
mode = { 'n', 'i' },
29+
},
30+
},
31+
},
32+
},
33+
},
34+
})
35+
end,
36+
},
1637
cmd = 'Trouble',
1738
keys = {
1839
{
@@ -119,33 +140,32 @@ return {
119140
-- Jump to the definition of the word under your cursor.
120141
-- This is where a variable was first declared, or where a function is defined, etc.
121142
-- To jump back, press <C-t>.
122-
map('gd', deprecated('grd', require('telescope.builtin').lsp_definitions), 'Goto Definition')
123-
map('grd', require('telescope.builtin').lsp_definitions, 'Goto Definition')
143+
map('gd', deprecated('grd', require('snacks').picker.lsp_definitions), 'Goto Definition')
144+
map('grd', require('snacks').picker.lsp_definitions, 'Goto Definition')
124145

125146
-- Find references for the word under your cursor.
126-
map('grr', require('telescope.builtin').lsp_references, 'Goto References')
147+
map('grr', require('snacks').picker.lsp_references, 'Goto References')
127148

128149
-- Jump to the implementation of the word under your cursor.
129150
-- Useful when your language has ways of declaring types without an actual implementation.
130-
map('gI', deprecated('gri', require('telescope.builtin').lsp_implementations), 'Goto Implementation')
131-
map('gri', require('telescope.builtin').lsp_implementations, 'Goto Implementation')
151+
map('gri', require('snacks').picker.lsp_implementations, 'Goto Implementation')
132152

133153
-- Jump to the type of the word under your cursor.
134154
-- Useful when you're not sure what type a variable is and you want to see
135155
-- the definition of its *type*, not where it was *defined*.
136-
map('grt', require('telescope.builtin').lsp_type_definitions, 'Type Definition')
156+
map('grt', require('snacks').picker.lsp_type_definitions, 'Type Definition')
137157

138158
map('<leader>ld', vim.diagnostic.open_float, 'Open diagnostic in float')
139159

140160
-- Fuzzy find all the symbols in your current document.
141161
-- Symbols are things like variables, functions, types, etc.
142-
map('<leader>ls', deprecated('gD', require('telescope.builtin').lsp_document_symbols), 'Document Symbols')
143-
map('gD', require('telescope.builtin').lsp_document_symbols, 'Document Symbols')
162+
map('<leader>ls', deprecated('gD', require('snacks').picker.lsp_symbols), 'Document Symbols')
163+
map('gD', require('snacks').picker.lsp_symbols, 'Document Symbols')
144164

145165
-- Fuzzy find all the symbols in your current workspace.
146166
-- Similar to document symbols, except searches over your entire project.
147-
map('<leader>lS', deprecated('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols), 'Workspace Symbols')
148-
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Workspace Symbols')
167+
map('<leader>lS', deprecated('gW', require('snacks').picker.lsp_workspace_symbols), 'Workspace Symbols')
168+
map('gW', require('snacks').picker.lsp_workspace_symbols, 'Workspace Symbols')
149169

150170
-- Rename the variable under your cursor.
151171
-- Most Language Servers support renaming across files, etc.
@@ -168,8 +188,10 @@ return {
168188
---@return boolean
169189
local function client_supports_method(client, method, bufnr)
170190
if vim.fn.has 'nvim-0.11' == 1 then
191+
---@diagnostic disable-next-line: param-type-mismatch
171192
return client:supports_method(method, bufnr)
172193
else
194+
---@diagnostic disable-next-line: param-type-mismatch
173195
return client.supports_method(method, { bufnr = bufnr })
174196
end
175197
end

lua/kickstart/plugins/snacks.lua

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
-- NOTE: Plugins can specify dependencies.
2+
--
3+
-- The dependencies are proper plugin specifications as well - anything
4+
-- you do for a plugin at the top level, you can do for a dependency.
5+
--
6+
-- Use the `dependencies` key to specify the dependencies of a particular plugin
7+
8+
return {
9+
{ -- Fuzzy Finder (files, lsp, etc)
10+
'folke/snacks.nvim',
11+
priority = 1000,
12+
lazy = false,
13+
dependencies = {
14+
-- Useful for getting pretty icons, but requires a Nerd Font.
15+
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
16+
},
17+
-- snacks.nvim is a plugin that contains a collection of QoL improvements.
18+
-- One of those plugins is called snacks-picker
19+
-- It is a fuzzy finder, inspired by Telescope, that comes with a lot of different
20+
-- things that it can fuzzy find! It's more than just a "file finder", it can search
21+
-- many different aspects of Neovim, your workspace, LSP, and more!
22+
--
23+
-- Two important keymaps to use while in a picker are:
24+
-- - Insert mode: <c-/>
25+
-- - Normal mode: ?
26+
--
27+
-- This opens a window that shows you all of the keymaps for the current
28+
-- Snacks picker. This is really useful to discover what snacks-picker can
29+
-- do as well as how to actually do it!
30+
31+
-- [[ Configure Snacks Pickers ]]
32+
-- See `:help snacks-picker` and `:help snacks-picker-setup`
33+
---@type snacks.Config
34+
opts = {
35+
input = { enabled = true },
36+
picker = { enabled = true },
37+
},
38+
-- See `:help snacks-pickers-sources`
39+
keys = {
40+
{
41+
'<leader>fb',
42+
function()
43+
Snacks.picker.buffers()
44+
end,
45+
desc = 'Find Buffers',
46+
},
47+
{
48+
'<leader>fh',
49+
function()
50+
Snacks.picker.help()
51+
end,
52+
desc = 'Find Help',
53+
},
54+
{
55+
'<leader>fk',
56+
function()
57+
Snacks.picker.keymaps()
58+
end,
59+
desc = 'Find Keymaps',
60+
},
61+
{
62+
'<leader>ff',
63+
function()
64+
Snacks.picker.files()
65+
end,
66+
desc = 'Find Files',
67+
},
68+
{
69+
'<leader>fs',
70+
function()
71+
Snacks.picker.pickers()
72+
end,
73+
desc = 'Find Select Picker',
74+
},
75+
{
76+
'<leader>fw',
77+
function()
78+
Snacks.picker.grep_word()
79+
end,
80+
desc = 'Find Current Word',
81+
},
82+
{
83+
'<leader>fg',
84+
function()
85+
Snacks.picker.grep()
86+
end,
87+
desc = 'Find by Grep',
88+
},
89+
{
90+
'<leader>fd',
91+
function()
92+
Snacks.picker.diagnostics()
93+
end,
94+
desc = 'Find Diagnostics',
95+
},
96+
{
97+
'<leader>fr',
98+
function()
99+
Snacks.picker.resume()
100+
end,
101+
desc = 'Find Resume',
102+
},
103+
{
104+
'<leader>f.',
105+
function()
106+
Snacks.picker.recent()
107+
end,
108+
desc = 'Find Recent Files',
109+
},
110+
{
111+
'<leader>f/',
112+
function()
113+
Snacks.picker.grep_buffers()
114+
end,
115+
desc = 'Find in Open Files',
116+
},
117+
{
118+
'<leader>/',
119+
function()
120+
Snacks.picker.lines()
121+
end,
122+
desc = 'Find in Current File',
123+
},
124+
{
125+
'<leader>fn',
126+
function()
127+
Snacks.picker.files { cwd = vim.fn.stdpath 'config' }
128+
end,
129+
desc = 'Find Neovim Files',
130+
},
131+
132+
{
133+
'<leader>e',
134+
function()
135+
Snacks.picker.explorer()
136+
end,
137+
},
138+
139+
{
140+
'<leader>g',
141+
function()
142+
Snacks.lazygit()
143+
end,
144+
},
145+
},
146+
},
147+
}
148+
-- vim: ts=2 sts=2 sw=2 et

0 commit comments

Comments
 (0)