nixeovim/modules/plugins/navigation/nvim-tree.nix
Dmitriy Pleshevskiy f3926f6365
modules/plugin: remove isDependency
do not import to local variable by default. Instead you should
set varName option.
2024-05-10 02:17:00 +03:00

74 lines
1.7 KiB
Nix

{ config, lib, pkgs, ... }:
let
inherit (lib.nix2lua) require pipe var call;
cfg = config.plugins.navigation.nvim-tree;
in
{
options.plugins.navigation.nvim-tree = with lib; {
enable = mkEnableOption "nvim-tree";
package = mkPackageOption pkgs.vimPlugins "nvim-tree-lua" { };
settings = mkOption {
type = types.attrs;
default = { };
description = ''
`:help nvim-tree-setup`
'';
};
disableNetrw = mkOption {
type = types.bool;
default = true;
description = ''
Disabling netrw is strongly advised.
`:help nvim-tree-netrw`
'';
};
keymap = {
withDefault = mkOption {
type = types.bool;
default = true;
description = "attach default mappings";
};
set = mkOption {
type = with types; listOf keymap;
default = [ ];
};
};
};
config = lib.mkIf cfg.enable {
fn.nvim-tree-lua-on-attach = lib.mkIf (cfg.keymap.set != [ ]) {
args = [ "bufnr" ];
content = { bufnr }: {
extra = lib.mkIf cfg.keymap.withDefault pipe [
(require "nvim-tree.api")
(var "config")
(var "mappings")
(call "default_on_attach" bufnr)
];
vim.keymap.set = map (attrs: attrs // { buffer = bufnr; }) cfg.keymap.set;
};
};
plugin.nvim-tree-lua = {
name = "nvim-tree";
package = cfg.package;
setupSettings = lib.mkMerge [
cfg.settings
(lib.mkIf (cfg.keymap.set != [ ]) {
on_attach = config.fn.nvim-tree-lua-on-attach.lambda;
})
];
};
plugin.nvim-web-devicons = { };
vim.g = lib.mkIf cfg.disableNetrw {
loaded_netrw = 1;
loaded_netrwPlugin = 1;
};
};
}