specs.nvim: init

This commit is contained in:
legendofmiracles 2021-12-11 23:02:59 -06:00 committed by Pedro Alves
parent ff824e9dba
commit 4b4328bf4b
2 changed files with 140 additions and 0 deletions

View file

@ -29,6 +29,7 @@
./utils/telescope.nix ./utils/telescope.nix
./utils/nvim-autopairs.nix ./utils/nvim-autopairs.nix
./utils/intellitab.nix ./utils/intellitab.nix
./utils/specs.nix
./languages/treesitter.nix ./languages/treesitter.nix
./languages/nix.nix ./languages/nix.nix

139
plugins/utils/specs.nix Normal file
View file

@ -0,0 +1,139 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.programs.nixvim.plugins.specs;
helpers = import ../helpers.nix { inherit lib; };
in {
options.programs.nixvim.plugins.specs = {
enable = mkEnableOption "Enable specs-nvim";
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;
};
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;
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}'');
};
};
in mkIf cfg.enable {
programs.nixvim = {
extraPlugins = [ pkgs.vimPlugins.specs-nvim ];
extraConfigLua = ''
require('specs').setup(${setup})
'';
};
};
}