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

155 lines
3.7 KiB
Nix
Raw Normal View History

2021-12-11 23:02:59 -06:00
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.specs;
2021-12-11 23:02:59 -06:00
helpers = import ../helpers.nix { inherit lib; };
in
{
options.plugins.specs = {
2021-12-11 23:02:59 -06:00
enable = mkEnableOption "Enable 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
package = mkOption {
type = types.package;
default = pkgs.vimPlugins.specs-nvim;
description = "Plugin to use for specs-nvim";
};
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;
description = "Delay in miliseconds";
};
increment = mkOption {
type = types.int;
default = 10;
description = "Increment in miliseconds";
};
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
'';
};
};
};
default = { builtin = "linear_fader"; };
};
resizer = mkOption {
type = types.submodule {
options = {
builtin = mkOption {
type = types.nullOr
(types.enum [ "shrink_resizer" "slide_resizer" "empty_resizer" ]);
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
'';
};
};
};
default = { builtin = "shrink_resizer"; };
};
ignored_filetypes = mkOption {
type = with types; listOf string;
default = [ ];
};
ignored_buffertypes = mkOption {
type = with types; listOf string;
default = [ "nofile" ];
};
};
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;
2022-11-27 16:55:34 -05:00
winhl = if (!isNull cfg.color) 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
};
in
mkIf cfg.enable {
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
extraPlugins = [ cfg.package ];
2021-12-11 23:02:59 -06:00
2022-11-27 16:55:34 -05:00
highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color;
2021-12-11 23:02:59 -06:00
extraConfigLua = ''
require('specs').setup(${setup})
'';
};
}