diff --git a/plugins/by-name/snacks/default.nix b/plugins/by-name/snacks/default.nix new file mode 100644 index 00000000..bf229d9c --- /dev/null +++ b/plugins/by-name/snacks/default.nix @@ -0,0 +1,259 @@ +{ lib, ... }: +let + inherit (lib) types; + inherit (lib.nixvim) defaultNullOpts; +in +lib.nixvim.neovim-plugin.mkNeovimPlugin { + name = "snacks"; + originalName = "snacks.nvim"; + package = "snacks-nvim"; + + maintainers = [ lib.maintainers.HeitorAugustoLN ]; + + settingsOptions = { + bigfile = { + enabled = defaultNullOpts.mkBool true '' + Whether to enable `bigfile` plugin. + ''; + + notify = defaultNullOpts.mkBool true '' + Whether to show notification when big file detected. + ''; + + size = defaultNullOpts.mkNum { __raw = "1.5 * 1024 * 1024"; } '' + The size at which a file is considered big. + ''; + + setup = + defaultNullOpts.mkRaw + '' + function(ctx) + vim.b.minianimate_disable = true + vim.schedule(function() + vim.bo[ctx.buf].syntax = ctx.ft + end) + end + '' + '' + Enable or disable features when a big file is detected. + ''; + }; + + notifier = { + enabled = defaultNullOpts.mkBool true '' + Whether to enable `notifier` plugin. + ''; + + timeout = defaultNullOpts.mkUnsignedInt 3000 '' + Timeout of notifier in milliseconds. + ''; + + width = { + min = defaultNullOpts.mkNum 40 '' + Minimum width of notification. + ''; + + max = defaultNullOpts.mkNum 0.4 '' + Maximum width of notification. + ''; + }; + + height = { + min = defaultNullOpts.mkNum 40 '' + Minimum height of notification. + ''; + + max = defaultNullOpts.mkNum 0.4 '' + Maximum height of notification. + ''; + }; + + margin = { + top = defaultNullOpts.mkUnsignedInt 0 '' + Top margin of notification. + ''; + + right = defaultNullOpts.mkUnsignedInt 1 '' + Right margin of notification. + ''; + + bottom = defaultNullOpts.mkUnsignedInt 0 '' + Bottom margin of notification. + ''; + }; + padding = defaultNullOpts.mkBool true '' + Whether to add 1 cell of left/right padding to the notification window. + ''; + + sort = + defaultNullOpts.mkListOf types.str + [ + "level" + "added" + ] + '' + How to sort notifications. + ''; + + icons = { + error = defaultNullOpts.mkStr " " '' + Icon for `error` notifications. + ''; + + warn = defaultNullOpts.mkStr " " '' + Icon for `warn` notifications. + ''; + + info = defaultNullOpts.mkStr " " '' + Icon for `info` notifications. + ''; + + debug = defaultNullOpts.mkStr " " '' + Icon for `debug` notifications. + ''; + + trace = defaultNullOpts.mkStr " " '' + Icon for `trace` notifications. + ''; + }; + + style = + defaultNullOpts.mkEnum + [ + "compact" + "fancy" + "minimal" + ] + "compact" + '' + Style of notifications. + ''; + top_down = defaultNullOpts.mkBool true '' + Whether to place notifications from top to bottom. + ''; + + date_format = defaultNullOpts.mkStr "%R" '' + Time format for notifications. + ''; + + refresh = defaultNullOpts.mkUnsignedInt 50 '' + Time in milliseconds to refresh notifications. + ''; + }; + + quickfile = { + enabled = defaultNullOpts.mkBool true '' + Whether to enable `quickfile` plugin. + ''; + + exclude = defaultNullOpts.mkListOf types.str [ "latex" ] '' + Filetypes to exclude from `quickfile` plugin. + ''; + }; + statuscolumn = { + enabled = defaultNullOpts.mkBool true '' + Whether to enable `statuscolumn` plugin. + ''; + + left = + defaultNullOpts.mkListOf types.str + [ + "mark" + "sign" + ] + '' + Priority of signs on the left (high to low). + ''; + + right = + defaultNullOpts.mkListOf types.str + [ + "fold" + "git" + ] + '' + Priority of signs on the right (high to low) + ''; + folds = { + open = defaultNullOpts.mkBool false '' + Whether to show open fold icons. + ''; + + git_hl = defaultNullOpts.mkBool false '' + Whether to use Git Signs hl for fold icons. + ''; + }; + git = { + patterns = + defaultNullOpts.mkListOf types.str + [ + "GitSign" + "MiniDiffSign" + ] + '' + Patterns to match Git signs. + ''; + }; + + refresh = defaultNullOpts.mkUnsignedInt 50 '' + Time in milliseconds to refresh statuscolumn. + ''; + }; + words = { + enabled = defaultNullOpts.mkBool true '' + Whether to enable `words` plugin. + ''; + + debounce = defaultNullOpts.mkUnsignedInt 200 '' + Time in ms to wait before updating. + ''; + + notify_jump = defaultNullOpts.mkBool false '' + Whether to show a notification when jumping. + ''; + + notify_end = defaultNullOpts.mkBool true '' + Whether to show a notification when reaching the end. + ''; + + foldopen = defaultNullOpts.mkBool true '' + Whether to open folds after jumping. + ''; + + jumplist = defaultNullOpts.mkBool true '' + Whether to set jump point before jumping. + ''; + + modes = + defaultNullOpts.mkListOf types.str + [ + "n" + "i" + "c" + ] + '' + Modes to show references. + ''; + }; + }; + + settingsExample = { + bigfile = { + enabled = true; + }; + statuscolumn = { + enabled = false; + }; + words = { + enabled = true; + debounce = 100; + }; + quickfile = { + enabled = false; + }; + notifier = { + enabled = true; + timeout = 3000; + }; + }; +} diff --git a/tests/test-sources/plugins/by-name/snacks/default.nix b/tests/test-sources/plugins/by-name/snacks/default.nix new file mode 100644 index 00000000..162a50b7 --- /dev/null +++ b/tests/test-sources/plugins/by-name/snacks/default.nix @@ -0,0 +1,180 @@ +{ + empty = { + plugins.snacks.enable = true; + }; + + example = { + plugins.snacks = { + enable = true; + + settings = { + bigfile = { + enabled = true; + }; + statuscolumn = { + enabled = false; + }; + words = { + enabled = true; + debounce = 100; + }; + quickfile = { + enabled = false; + }; + notifier = { + enabled = true; + timeout = 3000; + }; + }; + }; + }; + + default = { + plugins.snacks = { + enable = true; + + settings = { + bigfile = { + enabled = true; + notify = true; + size.__raw = "1.5 * 1024 * 1024"; + setup.__raw = '' + function(ctx) + vim.b.minianimate_disable = true + vim.schedule(function() + vim.bo[ctx.buf].syntax = ctx.ft + end) + end + ''; + }; + notifier = { + enabled = true; + timeout = 3000; + width = { + min = 40; + max = 0.4; + }; + height = { + min = 1; + max = 0.6; + }; + margin = { + top = 0; + right = 1; + bottom = 0; + }; + padding = true; + sort = [ + "level" + "added" + ]; + icons = { + error = " "; + warn = " "; + info = " "; + debug = " "; + trace = " "; + }; + style = "compact"; + top_down = true; + date_format = "%R"; + refresh = 50; + }; + quickfile = { + enabled = true; + exclude = [ "latex" ]; + }; + statuscolumn = { + left = [ + "mark" + "sign" + ]; + right = [ + "fold" + "git" + ]; + folds = { + open = false; + git_hl = false; + }; + git = { + patterns = [ + "GitSign" + "MiniDiffSign" + ]; + }; + refresh = 50; + }; + words = { + enabled = true; + debounce = 200; + notify_jump = false; + notify_end = true; + foldopen = true; + jumplist = true; + modes = [ + "n" + "i" + "c" + ]; + }; + }; + }; + }; + + all-plugins = { + plugins.snacks = { + enable = true; + + settings = { + bigfile = { + enabled = true; + notify = true; + size.__raw = "1.5 * 1024 * 1024"; + }; + notifier = { + enabled = true; + timeout = 5000; + width = { + min = 50; + max = 0.5; + }; + padding = false; + sort = [ + "added" + "level" + ]; + style = "fancy"; + refresh = 100; + date_format = "%R"; + top_down = false; + }; + quickfile = { + enabled = true; + exclude = [ "latex" ]; + }; + statuscolumn = { + enabled = true; + left = [ + "sign" + "mark" + ]; + folds.open = true; + refresh = 100; + }; + words = { + enabled = true; + debounce = 300; + notify_jump = true; + notify_end = false; + foldopen = false; + jumplist = true; + modes = [ + "n" + "i" + ]; + }; + }; + }; + }; +}