From e9a672c9ce111d4b9f8b7741cf5bd6410242d67a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 14 Apr 2024 15:49:16 +0300 Subject: [PATCH 1/3] plugins/neo-tree: init module --- flake.nix | 5 +++++ modules/plugins/filetree/default.nix | 1 + modules/plugins/filetree/neo-tree/config.nix | 20 +++++++++++++++++++ modules/plugins/filetree/neo-tree/default.nix | 6 ++++++ .../plugins/filetree/neo-tree/neo-tree.nix | 9 +++++++++ modules/plugins/filetree/nvimtree/default.nix | 2 +- 6 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 modules/plugins/filetree/neo-tree/config.nix create mode 100644 modules/plugins/filetree/neo-tree/default.nix create mode 100644 modules/plugins/filetree/neo-tree/neo-tree.nix diff --git a/flake.nix b/flake.nix index 78c3447..c2ef2d6 100644 --- a/flake.nix +++ b/flake.nix @@ -225,6 +225,11 @@ flake = false; }; + plugin-neo-tree-nvim = { + url = "github:nvim-neo-tree/neo-tree.nvim"; + flake = false; + }; + # Tablines plugin-nvim-bufferline-lua = { url = "github:akinsho/nvim-bufferline.lua"; diff --git a/modules/plugins/filetree/default.nix b/modules/plugins/filetree/default.nix index 1441b4f..0e930c7 100644 --- a/modules/plugins/filetree/default.nix +++ b/modules/plugins/filetree/default.nix @@ -1,5 +1,6 @@ { imports = [ ./nvimtree + ./neo-tree ]; } diff --git a/modules/plugins/filetree/neo-tree/config.nix b/modules/plugins/filetree/neo-tree/config.nix new file mode 100644 index 0000000..4b41aef --- /dev/null +++ b/modules/plugins/filetree/neo-tree/config.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + + cfg = config.vim.filetree.neo-tree; +in { + config = mkIf cfg.enable { + vim.startPlugins = [ + # dependencies + "plenary-nvim" # commons library + "image-nvim" # optional for image previews + "nui-nvim" # ui library + # neotree + "neo-tree-nvim" + ]; + }; +} diff --git a/modules/plugins/filetree/neo-tree/default.nix b/modules/plugins/filetree/neo-tree/default.nix new file mode 100644 index 0000000..7ecf12b --- /dev/null +++ b/modules/plugins/filetree/neo-tree/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./neo-tree.nix + ]; +} diff --git a/modules/plugins/filetree/neo-tree/neo-tree.nix b/modules/plugins/filetree/neo-tree/neo-tree.nix new file mode 100644 index 0000000..5fa3bca --- /dev/null +++ b/modules/plugins/filetree/neo-tree/neo-tree.nix @@ -0,0 +1,9 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.filetree.nvimTree = { + enable = mkEnableOption "filetree via neo-tree.nvim"; + setupOpts = mkPluginSetupOption "neo-tree" {}; + }; +} diff --git a/modules/plugins/filetree/nvimtree/default.nix b/modules/plugins/filetree/nvimtree/default.nix index 730ee5f..5a334e8 100644 --- a/modules/plugins/filetree/nvimtree/default.nix +++ b/modules/plugins/filetree/nvimtree/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./nvimtree.nix From 58a79e6364fe8bec491a0e346d0b276d4d31849a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 14 Apr 2024 16:18:50 +0300 Subject: [PATCH 2/3] filetree/neo-tree: add setup options until border styles --- flake.lock | 17 ++ modules/plugins/filetree/neo-tree/config.nix | 24 ++- .../plugins/filetree/neo-tree/neo-tree.nix | 148 +++++++++++++++++- 3 files changed, 179 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index af5c550..3b32972 100644 --- a/flake.lock +++ b/flake.lock @@ -915,6 +915,22 @@ "type": "github" } }, + "plugin-neo-tree-nvim": { + "flake": false, + "locked": { + "lastModified": 1713050882, + "narHash": "sha256-cZwOVpdMT0NCtp6Ha592QA2RzKVS6LhXXcjfDBCQ+0k=", + "owner": "nvim-neo-tree", + "repo": "neo-tree.nvim", + "rev": "22e566aeb075c94f670f34077e05ba95190dfb4a", + "type": "github" + }, + "original": { + "owner": "nvim-neo-tree", + "repo": "neo-tree.nvim", + "type": "github" + } + }, "plugin-neocord": { "flake": false, "locked": { @@ -1835,6 +1851,7 @@ "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", "plugin-modes-nvim": "plugin-modes-nvim", + "plugin-neo-tree-nvim": "plugin-neo-tree-nvim", "plugin-neocord": "plugin-neocord", "plugin-neodev-nvim": "plugin-neodev-nvim", "plugin-noice-nvim": "plugin-noice-nvim", diff --git a/modules/plugins/filetree/neo-tree/config.nix b/modules/plugins/filetree/neo-tree/config.nix index 4b41aef..ee6b327 100644 --- a/modules/plugins/filetree/neo-tree/config.nix +++ b/modules/plugins/filetree/neo-tree/config.nix @@ -4,17 +4,25 @@ ... }: let inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.toLuaObject) toLuaObject; cfg = config.vim.filetree.neo-tree; in { config = mkIf cfg.enable { - vim.startPlugins = [ - # dependencies - "plenary-nvim" # commons library - "image-nvim" # optional for image previews - "nui-nvim" # ui library - # neotree - "neo-tree-nvim" - ]; + vim = { + startPlugins = [ + # dependencies + "plenary-nvim" # commons library + "image-nvim" # optional for image previews + "nui-nvim" # ui library + # neotree + "neo-tree-nvim" + ]; + + luaConfigRc.neo-tree = entryAnywhere '' + require("neo-tree").setup(${toLuaObject cfg.setupOpts}) + ''; + }; }; } diff --git a/modules/plugins/filetree/neo-tree/neo-tree.nix b/modules/plugins/filetree/neo-tree/neo-tree.nix index 5fa3bca..75170e9 100644 --- a/modules/plugins/filetree/neo-tree/neo-tree.nix +++ b/modules/plugins/filetree/neo-tree/neo-tree.nix @@ -1,9 +1,153 @@ {lib, ...}: let - inherit (lib.options) mkEnableOption; + inherit (lib.types) bool str int submodule enum either listOf; + inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.filetree.nvimTree = { enable = mkEnableOption "filetree via neo-tree.nvim"; - setupOpts = mkPluginSetupOption "neo-tree" {}; + + # Permalink: + # https://github.com/nvim-neo-tree/neo-tree.nvim/blob/22e566aeb075c94f670f34077e05ba95190dfb4a/lua/neo-tree/defaults.lua + setupOpts = mkPluginSetupOption "neo-tree" { + add_blank_line_at_top = mkOption { + type = bool; + default = false; + description = '' + Whether to add a blank line at the top of the tree + ''; + }; + + auto_clean_after_session_restore = mkOption { + type = bool; + default = false; + description = '' + Whether to automatically clean up broken neo-tree buffers + saved in sessions + ''; + }; + + default_source = mkOption { + type = str; + default = "filesystem"; + description = '' + You can choose a specific source. + + `last` here which indicates the last used source + ''; + }; + + enable_diagnostics = mkEnableOption "diagnostics" // {default = true;}; + enable_git_status = mkEnableOption "git status" // {default = true;}; + enable_modified_markers = mkEnableOption "markers for files with unsaved changes." // {default = true;}; + enable_opened_markers = + mkEnableOption '' + tracking of opened files. + + Required for `components.name.highlight_opened_files` + '' + // {default = true;}; + + enable_refresh_on_write = + mkEnableOption '' + Refresh the tree when a file is written. + + Only used if `use_libuv_file_watcher` is false. + '' + // {default = true;}; + + enable_cursor_hijack = mkEnableOption '' + cursor hijacking. + + If enabled neotree will keep the cursor on the first letter of the filename when moving in the tree + ''; + + git_status_async = mkEnableOption '' + async git status. + + This will make the git status check async and will not block the UI. + ''; + + git_status_async_options = mkOption { + description = "These options are for people with VERY large git repos"; + type = submodule { + batch_size = mkOption { + type = int; + default = 1000; + description = "How many lines of git status results to process at a time"; + }; + + batch_delay = mkOption { + type = int; + default = 10; + description = "Delay, in ms, between batches. Spreads out the workload to let other processes run"; + }; + + max_lines = mkOption { + type = int; + default = 10000; + description = '' + How many lines of git status results to process. + + Anything after this will be dropped. Anything before this will be used. + The last items to be processed are the untracked files. + ''; + }; + }; + }; + + hide_root_node = mkOption { + type = bool; + default = false; + description = '' + Whether to hide the root node of the tree + ''; + }; + + retain_hidden_root_indent = mkOption { + type = bool; + default = false; + description = '' + Whether to retain the indent of the hidden root node + + IF the root node is hidden, keep the indentation anyhow. + This is needed if you use expanders because they render in the indent. + ''; + }; + + log_level = mkOption { + type = enum ["trace" "debug" "info" "warn" "error" "fatal"]; + default = "info"; + description = "Log level for the plugin."; + }; + + log_to_file = mkOption { + type = either bool str; + default = false; + example = literalExpression "/tmp/neo-tree.log"; + description = '' + Must be either a boolean or a path to your log file. + + Use :NeoTreeLogs to show the file + ''; + }; + + open_files_in_last_window = mkOption { + type = bool; + default = true; + description = '' + Whether to open files in the last window + + If disabled, neo-tree will open files in top left window + ''; + }; + + open_files_do_not_replace_types = mkOption { + type = listOf str; + default = ["terminal" "Trouble" "qf" "edgy"]; + descriptin = '' + A list of filetypes that should not be replaced when opening a file + ''; + }; + }; }; } From a6bb6c3e9180faadbd180d798e2f42ef7add533c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 18 Apr 2024 22:16:38 +0300 Subject: [PATCH 3/3] plugins/filetree: rename module name; default to neo-tree --- configuration.nix | 5 ++--- modules/plugins/filetree/neo-tree/config.nix | 4 ++-- modules/plugins/filetree/neo-tree/neo-tree.nix | 6 ++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/configuration.nix b/configuration.nix index 7e55050..3a7adba 100644 --- a/configuration.nix +++ b/configuration.nix @@ -127,9 +127,8 @@ inputs: let }; filetree = { - nvimTree = { - enable = true; - }; + nvimTree.enable = false; + neo-tree.enable = true; }; tabline = { diff --git a/modules/plugins/filetree/neo-tree/config.nix b/modules/plugins/filetree/neo-tree/config.nix index ee6b327..dd85287 100644 --- a/modules/plugins/filetree/neo-tree/config.nix +++ b/modules/plugins/filetree/neo-tree/config.nix @@ -5,7 +5,7 @@ }: let inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.toLuaObject) toLuaObject; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.filetree.neo-tree; in { @@ -20,7 +20,7 @@ in { "neo-tree-nvim" ]; - luaConfigRc.neo-tree = entryAnywhere '' + luaConfigRC.neo-tree = entryAnywhere '' require("neo-tree").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/filetree/neo-tree/neo-tree.nix b/modules/plugins/filetree/neo-tree/neo-tree.nix index 75170e9..b1ec260 100644 --- a/modules/plugins/filetree/neo-tree/neo-tree.nix +++ b/modules/plugins/filetree/neo-tree/neo-tree.nix @@ -3,7 +3,7 @@ inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.nvim.types) mkPluginSetupOption; in { - options.vim.filetree.nvimTree = { + options.vim.filetree.neo-tree = { enable = mkEnableOption "filetree via neo-tree.nvim"; # Permalink: @@ -67,6 +67,7 @@ in { This will make the git status check async and will not block the UI. ''; + /* git_status_async_options = mkOption { description = "These options are for people with VERY large git repos"; type = submodule { @@ -94,6 +95,7 @@ in { }; }; }; + */ hide_root_node = mkOption { type = bool; @@ -144,7 +146,7 @@ in { open_files_do_not_replace_types = mkOption { type = listOf str; default = ["terminal" "Trouble" "qf" "edgy"]; - descriptin = '' + description = '' A list of filetypes that should not be replaced when opening a file ''; };