From d459fd16cee9597224fda6afa2221b46e9c8614b Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Tue, 19 Nov 2024 01:17:09 +0100 Subject: [PATCH] neo-tree: move beforeAll to pluginRC --- modules/plugins/filetree/neo-tree/config.nix | 43 ++++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/modules/plugins/filetree/neo-tree/config.nix b/modules/plugins/filetree/neo-tree/config.nix index 0afd2bec..d2a114f3 100644 --- a/modules/plugins/filetree/neo-tree/config.nix +++ b/modules/plugins/filetree/neo-tree/config.nix @@ -4,7 +4,7 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.strings) optionalString; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.filetree.neo-tree; in { @@ -22,31 +22,30 @@ in { setupModule = "neo-tree"; inherit (cfg) setupOpts; - beforeAll = - optionalString (cfg.setupOpts.filesystem.hijack_netrw_behavior != "disabled") - # from https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/1326 - '' - vim.api.nvim_create_autocmd("BufEnter", { - group = vim.api.nvim_create_augroup("load_neo_tree", {}), - desc = "Loads neo-tree when openning a directory", - callback = function(args) - local stats = vim.uv.fs_stat(args.file) - - if not stats or stats.type ~= "directory" then - return - end - - require("lz.n").trigger_load("neo-tree-nvim") - - return true - end, - }) - ''; cmd = ["Neotree"]; - event = []; }; visuals.nvim-web-devicons.enable = true; + # from https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/1326 + pluginRC.neo-tree = + mkIf (cfg.setupOpts.filesystem.hijack_netrw_behavior != "disabled" && config.vim.lazy.enable) + (entryAnywhere '' + vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("load_neo_tree", {}), + desc = "Loads neo-tree when openning a directory", + callback = function(args) + local stats = vim.uv.fs_stat(args.file) + + if not stats or stats.type ~= "directory" then + return + end + + require("lz.n").trigger_load("neo-tree-nvim") + + return true + end, + }) + ''); }; }; }