{ pkgs, lib, helpers, ... }: let inherit (helpers) mkRaw; inherit (lib.marleyvim) keys; in { extraPackages = [pkgs.lazygit]; plugins.snacks = { enable = true; settings = { bigfile.enabled = true; notifier.enabled = true; quickfile.enabled = true; statuscolumn.enabled = true; words.enabled = true; }; }; keymaps = [ (keys.mk ["n"] "un" ( mkRaw '' function() Snacks.notifier.hide() end '' ) "Dismiss All Notifications") (keys.mk ["n"] "bd" ( mkRaw '' function() Snacks.bufdelete() end '' ) "Delete Buffer") (keys.mk ["n"] "bo" ( mkRaw '' function() Snacks.bufdelete.other() end '' ) "Delete Other Buffers") # LazyGit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (keys.mk ["n"] "gg" ( mkRaw '' function() Snacks.lazygit() end '' ) "Lazygit") (keys.mk ["n"] "gf" ( mkRaw '' function() Snacks.lazygit.log_file() end '' ) "Lazygit Current File History") (keys.mk ["n"] "gl" ( mkRaw '' function() Snacks.lazygit.log() end '' ) "Lazygit Log") # Git - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (keys.mk ["n"] "gb" ( mkRaw '' function() Snacks.git.blame_line() end '' ) "Git Blame Line") (keys.mk ["n" "x"] "gB" ( mkRaw '' function() Snacks.gitbrowse() end '' ) "Git Browse (open)") (keys.mk ["n" "x"] "gY" ( mkRaw '' function() Snacks.gitbrowse({ open = function(url) vim.fn.setreg("+", url) end }) end '' ) "Git Browse (copy)") ]; # Toggles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - extraConfigLua = # lua '' ---@param buf? number function format_enabled(buf) buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf local gaf = vim.g.autoformat local baf = vim.b[buf].autoformat -- If the buffer has a local value, use that if baf ~= nil then return baf end -- Otherwise use the global value if set, or true by default return gaf == nil or gaf end ---@param enable? boolean ---@param buf? boolean function format_enable(state, buf) if enable == nil then enable = true end if buf then vim.b.autoformat = enable else vim.g.autoformat = enable vim.b.autoformat = nil end end ---@param buf? boolean function toggle_format(buf) return Snacks.toggle({ name = "Auto Format (" .. (buf and "Buffer" or "Global") .. ")", get = function() if not buf then return vim.g.autoformat == nil or vim.g.autoformat end return format_enabled() end, set = function(state) format_enable(state, buf) end, }) end toggle_format():map("uf") toggle_format(true):map("uF") Snacks.toggle.option("spell", { name = "Spelling"}):map("us") Snacks.toggle.option("wrap", {name = "Wrap"}):map("uw") Snacks.toggle.option("relativenumber", { name = "Relative Number"}):map("uL") Snacks.toggle.diagnostics():map("ud") Snacks.toggle.line_number():map("ul") Snacks.toggle.option("conceallevel", {off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2}):map("uc") Snacks.toggle.treesitter():map("uT") Snacks.toggle.option("background", { off = "light", on = "dark" , name = "Dark Background"}):map("ub") if vim.lsp.inlay_hint then Snacks.toggle.inlay_hints():map("uh") end function maximize_window() ---@type {k:string, v:any}[]? local maximized = nil return Snacks.toggle({ name = "Maximize", get = function() return maximized ~= nil end, set = function(state) if state then maximized = {} local function set(k, v) table.insert(maximized, 1, { k = v, v = vim.o[k] }) vim.o[k] = v end set("winwidth", 999) set("winheight", 999) set("winminwidth", 10) set("winminheight", 4) vim.cmd("wincmd =") vim.api.nvim_create_autocmd("ExitPre", { once = true, group = vim.api.nvim_create_augroup("marleyvim_restore_max_exit_pre", { clear = true }), desc = "Restore width/height when closing Neovim while maximized", callback = function() maximize_window.set(false) end, }) else for _, opt in ipairs(maximized) do vim.o[opt.k] = opt.v end maximized = nil vim.cmd("wincmd =") end end, }) end maximize_window():map("wm") ''; }