misc: refactor imports, prefer adding helpers to args rather than importing it

This commit is contained in:
Gaetan Lepage 2023-11-06 15:04:08 +01:00 committed by Gaétan Lepage
parent 541b694873
commit b6724702b4
160 changed files with 697 additions and 736 deletions

View file

@ -1,11 +1,10 @@
{
config,
lib,
helpers,
config,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
autoGroupOption = types.submodule {
options = {
clear = mkOption {

View file

@ -1,6 +1,6 @@
{
config,
lib,
config,
pkgs,
...
}:

View file

@ -1,10 +1,10 @@
{
config,
lib,
helpers,
config,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
commandAttributes = types.submodule {
options = {
command = mkOption {

View file

@ -1,10 +1,10 @@
{
config,
lib,
helpers,
config,
...
} @ args:
}:
with lib; let
helpers = import ../lib/helpers.nix args;
filetypeDefinition = helpers.mkNullOrOption (types.attrsOf (
types.oneOf [
# Raw filetype

View file

@ -1,58 +1,57 @@
{
config,
lib,
helpers,
config,
...
}: let
helpers = import ../lib/helpers.nix {inherit lib;};
in
with lib; {
options = {
highlight = mkOption {
type = types.attrsOf helpers.highlightType;
default = {};
description = "Define highlight groups";
example = ''
highlight = {
Comment.fg = '#ff0000';
};
'';
};
match = mkOption {
type = types.attrsOf types.str;
default = {};
description = "Define match groups";
example = ''
match = {
ExtraWhitespace = '\\s\\+$';
};
'';
};
}:
with lib; {
options = {
highlight = mkOption {
type = types.attrsOf helpers.highlightType;
default = {};
description = "Define highlight groups";
example = ''
highlight = {
Comment.fg = '#ff0000';
};
'';
};
config = mkIf (config.highlight != {} || config.match != {}) {
extraConfigLuaPost =
(optionalString (config.highlight != {}) ''
-- Highlight groups {{
do
local highlights = ${helpers.toLuaObject config.highlight}
match = mkOption {
type = types.attrsOf types.str;
default = {};
description = "Define match groups";
example = ''
match = {
ExtraWhitespace = '\\s\\+$';
};
'';
};
};
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
config = mkIf (config.highlight != {} || config.match != {}) {
extraConfigLuaPost =
(optionalString (config.highlight != {}) ''
-- Highlight groups {{
do
local highlights = ${helpers.toLuaObject config.highlight}
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
-- }}
'')
+ (optionalString (config.match != {}) ''
-- Match groups {{
do
local match = ${helpers.toLuaObject config.match}
for k,v in pairs(match) do
vim.fn.matchadd(k, v)
end
end
-- }}
'')
+ (optionalString (config.match != {}) ''
-- Match groups {{
do
local match = ${helpers.toLuaObject config.match}
for k,v in pairs(match) do
vim.fn.matchadd(k, v)
end
end
-- }}
'');
};
}
'');
};
}

View file

@ -1,11 +1,10 @@
{
config,
lib,
helpers,
config,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
in {
with lib; {
options = {
maps =
mapAttrs

View file

@ -1,6 +1,6 @@
{
config,
lib,
config,
...
}:
with lib; let

View file

@ -1,11 +1,10 @@
{
config,
lib,
helpers,
config,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
in {
with lib; {
options = {
options = mkOption {
type = types.attrsOf types.anything;

View file

@ -1,7 +1,6 @@
{
pkgs,
config,
lib,
config,
...
}:
with lib; let