From ce2420b9dab282703fb08e72009f0787b1a7b097 Mon Sep 17 00:00:00 2001 From: kiyan Date: Sun, 21 Feb 2021 12:27:31 +0100 Subject: [PATCH] remove custom gx command in favor of netrw functionnalities and add documentation for netrw hijack --- README.md | 3 --- doc/nvim-tree-lua.txt | 17 ++++++++++++++--- lua/lib/lib.lua | 1 - lua/nvim-tree.lua | 19 ------------------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index c4476e30..53897076 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,6 @@ highlight NvimTreeFolderIcon guibg=blue - `I` will toggle visibility of folders hidden via |g:nvim_tree_ignore| - `H` will toggle visibility of dotfiles (files/folders starting with a `.`) - `R` will refresh the tree -- `gx` opens the file with the `open` command on MACOS and `xdg-open` in linux - Double left click acts like `` - Double right click acts like `` @@ -138,8 +137,6 @@ highlight NvimTreeFolderIcon guibg=blue This plugin is very fast because it uses the `libuv` `scandir` and `scandir_next` functions instead of spawning an `ls` process which can get slow on large files when combining with `stat` to get file informations. -The Netrw vim plugin is disabled, hence features like `gx` don't work across your windows/buffers. You could use a plugin like [this one](https://github.com/stsewd/gx-extended.vim) if you wish to use that feature. - ## Features - Open file in current buffer or in split with FzF like bindings (``, ``, ``, ``) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 6be0a535..432b86ac 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -180,12 +180,25 @@ Can be 0 or 1. When 1, will open the tree when entering a new tab if the tree was previously open. Default is 0 -|g:nvim_tree_width_allow_resize| *g:nvim_tree_width_allow_resize* +|g:nvim_tree_width_allow_resize| *g:nvim_tree_width_allow_resize* Can be 0 or 1. When 1, it will not resize the tree to it's original width when opening a new file. Default is 0 +|g:nvim_tree_hijack_netrw| *g:nvim_tree_hijack_netrw* + +Can be 0 or 1. When 1, disable netrw buffers when nvim-tree start but keeps +existing netrw functionnalities accross buffers (like `gx`). +1 by default. + +|g:nvim_tree_disable_netrw| *g:nvim_tree_disable_netrw* + +Can be 0 or 1. When 1, completely disable netrw and all related +functionnalities. +1 by default. + + ============================================================================== INFORMATIONS *nvim-tree-info* @@ -216,8 +229,6 @@ INFORMATIONS *nvim-tree-info* - '' will open the file as a preview (keeps the cursor in the tree) - 'I' will toggle visibility of folders hidden via |g:nvim_tree_ignore| - 'R' will refresh the tree -- 'gx' opens the file with the `open` command on macos and `xdg-open` -on linux. - Double left click acts like '' - Double right click acts like '' diff --git a/lua/lib/lib.lua b/lua/lib/lib.lua index 1dbd5e09..5ab25766 100644 --- a/lua/lib/lib.lua +++ b/lua/lib/lib.lua @@ -280,7 +280,6 @@ local function set_mappings() [bindings.next_git_item] = 'on_keypress("next_git_item")'; [bindings.dir_up] = 'on_keypress("dir_up")'; [bindings.close] = 'on_keypress("close")'; - gx = "xdg_open()"; } for k,v in pairs(mappings) do diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index e2ec48f8..5ccfb62d 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -196,25 +196,6 @@ function M.reset_highlight() renderer.render_hl(lib.Tree.bufnr) end -function M.xdg_open() - local node = lib.get_node_at_cursor() - -- TODO: this should open symlink targets - if not node or node.entries or node.link_to then return end - - local cmd - if vim.fn.has('unix') == 1 then - cmd = 'xdg-open' - else - cmd = 'open' - end - - vim.loop.spawn(cmd, {args={node.absolute_path}}, vim.schedule_wrap(function(code) - if code ~= 0 then - api.nvim_err_writeln("Could not open "..node.absolute_path) - end - end)) -end - colors.setup() vim.defer_fn(M.on_enter, 1)