Compare commits

..

No commits in common. "688e8e2ece3b094f09110a04756edff76dd98901" and "6086cea1d4c1d9e1f9990b86ddb40a05d594b10c" have entirely different histories.

5 changed files with 3 additions and 103 deletions

View file

@ -43,7 +43,7 @@ let
'';
};
buffer = mkOption {
type = with types; nullOr attrs;
type = with types; nullOr str;
default = null;
description = ''
The mapping will be effective in the current buffer only.
@ -129,6 +129,7 @@ let
genConfig = mkOption {
type = types.attrs;
readOnly = true;
internal = true;
};
};

View file

@ -9,13 +9,11 @@
./modules/filetype.nix
./modules/input.nix
./modules/plugin.nix
./modules/fn.nix
./modules/plugins/theme/catppuccin.nix
./modules/plugins/style/neoformat.nix
./modules/plugins/navigation/telescope.nix
./modules/plugins/navigation/nvim-tree.nix
./modules/plugins/gitsigns.nix
##################################################
(pkgs.path + "/nixos/modules/misc/assertions.nix")

View file

@ -1,61 +0,0 @@
{ lib, ... }:
let
fnOpts = { name, config, ... }: {
options = with lib; {
args = mkOption {
type = with types; listOf str;
default = [ ];
};
content = mkOption {
type = types.functionTo (lib.types.submoduleWith {
modules = [
{
options.extra = with lib; mkOption {
type = with types; nullOr attrs;
default = null;
};
}
./vim/keymap.nix
# ./vim/opts.nix
];
specialArgs = { inherit lib; };
});
default = { };
};
lambda = mkOption {
type = types.attrs;
readOnly = true;
internal = true;
};
};
config = {
lambda = with lib.nix2lua;
let
fnArgs = builtins.listToAttrs (map (v: { name = v; value = raw v; }) config.args);
innerCfg = config.content fnArgs;
in
lambda config.args (lib.flatten [
innerCfg.extra
(lib.flip map innerCfg.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
let
buf = lib.optionalString (vars.buffer != null) vars.buffer.raw;
m = if builtins.isList mode then lib.head mode else mode;
in
if innerCfg.vim.keymap._validate."${buf}"."${m}"."${lhs}" == rhs then vars.genConfig
else abort "This case should never happen."
))
]);
};
};
in
{
options.fn = with lib; mkOption {
type = with types; attrsOf (submodule fnOpts);
default = { };
};
}

View file

@ -1,38 +0,0 @@
{ config, lib, pkgs, ... }:
let cfg = config.plugins.gitsigns; in
{
options.plugins.gitsigns = with lib; {
enable = mkEnableOption "gitsigns-nvim";
package = mkPackageOption pkgs.vimPlugins "gitsigns-nvim" { };
settings = mkOption {
type = types.attrs;
default = { };
};
keymap.set = mkOption {
type = with types; listOf keymap;
};
};
config = lib.mkIf cfg.enable {
fn.gitsigns-nvim-on-attach = {
args = [ "bufnr" ];
content = { bufnr }: {
vim.keymap.set = map (attrs: attrs // { buffer = bufnr; }) cfg.keymap.set;
};
};
plugin.gitsigns-nvim = {
name = "gitsigns";
varName = "gs";
package = cfg.package;
setupSettings = cfg.settings // {
on_attach = config.fn.gitsigns-nvim-on-attach.lambda;
};
};
};
}

View file

@ -30,7 +30,7 @@ let cfg = config.vim.keymap; in
else m
)));
buf = lib.optionalString (buffer != null) buffer.raw;
buf = lib.optionalString (buffer != null) buffer;
in
lib.foldl lib.recursiveUpdate { }
(lib.flip map unwrappedModes (m: {