Skip to content

Commit

Permalink
neovim: add stylix.targets.neovim.plugin option
Browse files Browse the repository at this point in the history
Add the stylix.targets.neovim.plugin option to select between the
previous base16-nvim and the new default mini.base16 [1] plugin,
offering better plugin integration.

[1]: https://github.com/echasnovski/mini.base16

Link: danth#536

Co-authored-by: NAHO <[email protected]>
  • Loading branch information
2 people authored and Mikilio committed Nov 4, 2024
1 parent c36c039 commit 149f099
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions modules/neovim/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

{
options.stylix.targets.neovim = {
enable =
config.lib.stylix.mkEnableTarget "Neovim" true;

enable = config.lib.stylix.mkEnableTarget "Neovim" true;
plugin = lib.mkOption {
type = lib.types.enum [ "base16-nvim" "mini.base16" ];
default = "mini.base16";
description = "Plugin used for the colorscheme";
};
transparentBackground = {
main = lib.mkEnableOption "background transparency for the main Neovim window";
signColumn = lib.mkEnableOption "background transparency for the Neovim sign column";
Expand All @@ -17,27 +20,44 @@
cfg = config.stylix.targets.neovim;
in
{
plugins = lib.singleton {
plugin = pkgs.vimPlugins.base16-nvim;
type = "lua";
config = lib.mkMerge [
(with config.lib.stylix.colors.withHashtag; ''
plugins = [
(lib.mkIf (cfg.plugin == "base16-nvim") {
plugin = pkgs.vimPlugins.base16-nvim;
type = "lua";
config = with config.lib.stylix.colors.withHashtag; ''
require('base16-colorscheme').setup({
base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}',
base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}',
base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}',
base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}'
})
'')
(lib.mkIf cfg.transparentBackground.main ''
vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" })
vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" })
'')
(lib.mkIf cfg.transparentBackground.signColumn ''
vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" })
'')
];
};
'';
})
(lib.mkIf (cfg.plugin == "mini.base16") {
plugin = pkgs.vimPlugins.mini-nvim;
type = "lua";
config = with config.lib.stylix.colors.withHashtag; ''
require('mini.base16').setup({
palette = {
base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}',
base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}',
base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}',
base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}'
}
})
'';
})
];

extraLuaConfig = lib.mkMerge [
(lib.mkIf cfg.transparentBackground.main ''
vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" })
vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" })
'')
(lib.mkIf cfg.transparentBackground.signColumn ''
vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" })
'')
];
};
};
}

0 comments on commit 149f099

Please sign in to comment.