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,64 +2,61 @@
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;
};
sessionDirectory = mkOption {
description = "Set the session folder";
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;
};
sections = mkOption {
description = "Set your own sections";
type = types.nullOr (types.attrsOf (types.submodule {
options = {
description = mkOption {
description = "String shown in Dashboard buffer";
desc = mkOption {
description = "Item description";
type = types.str;
};
command = mkOption {
description = "Command or funcref";
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 = { };
default = null;
};
sessionDirectory = mkOption {
description = "Path to session file";
type = types.nullOr types.str;
default = null;
};
preview = mkOption {
@ -67,13 +64,7 @@ in
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;
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" ]);
hideTabline = mkOption {
description = "Whether to hide tabline in Dashboard buffer";
type = types.nullOr types.bool;
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 = {
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})'';
};
};
}