From 5a69dc471202a08e7a1eb539f63928a957549c82 Mon Sep 17 00:00:00 2001 From: traxys Date: Tue, 14 Mar 2023 11:30:45 +0100 Subject: [PATCH] neo-tree: Allow other plugins to insert their sources (#249) Some plugins define neo-tree sources. For theese plugins having an option 'neoTreeIntegration = true' would be useful. The problem is that if we set the plugins.neo-tree.sources to [""] then we ditch the default values of ["filesystem" ...]. The idea here is to define an internal extraSources option that takes care of the following: - If sources is null set it to the default sources - Concatenate sources and extraSources --- plugins/utils/neo-tree.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/utils/neo-tree.nix b/plugins/utils/neo-tree.nix index 16b4d5d7..0f3438e8 100644 --- a/plugins/utils/neo-tree.nix +++ b/plugins/utils/neo-tree.nix @@ -40,6 +40,10 @@ in { The name used here must be the same name you would use in a require() call. ''; + extraSources = helpers.mkNullOrOption (types.listOf types.str) '' + Extra sources to be added to the sources. This is an internal nixvim option. + ''; + addBlankLineAtTop = helpers.defaultNullOpts.mkBool false "Add a blank line at the top of the tree."; @@ -945,7 +949,15 @@ in { options = with cfg; { - inherit (cfg) sources; + # Concatenate sources and extraSources, setting sources to it's default value if it is null + # and extraSources is not null + sources = + if (!isNull cfg.extraSources) + then + if (isNull cfg.sources) + then ["filesystem" "git_status" "buffers"] ++ cfg.extraSources + else cfg.sources ++ cfg.extraSources + else cfg.sources; add_blank_line_at_top = cfg.addBlankLineAtTop; auto_clean_after_session_restore = cfg.autoCleanAfterSessionRestore; close_if_last_window = cfg.closeIfLastWindow;