From b9df79bce99d178c671f65ec9292100d3a938498 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Wed, 10 Jan 2024 14:36:44 -0600 Subject: [PATCH] feat(nvim): add netman for remote resource access --- .../nvim/lua/plugins/configs/neo-tree.lua | 34 +++++++++++++++++++ .../nvim/lua/plugins/configs/netman.lua | 8 +++++ 2 files changed, 42 insertions(+) create mode 100644 dots/.config/nvim/lua/plugins/configs/netman.lua diff --git a/dots/.config/nvim/lua/plugins/configs/neo-tree.lua b/dots/.config/nvim/lua/plugins/configs/neo-tree.lua index 11c41d50..8dca7a7a 100644 --- a/dots/.config/nvim/lua/plugins/configs/neo-tree.lua +++ b/dots/.config/nvim/lua/plugins/configs/neo-tree.lua @@ -5,20 +5,54 @@ return { "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", + "miversen33/netman.nvim" }, cmd = "Neotree", keys = { { "nt", "Neotree show toggle focus", desc = "Neotree: Toggle" }, }, + init = function() + -- Correctly hijack netrw, thanks to + -- https://github.com/nvim-neo-tree/neo-tree.nvim/issues/1247#issuecomment-1836294271 + vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("NeoTreeInit", { clear = true }), + callback = function() + local f = vim.fn.expand("%:p") + if vim.fn.isdirectory(f) ~= 0 then + vim.cmd("Neotree current dir=" .. f) + -- neo-tree is loaded now, delete the init autocmd + vim.api.nvim_clear_autocmds { group = "NeoTreeInit" } + end + end + }) + end, opts = function() vim.g.neo_tree_remove_legacy_commands = 1 return { + sources = { + "filesystem", + "git_status", + "buffers", + "netman.ui.neo-tree", + }, source_selector = { winbar = true, + sources = { + { + source = "filesystem", + }, + { + source = "buffers", + }, + { + source = "remote", + }, + }, }, filesystem = { use_libuv_file_watcher = true, + hijack_netrw_behavior = "open_current", }, window = { mappings = { diff --git a/dots/.config/nvim/lua/plugins/configs/netman.lua b/dots/.config/nvim/lua/plugins/configs/netman.lua new file mode 100644 index 00000000..aa8b5ddc --- /dev/null +++ b/dots/.config/nvim/lua/plugins/configs/netman.lua @@ -0,0 +1,8 @@ +return { + { + "miversen33/netman.nvim", + config = function() + require("netman") + end + } +}