diff --git a/plugins/utils/dashboard.nix b/plugins/utils/dashboard.nix index cb340315..754b3b69 100644 --- a/plugins/utils/dashboard.nix +++ b/plugins/utils/dashboard.nix @@ -2,78 +2,69 @@ with lib; let cfg = config.programs.nixvim.plugins.dashboard; + + helpers = import ./helpers.nix { inherit lib; }; in { options = { programs.nixvim.plugins.dashboard = { enable = mkEnableOption "Enable dashboard"; - executive = mkOption { - description = "Select the fuzzy search plugin"; - type = types.nullOr (types.enum [ "clap" "fzf" "telescope" ]); - default = null; - }; - - shortcuts = mkOption { - description = "Set the fuzzy search keymaps"; - type = types.nullOr (types.attrsOf types.str); - default = null; - }; - - shortcutsIcon = mkOption { - description = "Icons for shortcuts"; - type = types.nullOr (types.attrsOf types.str); - default = null; - }; - header = mkOption { description = "Header text"; - type = with types; nullOr (listOf str); + type = types.nullOr (types.listOf types.str); default = null; }; footer = mkOption { description = "Footer text"; - type = with types; nullOr (listOf str); + type = types.nullOr (types.listOf types.str); + default = null; + }; + + center = mkOption { + description = "Center section"; + type = types.nullOr (types.listOf (types.submodule { + options = { + icon = mkOption { + description = "Item icon"; + type = types.nullOr types.str; + default = null; + }; + + desc = mkOption { + description = "Item description"; + type = types.str; + }; + + shortcut = mkOption { + description = "Item shortcut"; + type = types.nullOr types.str; + default = null; + }; + + action = mkOption { + description = "Item action"; + type = types.nullOr types.str; + default = null; + }; + }; + })); default = null; }; sessionDirectory = mkOption { - description = "Set the session folder"; + description = "Path to session file"; type = types.nullOr types.str; default = null; }; - sections = mkOption { - description = "Set your own sections"; - type = types.nullOr (types.attrsOf (types.submodule { - options = { - description = mkOption { - description = "String shown in Dashboard buffer"; - type = types.str; - }; - - command = mkOption { - description = "Command or funcref"; - type = types.str; - }; - }; - })); - default = { }; - }; - preview = mkOption { description = "Preview options"; type = types.submodule { options = { command = mkOption { - description = "Command that can print output to neovim built-in terminal"; - type = types.nullOr types.str; - default = null; - }; - - pipeline = mkOption { - description = "Pipeline command"; + description = "Command to print file contents"; type = types.nullOr types.str; default = null; }; @@ -100,50 +91,41 @@ in default = { }; }; - fzf = mkOption { - description = "Some options for fzf"; - type = types.submodule { - options = { - float = mkOption { - description = "Fzf floating window mode"; - type = types.nullOr types.int; - default = null; - }; + hideStatusline = mkOption { + description = "Whether to hide statusline in Dashboard buffer"; + type = types.nullOr types.bool; + default = null; + }; - engine = mkOption { - description = "Grep tool to fzf use"; - type = types.nullOr (types.enum [ "rg" "ag" ]); - default = null; - }; - }; - }; - default = { }; + hideTabline = mkOption { + description = "Whether to hide tabline in Dashboard buffer"; + type = types.nullOr types.bool; + default = null; }; }; }; - config = mkIf cfg.enable { + config = + let + setupOptions = { + custom_header = cfg.header; + custom_footer = cfg.footer; + custom_center = cfg.center; + + preview_file_path = cfg.preview.file; + preview_file_height = cfg.preview.height; + preview_file_width = cfg.preview.width; + preview_command = cfg.preview.command; + + hide_statusline = cfg.hideStatusline; + hide_tabline = cfg.hideTabline; + + session_directory = cfg.sessionDirectory; + }; + in mkIf cfg.enable { programs.nixvim = { extraPlugins = [ pkgs.vimPlugins.dashboard-nvim ]; - extraPackages = if (cfg.fzf.engine == "ag") then [ pkgs.silver-searcher ] - else [ pkgs.ripgrep ]; - - globals = { - dashboard_default_executive = mkIf (!isNull cfg.executive) cfg.executive; - dashboard_custom_shortcut = mkIf (!isNull cfg.shortcuts) cfg.shortcuts; - dashboard_custom_shortcut_icon = mkIf (!isNull cfg.shortcutsIcon) cfg.shortcutsIcon; - dashboard_custom_header = mkIf (!isNull cfg.header) cfg.header; - dashboard_custom_footer = mkIf (!isNull cfg.footer) cfg.footer; - dashboard_session_directory = mkIf (!isNull cfg.sessionDirectory) cfg.sessionDirectory; - dashboard_custom_sections = mkIf (!isNull cfg.sections) cfg.sections; - dashboard_preview_command = mkIf (!isNull cfg.preview.command) cfg.preview.command; - dashboard_preview_pipeline = mkIf (!isNull cfg.preview.pipeline) cfg.preview.pipeline; - dashboard_preview_file = mkIf (!isNull cfg.preview.file) cfg.preview.file; - dashboard_preview_file_height = mkIf (!isNull cfg.preview.height) cfg.preview.height; - dashboard_preview_file_width = mkIf (!isNull cfg.preview.width) cfg.preview.width; - dashboard_fzf_float = mkIf (!isNull cfg.fzf.float) cfg.fzf.float; - dashboard_fzf_engine = mkIf (!isNull cfg.fzf.engine) cfg.fzf.engine; - }; + extraConfigLua = ''require("dashboard").setup(${helpers.toLuaObject setupOptions})''; }; }; }