Skip to content

Commit

Permalink
neovim: add stylix.targets.neovim.colorscheme option
Browse files Browse the repository at this point in the history
Add the stylix.targets.neovim.colorscheme 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
soulsoiledit and trueNAHO committed Sep 4, 2024
1 parent ef81ad9 commit b0fbf01
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions modules/neovim/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

{
options.stylix.targets.neovim = {
colorscheme = lib.mkOption {
type = lib.types.enum [ "base16-nvim" "mini.base16" ];
default = "mini.base16";
description = "Strategy for applying the colorscheme";
};
enable =
config.lib.stylix.mkEnableTarget "Neovim" true;

transparentBackground = {
main = lib.mkEnableOption "background transparency for the main Neovim window";
signColumn = lib.mkEnableOption "background transparency for the Neovim sign column";
Expand All @@ -21,14 +25,24 @@
plugin = pkgs.vimPlugins.base16-nvim;
type = "lua";
config = lib.mkMerge [
(with config.lib.stylix.colors.withHashtag; ''
(with config.lib.stylix.colors.withHashtag; lib.mkIf (cfg.colorscheme == "base16-nvim") ''
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}'
})
'')
(with config.lib.stylix.colors.withHashtag; lib.mkIf (cfg.colorscheme == "mini.base16") ''
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}'
}
})
'')
(lib.mkIf cfg.transparentBackground.main ''
vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" })
vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" })
Expand Down

0 comments on commit b0fbf01

Please sign in to comment.