diff --git a/home/editors/nvim/plugins/utils/snacks/dashboard.nix b/home/editors/nvim/plugins/utils/snacks/dashboard.nix index 3615d83..bbeda03 100644 --- a/home/editors/nvim/plugins/utils/snacks/dashboard.nix +++ b/home/editors/nvim/plugins/utils/snacks/dashboard.nix @@ -1,53 +1,83 @@ -let - themes = import ./themes.nix; - theme = themes.dg_baby; -in { - enabled = true; - preset = { - inherit (theme) header; - keys = [ +{ + plugins.snacks.dashboard = let + themes = import ./themes.nix; + theme = themes.dg_baby; + in { + enabled = true; + preset = { + inherit (theme) header; + keys = [ + { + icon = " "; + key = "f"; + desc = "Find File"; + action = ":lua Snacks.dashboard.pick('files')"; + } + { + icon = " "; + key = "n"; + desc = "New File"; + action = ":ene | startinsert"; + } + { + icon = " "; + key = "l"; + desc = "Live Grep"; + action = ":lua Snacks.dashboard.pick('live_grep')"; + } + { + icon = " "; + key = "o"; + desc = "Old Files"; + action = ":lua Snacks.dashboard.pick('oldfiles')"; + } + { + icon = " "; + key = "q"; + desc = "Quit"; + action = ":qa"; + } + ]; + }; + sections = [ + {section = "header";} { - icon = " "; - key = "f"; - desc = "Find File"; - action = ":lua Snacks.dashboard.pick('files')"; + section = "keys"; + gap = 1; + padding = 1; } { - icon = " "; - key = "n"; - desc = "New File"; - action = ":ene | startinsert"; - } - { - icon = " "; - key = "l"; - desc = "Live Grep"; - action = ":lua Snacks.dashboard.pick('live_grep')"; - } - { - icon = " "; - key = "o"; - desc = "Old Files"; - action = ":lua Snacks.dashboard.pick('oldfiles')"; - } - { - icon = " "; - key = "q"; - desc = "Quit"; - action = ":qa"; + title = theme.quote; + align = "center"; } ]; }; - sections = [ - {section = "header";} - { - section = "keys"; - gap = 1; - padding = 1; - } - { - title = theme.quote; - align = "center"; - } - ]; + + extraConfigLua = + # lua + '' + local prev = { new_name = "", old_name = "" } -- Prevents duplicate events + vim.api.nvim_create_autocmd("User", { + pattern = "NvimTreeSetup", + callback = function() + local events = require("nvim-tree.api").events + events.subscribe(events.Event.NodeRenamed, function(data) + if prev.new_name ~= data.new_name or prev.old_name ~= data.old_name then + data = data + Snacks.rename.on_rename_file(data.old_name, data.new_name) + end + end) + end, + }) + + vim.api.nvim_create_autocmd("User", { + pattern = "SnacksDashboardOpened", + callback = function() + if vim.bo.filetype == "snacks_dashboard" then + vim.b.minitrailspace_disable = true + vim.b.miniindentscope_disable = true + end + end, + }) + ''; } diff --git a/home/editors/nvim/plugins/utils/snacks/default.nix b/home/editors/nvim/plugins/utils/snacks/default.nix index 9ada84f..c79acde 100644 --- a/home/editors/nvim/plugins/utils/snacks/default.nix +++ b/home/editors/nvim/plugins/utils/snacks/default.nix @@ -1,4 +1,6 @@ { + imports = [./dashboard.nix]; + plugins.snacks = { enable = true; settings = { @@ -11,35 +13,6 @@ image.enabled = true; quickfile.enabled = true; rename.enabled = true; - dashboard = import ./dashboard.nix; }; }; - - extraConfigLua = - # lua - '' - local prev = { new_name = "", old_name = "" } -- Prevents duplicate events - vim.api.nvim_create_autocmd("User", { - pattern = "NvimTreeSetup", - callback = function() - local events = require("nvim-tree.api").events - events.subscribe(events.Event.NodeRenamed, function(data) - if prev.new_name ~= data.new_name or prev.old_name ~= data.old_name then - data = data - Snacks.rename.on_rename_file(data.old_name, data.new_name) - end - end) - end, - }) - - vim.api.nvim_create_autocmd("User", { - pattern = "SnacksDashboardOpened", - callback = function() - if vim.bo.filetype == "snacks_dashboard" then - vim.b.minitrailspace_disable = true - vim.b.miniindentscope_disable = true - end - end, - }) - ''; }