nix-community.nixvim/plugins/utils/dashboard.nix

132 lines
3.4 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.nixvim.plugins.dashboard;
2022-07-11 15:48:12 -04:00
2022-07-11 15:49:36 -04:00
helpers = import ../helpers.nix { inherit lib; };
in
{
options = {
programs.nixvim.plugins.dashboard = {
enable = mkEnableOption "Enable dashboard";
header = mkOption {
description = "Header text";
2022-07-11 15:48:12 -04:00
type = types.nullOr (types.listOf types.str);
default = null;
};
footer = mkOption {
description = "Footer text";
2022-07-11 15:48:12 -04:00
type = types.nullOr (types.listOf types.str);
default = null;
};
2022-07-11 15:48:12 -04:00
center = mkOption {
description = "Center section";
type = types.nullOr (types.listOf (types.submodule {
options = {
2022-07-11 15:48:12 -04:00
icon = mkOption {
description = "Item icon";
type = types.nullOr types.str;
default = null;
};
2022-07-11 15:48:12 -04:00
desc = mkOption {
description = "Item description";
type = types.str;
};
2022-07-11 15:48:12 -04:00
shortcut = mkOption {
description = "Item shortcut";
type = types.nullOr types.str;
default = null;
};
action = mkOption {
description = "Item action";
type = types.nullOr types.str;
default = null;
};
};
}));
2022-07-11 15:48:12 -04:00
default = null;
};
sessionDirectory = mkOption {
description = "Path to session file";
type = types.nullOr types.str;
default = null;
};
preview = mkOption {
description = "Preview options";
type = types.submodule {
options = {
command = mkOption {
2022-07-11 15:48:12 -04:00
description = "Command to print file contents";
type = types.nullOr types.str;
default = null;
};
file = mkOption {
description = "Path to preview file";
type = types.nullOr types.str;
default = null;
};
height = mkOption {
description = "The height of the preview file";
type = types.nullOr types.int;
default = null;
};
width = mkOption {
description = "The width of the preview file";
type = types.nullOr types.int;
default = null;
};
};
};
default = { };
};
2022-07-11 15:48:12 -04:00
hideStatusline = mkOption {
description = "Whether to hide statusline in Dashboard buffer";
type = types.nullOr types.bool;
default = null;
};
2022-07-11 15:48:12 -04:00
hideTabline = mkOption {
description = "Whether to hide tabline in Dashboard buffer";
type = types.nullOr types.bool;
default = null;
};
};
};
2022-07-11 15:48:12 -04:00
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 ];
2022-07-11 15:48:12 -04:00
extraConfigLua = ''require("dashboard").setup(${helpers.toLuaObject setupOptions})'';
};
};
}