dev: rebase on a less personalized neovim flake

This commit is contained in:
NotAShelf 2023-02-01 22:11:37 +03:00
commit 9c00808863
No known key found for this signature in database
GPG key ID: 5B5C8895F28445F1
70 changed files with 4910 additions and 0 deletions

11
modules/theme/config.nix Normal file
View file

@ -0,0 +1,11 @@
{ pkgs, config, lib, ... }:
with lib; {
config = {
vim.theme = {
enable = mkDefault false;
name = mkDefault "onedark";
style = mkDefault "darker";
extraConfig = mkDefault "";
};
};
}

11
modules/theme/default.nix Normal file
View file

@ -0,0 +1,11 @@
{
pkgs,
config,
lib,
...
}: {
imports = [
./theme.nix
./config.nix
];
}

View file

@ -0,0 +1,33 @@
{
onedark = {
setup = { style ? "dark" }: ''
-- OneDark theme
require('onedark').setup {
style = "${style}"
}
require('onedark').load()
'';
styles = [ "dark" "darker" "cool" "deep" "warm" "warmer" ];
};
tokyonight = {
setup = { style ? "night" }: ''
-- need to set style before colorscheme to apply
vim.g.tokyonight_style = '${style}'
vim.cmd[[colorscheme tokyonight]]
'';
styles = [ "day" "night" "storm" ];
};
catppuccin = {
setup = { style ? "mocha" }: ''
-- Catppuccin theme
require('catppuccin').setup {
flavour = "${style}"
}
-- setup must be called before loading
vim.cmd.colorscheme "catppuccin"
'';
styles = [ "latte" "frappe" "macchiato" "mocha" ];
};
}

40
modules/theme/theme.nix Normal file
View file

@ -0,0 +1,40 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with lib.attrsets;
with builtins; let
cfg = config.vim.theme;
supported_themes = import ./supported_themes.nix;
in {
options.vim.theme = {
enable = mkOption {
type = types.bool;
description = "Enable Theme";
};
name = mkOption {
type = types.enum (attrNames supported_themes);
description = "Supported themes can be found in `supported_themes.nix`";
};
style = mkOption {
type = with types; enum supported_themes.${cfg.name}.styles;
description = "Specific style for theme if it supports it";
};
extraConfig = mkOption {
type = with types; lines;
description = "Additional lua configuration to add before setup";
};
};
config = mkIf cfg.enable {
vim.startPlugins = [cfg.name];
vim.luaConfigRC.themeSetup = nvim.dag.entryBefore ["theme"] cfg.extraConfig;
vim.luaConfigRC.theme = supported_themes.${cfg.name}.setup {style = cfg.style;};
};
}