nvim-tree / nvim-tree.lua Goto Github PK
View Code? Open in Web Editor NEWA file explorer tree for neovim written in lua
License: Other
A file explorer tree for neovim written in lua
License: Other
I've encountered a few autocommand errors whilst using nvim tree
and
I'm not sure exactly how to reproduce either of them unfortunately I haven't had enough time to debug. The config I'm currently using is
let g:lua_tree_auto_close = 1 " 0 by default, closes the tree when it's the last window
let g:lua_tree_follow = 1 " On bufEnter find the current file
let g:lua_tree_bindings = {
\ "edit": "o",
\}
let g:lua_tree_ignore = [ '.git', 'node_modules' ]
I've also noticed that when I save a buffer nvim seems to block for like 1-2seconds. When I disable nvim-tree
things go back to normal.
Sorry this isn't too detailed I'll do some more digging when I get a chance and update this
Hi there,
I love your plugin, and I noticed that you don't have a key that opens files without leaving the tree's window.
It's a simple thing to add, and I have attached a snippet below of how I have it in my config.
I think this is a common enough usecase to include in the plugin though.
lv.tree_preview = function ()
local pos = api.nvim_win_get_cursor(0)
local tree = require "tree"
tree.on_keypress("edit")
bindings.exec[[LuaTreeClose]]
bindings.exec[[LuaTreeOpen]]
api.nvim_win_set_cursor(0, pos)
end
bindings.map.normal("<Tab>", ":lua lv.tree_preview()<CR>")
*I wrote some config wrappers in my code, but you get the idea
it pretty slow when I scrolling down/up (j/k) through folders, comparing to defx
The tree window is breaking neovim tab pages when opening the tree in a new tab.
:LuaTreeOpen
:tabnew
:LuaTreeClose
:LuaTreeOpen
The hl-Directory
group already exists, it would be nice to link to it by default.
highlight default link LuaTreeFolderName Directory
This is a completely stylistic addition which I found quite nice in other file explorers e.g. coc-explorer
below.
maybe this could be added as a config option so anyone who does or doesn't like it can toggle it.
I had a quick look at the code to see if it could be added easily and looks like in the renderer.lua
where the padding is added you could insert a special character one for most indents |
and one at the end of that indent level (can't find the exact unicode symbol atm). Naively just inserting the symbol breaks the position based highlighting. I'm happy to dig into it when I have some free time if you haven't already had a look (if you think it's fine to implement)
For example, in NerdTree, running NerdTreeFindFile also opens the tree if it's not already opened. Here we need tree to be opened in order to execute the find. Is that on purpose ?
I found one bug with it. Looks like it overrides some things globally, for example set number
. Here are steps to reproduce.
set number
in your init.vim:LuaTreeOpen
:LuaTreeOpen
, find some other file and open it in vertical splitOriginally posted by @kristijanhusak in #57 (comment)
Would it be possible to customize keybindings? (e.g.: change keybind to create a file or change keybind to expand directory from to something else)
i've noticed a few bugs when altering the fs:
Overwrite existing file: $renamedfile
. Strange.First of all, I want to say that I am really enjoying this plugin so far, especially coming from having tried nerdtree -> coc-explorer -> defx.
I am wondering, is there a way to create a directory, just like you can create files from nvim-tree? If not, would it be something possible to implement?
It seems like g:loaded_netrw
is being set by nvim-tree
at some point, which I probably wouldn't have noticed if not for the fact that I use gx
often to follow links in nvim. I know Netrw interferes with other alternative tree plugins as this has been something I've seen across several plugins. But is it possible to avoid disabling it altogether or at least maintaining the gx
behaviour. Maybe a replacement mapping to gx
that calls loads netrw only for that purpose.
Not entirely sure how that would work tbh
Hi,
I don't use devicons and currently if I want to change directory close/open icons I need to modify renderer.lua
. Can you make it configurable so that it can be set in init.vim
?
I'm not sure if it was caused by this PR, but "special" filenames now have a default icon (which is fine), but it looks like it's missing a space after:
Originally posted by @kristijanhusak in #71 (comment)
Thanks very much for this plugin, I'm already using it as replace for nerdtree. I haven't found a way to make it look like second the pic below.
I've already tried setting
let g:lua_tree_icons = {
\ 'default': ' ',
\}
And something else, that isn't related to this, but g:lua_tree_follow
defaults to 1, but in the docs it says it defaults to 0.
I'm seeing an issue when trying to use the &filetype
hook for LuaTree
to setup autocommands or a custom statusline for the buffer. I haven't looked through the code so this is a guess, but I wonder when the ft
is being set. Currently if I set my statusline to change when it detects the filetype=LuaTree
it doesn't work the first time. I also can't highlight the window using winhighlight
because it doesn't seem to pick up the filetype.
I've tried using coc-explorer
which also sets a filetype and things work fine.
If this isn't enough information please let me know I can try and do a minimal repro but I think just setting up an autocommand for LuaTree
buffers should be enough to see that the autocommand won't work the first time the buffer is opened
I would love to have the ability to open LuaTree on multiple tabs.
I use NERDTree with the vim-nerdtree-tabs plugin, which basically makes the tree behave like a panel as found in apps like VSCode or Atom.
This seems to be somewhat controversial (see NERDTree#faq) but it best fits the way I use vim, and judging by the popularity of the vim-nerdtree-tabs plugin, I am not alone.
I would be happy to work on a PR if this is something amicable to the goals of the project but which you don't want to implement yourself.
P.s. wow, this is an excellent plugin. It is considerably faster than NERDTree. Great job Kiyan!
Error detected while processing VimEnter Autocommands for "*":
E5108: Error executing lua ...e/lks/.config/nvim/plugged/nvim-tree.lua/lua/lib/git.lua:68: attempt to concatenate local 'git_root' (a nil value)
Doing:
not doing:
currently, the whole tree is redrawn all the time.
It should only redraw from the cursor to the end of the buffer
In my config files, I set the winhl
option for LuaTree when it starts, but it's being overwritten. LuaTree should use set winhl+=
to preserver existing options.
Btw, as soon as you merge the refactor PR I plan to help.
Below is a screenshot of the reason why I wanna modify it. Had to monkey-patch some files to make it.
OS: Ubuntu 18.04
terminal: Gnome Terminal
nvim: NVIM v0.5.0-392-gff1730373
nvim -u NORC
In any buffer, set the following option:
:set hidden
Then, call :LuaTreeToggle
a few times. When inspecting the buffer list, this is the result:
:buffers
1 %a "[No Name]" line 1
4 h "[No Name]" line 1
6 h "[No Name]" line 1
8 h "[No Name]" line 1
10 h "[No Name]" line 1
Press ENTER or type command to continue
After investigating the issue a bit, it seems to come from this line:
https://github.com/kyazdani42/nvim-tree.lua/blob/7e3ff3db86effd9901448ff8d553af71526e979a/lua/lib/winutils.lua#L69
According to the documentation, :new
opens a new window with an empty file in it, hence why the buffer isn't discarded. Using :vsplit
instead seems to fix the bug, but I'm not familiar enough with (Neo)vim's quirks to know whether this causes other undesirable side effects.
Thanks for the cool plugin by the way, it has nice defaults and works really well out of the box :)
When I close (toggle) tree for the first time this error appears:
E5108: Error executing lua .../.local/share/nvim/plugged/nvim-tree.lua/lua/lib/lib.lua:252: Vim(lua):E5108: Error executing lua .../.local/share/nvim/plugged/nvim-tree.lua/lua/tree.lua:100: attempt to call field 'defer_fn' (a nil value)
When I try to open it again (toggle), this appears:
E5108: Error executing lua .../.local/share/nvim/plugged/nvim-tree.lua/lua/lib/lib.lua:231: Vim:E95: Buffer with this name already exists
I'm not sure if title is descriptive enough, but i'll give steps to reproduce.
Basically, when nvim-tree is last window, and you open file from it, later it errors out:
Steps:
:LuaTreeOpen
:LuaTreeToggle
or :LuaTreeOpen
. Toggle throws error, open silently fails.I guess there are 2 available fixes:
Is there a reason why netrw is being disabled? gx
doesn't work without it in other buffers.
let g:lua_tree_git_hl = 1
let g:lua_tree_show_icons = {
\ 'git': 0,
}
If you change a file, the color doesn't get updated, according to the docs it should work without icons
from this comment
Firstly thanks for the awesome plugin, it's super snappy ๐ฏ
Sorry I bundled two issues in one.
I noticed that the plugin doesn't give the nvim-tree
buffers specific filetypes so it's hard to set autocommands or use the filetype to do whatever a user might want with that buffer e.g. nerdtree
or coc-explorer
etc. buffers have a filetype so I could have line number on or off by setting a filetype autocommand or using a ftplugin file. Or in my statusline I can check the filetype and show a formatted name with an icon for that kind of buffer or hide the statusline in that buffer altogether ๐คท.
I'd be up for raising a PR for that if that interests you at all?
This is a fairly common issue with a lot of different plugins, as far as I can guess the highlights set in the nvim-tree
buffer are only done once not on Colorscheme
changed. Think a fix here would be register a function in the plugin to apply the highlights and call it when the colorscheme changes.
Error detected while processing VimEnter Autocommands for "*":
E5108: Error executing lua .../.config/nvim/plugged/nvim-tree.lua/lua/lib/renderer.lua:39: attempt to get length of local 'extension' (a nil value)
Hey thanks for this cool plugin! ๐
I think it would be a cool feature to integrate git also into the operations to the file system. So if I call an operation to remove or rename on an object, it would be great if the git equivalent commands could be used. So to name git-rm
and git-mv
. Of course this should only be done when inside a git repository and if the object is actually tracked by git (already). I would not handle operations creating new objects.
Curious what you think about this idea. ๐
@kyazdani42 looks like the latest commit broke handling of indent markers for image files.
This doesn't seem to have affected other filetypes though so not sure if images are special cased somehow
If a user doesn't specify items in the lua_tree_icons
map vim fails to startup/crashes
let g:lua_tree_icons = {
\ 'folder': {
\ 'default': "๎ฟ",
\ 'open': "๎พ"
\ }
The fix here is just to make sure to specify the whole thing, so not a huge issue this is just FYI since it's kind of a gnarly bug
Hi,
very nice plugin, works really fast!
I have few feature requests that you might consider:
vim-gitgutter
does with ]c
and [c
I'm currently using these features in defx.nvim, and I'm also author of git and icons plugins for defx.
Congrats on merging the refactor ๐
Just tried it out and it feels even snappier ๐ฅ.
A strange issue I'm having that started before the refactor but has gotten worse, is that some buffer local options aren't working for some reason. The nonumber
and nolist
setting seems to now no longer be working.
I've tried with a minimal vimrc with just
call plug#begin(stdpath('data') . '/plugged')
Plug 'kyazdani42/nvim-tree.lua'
call plug#end()
set number relativenumber
set list
As you can see in the screenshot for some reason the set local
call in Tree.lua
isn't working I'm not really sure I understand. I also tried creating a after/ftplugin/LuaTree.vim
to override things but that still didn't work.
If I remove the settings from my init.vim
everything works but I need/like those settings not sure why the buffer isn't overriding it ๐
Hey,
i really like the state of the plugin right now, it's really great. I'm completely switched to it.
I want to suggest few more improvements. Will work on them myself, just want a confirmation from your side:
Allow multiple keys for single action
I'm used to using o
for open action, but sometimes I also try to use <CR>
. Currently I can map only one of these.
Show current cwd at top
When I work on similar projects, sometimes i forget in which folder I am. Having the info at top (beside the ..
) would help. I'm aware that this will require changing all if checks where we have if node.name == '..' then return end
, but it should not be a complicated change.
if you delete or rename a file, folder can have a git status of D
or D
and ??
.
Renaming could be detected but it might be a little bit complicated. Even for files, it would be a little bit hard.
Another solution would be to show that this folder has a new and deleted state.
Folder should only be checked if it has changed (stat.atime
, stat.ctime
)
Hi,
is there any specific reason why folders have git status icon after, and files have it before? :)
I would like to make that consistent, and also to introduce an option to highlight the whole item when it is "dirty". What do you think about that?
Whilst swapping branches and dealing with a merge conflict I tried to open lua tree and got the following errors. I've seen these before but not sure exactly what causes them, sorry. Just noting here for now will update later once I'm not at work with a clearer way to reproduce if I find it.
E5108: Error executing lua ...al/share/nvim/plugged/nvim-tree.lua/lua/lib/renderer.lua:81: bad argument #1 to 'ipairs' (table expected, got nil)
E5108: Error executing lua ...al/share/nvim/plugged/nvim-tree.lua/lua/lib/renderer.lua:81: bad argument #1 to 'ipairs' (table expected, got nil)
Error detected while processing BufEnter Autocommands for "*":
E5108: Error executing lua .../.local/share/nvim/plugged/nvim-tree.lua/lua/lib/lib.lua:172: Cursor position outside buffer
E5108: Error executing lua .../.local/share/nvim/plugged/nvim-tree.lua/lua/lib/lib.lua:172: Cursor position outside buffer
E5108: Error executing lua .../.local/share/nvim/plugged/nvim-tree.lua/lua/lib/lib.lua:172: Cursor position outside buffer
E5108: Error executing lua ...al/share/nvim/plugged/nvim-tree.lua/lua/lib/renderer.lua:81: bad argument #1 to 'ipairs' (table expected, got nil)
E5108: Error executing lua ...al/share/nvim/plugged/nvim-tree.lua/lua/lib/renderer.lua:81: bad argument #1 to 'ipairs' (table expected, got nil)
splitbellow
is a global option.
'splitbelow' 'sb' boolean (default off)
global
Actually, I can see other global options being set as well, like sidescroll
It get error when I open tree
E5108: Error executing lua .../.config/nvim/plugged/nvim-tree.lua/lua/lib/renderer.lua:271: Expected lua string
Thanks for fixing #9 so quickly ๐ .
I ran into another issue FYI ๐ , when buffers from different repositories are open, nvim-tree doesn't move to the current project root (or alternatively the directory that contains the file). The GIF below hopefully shows what I mean. The first buffer in the GIF is my dotfiles repo, but I opened vim in a dart project repo. LuaTree sticks to the initial directory, and when I move into the dotfiles project it doesn't change the tree to show the new dir.
Note: using LuaTreeFindFile
in a buffer in a different project than lua tree does nothing
Still reading through the code so not exactly sure what is going on yet. Looks like maybe ROOT_PATH
isn't being updated when you enter a new dir ๐คทโโ๏ธ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.