2024-02-08 03:07:42 +00:00
|
|
|
{ config, lib, pkgs, helpers, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.colorschemes.lush;
|
|
|
|
|
|
|
|
schemeType = { config, lib, ... }: {
|
|
|
|
options = {
|
2024-02-08 11:31:42 +00:00
|
|
|
extraConfigLua = lib.mkOption {
|
2024-02-08 03:07:42 +00:00
|
|
|
type = lib.types.lines;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
2024-02-14 13:14:47 +00:00
|
|
|
Theme-specific Lua code to be included for the colorscheme plugin.
|
|
|
|
This is mainly useful for organizing the color palette in your
|
|
|
|
preferred way.
|
2024-02-08 03:07:42 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
highlights = lib.mkOption {
|
|
|
|
type = with lib.types; attrsOf anything;
|
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
The highlight group object to be exported with Lush. This is the data
|
|
|
|
to be exported with `lush()` function from lush.nvim.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
mkLushColorSchemes = name: theme:
|
|
|
|
let
|
|
|
|
# Converts each of the highlight group into a function to be able parsed and
|
|
|
|
# used by Lush.
|
|
|
|
highlightList =
|
|
|
|
lib.mapAttrsToList
|
|
|
|
(highlight: arguments: "${highlight}(${helpers.toLuaObject arguments})")
|
|
|
|
theme.highlights;
|
|
|
|
in
|
|
|
|
# This is based from rktjmp/lush-template. We'll improve on things from
|
2024-02-25 10:20:13 +00:00
|
|
|
# here whenever necessary.
|
2024-07-31 05:21:03 +00:00
|
|
|
lib.nameValuePair "colors/${name}.lua" {
|
|
|
|
text = ''
|
|
|
|
${cfg.extraConfigLua}
|
|
|
|
${theme.extraConfigLua}
|
2024-02-08 03:07:42 +00:00
|
|
|
|
2024-07-31 05:21:03 +00:00
|
|
|
vim.g.colors_name = '${name}'
|
|
|
|
vim.o.termguicolors = true
|
2024-02-08 03:07:42 +00:00
|
|
|
|
2024-07-31 05:21:03 +00:00
|
|
|
-- This needs to be parsed twice: once to generate the Lush spec
|
|
|
|
-- and the other to actually apply the spec.
|
|
|
|
--
|
|
|
|
-- @diagnostic disable: undefined-global
|
|
|
|
local spec = lush(function(injected_functions)
|
|
|
|
local sym = injected_functions.sym
|
|
|
|
return { ${lib.concatStringsSep "," highlightList} }
|
|
|
|
end)
|
2024-02-09 09:35:43 +00:00
|
|
|
|
2024-07-31 05:21:03 +00:00
|
|
|
-- We then apply the theme.
|
|
|
|
lush(spec)
|
|
|
|
'';
|
|
|
|
};
|
2024-02-08 03:07:42 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.colorschemes.lush = {
|
|
|
|
enable = lib.mkEnableOption "theming with lush.nvim";
|
|
|
|
|
2024-09-28 11:37:57 +00:00
|
|
|
package = lib.mkPackageOption pkgs [ "vimPlugins" "lush-nvim" ] { };
|
2024-02-08 03:07:42 +00:00
|
|
|
|
2024-02-08 11:31:42 +00:00
|
|
|
extraConfigLua = lib.mkOption {
|
2024-02-08 03:07:42 +00:00
|
|
|
type = lib.types.lines;
|
|
|
|
default = ''
|
|
|
|
local lush = require('lush')
|
|
|
|
'';
|
|
|
|
example = ''
|
|
|
|
local lush = require('lush')
|
|
|
|
local hsl = lush.hsl
|
|
|
|
local hsluv = lush.hsluv
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Additional Lua code to be prepended before the Lush theme export.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
themes = lib.mkOption {
|
|
|
|
type = with lib.types; attrsOf (submodule schemeType);
|
|
|
|
description = ''
|
|
|
|
A set of Lush-created themes. Each of these themes is to be exported as
|
|
|
|
a colorscheme plugin to NixVim usable with
|
|
|
|
{option}`colorscheme`.
|
|
|
|
|
|
|
|
It can serve as an alternative to {option}`colorschemes.base16` or the
|
|
|
|
colorscheme plugins if you want a framework for creating more
|
|
|
|
expressive colorschemes.
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
"example-theme".highlights = {
|
|
|
|
Normal = {
|
|
|
|
fg.__raw = "hsluv('#300000')";
|
|
|
|
bg.__raw = "hsluv('#600000')";
|
|
|
|
};
|
|
|
|
CursorLine.bg.__raw = "Normal.bg.lighten(5)";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
extraPlugins = [ cfg.package ];
|
|
|
|
|
|
|
|
extraFiles =
|
|
|
|
lib.mapAttrs' mkLushColorSchemes cfg.themes;
|
|
|
|
};
|
|
|
|
}
|