1
Fork 0

feat: dynamic theming attempt

This commit is contained in:
Matei Adriel 2022-03-10 21:59:18 +02:00
parent 18c51ecc13
commit 2757c649b9
18 changed files with 120 additions and 30 deletions

View file

@ -1,29 +1,32 @@
{ pkgs, ... }:
{ pkgs, lib, ... }:
let
githubAlacrittyTheme =
"${pkgs.githubNvimTheme}/terminal/alacritty/github_light.yml";
themes = pkgs.myThemes;
createTheme = (theme: {
xdg.configFile."alacritty/themes/${theme.name}.yml".text = builtins.toJSON
(lib.attrs.recursiveUpdate theme.alacritty.settings {
import = [ "~/.config/alacritty/alacritty.yml" ];
});
});
createThemeConfigs = lib.lists.foldr
(acc: theme: lib.attrs.recursiveUpdate acc (createTheme theme))
{ }
themes;
in
{
imports = [
{
home-manager.users.adrielus = createThemeConfigs;
}
];
home-manager.users.adrielus.programs.alacritty = {
enable = true;
settings = {
import = [ githubAlacrittyTheme ];
window = {
decorations = "none";
padding = {
x = 8;
y = 8;
};
gtk_theme_variant = "light";
};
# transparent bg:)
# background_opacity = 0.6;
window.decorations = "none";
fonts.normal.family = "Nerd Font Source Code Pro";
};
};

View file

@ -1,10 +1,30 @@
{ pkgs, ... }:
{ pkgs, lib, ... }:
let
themes = pkgs.myThemes;
# config-nvim = "/etc/nixos/configuration/dotfiles/neovim";
config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
name = "config-nvim";
src = ../../dotfiles/neovim;
};
themePlugins = lib.lists.concatMap (theme: theme.neovim.plugins) themes;
loadTheme = (theme: ''
if currentTheme = "${theme.name}" then
${theme.neovim.theme}
vim.g.lualineTheme = ${theme.neovim.lualineTheme}
end
'');
loadThemes = ''
local currentTheme = os.getenv("THEME");
${pkgs.myHelpers.mergeLines (lib.lists.forEach themes loadTheme)};
'';
in
{
home-manager.users.adrielus.programs.neovim = {
@ -37,9 +57,8 @@ in
];
plugins = with pkgs.vimPlugins;
with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; [
with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; themePlugins + [
config-nvim # my neovim config
github-nvim-theme # github theme for neovim
nvim-lspconfig # configures lsps for me
nvim-autopairs # close pairs for me
telescope-nvim # fuzzy search for say opening files

View file

@ -23,4 +23,6 @@
# Render git repo using gource
"git-render" = "gource -f -s 1 -c 4 --key";
alacritty = "alacritty --config-file $XDG_CONFIG_HOME/alacritty/themes/$THEME.yml";
}

View file

@ -8,6 +8,9 @@ let
# Sets neovim as default editor
EDITOR = "nvim";
# Sets the current theme used by all programs
THEME = "github-light";
};
in
{

View file

@ -1,4 +1,12 @@
{ pkgs, ... }: {
{ pkgs, lib, ... }:
let
sourceTmuxTheme = (theme: ''
# Only load this theme if it's the current one
if '[[ "$THEME" =~ ${theme.name} ]]' 'source ${theme.tmux.path}'
'');
tmuxThemes = pkgs.myHelpers.mergeLines (lib.lists.forEach pkgs.myThemes sourceTmuxTheme);
in
{
home-manager.users.adrielus.programs = {
# Add tmux-navigator plugin to neovim
neovim.extraPackages = [ pkgs.vimPlugins.vim-tmux-navigator ];
@ -16,8 +24,8 @@
];
extraConfig = ''
# Use github light theme
source-file ${pkgs.githubNvimTheme}/terminal/tmux/github_light.conf
# Load every theme available
${tmuxThemes}
# load the rest of the config
source-file ${../../dotfiles/tmux/tmux.conf}

View file

@ -95,8 +95,8 @@ main =
startup :: X ()
startup = do
spawn "xwallpaper --zoom ./background.jpg"
spawn "xwallpaper --zoom ./picutres/portal.png"
-- spawn "Discord"
-- spawn "google-chrome-stable"
-- spawn "alacritty"
-- spawn "alacritty"