dashboard.nvim: update options

This commit is contained in:
imMaturana 2022-07-11 15:48:12 -04:00 committed by Pedro Alves
parent c619977f03
commit b8d15fcfbe

View file

@ -2,78 +2,69 @@
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.dashboard; cfg = config.programs.nixvim.plugins.dashboard;
helpers = import ./helpers.nix { inherit lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.dashboard = { programs.nixvim.plugins.dashboard = {
enable = mkEnableOption "Enable 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 { header = mkOption {
description = "Header text"; description = "Header text";
type = with types; nullOr (listOf str); type = types.nullOr (types.listOf types.str);
default = null; default = null;
}; };
footer = mkOption { footer = mkOption {
description = "Footer text"; 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; default = null;
}; };
sessionDirectory = mkOption { sessionDirectory = mkOption {
description = "Set the session folder"; description = "Path to session file";
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; 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 { preview = mkOption {
description = "Preview options"; description = "Preview options";
type = types.submodule { type = types.submodule {
options = { options = {
command = mkOption { command = mkOption {
description = "Command that can print output to neovim built-in terminal"; description = "Command to print file contents";
type = types.nullOr types.str;
default = null;
};
pipeline = mkOption {
description = "Pipeline command";
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
}; };
@ -100,50 +91,41 @@ in
default = { }; default = { };
}; };
fzf = mkOption { hideStatusline = mkOption {
description = "Some options for fzf"; description = "Whether to hide statusline in Dashboard buffer";
type = types.submodule { type = types.nullOr types.bool;
options = { default = null;
float = mkOption { };
description = "Fzf floating window mode";
type = types.nullOr types.int;
default = null;
};
engine = mkOption { hideTabline = mkOption {
description = "Grep tool to fzf use"; description = "Whether to hide tabline in Dashboard buffer";
type = types.nullOr (types.enum [ "rg" "ag" ]); type = types.nullOr types.bool;
default = null; default = null;
};
};
};
default = { };
}; };
}; };
}; };
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 = { programs.nixvim = {
extraPlugins = [ pkgs.vimPlugins.dashboard-nvim ]; extraPlugins = [ pkgs.vimPlugins.dashboard-nvim ];
extraPackages = if (cfg.fzf.engine == "ag") then [ pkgs.silver-searcher ] extraConfigLua = ''require("dashboard").setup(${helpers.toLuaObject setupOptions})'';
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;
};
}; };
}; };
} }