mirror of
https://github.com/nvim-tree/nvim-tree.lua
synced 2024-09-08 02:35:42 +02:00
renaming: lua-tree -> nvim-tree
This commit is contained in:
parent
2e7118ca17
commit
05711754d9
12 changed files with 189 additions and 196 deletions
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Tree.lua is a simple tree for neovim
|
||||
nvim-tree.lua is a file explorer / filesystem tree view plugin for neovim
|
||||
Copyright © 2019 Yazdani Kiyan
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
61
README.md
61
README.md
|
@ -2,43 +2,36 @@
|
|||
|
||||
## Notice
|
||||
|
||||
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.
|
||||
This plugin doesn't support windows yet. \
|
||||
This plugin requires [neovim nightly](https://github.com/neovim/neovim/wiki/Installing-Neovim).
|
||||
|
||||
## Install
|
||||
|
||||
Install with [vim-plug](https://github.com/junegunn/vim-plug):
|
||||
|
||||
```vim
|
||||
" master (neovim git)
|
||||
" requires
|
||||
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
|
||||
|
||||
```vim
|
||||
let g:lua_tree_side = 'right' | 'left' "left by default
|
||||
let g:lua_tree_width = 40 "30 by default
|
||||
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_quit_on_open = 1 "0 by default, closes the tree when you open a file
|
||||
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_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
|
||||
let g:lua_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
|
||||
let g:lua_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
|
||||
let g:lua_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||
let g:lua_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open
|
||||
let g:lua_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file
|
||||
let g:lua_tree_show_icons = {
|
||||
let g:nvim_tree_side = 'right' | 'left' "left by default
|
||||
let g:nvim_tree_width = 40 "30 by default
|
||||
let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
|
||||
let g:nvim_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim`
|
||||
let g:nvim_tree_auto_close = 1 "0 by default, closes the tree when it's the last window
|
||||
let g:nvim_tree_quit_on_open = 1 "0 by default, closes the tree when you open a file
|
||||
let g:nvim_tree_follow = 1 "0 by default, this option allows the cursor to be updated when entering a buffer
|
||||
let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
|
||||
let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
|
||||
let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
|
||||
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||
let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open
|
||||
let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file
|
||||
let g:nvim_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 0,
|
||||
\ 'files': 0,
|
||||
|
@ -50,7 +43,7 @@ let g:lua_tree_show_icons = {
|
|||
" You can edit keybindings be defining this variable
|
||||
" You don't have to define all keys.
|
||||
" NOTE: the 'edit' key will wrap/unwrap a folder and open a file
|
||||
let g:lua_tree_bindings = {
|
||||
let g:nvim_tree_bindings = {
|
||||
\ 'edit': ['<CR>', 'o'],
|
||||
\ 'edit_vsplit': '<C-v>',
|
||||
\ 'edit_split': '<C-x>',
|
||||
|
@ -73,11 +66,11 @@ let g:lua_tree_bindings = {
|
|||
|
||||
" Disable default mappings by plugin
|
||||
" Bindings are enable by default, disabled on any non-zero value
|
||||
" let lua_tree_disable_keybindings=1
|
||||
" let nvim_tree_disable_keybindings=1
|
||||
|
||||
" default will show icon by default if no icon is provided
|
||||
" default shows no icon by default
|
||||
let g:lua_tree_icons = {
|
||||
let g:nvim_tree_icons = {
|
||||
\ 'default': '',
|
||||
\ 'symlink': '',
|
||||
\ 'git': {
|
||||
|
@ -94,15 +87,15 @@ let g:lua_tree_icons = {
|
|||
\ }
|
||||
\ }
|
||||
|
||||
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
|
||||
nnoremap <C-n> :NvimTreeToggle<CR>
|
||||
nnoremap <leader>r :NvimTreeRefresh<CR>
|
||||
nnoremap <leader>n :NvimTreeFindFile<CR>
|
||||
" NvimTreeOpen and NvimTreeClose 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 LuaTreeFolderIcon guibg=blue
|
||||
" a list of groups can be found at `:help nvim_tree_highlight`
|
||||
highlight NvimTreeFolderIcon guibg=blue
|
||||
```
|
||||
|
||||
## KeyBindings
|
||||
|
@ -126,7 +119,7 @@ highlight LuaTreeFolderIcon guibg=blue
|
|||
- `<C-x>` will open the file in a horizontal split
|
||||
- `<C-t>` will open the file in a new tab
|
||||
- `<Tab>` will open the file as a preview (keeps the cursor in the tree)
|
||||
- `I` will toggle visibility of folders hidden via |g:lua_tree_ignore|
|
||||
- `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
|
||||
|
|
|
@ -12,69 +12,69 @@ This file explorer doesn't work on windows and requires neovim `nightly`
|
|||
==============================================================================
|
||||
QUICK START *nvim-tree-quickstart*
|
||||
|
||||
open the tree with :LuaTreeToggle
|
||||
open the tree with :NvimTreeToggle
|
||||
>
|
||||
nnoremap <C-n> :LuaTreeToggle<CR>
|
||||
lua require 'tree'.toggle()
|
||||
nnoremap <C-n> :NvimTreeToggle<CR>
|
||||
lua require 'nvim-tree'.toggle()
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
COMMANDS *nvim-tree-commands*
|
||||
|
||||
|:LuaTreeOpen| *:LuaTreeOpen*
|
||||
|:NvimTreeOpen| *:NvimTreeOpen*
|
||||
|
||||
opens the tree
|
||||
|
||||
|:LuaTreeClose| *:LuaTreeClose*
|
||||
|:NvimTreeClose| *:NvimTreeClose*
|
||||
|
||||
closes the tree
|
||||
|
||||
|:LuaTreeToggle| *:LuaTreeToggle*
|
||||
|:NvimTreeToggle| *:NvimTreeToggle*
|
||||
|
||||
open or close the tree
|
||||
|
||||
|:LuaTreeRefresh| *:LuaTreeRefresh*
|
||||
|:NvimTreeRefresh| *:NvimTreeRefresh*
|
||||
|
||||
refresh the tree
|
||||
|
||||
|:LuaTreeFindFile| *:LuaTreeFindFile*
|
||||
|:NvimTreeFindFile| *:NvimTreeFindFile*
|
||||
|
||||
The command will change the cursor in the tree for the current bufname.
|
||||
|
||||
It will also open the leafs of the tree leading to the file in the buffer
|
||||
(if you opened a file with something else than the LuaTree, like `fzf` or
|
||||
(if you opened a file with something else than the NvimTree, like `fzf` or
|
||||
`:split`)
|
||||
|
||||
|:LuaTreeClipboard| *:LuaTreeClipboard*
|
||||
|:NvimTreeClipboard| *:NvimTreeClipboard*
|
||||
|
||||
Print clipboard content for both cut and copy
|
||||
|
||||
==============================================================================
|
||||
OPTIONS *nvim-tree-options*
|
||||
|
||||
|g:lua_tree_width| *g:lua_tree_width*
|
||||
|g:nvim_tree_width| *g:nvim_tree_width*
|
||||
|
||||
width of the window (default to 30)
|
||||
|
||||
|g:lua_tree_side| *g:lua_tree_side*
|
||||
|g:nvim_tree_side| *g:nvim_tree_side*
|
||||
|
||||
where the window will open (default to 'left')
|
||||
- 'left' or 'right'
|
||||
|
||||
|g:lua_tree_ignore| *g:lua_tree_ignore*
|
||||
|g:nvim_tree_ignore| *g:nvim_tree_ignore*
|
||||
|
||||
An array of strings that the tree won't load and display.
|
||||
useful to hide large data/cache folders.
|
||||
>
|
||||
example: let g:lua_tree_ignore = [ '.git', 'node_modules' ]
|
||||
example: let g:nvim_tree_ignore = [ '.git', 'node_modules' ]
|
||||
|
||||
|g:lua_tree_show_icons| *g:lua_tree_show_icons*
|
||||
|g:nvim_tree_show_icons| *g:nvim_tree_show_icons*
|
||||
|
||||
Dictionnary, if your terminal or font doesn't support certain unicode
|
||||
character, the tree UI might be messed up. The following configuration
|
||||
can disable icons per type:
|
||||
>
|
||||
let g:lua_tree_show_icons = {
|
||||
let g:nvim_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 1,
|
||||
\ 'icons': 1
|
||||
|
@ -85,7 +85,7 @@ to render the icons. The `icons` key can only work if `nvim-web-devicons`
|
|||
is installed and in your |runtimepath|
|
||||
(https://github.com/kyazdani42/nvim-web-devicons)
|
||||
|
||||
|g:lua_tree_icons| *g:lua_tree_icons*
|
||||
|g:nvim_tree_icons| *g:nvim_tree_icons*
|
||||
|
||||
You can set icons for:
|
||||
|
||||
|
@ -94,7 +94,7 @@ You can set icons for:
|
|||
or if you are not using icons.
|
||||
- Symlinks. If an icon is not provided, the `default` icon is used.
|
||||
>
|
||||
let g:lua_tree_icons = {
|
||||
let g:nvim_tree_icons = {
|
||||
\ 'default': '',
|
||||
\ 'symlink': '',
|
||||
\ 'git': {
|
||||
|
@ -111,66 +111,66 @@ You can set icons for:
|
|||
\ }
|
||||
\ }
|
||||
|
||||
|g:lua_tree_git_hl| *g:lua_tree_git_hl*
|
||||
|g:nvim_tree_git_hl| *g:nvim_tree_git_hl*
|
||||
|
||||
You can enable file highlight for git attributes by setting this property.
|
||||
This can be used with or without the icons.
|
||||
|
||||
|
||||
|g:lua_tree_follow| *g:lua_tree_follow*
|
||||
|g:nvim_tree_follow| *g:nvim_tree_follow*
|
||||
|
||||
Can be `0` or `1`. When `1`, will update the cursor to update to the correct
|
||||
location in the tree on |BufEnter|.
|
||||
Default is 0
|
||||
|
||||
|g:lua_tree_auto_open| *g:lua_tree_auto_open*
|
||||
|g:nvim_tree_auto_open| *g:nvim_tree_auto_open*
|
||||
|
||||
Can be `0` or `1`. When `1`, will open the tree when the package is loaded.
|
||||
It's not relying on VimEnter anymore.
|
||||
Default is 0
|
||||
|
||||
|g:lua_tree_auto_close| *g:lua_tree_auto_close*
|
||||
|g:nvim_tree_auto_close| *g:nvim_tree_auto_close*
|
||||
|
||||
Can be `0` or `1`. When `1`, will bind |BufEnter| to automatically
|
||||
close the tree if it's the last window.
|
||||
Default is 0
|
||||
|
||||
|g:lua_tree_quit_on_open| *g:lua_tree_quit_on_open*
|
||||
|g:nvim_tree_quit_on_open| *g:nvim_tree_quit_on_open*
|
||||
|
||||
Can be `0` or `1`. When `1`, will close the tree when a file is opened.
|
||||
Applies to: `preview`, `edit`, `edit_vsplit`, `edit_split`, `edit_tab`.
|
||||
Default is 0
|
||||
|
||||
|g:lua_tree_disable_keybindings| *g:lua_tree_disable_keybindings*
|
||||
|g:nvim_tree_disable_keybindings| *g:nvim_tree_disable_keybindings*
|
||||
|
||||
Can be `0` or `1`. When `1`, will disable all keybindings by the plugin.
|
||||
|g:lua_tree_bindings| as well as default bindings will not take effect.
|
||||
|g:nvim_tree_bindings| as well as default bindings will not take effect.
|
||||
Default is 0
|
||||
|
||||
|g:lua_tree_indent_markers| *g:lua_tree_indent_markers*
|
||||
|g:nvim_tree_indent_markers| *g:nvim_tree_indent_markers*
|
||||
|
||||
Can be `0` or `1`. When `1`, will display indent markers when folders are open
|
||||
Default is 0
|
||||
|
||||
|g:lua_tree_hide_dotfiles| *g:lua_tree_hide_dotfiles*
|
||||
|g:nvim_tree_hide_dotfiles| *g:nvim_tree_hide_dotfiles*
|
||||
|
||||
Can be `0` or `1`. When `1`, will hide dotfiles, files or folders which start
|
||||
with the `.` character.
|
||||
Default is 0
|
||||
|
||||
|g:lua_tree_root_folder_modifier| *g:lua_tree_root_folder_modifier*
|
||||
|g:nvim_tree_root_folder_modifier| *g:nvim_tree_root_folder_modifier*
|
||||
|
||||
In what format to show root folder. See `:help filename-modifiers` for
|
||||
available options.
|
||||
Default is `:~`
|
||||
|
||||
|g:lua_tree_tab_open| *g:lua_tree_tab_open*
|
||||
|g:nvim_tree_tab_open| *g:nvim_tree_tab_open*
|
||||
|
||||
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:lua_tree_width_allow_resize| *g:lua_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.
|
||||
|
@ -203,7 +203,7 @@ INFORMATIONS *nvim-tree-info*
|
|||
- '<C-x>' will open the file in a horizontal split
|
||||
- '<C-t>' will open the file in a new tab
|
||||
- '<Tab>' will open the file as a preview (keeps the cursor in the tree)
|
||||
- 'I' will toggle visibility of folders hidden via |g:lua_tree_ignore|
|
||||
- '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.
|
||||
|
@ -211,12 +211,12 @@ on linux.
|
|||
- Double left click acts like '<CR>'
|
||||
- Double right click acts like '<C-]>'
|
||||
|
||||
|g:lua_tree_bindings| *g:lua_tree_bindings*
|
||||
|g:nvim_tree_bindings| *g:nvim_tree_bindings*
|
||||
|
||||
you can change default keybindings by defining this variable.
|
||||
default keybindings will be applied to undefined keys.
|
||||
>
|
||||
let g:lua_tree_bindings = {
|
||||
let g:nvim_tree_bindings = {
|
||||
\ edit: ['<cr>', 'o'], // Multiple keys provided via list
|
||||
\ edit_vsplit: '<c-v>',
|
||||
\ edit_split: '<c-x>',
|
||||
|
@ -259,50 +259,50 @@ Mouse support defined in |KeyBindings|
|
|||
==============================================================================
|
||||
HIGHLIGHT GROUPS *nvim-tree-highlight*
|
||||
|
||||
|lua_tree_highlight| *lua_tree_highlight*
|
||||
|nvim_tree_highlight| *nvim_tree_highlight*
|
||||
|
||||
All the following highlight groups can be configured by hand. It is not
|
||||
advised to colorize the background of these groups.
|
||||
|
||||
Example (in your `init.vim`):
|
||||
>
|
||||
highlight LuaTreeSymlink guifg=blue gui=bold,underline
|
||||
highlight NvimTreeSymlink guifg=blue gui=bold,underline
|
||||
<
|
||||
You should have 'termguicolors' enabled, otherwise, colors will not be
|
||||
applied.
|
||||
|
||||
LuaTreeSymlink
|
||||
LuaTreeFolderName
|
||||
LuaTreeRootFolder
|
||||
LuaTreeFolderIcon
|
||||
LuaTreeExecFile
|
||||
LuaTreeSpecialFile
|
||||
LuaTreeImageFile
|
||||
LuaTreeMarkdownFile
|
||||
LuaTreeIndentMarker
|
||||
NvimTreeSymlink
|
||||
NvimTreeFolderName
|
||||
NvimTreeRootFolder
|
||||
NvimTreeFolderIcon
|
||||
NvimTreeExecFile
|
||||
NvimTreeSpecialFile
|
||||
NvimTreeImageFile
|
||||
NvimTreeMarkdownFile
|
||||
NvimTreeIndentMarker
|
||||
|
||||
LuaTreeLicenseIcon
|
||||
LuaTreeYamlIcon
|
||||
LuaTreeTomlIcon
|
||||
LuaTreeGitignoreIcon
|
||||
LuaTreeJsonIcon
|
||||
NvimTreeLicenseIcon
|
||||
NvimTreeYamlIcon
|
||||
NvimTreeTomlIcon
|
||||
NvimTreeGitignoreIcon
|
||||
NvimTreeJsonIcon
|
||||
|
||||
LuaTreeLuaIcon
|
||||
LuaTreePythonIcon
|
||||
LuaTreeShellIcon
|
||||
LuaTreeJavascriptIcon
|
||||
LuaTreeCIcon
|
||||
LuaTreeReactIcon
|
||||
LuaTreeHtmlIcon
|
||||
LuaTreeRustIcon
|
||||
LuaTreeVimIcon
|
||||
LuaTreeTypescriptIcon
|
||||
NvimTreeLuaIcon
|
||||
NvimTreePythonIcon
|
||||
NvimTreeShellIcon
|
||||
NvimTreeJavascriptIcon
|
||||
NvimTreeCIcon
|
||||
NvimTreeReactIcon
|
||||
NvimTreeHtmlIcon
|
||||
NvimTreeRustIcon
|
||||
NvimTreeVimIcon
|
||||
NvimTreeTypescriptIcon
|
||||
|
||||
LuaTreeGitDirty
|
||||
LuaTreeGitStaged
|
||||
LuaTreeGitMerge
|
||||
LuaTreeGitRenamed
|
||||
LuaTreeGitNew
|
||||
NvimTreeGitDirty
|
||||
NvimTreeGitStaged
|
||||
NvimTreeGitMerge
|
||||
NvimTreeGitRenamed
|
||||
NvimTreeGitNew
|
||||
|
||||
There are also links to normal bindings to style the tree itself.
|
||||
|
||||
|
@ -315,10 +315,10 @@ CursorColumn
|
|||
There are also links for file highlight with git properties
|
||||
These all link to there Git equivalent
|
||||
|
||||
LuaTreeFileDirty
|
||||
LuaTreeFileStaged
|
||||
LuaTreeFileMerge
|
||||
LuaTreeFileNew
|
||||
LuaTreeFileRenamed
|
||||
NvimTreeFileDirty
|
||||
NvimTreeFileStaged
|
||||
NvimTreeFileMerge
|
||||
NvimTreeFileNew
|
||||
NvimTreeFileRenamed
|
||||
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||
|
|
|
@ -56,12 +56,12 @@ local function get_links()
|
|||
CursorLine = 'CursorLine',
|
||||
VertSplit = 'VertSplit',
|
||||
CursorColumn = 'CursorColumn',
|
||||
FileDirty = 'LuaTreeGitDirty',
|
||||
FileNew = 'LuaTreeGitNew',
|
||||
FileRenamed = 'LuaTreeGitRenamed',
|
||||
FileMerge = 'LuaTreeGitMerge',
|
||||
FileStaged = 'LuaTreeGitStaged',
|
||||
FileDeleted = 'LuaTreeGitDeleted',
|
||||
FileDirty = 'NvimTreeGitDirty',
|
||||
FileNew = 'NvimTreeGitNew',
|
||||
FileRenamed = 'NvimTreeGitRenamed',
|
||||
FileMerge = 'NvimTreeGitMerge',
|
||||
FileStaged = 'NvimTreeGitStaged',
|
||||
FileDeleted = 'NvimTreeGitDeleted',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -72,12 +72,12 @@ function M.setup()
|
|||
local higlight_groups = get_hl_groups()
|
||||
for k, d in pairs(higlight_groups) do
|
||||
local gui = d.gui or 'NONE'
|
||||
api.nvim_command('hi def LuaTree'..k..' gui='..gui..' guifg='..d.fg)
|
||||
api.nvim_command('hi def NvimTree'..k..' gui='..gui..' guifg='..d.fg)
|
||||
end
|
||||
|
||||
local links = get_links()
|
||||
for k, d in pairs(links) do
|
||||
api.nvim_command('hi def link LuaTree'..k..' '..d)
|
||||
api.nvim_command('hi def link NvimTree'..k..' '..d)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local M = {}
|
||||
|
||||
function M.get_icon_state()
|
||||
local show_icons = vim.g.lua_tree_show_icons or { git = 1, folders = 1, files = 1 }
|
||||
local show_icons = vim.g.nvim_tree_show_icons or { git = 1, folders = 1, files = 1 }
|
||||
local icons = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
|
@ -20,7 +20,7 @@ function M.get_icon_state()
|
|||
}
|
||||
}
|
||||
|
||||
local user_icons = vim.g.lua_tree_icons
|
||||
local user_icons = vim.g.nvim_tree_icons
|
||||
if user_icons then
|
||||
if user_icons.default then
|
||||
icons.default = user_icons.default
|
||||
|
@ -50,7 +50,7 @@ function M.get_icon_state()
|
|||
end
|
||||
|
||||
function M.get_bindings()
|
||||
local keybindings = vim.g.lua_tree_bindings or {}
|
||||
local keybindings = vim.g.nvim_tree_bindings or {}
|
||||
return {
|
||||
edit = keybindings.edit or {'<CR>', 'o'},
|
||||
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
||||
|
@ -75,8 +75,8 @@ end
|
|||
|
||||
function M.window_options()
|
||||
local opts = {}
|
||||
opts.winhl = 'EndOfBuffer:LuaTreeEndOfBuffer,Normal:LuaTreeNormal,CursorLine:LuaTreeCursorLine,VertSplit:LuaTreeVertSplit'
|
||||
if vim.g.lua_tree_side == 'right' then
|
||||
opts.winhl = 'EndOfBuffer:NvimTreeEndOfBuffer,Normal:NvimTreeNormal,CursorLine:NvimTreeCursorLine,VertSplit:NvimTreeVertSplit'
|
||||
if vim.g.nvim_tree_side == 'right' then
|
||||
opts.side = 'L'
|
||||
opts.open_command = 'h'
|
||||
opts.preview_command = 'l'
|
||||
|
|
|
@ -13,7 +13,7 @@ local function clear_prompt()
|
|||
end
|
||||
|
||||
local function refresh_tree()
|
||||
vim.api.nvim_command(":LuaTreeRefresh")
|
||||
vim.api.nvim_command(":NvimTreeRefresh")
|
||||
end
|
||||
|
||||
local function create_file(file)
|
||||
|
|
|
@ -14,10 +14,10 @@ local M = {}
|
|||
|
||||
M.Tree = {
|
||||
entries = {},
|
||||
buf_name = 'LuaTree',
|
||||
buf_name = 'NvimTree',
|
||||
cwd = nil,
|
||||
win_width = vim.g.lua_tree_width or 30,
|
||||
win_width_allow_resize = vim.g.lua_tree_width_allow_resize,
|
||||
win_width = vim.g.nvim_tree_width or 30,
|
||||
win_width_allow_resize = vim.g.nvim_tree_width_allow_resize,
|
||||
loaded = false,
|
||||
bufnr = nil,
|
||||
winnr = function()
|
||||
|
@ -125,7 +125,7 @@ function M.refresh_tree()
|
|||
-- if stat.mtime.sec ~= M.Tree.last_modified then
|
||||
refresh_nodes(M.Tree)
|
||||
-- end
|
||||
if config.get_icon_state().show_git_icon or vim.g.lua_tree_git_hl then
|
||||
if config.get_icon_state().show_git_icon or vim.g.nvim_tree_git_hl then
|
||||
git.reload_roots()
|
||||
refresh_git(M.Tree)
|
||||
end
|
||||
|
@ -206,7 +206,7 @@ function M.open_file(mode, filename)
|
|||
api.nvim_command('vertical resize '..M.Tree.win_width)
|
||||
M.win_focus(cur_win)
|
||||
end
|
||||
if vim.g.lua_tree_quit_on_open == 1 and mode ~= 'preview' then
|
||||
if vim.g.nvim_tree_quit_on_open == 1 and mode ~= 'preview' then
|
||||
M.close()
|
||||
end
|
||||
end
|
||||
|
@ -218,13 +218,13 @@ function M.change_dir(foldername)
|
|||
end
|
||||
|
||||
local function set_mapping(buf, key, fn)
|
||||
api.nvim_buf_set_keymap(buf, 'n', key, ':lua require"tree".'..fn..'<cr>', {
|
||||
api.nvim_buf_set_keymap(buf, 'n', key, ':lua require"nvim-tree".'..fn..'<cr>', {
|
||||
nowait = true, noremap = true, silent = true
|
||||
})
|
||||
end
|
||||
|
||||
local function set_mappings()
|
||||
if vim.g.lua_tree_disable_keybindings == 1 then
|
||||
if vim.g.nvim_tree_disable_keybindings == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ local luv = vim.loop
|
|||
|
||||
local M = {
|
||||
show_ignored = false,
|
||||
show_dotfiles = vim.g.lua_tree_hide_dotfiles ~= 1,
|
||||
show_dotfiles = vim.g.nvim_tree_hide_dotfiles ~= 1,
|
||||
}
|
||||
|
||||
local path_to_matching_str = require'lib.utils'.path_to_matching_str
|
||||
|
@ -66,8 +66,8 @@ end
|
|||
|
||||
local function gen_ignore_check()
|
||||
local ignore_list = {}
|
||||
if vim.g.lua_tree_ignore and #vim.g.lua_tree_ignore > 0 then
|
||||
for _, entry in pairs(vim.g.lua_tree_ignore) do
|
||||
if vim.g.nvim_tree_ignore and #vim.g.nvim_tree_ignore > 0 then
|
||||
for _, entry in pairs(vim.g.nvim_tree_ignore) do
|
||||
ignore_list[entry] = true
|
||||
end
|
||||
end
|
||||
|
@ -211,7 +211,7 @@ function M.populate(entries, cwd)
|
|||
table.insert(entries, file)
|
||||
end
|
||||
|
||||
if (not icon_config.show_git_icon) and vim.g.lua_tree_git_hl ~= 1 then
|
||||
if (not icon_config.show_git_icon) and vim.g.nvim_tree_git_hl ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ local api = vim.api
|
|||
local lines = {}
|
||||
local hl = {}
|
||||
local index = 0
|
||||
local namespace_id = api.nvim_create_namespace('LuaTreeHighlights')
|
||||
local namespace_id = api.nvim_create_namespace('NvimTreeHighlights')
|
||||
|
||||
local icon_state = config.get_icon_state()
|
||||
|
||||
|
@ -29,7 +29,7 @@ if icon_state.show_folder_icon then
|
|||
end
|
||||
set_folder_hl = function(line, depth, icon_len, name_len, hl_group)
|
||||
table.insert(hl, {hl_group, line, depth+icon_len, depth+icon_len+name_len})
|
||||
table.insert(hl, {'LuaTreeFolderIcon', line, depth, depth+icon_len})
|
||||
table.insert(hl, {'NvimTreeFolderIcon', line, depth, depth+icon_len})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -69,38 +69,38 @@ end
|
|||
local get_git_icons = function() return "" end
|
||||
local get_git_hl = function() return end
|
||||
|
||||
if vim.g.lua_tree_git_hl == 1 then
|
||||
if vim.g.nvim_tree_git_hl == 1 then
|
||||
local git_hl = {
|
||||
["M "] = { { hl = "LuaTreeFileStaged" } },
|
||||
[" M"] = { { hl = "LuaTreeFileDirty" } },
|
||||
["M "] = { { hl = "NvimTreeFileStaged" } },
|
||||
[" M"] = { { hl = "NvimTreeFileDirty" } },
|
||||
["MM"] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileDirty" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileDirty" }
|
||||
},
|
||||
["A "] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileNew" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileNew" }
|
||||
},
|
||||
["AD"] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileDeleted" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileDeleted" }
|
||||
},
|
||||
["AM"] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileNew" },
|
||||
{ hl = "LuaTreeFileDirty" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileNew" },
|
||||
{ hl = "NvimTreeFileDirty" }
|
||||
},
|
||||
["??"] = { { hl = "LuaTreeFileNew" } },
|
||||
["R "] = { { hl = "LuaTreeFileRenamed" } },
|
||||
["UU"] = { { hl = "LuaTreeFileMerge" } },
|
||||
[" D"] = { { hl = "LuaTreeFileDeleted" } },
|
||||
["??"] = { { hl = "NvimTreeFileNew" } },
|
||||
["R "] = { { hl = "NvimTreeFileRenamed" } },
|
||||
["UU"] = { { hl = "NvimTreeFileMerge" } },
|
||||
[" D"] = { { hl = "NvimTreeFileDeleted" } },
|
||||
["D "] = {
|
||||
{ hl = "LuaTreeFileDeleted" },
|
||||
{ hl = "LuaTreeFileStaged" }
|
||||
{ hl = "NvimTreeFileDeleted" },
|
||||
{ hl = "NvimTreeFileStaged" }
|
||||
},
|
||||
[" A"] = { { hl = "none" } },
|
||||
["RM"] = { { hl = "LuaTreeFileRenamed" } },
|
||||
dirty = { { hl = "LuaTreeFileDirty" } },
|
||||
["RM"] = { { hl = "NvimTreeFileRenamed" } },
|
||||
dirty = { { hl = "NvimTreeFileDirty" } },
|
||||
}
|
||||
get_git_hl = function(node)
|
||||
local git_status = node.git_status
|
||||
|
@ -121,33 +121,33 @@ end
|
|||
|
||||
if icon_state.show_git_icon then
|
||||
local git_icon_state = {
|
||||
["M "] = { { icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" } },
|
||||
[" M"] = { { icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" } },
|
||||
["M "] = { { icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" } },
|
||||
[" M"] = { { icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" } },
|
||||
["MM"] = {
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" }
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" }
|
||||
},
|
||||
["A "] = {
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitNew" }
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitNew" }
|
||||
},
|
||||
[" A"] = {
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitNew" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitNew" },
|
||||
},
|
||||
["AM"] = {
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitNew" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" }
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitNew" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" }
|
||||
},
|
||||
["??"] = { { icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitDirty" } },
|
||||
["R "] = { { icon = icon_state.icons.git_icons.renamed, hl = "LuaTreeGitRenamed" } },
|
||||
["??"] = { { icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitDirty" } },
|
||||
["R "] = { { icon = icon_state.icons.git_icons.renamed, hl = "NvimTreeGitRenamed" } },
|
||||
["RM"] = {
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" },
|
||||
{ icon = icon_state.icons.git_icons.renamed, hl = "LuaTreeGitRenamed" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" },
|
||||
{ icon = icon_state.icons.git_icons.renamed, hl = "NvimTreeGitRenamed" },
|
||||
},
|
||||
["UU"] = { { icon = icon_state.icons.git_icons.unmerged, hl = "LuaTreeGitMerge" } },
|
||||
[" D"] = { { icon = icon_state.icons.git_icons.deleted, hl = "LuaTreeGitDeleted" } },
|
||||
dirty = { { icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" } },
|
||||
["UU"] = { { icon = icon_state.icons.git_icons.unmerged, hl = "NvimTreeGitMerge" } },
|
||||
[" D"] = { { icon = icon_state.icons.git_icons.deleted, hl = "NvimTreeGitDeleted" } },
|
||||
dirty = { { icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" } },
|
||||
}
|
||||
|
||||
get_git_icons = function(node, line, depth, icon_len)
|
||||
|
@ -157,7 +157,7 @@ if icon_state.show_git_icon then
|
|||
local icon = ""
|
||||
local icons = git_icon_state[git_status]
|
||||
if not icons then
|
||||
if vim.g.lua_tree_git_hl ~= 1 then
|
||||
if vim.g.nvim_tree_git_hl ~= 1 then
|
||||
utils.echo_warning('Unrecognized git state "'..git_status..'". Please open up an issue on https://github.com/kyazdani42/nvim-tree.lua/issues with this message.')
|
||||
end
|
||||
icons = git_icon_state.dirty
|
||||
|
@ -175,7 +175,7 @@ local get_padding = function(depth)
|
|||
return string.rep(' ', depth)
|
||||
end
|
||||
|
||||
if vim.g.lua_tree_indent_markers == 1 then
|
||||
if vim.g.nvim_tree_indent_markers == 1 then
|
||||
get_padding = function(depth, idx, tree, _, markers)
|
||||
local padding = ""
|
||||
if depth ~= 0 then
|
||||
|
@ -209,13 +209,13 @@ local special = {
|
|||
["readme.md"] = true,
|
||||
}
|
||||
|
||||
local root_folder_modifier = vim.g.lua_tree_root_folder_modifier or ':~'
|
||||
local root_folder_modifier = vim.g.nvim_tree_root_folder_modifier or ':~'
|
||||
|
||||
local function update_draw_data(tree, depth, markers)
|
||||
if tree.cwd and tree.cwd ~= '/' then
|
||||
local root_name = vim.fn.fnamemodify(tree.cwd, root_folder_modifier):gsub('/$', '').."/.."
|
||||
table.insert(lines, root_name)
|
||||
table.insert(hl, {'LuaTreeRootFolder', index, 0, string.len(root_name)})
|
||||
table.insert(hl, {'NvimTreeRootFolder', index, 0, string.len(root_name)})
|
||||
index = 1
|
||||
end
|
||||
|
||||
|
@ -223,7 +223,7 @@ local function update_draw_data(tree, depth, markers)
|
|||
local padding = get_padding(depth, idx, tree, node, markers)
|
||||
local offset = string.len(padding)
|
||||
if depth > 0 then
|
||||
table.insert(hl, { 'LuaTreeIndentMarker', index, 0, offset })
|
||||
table.insert(hl, { 'NvimTreeIndentMarker', index, 0, offset })
|
||||
end
|
||||
|
||||
local git_hl = get_git_hl(node)
|
||||
|
@ -232,7 +232,7 @@ local function update_draw_data(tree, depth, markers)
|
|||
local icon = get_folder_icon(node.open, node.link_to ~= nil)
|
||||
local git_icon = get_git_icons(node, index, offset, #icon+1) or ""
|
||||
-- INFO: this is mandatory in order to keep gui attributes (bold/italics)
|
||||
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'LuaTreeFolderName')
|
||||
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'NvimTreeFolderName')
|
||||
if git_hl then
|
||||
set_folder_hl(index, offset, #icon, #node.name+#git_icon, git_hl)
|
||||
end
|
||||
|
@ -245,7 +245,7 @@ local function update_draw_data(tree, depth, markers)
|
|||
end
|
||||
elseif node.link_to then
|
||||
local icon = get_symlink_icon()
|
||||
local link_hl = git_hl or 'LuaTreeSymlink'
|
||||
local link_hl = git_hl or 'NvimTreeSymlink'
|
||||
table.insert(hl, { link_hl, index, offset, -1 })
|
||||
table.insert(lines, padding..icon..node.name.." ➛ "..node.link_to)
|
||||
index = index + 1
|
||||
|
@ -256,7 +256,7 @@ local function update_draw_data(tree, depth, markers)
|
|||
if special[node.name] then
|
||||
icon = get_special_icon()
|
||||
git_icons = get_git_icons(node, index, offset, 0)
|
||||
table.insert(hl, {'LuaTreeSpecialFile', index, offset+#git_icons, -1})
|
||||
table.insert(hl, {'NvimTreeSpecialFile', index, offset+#git_icons, -1})
|
||||
else
|
||||
icon = get_file_icon(node.name, node.extension, index, offset)
|
||||
git_icons = get_git_icons(node, index, offset, #icon)
|
||||
|
@ -264,9 +264,9 @@ local function update_draw_data(tree, depth, markers)
|
|||
table.insert(lines, padding..icon..git_icons..node.name)
|
||||
|
||||
if node.executable then
|
||||
table.insert(hl, {'LuaTreeExecFile', index, offset+#icon+#git_icons, -1 })
|
||||
table.insert(hl, {'NvimTreeExecFile', index, offset+#icon+#git_icons, -1 })
|
||||
elseif picture[node.extension] then
|
||||
table.insert(hl, {'LuaTreeImageFile', index, offset+#icon+#git_icons, -1 })
|
||||
table.insert(hl, {'NvimTreeImageFile', index, offset+#icon+#git_icons, -1 })
|
||||
end
|
||||
|
||||
if git_hl then
|
||||
|
|
|
@ -7,7 +7,7 @@ end
|
|||
|
||||
function M.echo_warning(msg)
|
||||
api.nvim_command('echohl WarningMsg')
|
||||
api.nvim_command("echom '[LuaTree] "..msg:gsub("'", "''").."'")
|
||||
api.nvim_command("echom '[NvimTree] "..msg:gsub("'", "''").."'")
|
||||
api.nvim_command('echohl None')
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ function M.toggle()
|
|||
if lib.win_open() then
|
||||
lib.close()
|
||||
else
|
||||
if vim.g.lua_tree_follow == 1 then
|
||||
if vim.g.nvim_tree_follow == 1 then
|
||||
vim.schedule(function() M.find_file(true) end)
|
||||
else
|
||||
vim.schedule(lib.open)
|
||||
|
@ -122,7 +122,7 @@ function M.on_enter()
|
|||
if is_dir then
|
||||
api.nvim_command('cd '..bufname)
|
||||
end
|
||||
local should_open = vim.g.lua_tree_auto_open == 1 and (bufname == '' or is_dir)
|
||||
local should_open = vim.g.nvim_tree_auto_open == 1 and (bufname == '' or is_dir)
|
||||
colors.setup()
|
||||
lib.init(should_open, should_open)
|
||||
end
|
||||
|
@ -177,7 +177,7 @@ end
|
|||
|
||||
function M.buf_enter()
|
||||
update_root_dir()
|
||||
if vim.g.lua_tree_follow == 1 then
|
||||
if vim.g.nvim_tree_follow == 1 then
|
||||
M.find_file(false)
|
||||
end
|
||||
end
|
|
@ -6,27 +6,27 @@ set cpo&vim
|
|||
let g:loaded_netrw = 1
|
||||
let g:loaded_netrwPlugin = 1
|
||||
|
||||
hi def link LuaTreePopup Normal
|
||||
hi def link NvimTreePopup Normal
|
||||
|
||||
augroup LuaTree
|
||||
au BufWritePost * lua require'tree'.refresh()
|
||||
au BufEnter * lua require'tree'.buf_enter()
|
||||
augroup NvimTree
|
||||
au BufWritePost * lua require'nvim-tree'.refresh()
|
||||
au BufEnter * lua require'nvim-tree'.buf_enter()
|
||||
if get(g:, 'lua_tree_auto_close') == 1
|
||||
au WinClosed * lua require'tree'.on_leave()
|
||||
au WinClosed * lua require'nvim-tree'.on_leave()
|
||||
endif
|
||||
au ColorScheme * lua require'tree'.reset_highlight()
|
||||
au User FugitiveChanged lua require'tree'.refresh()
|
||||
au ColorScheme * lua require'nvim-tree'.reset_highlight()
|
||||
au User FugitiveChanged lua require'nvim-tree'.refresh()
|
||||
if get(g:, 'lua_tree_tab_open') == 1
|
||||
au TabEnter * lua require'tree'.tab_change()
|
||||
au TabEnter * lua require'nvim-tree'.tab_change()
|
||||
endif
|
||||
augroup end
|
||||
|
||||
command! LuaTreeOpen lua require'tree'.open()
|
||||
command! LuaTreeClose lua require'tree'.close()
|
||||
command! LuaTreeToggle lua require'tree'.toggle()
|
||||
command! LuaTreeRefresh lua require'tree'.refresh()
|
||||
command! LuaTreeClipboard lua require'tree'.print_clipboard()
|
||||
command! LuaTreeFindFile lua require'tree'.find_file(true)
|
||||
command! NvimTreeOpen lua require'nvim-tree'.open()
|
||||
command! NvimTreeClose lua require'nvim-tree'.close()
|
||||
command! NvimTreeToggle lua require'nvim-tree'.toggle()
|
||||
command! NvimTreeRefresh lua require'nvim-tree'.refresh()
|
||||
command! NvimTreeClipboard lua require'nvim-tree'.print_clipboard()
|
||||
command! NvimTreeFindFile lua require'nvim-tree'.find_file(true)
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
|
Loading…
Reference in a new issue