neovim: init (#496)

Co-authored-by: Daniel Thwaites <danthwaites30@btinternet.com>
This commit is contained in:
Donovan Glover 2024-08-06 11:42:04 +00:00 committed by GitHub
parent c0309fc3f4
commit 3499dff34d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 2 deletions

42
modules/neovim/hm.nix Normal file
View file

@ -0,0 +1,42 @@
{ pkgs, config, lib, ... }:
{
options.stylix.targets.neovim = {
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";
};
};
config = lib.mkIf (config.stylix.enable && config.stylix.targets.neovim.enable) {
programs.neovim =
let
cfg = config.stylix.targets.neovim;
in
{
plugins = lib.singleton {
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" })
'');
};
};
};
}

View file

@ -51,10 +51,9 @@ let
in {
options.stylix.targets.vim.enable =
config.lib.stylix.mkEnableTarget "Vim and/or Neovim" true;
config.lib.stylix.mkEnableTarget "Vim" true;
config = lib.mkIf (config.stylix.enable && config.stylix.targets.vim.enable) {
programs.vim = vimOptions;
programs.neovim = vimOptions;
};
}