Refacto: rewrite everything
- The tree is created with libuv functions, which makes it blazingly fast. - The tree may now be faster than any other vim trees, it can handle directories with thousands of files without any latency at all (tested on 40K files, works flawlessly). - More solid logic for opening and closing the tree. - tree state is remembered (closing / opening a folder keeps opened subdirectories open) - detection of multiple git projects in the tree - more icon support - smart rendering - smart updates - ms windows support - gx replacement function running xdg-open on linux, open on macos
This commit is contained in:
68
README.md
68
README.md
@@ -2,13 +2,23 @@
|
||||
|
||||
## Notice
|
||||
|
||||
- This plugin does not work on windows.
|
||||
This plugin doesn't support windows. \
|
||||
This plugin requires [neovim nightly](https://github.com/neovim/neovim/wiki/Installing-Neovim). \
|
||||
You can switch to commit `afc86a9` if you use neovim 0.4.x. \
|
||||
Note that the old version has less features and is much slower than the new one.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [vim-plug](https://github.com/junegunn/vim-plug):
|
||||
```vim
|
||||
" master (neovim git)
|
||||
Plug 'kyazdani42/nvim-web-devicons' " for file icons
|
||||
Plug 'kyazdani42/nvim-tree.lua'
|
||||
|
||||
" old version that runs on neovim 0.4.x
|
||||
Plug 'kyazdani42/nvim-tree.lua' { 'commit': 'afc86a9' }
|
||||
" for icons in old version
|
||||
Plug 'ryanoasis/vim-devicons'
|
||||
```
|
||||
|
||||
## Setup
|
||||
@@ -16,11 +26,10 @@ Plug 'kyazdani42/nvim-tree.lua'
|
||||
```vim
|
||||
let g:lua_tree_side = 'right' | 'left' "left by default
|
||||
let g:lua_tree_size = 40 "30 by default
|
||||
let g:lua_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default, not working on mac atm
|
||||
let g:lua_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
|
||||
let g:lua_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim`
|
||||
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 "0 by default, this option will bind BufEnter to the LuaTreeFindFile command
|
||||
" :help LuaTreeFindFile for more info
|
||||
let g:lua_tree_follow = 1 "0 by default, this option allows the cursor to be updated when entering a buffer
|
||||
let g:lua_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 0,
|
||||
@@ -28,7 +37,7 @@ let g:lua_tree_show_icons = {
|
||||
\}
|
||||
"If 0, do not show the icons for one of 'git' 'folder' and 'files'
|
||||
"1 by default, notice that if 'files' is 1, it will only display
|
||||
"if web-devicons is installed and on your runtimepath
|
||||
"if nvim-web-devicons is installed and on your runtimepath
|
||||
|
||||
" You can edit keybindings be defining this variable
|
||||
" You don't have to define all keys.
|
||||
@@ -44,14 +53,27 @@ let g:lua_tree_bindings = {
|
||||
\ 'rename': 'r'
|
||||
\ }
|
||||
|
||||
" default will show icon by default if no icon is provided
|
||||
" default shows no icon by default
|
||||
let g:lua_tree_icons = {
|
||||
\ 'default': '',
|
||||
\ 'git': {
|
||||
\ 'unstaged': "✗",
|
||||
\ 'staged': "✓",
|
||||
\ 'unmerged': "═",
|
||||
\ 'renamed': "➜",
|
||||
\ 'untracked': "★"
|
||||
\ }
|
||||
\ }
|
||||
|
||||
nnoremap <C-n> :LuaTreeToggle<CR>
|
||||
nnoremap <leader>r :LuaTreeRefresh<CR>
|
||||
nnoremap <leader>n :LuaTreeFindFile<CR>
|
||||
" LuaTreeOpen and LuaTreeClose are also available if you need them
|
||||
|
||||
set termguicolors " this variable must be enabled for colors to be applied properly
|
||||
|
||||
" a list of groups can be found at `:help lua_tree_highlight`
|
||||
highlight LuaTreeFolderName guibg=cyan gui=bold,underline
|
||||
highlight LuaTreeFolderIcon guibg=blue
|
||||
```
|
||||
|
||||
@@ -60,33 +82,33 @@ highlight LuaTreeFolderIcon guibg=blue
|
||||
- move around like in any vim buffer
|
||||
- `<CR>` on `..` will cd in the above directory
|
||||
- `.` will cd in the directory under the cursor
|
||||
- type `a` to add a file
|
||||
- type `a` to add a file. Adding a directory requires leaving a leading `/` at the end of the path.
|
||||
> you can add multiple directories by doing foo/bar/baz/f and it will add foo bar and baz directories and f as a file
|
||||
- type `r` to rename a file
|
||||
- type `d` to delete a file (will prompt for confirmation)
|
||||
- if the file is a directory, `<CR>` will open the directory
|
||||
- otherwise it will open the file in the buffer near the tree
|
||||
- if the file is a symlink, `<CR>` will follow the symlink
|
||||
- if the file is a directory, `<CR>` will open the directory otherwise it will open the file in the buffer near the tree
|
||||
- if the file is a symlink, `<CR>` will follow the symlink (if the target is a file)
|
||||
- type `<C-v>` will open the file in a vertical split
|
||||
- type `<C-x>` will open the file in a horizontal split
|
||||
- type `<C-t>` will open the file in a new tab
|
||||
- type `gx` to open the file with the `open` command on MACOS and `xdg-open` in linux
|
||||
- Double left click acts like `<CR>`
|
||||
- Double right click acts like `.`
|
||||
|
||||
## Note
|
||||
|
||||
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.
|
||||
|
||||
## Features
|
||||
- [x] Open file in current buffer or in split with FzF like bindings (`<CR>`, `<C-v>`, `<C-x>`, `<C-t>`)
|
||||
- [x] File icons with vim-devicons
|
||||
- [x] Syntax highlighting ([exa](https://github.com/ogham/exa) like)
|
||||
- [x] Change directory with `.`
|
||||
- [x] Add / Rename / delete files
|
||||
- [x] Git integration
|
||||
- [x] Mouse support
|
||||
- Open file in current buffer or in split with FzF like bindings (`<CR>`, `<C-v>`, `<C-x>`, `<C-t>`)
|
||||
- File icons with nvim-web-devicons
|
||||
- Syntax highlighting ([exa](https://github.com/ogham/exa) like)
|
||||
- Change directory with `.`
|
||||
- Add / Rename / delete files
|
||||
- Git integration
|
||||
- Mouse support
|
||||
- It's fast
|
||||
|
||||
## Screenshot
|
||||
|
||||

|
||||
|
||||
## TODO
|
||||
|
||||
- Tree creation could be async
|
||||
- bufferize tree
|
||||
- better default colors (use vim highlight groups)
|
||||
|
||||
Reference in New Issue
Block a user