mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
feature: add base16 support (#389)
* modules: add base16 Theming support theme/theme.nix: fix formatting supported-themes.nix: formatting clean up base16-colors.nix theme: fix plugin setup, change base16 flake input * theme/theme.nix: fix formatting * types/theme.nix: add check regex matching types/theme.nix: fixed regex matching * lib/types: rename custom.nix to types.nix, mov theme.nix into types.nix * plugins/theme: apply requested changes types/types.nix: remove unneeded inherit theme/theme.nix: remove commented inherit * theme/theme.nix: fix up base16 helper func Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * theme/theme.nix: move listToAttrs inheriting, fix base16-colors declaration * theme/theme.nix: add documentation to vim.theme.name * release-notes/rl-0.7.md: add changelog entry for base16 * theme/theme.nix: fix documentation rendering --------- Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>
This commit is contained in:
parent
6670d752c7
commit
bdf777dc8a
7 changed files with 71 additions and 8 deletions
|
@ -229,3 +229,8 @@ everyone.
|
||||||
- Add LSP and Treesitter support for R under `vim.languages.R`.
|
- Add LSP and Treesitter support for R under `vim.languages.R`.
|
||||||
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
|
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
|
||||||
ccc
|
ccc
|
||||||
|
|
||||||
|
[Bloxx12](https://github.com/Bloxx12)
|
||||||
|
|
||||||
|
- Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under
|
||||||
|
`vim.theme`
|
||||||
|
|
17
flake.lock
17
flake.lock
|
@ -172,6 +172,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-base16": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1716483968,
|
||||||
|
"narHash": "sha256-GRF/6AobXHamw8TZ3FjL7SI6ulcpwpcohsIuZeCSh2A=",
|
||||||
|
"owner": "rrethy",
|
||||||
|
"repo": "base16-nvim",
|
||||||
|
"rev": "6ac181b5733518040a33017dde654059cd771b7c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rrethy",
|
||||||
|
"repo": "base16-nvim",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-bufdelete-nvim": {
|
"plugin-bufdelete-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -1802,6 +1818,7 @@
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nmd": "nmd",
|
"nmd": "nmd",
|
||||||
"plugin-alpha-nvim": "plugin-alpha-nvim",
|
"plugin-alpha-nvim": "plugin-alpha-nvim",
|
||||||
|
"plugin-base16": "plugin-base16",
|
||||||
"plugin-bufdelete-nvim": "plugin-bufdelete-nvim",
|
"plugin-bufdelete-nvim": "plugin-bufdelete-nvim",
|
||||||
"plugin-catppuccin": "plugin-catppuccin",
|
"plugin-catppuccin": "plugin-catppuccin",
|
||||||
"plugin-ccc": "plugin-ccc",
|
"plugin-ccc": "plugin-ccc",
|
||||||
|
|
|
@ -349,6 +349,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# Themes
|
# Themes
|
||||||
|
plugin-base16 = {
|
||||||
|
url = "github:rrethy/base16-nvim";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
plugin-tokyonight = {
|
plugin-tokyonight = {
|
||||||
url = "github:folke/tokyonight.nvim";
|
url = "github:folke/tokyonight.nvim";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
typesDag = import ./dag.nix {inherit lib;};
|
typesDag = import ./dag.nix {inherit lib;};
|
||||||
typesPlugin = import ./plugins.nix {inherit inputs lib;};
|
typesPlugin = import ./plugins.nix {inherit inputs lib;};
|
||||||
typesLanguage = import ./languages.nix {inherit lib;};
|
typesLanguage = import ./languages.nix {inherit lib;};
|
||||||
typesCustom = import ./custom.nix {inherit lib;};
|
typesTypes = import ./types.nix {inherit lib;};
|
||||||
in {
|
in {
|
||||||
inherit (typesDag) dagOf;
|
inherit (typesDag) dagOf;
|
||||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
||||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||||
inherit (typesCustom) anythingConcatLists char;
|
inherit (typesTypes) anythingConcatLists char hexColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
|
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
|
||||||
|
inherit (lib.strings) isString;
|
||||||
inherit (lib.types) anything attrsOf;
|
inherit (lib.types) anything attrsOf;
|
||||||
inherit (lib.nvim.types) anythingConcatLists;
|
inherit (lib.nvim.types) anythingConcatLists;
|
||||||
inherit (builtins) typeOf isAttrs any head concatLists stringLength;
|
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
|
||||||
in {
|
in {
|
||||||
# HACK: Does this break anything in our case?
|
# HACK: Does this break anything in our case?
|
||||||
# A modified version of the nixpkgs anything type that concatenates lists
|
# A modified version of the nixpkgs anything type that concatenates lists
|
||||||
|
@ -58,4 +59,11 @@ in {
|
||||||
check = value: stringLength value < 2;
|
check = value: stringLength value < 2;
|
||||||
merge = mergeEqualOption;
|
merge = mergeEqualOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hexColor = mkOptionType {
|
||||||
|
name = "hex-color";
|
||||||
|
descriptionClass = "noun";
|
||||||
|
description = "RGB color in hex format";
|
||||||
|
check = v: isString v && (match "#?[0-9a-fA-F]{6}" v) != null;
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -4,7 +4,14 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.trivial) boolToString warnIf;
|
inherit (lib.trivial) boolToString warnIf;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
in {
|
in {
|
||||||
|
base16 = {
|
||||||
|
setup = {base16-colors, ...}: ''
|
||||||
|
-- Base16 theme
|
||||||
|
require('base16-colorscheme').setup(${toLuaObject base16-colors})
|
||||||
|
'';
|
||||||
|
};
|
||||||
onedark = {
|
onedark = {
|
||||||
setup = {style ? "dark", ...}: ''
|
setup = {style ? "dark", ...}: ''
|
||||||
-- OneDark theme
|
-- OneDark theme
|
||||||
|
@ -20,6 +27,7 @@ in {
|
||||||
setup = {
|
setup = {
|
||||||
style ? "night",
|
style ? "night",
|
||||||
transparent,
|
transparent,
|
||||||
|
...
|
||||||
}: ''
|
}: ''
|
||||||
require('tokyonight').setup {
|
require('tokyonight').setup {
|
||||||
transparent = ${boolToString transparent};
|
transparent = ${boolToString transparent};
|
||||||
|
@ -42,6 +50,7 @@ in {
|
||||||
setup = {
|
setup = {
|
||||||
style ? "mocha",
|
style ? "mocha",
|
||||||
transparent ? false,
|
transparent ? false,
|
||||||
|
...
|
||||||
}: ''
|
}: ''
|
||||||
-- Catppuccin theme
|
-- Catppuccin theme
|
||||||
require('catppuccin').setup {
|
require('catppuccin').setup {
|
||||||
|
|
|
@ -4,32 +4,51 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.attrsets) attrNames;
|
inherit (lib.attrsets) attrNames listToAttrs;
|
||||||
|
inherit (lib.strings) hasPrefix;
|
||||||
inherit (lib.types) bool lines enum;
|
inherit (lib.types) bool lines enum;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.dag) entryBefore;
|
inherit (lib.nvim.dag) entryBefore;
|
||||||
|
inherit (lib.nvim.types) hexColor;
|
||||||
|
|
||||||
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"];
|
||||||
|
base16Options = listToAttrs (map (n: {
|
||||||
|
name = "base0${n}";
|
||||||
|
value = mkOption {
|
||||||
|
description = "The base0${n} color to use";
|
||||||
|
type = hexColor;
|
||||||
|
apply = v:
|
||||||
|
if hasPrefix "#" v
|
||||||
|
then v
|
||||||
|
else "#${v}";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
numbers);
|
||||||
in {
|
in {
|
||||||
options.vim.theme = {
|
options.vim.theme = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
description = "Enable theming";
|
description = "Enable theming";
|
||||||
};
|
};
|
||||||
|
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = enum (attrNames supportedThemes);
|
type = enum (attrNames supportedThemes);
|
||||||
description = "Supported themes can be found in `supportedThemes.nix`";
|
description = ''
|
||||||
|
Supported themes can be found in {file}`supportedThemes.nix`.
|
||||||
|
Setting the theme to "base16" enables base16 theming and
|
||||||
|
requires all of the colors in {option}`vim.theme.base16-colors` to be set.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
base16-colors = base16Options;
|
||||||
|
|
||||||
style = mkOption {
|
style = mkOption {
|
||||||
type = enum supportedThemes.${cfg.name}.styles;
|
type = enum supportedThemes.${cfg.name}.styles;
|
||||||
description = "Specific style for theme if it supports it";
|
description = "Specific style for theme if it supports it";
|
||||||
};
|
};
|
||||||
|
|
||||||
transparent = mkOption {
|
transparent = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -47,7 +66,7 @@ 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;}}
|
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue