nixvim: expose config for nixvim's standalone mode (#415)
Link: https://github.com/danth/stylix/pull/415 Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
commit
e7c09d2066
2 changed files with 109 additions and 80 deletions
|
|
@ -199,6 +199,35 @@ to customize this.
|
|||
> Similarly, [`stylix.override`](options/global/nixos.md#stylixoverride) is not inherited
|
||||
> if the color scheme is different.
|
||||
|
||||
## Standalone Nixvim
|
||||
|
||||
When using a NixOS or home-manager installation of [Nixvim], you can use Stylix
|
||||
as normal. However, when using Nixvim's ["standalone" configuration mode][Nixvim Standalone],
|
||||
you will need to pass Stylix's generated config to Nixvim yourself.
|
||||
|
||||
The generated config can be accessed as `config.lib.stylix.nixvim.config`. You
|
||||
can use this as a module in your standalone Nixvim Configuration or an
|
||||
extension of it.
|
||||
|
||||
For example:
|
||||
|
||||
```nix
|
||||
{ inputs, config, pkgs, ... }:
|
||||
let
|
||||
inherit (pkgs.stdenv.hostPlatform) system;
|
||||
nixvim-package = inputs.nixvim-config.packages.${system}.default;
|
||||
extended-nixvim = nixvim-package.extend config.lib.stylix.nixvim.config;
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [
|
||||
extended-nixvim
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
[Nixvim]: https://nix-community.github.io/nixvim
|
||||
[Nixvim Standalone]: https://nix-community.github.io/nixvim/user-guide/install.html#standalone-usage
|
||||
|
||||
## Turning targets on and off
|
||||
|
||||
A target is anything which can have colors, fonts or a wallpaper applied to it.
|
||||
|
|
|
|||
|
|
@ -6,15 +6,81 @@
|
|||
}:
|
||||
let
|
||||
cfg = config.stylix.targets.nixvim;
|
||||
# Maps `stylix.targets.plugin` values to the appropriate nixvim configuration
|
||||
pluginConfigs = {
|
||||
"base16-nvim" = {
|
||||
inherit highlightOverride;
|
||||
|
||||
colorschemes.base16 = {
|
||||
enable = true;
|
||||
|
||||
colorscheme = {
|
||||
inherit (config.lib.stylix.colors.withHashtag)
|
||||
base00
|
||||
base01
|
||||
base02
|
||||
base03
|
||||
base04
|
||||
base05
|
||||
base06
|
||||
base07
|
||||
base08
|
||||
base09
|
||||
base0A
|
||||
base0B
|
||||
base0C
|
||||
base0D
|
||||
base0E
|
||||
base0F
|
||||
;
|
||||
};
|
||||
};
|
||||
};
|
||||
"mini.base16" = {
|
||||
inherit highlightOverride;
|
||||
|
||||
plugins.mini = {
|
||||
enable = true;
|
||||
|
||||
modules.base16.palette = {
|
||||
inherit (config.lib.stylix.colors.withHashtag)
|
||||
base00
|
||||
base01
|
||||
base02
|
||||
base03
|
||||
base04
|
||||
base05
|
||||
base06
|
||||
base07
|
||||
base08
|
||||
base09
|
||||
base0A
|
||||
base0B
|
||||
base0C
|
||||
base0D
|
||||
base0E
|
||||
base0F
|
||||
;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
# Transparent is used a few times below
|
||||
transparent = {
|
||||
bg = "none";
|
||||
ctermbg = "none";
|
||||
};
|
||||
highlightOverride = {
|
||||
Normal = lib.mkIf cfg.transparentBackground.main transparent;
|
||||
NonText = lib.mkIf cfg.transparentBackground.main transparent;
|
||||
SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.stylix.targets.nixvim = {
|
||||
enable = config.lib.stylix.mkEnableTarget "nixvim" true;
|
||||
plugin = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"base16-nvim"
|
||||
"mini.base16"
|
||||
];
|
||||
type = lib.types.enum (builtins.attrNames pluginConfigs);
|
||||
default = "mini.base16";
|
||||
description = "Plugin used for the colorscheme";
|
||||
};
|
||||
|
|
@ -63,80 +129,14 @@ in
|
|||
})
|
||||
];
|
||||
|
||||
config =
|
||||
lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixvim))
|
||||
(
|
||||
lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) (
|
||||
lib.mkMerge [
|
||||
(lib.mkIf (cfg.plugin == "base16-nvim") {
|
||||
programs.nixvim.colorschemes.base16 = {
|
||||
enable = true;
|
||||
|
||||
colorscheme = {
|
||||
inherit (config.lib.stylix.colors.withHashtag)
|
||||
base00
|
||||
base01
|
||||
base02
|
||||
base03
|
||||
base04
|
||||
base05
|
||||
base06
|
||||
base07
|
||||
base08
|
||||
base09
|
||||
base0A
|
||||
base0B
|
||||
base0C
|
||||
base0D
|
||||
base0E
|
||||
base0F
|
||||
;
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf (cfg.plugin == "mini.base16") {
|
||||
programs.nixvim.plugins.mini = {
|
||||
enable = true;
|
||||
|
||||
modules.base16.palette = {
|
||||
inherit (config.lib.stylix.colors.withHashtag)
|
||||
base00
|
||||
base01
|
||||
base02
|
||||
base03
|
||||
base04
|
||||
base05
|
||||
base06
|
||||
base07
|
||||
base08
|
||||
base09
|
||||
base0A
|
||||
base0B
|
||||
base0C
|
||||
base0D
|
||||
base0E
|
||||
base0F
|
||||
;
|
||||
};
|
||||
};
|
||||
})
|
||||
{
|
||||
programs.nixvim = {
|
||||
highlightOverride =
|
||||
let
|
||||
transparent = {
|
||||
bg = "none";
|
||||
ctermbg = "none";
|
||||
};
|
||||
in
|
||||
{
|
||||
Normal = lib.mkIf cfg.transparentBackground.main transparent;
|
||||
NonText = lib.mkIf cfg.transparentBackground.main transparent;
|
||||
SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent;
|
||||
};
|
||||
};
|
||||
}
|
||||
]
|
||||
)
|
||||
);
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
lib.stylix.nixvim.config = pluginConfigs.${cfg.plugin};
|
||||
}
|
||||
(lib.mkIf (config.stylix.enable && cfg.enable && options.programs ? nixvim) (
|
||||
lib.optionalAttrs (options.programs ? nixvim) {
|
||||
programs.nixvim = config.lib.stylix.nixvim.config;
|
||||
}
|
||||
))
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue