Add Vim module

This commit is contained in:
Daniel Thwaites 2020-12-20 19:19:08 +00:00
parent 4ac0094a53
commit 536e20fdce
No known key found for this signature in database
GPG key ID: D8AFC4BF05670F9D
4 changed files with 59 additions and 0 deletions

View file

@ -3,5 +3,6 @@
./stylix/default.nix
./modules/console.nix
./modules/vim.nix
];
}

35
modules/vim.nix Normal file
View file

@ -0,0 +1,35 @@
{ pkgs, config, ... }:
let
base16-vim = pkgs.fetchFromGitHub {
owner = "chriskempson";
repo = "base16-vim";
rev = "6191622d5806d4448fa2285047936bdcee57a098";
sha256 = "6FsT87qcl9GBxgxrPx2bPULIMA/O8TRxHaN49qMM4uM=";
};
themePlugin = pkgs.vimUtils.buildVimPlugin {
name = "stylix";
src = base16-vim;
data = config.lib.stylix.base16.json;
passAsFile = [ "data" ];
buildPhase = ''
mkdir -p $out/colors
${pkgs.mustache-go}/bin/mustache $dataPath \
$src/templates/default.mustache > $out/colors/base16-stylix.vim
'';
};
vimOptions = {
plugins = [ themePlugin ];
extraConfig = "colorscheme base16-stylix";
};
in {
stylix.homeModule = {
programs.vim = vimOptions;
programs.neovim = vimOptions;
};
}

22
stylix/base16.nix Normal file
View file

@ -0,0 +1,22 @@
# Used to build templates from http://chriskempson.com/projects/base16/
{ pkgs, config, ... }:
{
config.lib.stylix.base16 = rec {
json = builtins.toJSON (config.lib.stylix.colors // {
# Additional attributes only used for base16
scheme-name = "Stylix";
scheme-slug = "stylix";
scheme-author = "Stylix";
});
buildTemplate = name: templatePath:
pkgs.runCommand "base16-${name}"
{
inherit json templatePath;
passAsFile = [ "json" ];
}
"${pkgs.mustache-go}/bin/mustache $jsonPath $templatePath > $out";
};
}

View file

@ -4,6 +4,7 @@ with lib;
{
imports = [
./base16.nix
./colors.nix
./fonts.nix
./home-manager.nix