mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
theme: finish switching to setupOpts, not building
This commit is contained in:
parent
ba1c3645ee
commit
b66ee19ff3
2 changed files with 116 additions and 69 deletions
|
@ -3,19 +3,28 @@
|
||||||
lib,
|
lib,
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.modules) mkDefault;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.types) bool str;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
cfg = config.vim.theme;
|
cfg = config.vim.theme;
|
||||||
|
|
||||||
|
mkEnableOption' = name: mkEnableOption name // {default = true;};
|
||||||
|
# mkEnableOption' = name: mkEnableOption name;
|
||||||
in {
|
in {
|
||||||
base16 = {
|
base16 = {
|
||||||
setupOpts = {
|
setupOpts = mkPluginSetupOption "base16" {
|
||||||
inherit (cfg) base16-colors;
|
inherit (cfg) base16-colors;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
onedark = {
|
onedark = {
|
||||||
setupOpts = {
|
setupOpts = mkPluginSetupOption "onedark" {
|
||||||
style = cfg.style ? "dark";
|
style = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "dark";
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
setup = _: ''
|
setup = ''
|
||||||
-- OneDark theme
|
-- OneDark theme
|
||||||
require('onedark').load()
|
require('onedark').load()
|
||||||
'';
|
'';
|
||||||
|
@ -23,54 +32,77 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
tokyonight = {
|
tokyonight = {
|
||||||
setupOpts = {
|
setupOpts = mkPluginSetupOption "tokyonight" {
|
||||||
inherit (cfg) transparent;
|
transparent = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = cfg.transparent;
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
setup = _: ''
|
setup = ''
|
||||||
vim.cmd[[colorscheme tokyonight-${cfg.style ? "night"}]]
|
vim.cmd[[colorscheme tokyonight-${cfg.style ? "night"}]]
|
||||||
'';
|
'';
|
||||||
styles = ["day" "night" "storm" "moon"];
|
styles = ["day" "night" "storm" "moon"];
|
||||||
};
|
};
|
||||||
|
|
||||||
dracula = {
|
dracula = {
|
||||||
setupOpts = {
|
setupOpts = mkPluginSetupOption "dracula" {
|
||||||
transparent_bg = cfg.transparent;
|
transparent_bg = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = cfg.transparent;
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
setup = _: ''
|
setup = ''
|
||||||
require('dracula').load();
|
require('dracula').load();
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
catppuccin = {
|
catppuccin = {
|
||||||
setupOpts = {
|
setupOpts = mkPluginSetupOption "catppuccin" {
|
||||||
flavour = cfg.style ? "mocha";
|
# flavour = cfg.style ? "mocha";
|
||||||
transparent_background = cfg.transparent;
|
flavour = mkOption {
|
||||||
term_colors = mkDefault true;
|
type = str;
|
||||||
|
default = cfg.style ? "mocha";
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
|
transparent_background = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = cfg.transparency;
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
|
term_colors = mkEnableOption' "term_colors";
|
||||||
integrations = {
|
integrations = {
|
||||||
nvimtree = {
|
nvimtree = {
|
||||||
enabled = mkDefault true;
|
enabled = mkEnableOption' "enabled";
|
||||||
transparent_panel = cfg.transparent;
|
transparent_panel = mkOption {
|
||||||
show_root = mkDefault true;
|
type = bool;
|
||||||
|
default = cfg.transparency;
|
||||||
|
};
|
||||||
|
show_root = mkEnableOption' "show_root";
|
||||||
};
|
};
|
||||||
|
|
||||||
hop = mkDefault true;
|
hop = mkEnableOption' "hop";
|
||||||
gitsigns = mkDefault true;
|
gitsigns = mkEnableOption' "gitsigns";
|
||||||
telescope = mkDefault true;
|
telescope = mkEnableOption' "telescope";
|
||||||
treesitter = mkDefault true;
|
treesitter = mkEnableOption' "treesitter";
|
||||||
treesitter_context = mkDefault true;
|
treesitter_context = mkEnableOption' "treesitter_context";
|
||||||
ts_rainbow = mkDefault true;
|
ts_rainbow = mkEnableOption' "ts_rainbow";
|
||||||
fidget = mkDefault true;
|
fidget = mkEnableOption' "fidget";
|
||||||
alpha = mkDefault true;
|
alpha = mkEnableOption' "alpha";
|
||||||
leap = mkDefault true;
|
leap = mkEnableOption' "leap";
|
||||||
markdown = mkDefault true;
|
markdown = mkEnableOption' "markdown";
|
||||||
noice = mkDefault true;
|
noice = mkEnableOption' "noice";
|
||||||
# nvim-notify
|
# nvim-notify
|
||||||
notify = mkDefault true;
|
notify = mkEnableOption' "notify";
|
||||||
which_key = mkDefault true;
|
which_key = mkEnableOption' "which_key";
|
||||||
navic = {
|
navic = mkOption {
|
||||||
enabled = mkDefault true;
|
enabled = mkEnableOption' "enabled";
|
||||||
# lualine will set backgound to mantle
|
# lualine will set backgound to mantle
|
||||||
custom_bg = "NONE";
|
custom_bg = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "NONE";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -83,8 +115,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
oxocarbon = {
|
oxocarbon = {
|
||||||
setupOpts = {};
|
setupOpts = mkPluginSetupOption "oxocarbon" {};
|
||||||
setup = _: ''
|
setup = ''
|
||||||
require('oxocarbon')
|
require('oxocarbon')
|
||||||
vim.opt.background = "${cfg.style ? "dark"}"
|
vim.opt.background = "${cfg.style ? "dark"}"
|
||||||
vim.cmd.colorscheme = "oxocarbon"
|
vim.cmd.colorscheme = "oxocarbon"
|
||||||
|
@ -102,32 +134,32 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
gruvbox = {
|
gruvbox = {
|
||||||
setupOpts = {
|
setupOpts = mkPluginSetupOption "gruvbox" {
|
||||||
transparent_mode = cfg.transparent;
|
transparent_mode = cfg.transparent;
|
||||||
# add neovim terminal colors
|
# add neovim terminal colors
|
||||||
terminal_colors = mkDefault true;
|
terminal_colors = mkEnableOption' "terminal_colors";
|
||||||
undercurl = mkDefault true;
|
undercurl = mkEnableOption' "undercurls";
|
||||||
underline = mkDefault true;
|
underline = mkEnableOption' "underline";
|
||||||
bold = mkDefault true;
|
bold = mkEnableOption' "bold";
|
||||||
italic = {
|
italic = {
|
||||||
strings = mkDefault true;
|
strings = mkEnableOption' "strings";
|
||||||
emphasis = mkDefault true;
|
emphasis = mkEnableOption' "emphasis";
|
||||||
comments = mkDefault true;
|
comments = mkEnableOption' "comments";
|
||||||
operators = mkDefault false;
|
operators = mkEnableOption "operators";
|
||||||
folds = mkDefault true;
|
folds = mkEnableOption' "folds";
|
||||||
};
|
};
|
||||||
strikethrough = mkDefault true;
|
strikethrough = mkEnableOption' "strikethrough";
|
||||||
invert_selection = mkDefault false;
|
invert_selection = mkEnableOption "invert_selection";
|
||||||
invert_signs = mkDefault false;
|
invert_signs = mkEnableOption "invert_signs";
|
||||||
invert_tabline = mkDefault false;
|
invert_tabline = mkEnableOption "invert_tabline";
|
||||||
invert_intend_guides = mkDefault false;
|
invert_intend_guides = mkEnableOption "invert_intend_guides";
|
||||||
inverse = mkDefault true;
|
inverse = mkEnableOption' "inverse";
|
||||||
contrast = "";
|
contrast = "";
|
||||||
palette_overrides = {};
|
palette_overrides = {};
|
||||||
overrides = {};
|
overrides = {};
|
||||||
dim_inactive = mkDefault false;
|
dim_inactive = mkEnableOption "dim_inactive";
|
||||||
};
|
};
|
||||||
setup = _: ''
|
setup = ''
|
||||||
-- Gruvbox theme
|
-- Gruvbox theme
|
||||||
vim.o.background = "${cfg.style ? "dark"}"
|
vim.o.background = "${cfg.style ? "dark"}"
|
||||||
vim.cmd("colorscheme gruvbox")
|
vim.cmd("colorscheme gruvbox")
|
||||||
|
@ -135,25 +167,33 @@ in {
|
||||||
styles = ["dark" "light"];
|
styles = ["dark" "light"];
|
||||||
};
|
};
|
||||||
rose-pine = {
|
rose-pine = {
|
||||||
setupOpts = {
|
setupOpts = mkPluginSetupOption "rose-pine" {
|
||||||
dark_variant = cfg.style ? "main";
|
dark_variant = mkOption {
|
||||||
dim_inactive_windows = mkDefault false;
|
type = str;
|
||||||
extend_background_behind_borders = mkDefault true;
|
style = cfg.style ? "main";
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
|
dim_inactive_windows = mkEnableOption "dim_inactive_windows";
|
||||||
|
extend_background_behind_borders = mkEnableOption' "extend_background_behind_borders";
|
||||||
|
|
||||||
enable = {
|
enable = {
|
||||||
terminal = mkDefault true;
|
terminal = mkEnableOption' "terminal";
|
||||||
migrations = mkDefault true;
|
migrations = mkEnableOption' "migrations";
|
||||||
};
|
};
|
||||||
|
|
||||||
styles = {
|
styles = {
|
||||||
bold = mkDefault false;
|
bold = mkEnableOption "bold";
|
||||||
# I would like to add more options for this
|
# I would like to add more options for this
|
||||||
italic = mkDefault false;
|
italic = mkEnableOption "italic";
|
||||||
transparency = cfg.transparent;
|
transparency = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = cfg.transparent;
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
setup = _: ''
|
setup = ''
|
||||||
vim.cmd("colorscheme rose-pine")
|
vim.cmd("colorscheme rose-pine")
|
||||||
'';
|
'';
|
||||||
styles = ["main" "moon" "dawn"];
|
styles = ["main" "moon" "dawn"];
|
||||||
|
|
|
@ -10,12 +10,11 @@
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.dag) entryBefore;
|
inherit (lib.nvim.dag) entryBefore;
|
||||||
inherit (lib.nvim.types) hexColor;
|
inherit (lib.nvim.types) hexColor;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
cfg = config.vim.theme;
|
cfg = config.vim.theme;
|
||||||
supportedThemes = import ./supported-themes.nix {
|
supportedThemes = import ./supported-themes.nix {
|
||||||
inherit lib config;
|
inherit lib config;
|
||||||
};
|
};
|
||||||
|
|
||||||
numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"];
|
numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"];
|
||||||
base16Options = listToAttrs (map (n: {
|
base16Options = listToAttrs (map (n: {
|
||||||
name = "base0${n}";
|
name = "base0${n}";
|
||||||
|
@ -62,11 +61,19 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = let
|
||||||
|
name' =
|
||||||
|
if cfg.name == "base16"
|
||||||
|
then "base16-colorscheme"
|
||||||
|
else cfg.name;
|
||||||
|
in {
|
||||||
startPlugins = [cfg.name];
|
startPlugins = [cfg.name];
|
||||||
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
|
|
||||||
|
require(${name'}).setup(${toLuaObject supportedThemes.${cfg.name}.setupOpts})
|
||||||
|
|
||||||
|
${supportedThemes.${cfg.name}.setup}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue