-- Snacks needs to be loaded very early, so it gets its own special file. local set = vim.keymap.set local lazyvim_format = require('lib.lazyvim.format') local lazyvim_root = require('lib.lazyvim.root') require('snacks').setup({ bigfile = { enabled = true }, dashboard = { enabled = true }, }) -- Buffers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- set({ 'n' }, 'bd', function() Snacks.bufdelete() end, { desc = 'Delete buffer' }) set({ 'n' }, 'bo', function() Snacks.bufdelete.other() end, { desc = 'Delete other buffers' }) -- Toggles -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- local toggle = Snacks.toggle lazyvim_format.snacks_toggle():map('uf') lazyvim_format.snacks_toggle(true):map('uF') -- current buffer only toggle.option('spell', { name = 'spelling' }):map('us') toggle.option('wrap', { name = 'wrap' }):map('uw') toggle.option('relativenumber', { name = 'relative number' }):map('uL') toggle.line_number():map('ul') toggle.diagnostics():map('ud') toggle .option( 'conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 } ) :map('uc') toggle.treesitter():map('uT') if vim.lsp.inlay_hint then toggle.inlay_hints():map('uh') end -- Git -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- set({ 'n' }, 'gb', function() Snacks.git.blame_line() end, { desc = 'Git blame line' }) set({ 'n' }, 'gB', function() Snacks.gitbrowse() end, { desc = 'Git browse (open)' }) set({ 'n' }, 'gY', function() Snacks.gitbrowse({ open = function(url) vim.fn.setreg('+', url) end, }) end, { desc = 'Git browse (copy)' }) -- LazyGit -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- if vim.fn.executable('lazygit') == 1 then set({ 'n' }, 'gg', function() Snacks.lazygit({ cwd = lazyvim_root.git() }) end, { desc = 'Lazygit (root dir)' }) -- set({ 'n' }, 'gG', function() -- Snacks.lazygit() -- end, { desc = 'Lazygit (cwd)' }) set({ 'n' }, 'gf', function() Snacks.lazygit.log_file() end, { desc = 'Lazygit current file history' }) set({ 'n' }, 'gl', function() Snacks.lazygit.log({ cwd = lazyvim_root.git() }) end, { desc = 'Lazygit log' }) -- set({ 'n' }, 'gL', function() -- Snacks.lazygit.log() -- end, { desc = 'Lazygit log (cwd)' }) end