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

@ -33,7 +33,7 @@ function M.setup()
helpers.global("mapleader", "<Space>")
-- Set theme
require('github-theme').setup({theme_style = "light", dark_float = true})
-- require('github-theme').setup({theme_style = "light", dark_float = true, transparent = true})
end
return M

View file

@ -2,7 +2,7 @@ local M = {}
function M.setup()
require('lualine').setup({
theme = "github",
theme = vim.g.lualineTheme,
-- Integration with other plugins
extensions = {"nvim-tree"}

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,7 +95,7 @@ main =
startup :: X ()
startup = do
spawn "xwallpaper --zoom ./background.jpg"
spawn "xwallpaper --zoom ./picutres/portal.png"
-- spawn "Discord"
-- spawn "google-chrome-stable"

View file

@ -2,7 +2,7 @@
imports = [
./dev
./applications
./theme
./themes
./overlays
./network.nix

8
modules/helpers.nix Normal file
View file

@ -0,0 +1,8 @@
{ lib, ... }: {
mergeLines = (lines: lib.foldr
(a: b: ''
${a}
${b}
'') ""
lines);
}

View file

@ -1,6 +1,7 @@
{ pkgs, ... }: {
nixpkgs.overlays = [
(import ./tweakSources.nix)
(import ./myPackages.nix)
(import ./npm.nix)
# I hope this works (spoiler: it did not)

View file

@ -59,10 +59,11 @@ in
};
};
githubNvimTheme = githubNvimTheme;
# Vim plugins
myVimPlugins = {
githubNvimTheme = githubNvimTheme;
telescope-file-browser-nvim =
plugin "file_browser" telescope-file-browser-nvim;

View file

@ -0,0 +1,5 @@
self: super:
with self; {
myHelpers = self.callPackage (import ../helpers.nix) { };
myThemes = self.callPackage (import ../themes/themes.nix) { };
}

View file

@ -0,0 +1,29 @@
variant: { pkgs, ... }: {
name = "github-${variant}";
neovim = {
plugins = [
pkgs.myVimPlugins.github-nvim-theme # github theme for neovim
];
theme = ''
require('github-theme').setup({theme_style = "light", dark_float = true, transparent = true})
'';
lualineTheme = "github";
};
tmux.path = "${pkgs.githubNvimTheme}/terminal/tmux/github_light.conf";
alacritty.settings = {
import = [ "${pkgs.githubNvimTheme}/terminal/alacritty/github_light.yml" ];
window = {
padding = {
x = 8;
y = 8;
};
# transparent bg:)
background_opacity = 0.8;
gtk_theme_variant = "light";
};
};
}

2
modules/themes/theme.nix Normal file
View file

@ -0,0 +1,2 @@

View file

@ -0,0 +1,9 @@
{ pkgs }:
let githubVariant = import ./githubVariant.nix;
in
lib.map (theme: pkgs.callPackage theme { }) [
githubVariant
"light"
githubVariant
"dark"
]