nixeovim/modules/plugins/navigation/nvim-tree.nix

75 lines
1.7 KiB
Nix
Raw Permalink Normal View History

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