nix-community.nixvim/plugins/utils/specs.nix

167 lines
3.7 KiB
Nix
Raw Normal View History

{
lib,
helpers,
config,
pkgs,
...
}:
2024-05-05 19:39:35 +02:00
with lib;
let
cfg = config.plugins.specs;
2024-05-05 19:39:35 +02:00
in
{
options.plugins.specs = {
2023-01-22 03:32:08 +00:00
enable = mkEnableOption "specs-nvim";
2021-12-11 23:02:59 -06:00
package = helpers.mkPluginPackageOption "specs-nvim" pkgs.vimPlugins.specs-nvim;
general: add package options (#127) * barbar: package option * Base16: package option * gruvbox: package option * nord: package option * one: package option * onedark: package option * tokyonight: package option * nvim-cmp: package option * coq: package option * lspkind: package option * helpers: added package option to mkPlugin * fugitive: package option * gitgutter: package option * gitsigns: package option * neogit: package option * ledger: package option * nix: package option * plantuml-syntax: package option * treesitter-context: package option + formatting * treesitter-refactor: package option + formatting * treesitter: package option * zig: package option * null-ls: package option * null-ls/servers: package option * lsp-lines: package option * lspsaga: package option * trouble: package option * luasnip: added description for package option * airline: package option * lightline: package option * lualine: package option * telescope: package option * telescope/frecency: package option * telescope/fzf-native: package option * telescope/media-files: package option * comment-nvim: package option * vim-commentary: package option * dashboard: package option * easyescape: package option * emmet: package option * endwise: package option * floaterm: package option * goyo: package option * intellitab: package option * mark-radar: package option * notify: package option * nvim-autopairs: package option * nvim-tree: package option * project-nvim: package option * specs: package option * startify: package option * surround: package option * undotree: package option
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 {
2024-05-05 19:39:35 +02:00
type = types.nullOr (
types.enum [
"linear_fader"
"exp_fader"
"pulse_fader"
"empty_fader"
]
);
2021-12-11 23:02:59 -06:00
default = "linear_fader";
};
custom = mkOption {
type = types.lines;
default = "";
example = ''
function(blend, cnt)
if cnt > 100 then
return 80
else return nil end
end
'';
};
};
};
2024-05-05 19:39:35 +02:00
default = {
builtin = "linear_fader";
};
2021-12-11 23:02:59 -06:00
};
resizer = mkOption {
type = types.submodule {
options = {
builtin = mkOption {
2024-05-05 19:39:35 +02:00
type = types.nullOr (
types.enum [
"shrink_resizer"
"slide_resizer"
"empty_resizer"
]
);
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
'';
};
};
};
2024-05-05 19:39:35 +02:00
default = {
builtin = "shrink_resizer";
};
2021-12-11 23:02:59 -06:00
};
ignored_filetypes = mkOption {
type = with types; listOf str;
2024-05-05 19:39:35 +02:00
default = [ ];
2021-12-11 23:02:59 -06:00
};
ignored_buffertypes = mkOption {
type = with types; listOf str;
2024-05-05 19:39:35 +02:00
default = [ "nofile" ];
2021-12-11 23:02:59 -06:00
};
};
2024-05-05 19:39:35 +02: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
);
2024-05-05 19:39:35 +02:00
ignore_buftypes = attrsets.listToAttrs (
lib.lists.map (x: attrsets.nameValuePair x true) cfg.ignored_buffertypes
);
2024-05-05 19:39:35 +02:00
popup = {
inherit (cfg) blend width;
winhl = if (cfg.color != null) then "SpecsPopColor" else "PMenu";
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}''
);
resizer = helpers.mkRaw (
if cfg.resizer.builtin == null then
cfg.resizer.custom
else
''require("specs").${cfg.resizer.builtin}''
);
};
2021-12-11 23:02:59 -06:00
};
2024-05-05 19:39:35 +02:00
in
mkIf cfg.enable {
2024-05-05 19:39:35 +02: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})
'';
};
}