2022-09-18 11:19:23 +01:00
|
|
|
{
|
2023-02-20 11:42:13 +01:00
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
|
|
|
pkgs,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.plugins.specs;
|
|
|
|
in
|
|
|
|
{
|
2022-09-18 11:19:23 +01:00
|
|
|
options.plugins.specs = {
|
2023-01-22 03:32:08 +00:00
|
|
|
enable = mkEnableOption "specs-nvim";
|
2021-12-11 23:02:59 -06:00
|
|
|
|
2024-05-17 14:09:20 +02:00
|
|
|
package = helpers.mkPluginPackageOption "specs-nvim" pkgs.vimPlugins.specs-nvim;
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2021-12-11 23:02:59 -06:00
|
|
|
show_jumps = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
min_jump = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 30;
|
|
|
|
};
|
|
|
|
|
|
|
|
delay = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
2024-03-07 19:44:13 +01:00
|
|
|
description = "Delay in milliseconds";
|
2021-12-11 23:02:59 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
increment = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 10;
|
2024-03-07 19:44:13 +01:00
|
|
|
description = "Increment in milliseconds";
|
2021-12-11 23:02:59 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
blend = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 10;
|
|
|
|
};
|
|
|
|
|
2022-11-27 16:55:34 -05:00
|
|
|
color = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
2021-12-11 23:02:59 -06:00
|
|
|
width = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 10;
|
|
|
|
};
|
|
|
|
|
|
|
|
fader = mkOption {
|
|
|
|
type = types.submodule {
|
|
|
|
options = {
|
|
|
|
builtin = mkOption {
|
|
|
|
type = types.nullOr (
|
|
|
|
types.enum [
|
|
|
|
"linear_fader"
|
|
|
|
"exp_fader"
|
|
|
|
"pulse_fader"
|
|
|
|
"empty_fader"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
default = "linear_fader";
|
|
|
|
};
|
|
|
|
|
|
|
|
custom = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
function(blend, cnt)
|
|
|
|
if cnt > 100 then
|
|
|
|
return 80
|
|
|
|
else return nil end
|
|
|
|
end
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
default = {
|
|
|
|
builtin = "linear_fader";
|
|
|
|
};
|
2021-12-11 23:02:59 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
resizer = mkOption {
|
|
|
|
type = types.submodule {
|
|
|
|
options = {
|
|
|
|
builtin = mkOption {
|
2023-02-20 11:42:13 +01:00
|
|
|
type = types.nullOr (
|
|
|
|
types.enum [
|
|
|
|
"shrink_resizer"
|
|
|
|
"slide_resizer"
|
|
|
|
"empty_resizer"
|
2024-05-05 19:39:35 +02:00
|
|
|
]
|
2023-02-20 11:42:13 +01:00
|
|
|
);
|
2021-12-11 23:02:59 -06:00
|
|
|
default = "shrink_resizer";
|
|
|
|
};
|
|
|
|
|
|
|
|
custom = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
function(width, ccol, cnt)
|
|
|
|
if width-cnt > 0 then
|
|
|
|
return {width+cnt, ccol}
|
|
|
|
else return nil end
|
|
|
|
end
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
default = {
|
|
|
|
builtin = "shrink_resizer";
|
|
|
|
};
|
2021-12-11 23:02:59 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
ignored_filetypes = mkOption {
|
2023-08-10 18:35:28 +02:00
|
|
|
type = with types; listOf str;
|
2023-02-20 11:42:13 +01:00
|
|
|
default = [ ];
|
2021-12-11 23:02:59 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
ignored_buffertypes = mkOption {
|
2023-08-10 18:35:28 +02:00
|
|
|
type = with types; listOf str;
|
2023-02-20 11:42:13 +01:00
|
|
|
default = [ "nofile" ];
|
2021-12-11 23:02:59 -06:00
|
|
|
};
|
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
config =
|
|
|
|
let
|
|
|
|
setup = helpers.toLuaObject {
|
|
|
|
inherit (cfg) show_jumps min_jump;
|
|
|
|
ignore_filetypes = attrsets.listToAttrs (
|
|
|
|
lib.lists.map (x: attrsets.nameValuePair x true) cfg.ignored_filetypes
|
|
|
|
);
|
|
|
|
ignore_buftypes = attrsets.listToAttrs (
|
|
|
|
lib.lists.map (x: attrsets.nameValuePair x true) cfg.ignored_buffertypes
|
|
|
|
);
|
|
|
|
popup = {
|
|
|
|
inherit (cfg) blend width;
|
2023-05-22 15:45:47 +05:30
|
|
|
winhl = if (cfg.color != null) then "SpecsPopColor" else "PMenu";
|
2023-02-20 11:42:13 +01:00
|
|
|
delay_ms = cfg.delay;
|
|
|
|
inc_ms = cfg.increment;
|
|
|
|
fader = helpers.mkRaw (
|
|
|
|
if cfg.fader.builtin == null then cfg.fader.custom else ''require("specs").${cfg.fader.builtin}''
|
2024-05-05 19:39:35 +02:00
|
|
|
);
|
2023-02-20 11:42:13 +01:00
|
|
|
resizer = helpers.mkRaw (
|
|
|
|
if cfg.resizer.builtin == null then
|
|
|
|
cfg.resizer.custom
|
2024-05-05 19:39:35 +02:00
|
|
|
else
|
2023-02-20 11:42:13 +01:00
|
|
|
''require("specs").${cfg.resizer.builtin}''
|
2024-05-05 19:39:35 +02:00
|
|
|
);
|
|
|
|
};
|
2021-12-11 23:02:59 -06:00
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
in
|
2022-09-18 11:19:23 +01:00
|
|
|
mkIf cfg.enable {
|
2023-02-20 11:42:13 +01:00
|
|
|
extraPlugins = [ cfg.package ];
|
2021-12-11 23:02:59 -06:00
|
|
|
|
2023-05-22 15:45:47 +05:30
|
|
|
highlight.SpecsPopColor.bg = mkIf (cfg.color != null) cfg.color;
|
2022-11-27 16:55:34 -05:00
|
|
|
|
2021-12-11 23:02:59 -06:00
|
|
|
extraConfigLua = ''
|
|
|
|
require('specs').setup(${setup})
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|