chore/remove globals (#1279)
* remove renderer globals: nvim_tree_add_trailing nvim_tree_highlight_opened_files nvim_tree_root_folder_modifier nvim_tree_special_files * remove renderer globals: nvim_tree_icon_padding * remove renderer globals: nvim_tree_symlink_arrow * remove renderer globals: nvim_tree_show_icons, nvim_tree_show_icons * remove renderer globals: nvim_tree_git_hl * remove renderer globals: nvim_tree_group_empty * remove renderer globals: respect_buf_cwd * remove renderer globals: nvim_tree_create_in_closed_folder * remove globals: consistency in legacy checks * remove renderer globals: nvim_tree_special_files * renderer.icons.symbols -> glyphs
This commit is contained in:
parent
6abc87b1d9
commit
3ba383d591
92
README.md
92
README.md
@ -32,60 +32,11 @@ use {
|
||||
|
||||
## Setup
|
||||
|
||||
Options are currently being migrated into the setup function, you need to run `require'nvim-tree'.setup()` in your personal configurations.
|
||||
Setup should be run in a lua file or in a lua heredoc (`:help lua-heredoc`) if using in a vim file.
|
||||
Note that options under the `g:` command should be set **BEFORE** running the setup function.
|
||||
These are being migrated to the setup function incrementally, check [this issue](https://github.com/kyazdani42/nvim-tree.lua/issues/674) if you encounter any problems related to configs not working after update.
|
||||
Legacy `g:` options have been migrated to the setup function. See [this issue](https://github.com/kyazdani42/nvim-tree.lua/issues/674) for information on migrating your configuration.
|
||||
|
||||
```vim
|
||||
" vimrc
|
||||
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_highlight_opened_files = 1 "0 by default, will enable folder and file icon highlight for opened files/directories.
|
||||
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names
|
||||
let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree
|
||||
let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
|
||||
let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target.
|
||||
let g:nvim_tree_respect_buf_cwd = 1 "0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
|
||||
let g:nvim_tree_create_in_closed_folder = 1 "0 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1.
|
||||
let g:nvim_tree_special_files = { 'README.md': 1, 'Makefile': 1, 'MAKEFILE': 1 } " List of filenames that gets highlighted with NvimTreeSpecialFile
|
||||
let g:nvim_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 0,
|
||||
\ 'files': 0,
|
||||
\ 'folder_arrows': 0,
|
||||
\ }
|
||||
"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 nvim-web-devicons is installed and on your runtimepath.
|
||||
"if folder is 1, you can also tell folder_arrows 1 to show small arrows next to the folder icons.
|
||||
"but this will not work when you set renderer.indent_markers.enable (because of UI conflict)
|
||||
|
||||
" default will show icon by default if no icon is provided
|
||||
" default shows no icon by default
|
||||
let g:nvim_tree_icons = {
|
||||
\ 'default': "",
|
||||
\ 'symlink': "",
|
||||
\ 'git': {
|
||||
\ 'unstaged': "✗",
|
||||
\ 'staged': "✓",
|
||||
\ 'unmerged': "",
|
||||
\ 'renamed': "➜",
|
||||
\ 'untracked': "★",
|
||||
\ 'deleted': "",
|
||||
\ 'ignored': "◌"
|
||||
\ },
|
||||
\ 'folder': {
|
||||
\ 'arrow_open': "",
|
||||
\ 'arrow_closed': "",
|
||||
\ 'default': "",
|
||||
\ 'open': "",
|
||||
\ 'empty': "",
|
||||
\ 'empty_open': "",
|
||||
\ 'symlink': "",
|
||||
\ 'symlink_open': "",
|
||||
\ }
|
||||
\ }
|
||||
|
||||
nnoremap <C-n> :NvimTreeToggle<CR>
|
||||
nnoremap <leader>r :NvimTreeRefresh<CR>
|
||||
nnoremap <leader>n :NvimTreeFindFile<CR>
|
||||
@ -118,6 +69,7 @@ require'nvim-tree'.setup {
|
||||
-- nested options are documented by accessing them with `.` (eg: `:help nvim-tree.view.mappings.list`).
|
||||
require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
||||
auto_reload_on_write = true,
|
||||
create_in_closed_folder = false,
|
||||
disable_netrw = false,
|
||||
hijack_cursor = false,
|
||||
hijack_netrw = true,
|
||||
@ -129,6 +81,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
||||
sort_by = "name",
|
||||
update_cwd = false,
|
||||
reload_on_bufenter = false,
|
||||
respect_buf_cwd = false,
|
||||
view = {
|
||||
width = 30,
|
||||
height = 30,
|
||||
@ -146,6 +99,11 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
add_trailing = false,
|
||||
group_empty = false,
|
||||
highlight_git = false,
|
||||
highlight_opened_files = "none",
|
||||
root_folder_modifier = ":~",
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
icons = {
|
||||
@ -157,7 +115,39 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
||||
icons = {
|
||||
webdev_colors = true,
|
||||
git_placement = "before",
|
||||
padding = " ",
|
||||
symlink_arrow = " ➛ ",
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = true,
|
||||
git = true,
|
||||
},
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
folder = {
|
||||
arrow_closed = "",
|
||||
arrow_open = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
|
||||
},
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
|
||||
@ -87,6 +87,7 @@ Values may be functions. Warning: this may result in unexpected behaviour.
|
||||
>
|
||||
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
|
||||
auto_reload_on_write = true,
|
||||
create_in_closed_folder = false,
|
||||
disable_netrw = false,
|
||||
hijack_cursor = false,
|
||||
hijack_netrw = true,
|
||||
@ -98,6 +99,7 @@ Values may be functions. Warning: this may result in unexpected behaviour.
|
||||
sort_by = "name",
|
||||
update_cwd = false,
|
||||
reload_on_bufenter = false,
|
||||
respect_buf_cwd = false,
|
||||
view = {
|
||||
width = 30,
|
||||
height = 30,
|
||||
@ -115,6 +117,11 @@ Values may be functions. Warning: this may result in unexpected behaviour.
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
add_trailing = false,
|
||||
group_empty = false,
|
||||
highlight_git = false,
|
||||
highlight_opened_files = "none",
|
||||
root_folder_modifier = ":~",
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
icons = {
|
||||
@ -126,7 +133,39 @@ Values may be functions. Warning: this may result in unexpected behaviour.
|
||||
icons = {
|
||||
webdev_colors = true,
|
||||
git_placement = "before",
|
||||
padding = " ",
|
||||
symlink_arrow = " ➛ ",
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = true,
|
||||
git = true,
|
||||
},
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
folder = {
|
||||
arrow_closed = "",
|
||||
arrow_open = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
|
||||
},
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
@ -205,9 +244,6 @@ Values may be functions. Warning: this may result in unexpected behaviour.
|
||||
} -- END_DEFAULT_OPTS
|
||||
<
|
||||
|
||||
As options are currently being migrated, configuration of global options in
|
||||
|nvim-tree-options| should be done BEFORE the setup call.
|
||||
|
||||
Here is a list of the options available in the setup call:
|
||||
|
||||
*nvim-tree.disable_netrw*
|
||||
@ -243,6 +279,11 @@ in some scenarios (eg using vim startify).
|
||||
Reloads the explorer every time a buffer is written to.
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
*nvim-tree.create_in_closed_folder*
|
||||
Creating a file when the cursor is on a closed folder will set the
|
||||
path to be inside the closed folder, otherwise the parent folder.
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
*nvim-tree.open_on_tab*
|
||||
Opens the tree automatically when switching tabpage or opening a new tabpage
|
||||
if the tree was previously open.
|
||||
@ -269,6 +310,10 @@ Changes the tree root directory on `DirChanged` and refreshes the tree.
|
||||
Automatically reloads the tree on `BufEnter` nvim-tree.
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
*nvim-tree.respect_buf_cwd*
|
||||
Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
*nvim-tree.hijack_directories*
|
||||
hijacks new directory buffers when they are opened (`:e dir`).
|
||||
|
||||
@ -346,7 +391,7 @@ Git integration with icons and colors.
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
*nvim-tree.git.ignore*
|
||||
Ignore files based on `.gitignore`.
|
||||
Ignore files based on `.gitignore`. Requires |git.enable| `= true`
|
||||
Toggle via the `toggle_git_ignored` action, default mapping `I`.
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
@ -354,9 +399,9 @@ Git integration with icons and colors.
|
||||
Kills the git process after some time if it takes too long.
|
||||
Type: `number`, Default: `400` (ms)
|
||||
|
||||
You will still need to configure `g:nvim_tree_show_icons.git` or
|
||||
`g:nvim_tree_git_hl` to be able to see things in the tree. This will be
|
||||
changed in the future versions.
|
||||
You will still need to set |renderer.icons.show.git| `= true` or
|
||||
|renderer.highlight_git| `= true` to be able to see things in the
|
||||
tree. This will be changed in the future versions.
|
||||
|
||||
The configurable timeout will kill the current process and so disable the
|
||||
git integration for the project that takes too long.
|
||||
@ -421,6 +466,29 @@ Window / buffer setup.
|
||||
*nvim-tree.renderer*
|
||||
UI rendering setup
|
||||
|
||||
*nvim-tree.renderer.add_trailing*
|
||||
Appends a trailing slash to folder names.
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
*nvim-tree.renderer.group_empty*
|
||||
Compact folders that only contain a single folder into one node in the file tree.
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
*nvim-tree.renderer.highlight_git*
|
||||
Enable file highlight for git attributes using `NvimTreeGit*` highlight groups.
|
||||
This can be used with or without the icons.
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
*nvim-tree.renderer.highlight_opened_files*
|
||||
Highlight icons and/or names for opened files.
|
||||
Value can be `"none"`, `"icon"`, `"name"` or `"all"`.
|
||||
Type: `string`, Default: `"none"`
|
||||
|
||||
*nvim-tree.renderer.root_folder_modifier*
|
||||
In what format to show root folder. See `:help filename-modifiers` for
|
||||
available options.
|
||||
Type: `string`, Default: `":~"`
|
||||
|
||||
*nvim-tree.renderer.indent_markers*
|
||||
Configuration options for tree indent markers.
|
||||
|
||||
@ -447,6 +515,78 @@ UI rendering setup
|
||||
Note that the diagnostic signs will take precedence over the git signs.
|
||||
Type: `after`, `before` or `signcolumn`, Default: `before`
|
||||
|
||||
*nvim-tree.renderer.icons.padding*
|
||||
Inserted between icon and filename.
|
||||
Use with caution, it could break rendering if you set an empty string depending on your font.
|
||||
Type: `string`, Default: `" "`
|
||||
|
||||
*nvim-tree.renderer.icons.symlink_arrow*
|
||||
Used as a separator between symlinks' source and target.
|
||||
Type: `string`, Default: `" ➛ "`
|
||||
|
||||
*nvim-tree.renderer.icons.show*
|
||||
Configuration options for showing icon types.
|
||||
|
||||
*nvim-tree.renderer.icons.show.file*
|
||||
Show an icon before the file name. `nvim-web-devicons` will be used if available.
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
*nvim-tree.renderer.icons.show.folder*
|
||||
Show an icon before the folder name.
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
*nvim-tree.renderer.icons.show.folder_arrow*
|
||||
Show a small arrow before the folder icon.
|
||||
Requires |renderer.icons.show.folder| `= true` and |renderer.indent_markers.enable| `= false`
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
*nvim-tree.renderer.icons.show.git*
|
||||
Show a git status icon, see |renderer.icons.git_placement|
|
||||
Requires |git.enable| `= true`
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
*nvim-tree.renderer.icons.glyphs*
|
||||
Configuration options for icon glyphs.
|
||||
|
||||
*nvim-tree.renderer.icons.glyphs.default*
|
||||
Glyph for files. Will be overridden by `nvim-web-devicons` if available.
|
||||
Type: `string`, Default: `""`
|
||||
|
||||
*nvim-tree.renderer.icons.glyphs.symlink*
|
||||
Glyph for symlinks to files.
|
||||
Type: `string`, Default: `""`
|
||||
|
||||
*nvim-tree.renderer.icons.glyphs.folder*
|
||||
Glyphs for directories.
|
||||
Type: `table`, Default:
|
||||
`{`
|
||||
`arrow_closed = "",`
|
||||
`arrow_open = "",`
|
||||
`default = "",`
|
||||
`open = "",`
|
||||
`empty = "",`
|
||||
`empty_open = "",`
|
||||
`symlink = "",`
|
||||
`symlink_open = "",`
|
||||
`}`
|
||||
|
||||
*nvim-tree.renderer.icons.glyphs.git*
|
||||
Glyphs for git status.
|
||||
Type: `table`, Default:
|
||||
`{`
|
||||
`unstaged = "✗",`
|
||||
`staged = "✓",`
|
||||
`unmerged = "",`
|
||||
`renamed = "➜",`
|
||||
`untracked = "★",`
|
||||
`deleted = "",`
|
||||
`ignored = "◌",`
|
||||
`}`
|
||||
|
||||
*nvim-tree.renderer.special_files*
|
||||
A list of filenames that gets highlighted with `NvimTreeSpecialFile`.
|
||||
Type: `table`, Default: `{ "Cargo.toml", "Makefile", "README.md", "readme.md", }`
|
||||
|
||||
*nvim-tree.filters*
|
||||
Filtering options.
|
||||
|
||||
@ -578,133 +718,6 @@ Configuration for diagnostic logging.
|
||||
Git processing.
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
==============================================================================
|
||||
OPTIONS *nvim-tree-options*
|
||||
|
||||
|g:nvim_tree_show_icons| *g:nvim_tree_show_icons*
|
||||
|
||||
Dictionary, 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:nvim_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 1,
|
||||
\ 'files': 1,
|
||||
\ 'folder_arrows': 1,
|
||||
\}
|
||||
|
||||
Can be one of `1` and `0` for each key. By default the tree will try
|
||||
to render the icons. The `files` key can only work if `nvim-web-devicons`
|
||||
is installed and in your |runtimepath|
|
||||
(https://github.com/kyazdani42/nvim-web-devicons)
|
||||
if folder is 1, you can also set `folder_arrows = 1` to show small arrows
|
||||
next to the folder icons but this will not work when you set
|
||||
|renderer.indent_markers.enable| (because of UI conflict).
|
||||
|
||||
|g:nvim_tree_highlight_opened_files| *g:nvim_tree_highlight_opened_files*
|
||||
|
||||
Highlight icons and/or names for opened files and directories
|
||||
Default is 0
|
||||
|
||||
Must be:
|
||||
0: No highlight
|
||||
1: Enable highligting for folders and file icons only.
|
||||
2: Enable highligting for folders and file names only.
|
||||
3: Enable highligting for folders and both file icons and names.
|
||||
|
||||
|g:nvim_tree_icons| *g:nvim_tree_icons*
|
||||
|
||||
You can set icons for:
|
||||
|
||||
- The git status.
|
||||
- The default icon that shows when no icon is found for a file
|
||||
or if you are not using icons.
|
||||
- Symlinks. If an icon is not provided, the `default` icon is used.
|
||||
>
|
||||
let g:nvim_tree_icons = {
|
||||
\ 'default': "",
|
||||
\ 'symlink': "",
|
||||
\ 'git': {
|
||||
\ 'unstaged': "✗",
|
||||
\ 'staged': "✓",
|
||||
\ 'unmerged': "",
|
||||
\ 'renamed': "➜",
|
||||
\ 'untracked': "★",
|
||||
\ 'deleted': "",
|
||||
\ },
|
||||
\ 'folder': {
|
||||
\ 'arrow_open': "",
|
||||
\ 'arrow_closed': "",
|
||||
\ 'default': "",
|
||||
\ 'open': "",
|
||||
\ 'empty': "",
|
||||
\ 'empty_open': "",
|
||||
\ 'symlink': "",
|
||||
\ 'symlink_open': "",
|
||||
\ },
|
||||
\ 'lsp': {
|
||||
\ 'hint': "",
|
||||
\ 'info': "",
|
||||
\ 'warning': "",
|
||||
\ 'error': "",
|
||||
\ }
|
||||
\ }
|
||||
|
||||
|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: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:nvim_tree_add_trailing| *g:nvim_tree_add_trailing*
|
||||
|
||||
Can be 0 or 1. When 1, appends a trailing slash to folder names.
|
||||
0 by default.
|
||||
|
||||
|g:nvim_tree_group_empty| *g:nvim_tree_group_empty*
|
||||
|
||||
Can be 0 or 1. When 1, folders that contain only one folder are grouped
|
||||
together. 0 by default.
|
||||
|
||||
|g:nvim_tree_special_files| *g:nvim_tree_special_files*
|
||||
|
||||
A list of filenames that gets highlighted with `NvimTreeSpecialFile`.
|
||||
default table is
|
||||
|
||||
>
|
||||
{
|
||||
["Cargo.toml"] = true,
|
||||
Makefile = true,
|
||||
["README.md"] = true,
|
||||
["readme.md"] = true,
|
||||
}
|
||||
<
|
||||
|
||||
|g:nvim_tree_icon_padding| *g:nvim_tree_icon_padding*
|
||||
|
||||
One space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
|
||||
|
||||
|g:nvim_tree_symlink_arrow| *g:nvim_tree_symlink_arrow*
|
||||
|
||||
Defaults to ' ➛ '. Used as a separator between symlinks' source and target.
|
||||
|
||||
|g:nvim_tree_respect_buf_cwd| *g:nvim_tree_respect_buf_cwd*
|
||||
|
||||
Can be 0 or 1. 0 by default.
|
||||
Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
|
||||
|
||||
|g:nvim_tree_create_in_closed_folder| *g:nvim_tree_create_in_closed_folder*
|
||||
|
||||
Can be 0 or 1. 0 by default.
|
||||
Creating a file when the cursor is on a closed folder will set the
|
||||
path to be inside the closed folder when 1, and on the parent folder when 0.
|
||||
|
||||
==============================================================================
|
||||
INFORMATIONS *nvim-tree-info*
|
||||
|
||||
|
||||
@ -344,6 +344,7 @@ end
|
||||
|
||||
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||
auto_reload_on_write = true,
|
||||
create_in_closed_folder = false,
|
||||
disable_netrw = false,
|
||||
hijack_cursor = false,
|
||||
hijack_netrw = true,
|
||||
@ -355,6 +356,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||
sort_by = "name",
|
||||
update_cwd = false,
|
||||
reload_on_bufenter = false,
|
||||
respect_buf_cwd = false,
|
||||
view = {
|
||||
width = 30,
|
||||
height = 30,
|
||||
@ -372,6 +374,11 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
add_trailing = false,
|
||||
group_empty = false,
|
||||
highlight_git = false,
|
||||
highlight_opened_files = "none",
|
||||
root_folder_modifier = ":~",
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
icons = {
|
||||
@ -383,7 +390,39 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||
icons = {
|
||||
webdev_colors = true,
|
||||
git_placement = "before",
|
||||
padding = " ",
|
||||
symlink_arrow = " ➛ ",
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = true,
|
||||
git = true,
|
||||
},
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
folder = {
|
||||
arrow_closed = "",
|
||||
arrow_open = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
|
||||
},
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
@ -548,6 +587,9 @@ function M.setup(conf)
|
||||
require("nvim-tree.lib").setup(opts)
|
||||
require("nvim-tree.renderer").setup(opts)
|
||||
require("nvim-tree.live-filter").setup(opts)
|
||||
if M.config.renderer.icons.show.file and pcall(require, "nvim-web-devicons") then
|
||||
require("nvim-web-devicons").setup()
|
||||
end
|
||||
|
||||
setup_vim_commands()
|
||||
setup_autocommands(opts)
|
||||
|
||||
@ -42,7 +42,7 @@ local function get_num_nodes(iter)
|
||||
end
|
||||
|
||||
local function get_containing_folder(node)
|
||||
local is_open = vim.g.nvim_tree_create_in_closed_folder == 1 or node.open
|
||||
local is_open = M.config.create_in_closed_folder or node.open
|
||||
if node.nodes ~= nil and is_open then
|
||||
return utils.path_add_trailing(node.absolute_path)
|
||||
end
|
||||
@ -112,4 +112,8 @@ function M.fn(node)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = opts
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -236,6 +236,7 @@ function M.setup(opts)
|
||||
require("nvim-tree.actions.open-file").setup(opts)
|
||||
require("nvim-tree.actions.change-dir").setup(opts)
|
||||
require("nvim-tree.actions.copy-paste").setup(opts)
|
||||
require("nvim-tree.actions.create-file").setup(opts)
|
||||
|
||||
local user_map_config = (opts.view or {}).mappings or {}
|
||||
local options = vim.tbl_deep_extend("force", DEFAULT_MAPPING_CONFIG, user_map_config)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
local api = vim.api
|
||||
local icons = require "nvim-tree.renderer.icon-config"
|
||||
|
||||
local M = {}
|
||||
|
||||
@ -84,9 +83,6 @@ local function get_links()
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
if icons.get_config().show_file_icon and icons.get_config().has_devicons then
|
||||
require("nvim-web-devicons").setup()
|
||||
end
|
||||
local higlight_groups = get_hl_groups()
|
||||
for k, d in pairs(higlight_groups) do
|
||||
local gui = d.gui and " gui=" .. d.gui or ""
|
||||
|
||||
@ -69,7 +69,7 @@ function M.explore(node, status)
|
||||
|
||||
local is_root = node.cwd ~= nil
|
||||
local child_folder_only = common.has_one_child_folder(node) and node.nodes[1]
|
||||
if vim.g.nvim_tree_group_empty == 1 and not is_root and child_folder_only then
|
||||
if M.config.group_empty and not is_root and child_folder_only then
|
||||
node.group_next = child_folder_only
|
||||
local ns = M.explore(child_folder_only, status)
|
||||
node.nodes = ns or {}
|
||||
@ -81,4 +81,8 @@ function M.explore(node, status)
|
||||
return node.nodes
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = opts.renderer
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -31,8 +31,10 @@ function Explorer:expand(node)
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
require("nvim-tree.explorer.explore").setup(opts)
|
||||
require("nvim-tree.explorer.filters").setup(opts)
|
||||
require("nvim-tree.explorer.sorters").setup(opts)
|
||||
require("nvim-tree.explorer.reload").setup(opts)
|
||||
end
|
||||
|
||||
M.Explorer = Explorer
|
||||
|
||||
@ -70,7 +70,7 @@ function M.reload(node, status)
|
||||
|
||||
local is_root = node.cwd ~= nil
|
||||
local child_folder_only = common.has_one_child_folder(node) and node.nodes[1]
|
||||
if vim.g.nvim_tree_group_empty == 1 and not is_root and child_folder_only then
|
||||
if M.config.group_empty and not is_root and child_folder_only then
|
||||
node.group_next = child_folder_only
|
||||
local ns = M.reload(child_folder_only, status)
|
||||
node.nodes = ns or {}
|
||||
@ -82,4 +82,8 @@ function M.reload(node, status)
|
||||
return node.nodes
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = opts.renderer
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -176,6 +176,103 @@ local g_migrations = {
|
||||
o.renderer.indent_markers.enable = vim.g.nvim_tree_indent_markers == 1
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_add_trailing = function(o)
|
||||
utils.table_create_missing(o, "renderer")
|
||||
if o.renderer.add_trailing == nil then
|
||||
o.renderer.add_trailing = vim.g.nvim_tree_add_trailing == 1
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_highlight_opened_files = function(o)
|
||||
utils.table_create_missing(o, "renderer")
|
||||
if o.renderer.highlight_opened_files == nil then
|
||||
if vim.g.nvim_tree_highlight_opened_files == 1 then
|
||||
o.renderer.highlight_opened_files = "icon"
|
||||
elseif vim.g.nvim_tree_highlight_opened_files == 2 then
|
||||
o.renderer.highlight_opened_files = "name"
|
||||
elseif vim.g.nvim_tree_highlight_opened_files == 3 then
|
||||
o.renderer.highlight_opened_files = "all"
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_root_folder_modifier = function(o)
|
||||
utils.table_create_missing(o, "renderer")
|
||||
if o.renderer.root_folder_modifier == nil then
|
||||
o.renderer.root_folder_modifier = vim.g.nvim_tree_root_folder_modifier
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_special_files = function(o)
|
||||
utils.table_create_missing(o, "renderer")
|
||||
if o.renderer.special_files == nil and type(vim.g.nvim_tree_special_files) == "table" then
|
||||
o.renderer.special_files = {}
|
||||
for k, v in pairs(vim.g.nvim_tree_special_files) do
|
||||
if v ~= 0 then
|
||||
table.insert(o.renderer.special_files, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_icon_padding = function(o)
|
||||
utils.table_create_missing(o, "renderer.icons")
|
||||
if o.renderer.icons.padding == nil then
|
||||
o.renderer.icons.padding = vim.g.nvim_tree_icon_padding
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_symlink_arrow = function(o)
|
||||
utils.table_create_missing(o, "renderer.icons")
|
||||
if o.renderer.icons.symlink_arrow == nil then
|
||||
o.renderer.icons.symlink_arrow = vim.g.nvim_tree_symlink_arrow
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_show_icons = function(o)
|
||||
utils.table_create_missing(o, "renderer.icons")
|
||||
if o.renderer.icons.show == nil and type(vim.g.nvim_tree_show_icons) == "table" then
|
||||
o.renderer.icons.show = {}
|
||||
o.renderer.icons.show.file = vim.g.nvim_tree_show_icons.files == 1
|
||||
o.renderer.icons.show.folder = vim.g.nvim_tree_show_icons.folders == 1
|
||||
o.renderer.icons.show.folder_arrow = vim.g.nvim_tree_show_icons.folder_arrows == 1
|
||||
o.renderer.icons.show.git = vim.g.nvim_tree_show_icons.git == 1
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_icons = function(o)
|
||||
utils.table_create_missing(o, "renderer.icons")
|
||||
if o.renderer.icons.glyphs == nil and type(vim.g.nvim_tree_icons) == "table" then
|
||||
o.renderer.icons.glyphs = vim.g.nvim_tree_icons
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_git_hl = function(o)
|
||||
utils.table_create_missing(o, "renderer")
|
||||
if o.renderer.highlight_git == nil then
|
||||
o.renderer.highlight_git = vim.g.nvim_tree_git_hl == 1
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_group_empty = function(o)
|
||||
utils.table_create_missing(o, "renderer")
|
||||
if o.renderer.group_empty == nil then
|
||||
o.renderer.group_empty = vim.g.nvim_tree_group_empty == 1
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_respect_buf_cwd = function(o)
|
||||
if o.respect_buf_cwd == nil then
|
||||
o.respect_buf_cwd = vim.g.nvim_tree_respect_buf_cwd == 1
|
||||
end
|
||||
end,
|
||||
|
||||
nvim_tree_create_in_closed_folder = function(o)
|
||||
if o.create_in_closed_folder == nil then
|
||||
o.create_in_closed_folder = vim.g.nvim_tree_create_in_closed_folder == 1
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
local function refactored(opts)
|
||||
|
||||
@ -68,8 +68,7 @@ function M.set_target_win()
|
||||
end
|
||||
|
||||
local function handle_buf_cwd(cwd)
|
||||
local respect_buf_cwd = vim.g.nvim_tree_respect_buf_cwd or 0
|
||||
if respect_buf_cwd == 1 and cwd ~= core.get_explorer().cwd then
|
||||
if M.respect_buf_cwd and cwd ~= core.get_explorer().cwd then
|
||||
require("nvim-tree.actions.change-dir").fn(cwd)
|
||||
end
|
||||
end
|
||||
@ -123,6 +122,7 @@ M.set_index_and_redraw = require("nvim-tree.actions.find-file").fn
|
||||
function M.setup(opts)
|
||||
M.hijack_unnamed_buffer_when_opening = opts.hijack_unnamed_buffer_when_opening
|
||||
M.hijack_directories = opts.hijack_directories
|
||||
M.respect_buf_cwd = opts.respect_buf_cwd
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -34,8 +34,8 @@ function Builder:configure_trailing_slash(with_trailing)
|
||||
return self
|
||||
end
|
||||
|
||||
function Builder:configure_special_map(special_map)
|
||||
self.special_map = special_map
|
||||
function Builder:configure_special_files(special_files)
|
||||
self.special_files = special_files
|
||||
return self
|
||||
end
|
||||
|
||||
@ -50,14 +50,8 @@ function Builder:configure_filter(filter, prefix)
|
||||
return self
|
||||
end
|
||||
|
||||
function Builder:configure_opened_file_highlighting(level)
|
||||
if level == 1 then
|
||||
self.open_file_highlight = "icon"
|
||||
elseif level == 2 then
|
||||
self.open_file_highlight = "name"
|
||||
elseif level == 3 then
|
||||
self.open_file_highlight = "all"
|
||||
end
|
||||
function Builder:configure_opened_file_highlighting(highlight_opened_files)
|
||||
self.highlight_opened_files = highlight_opened_files
|
||||
|
||||
return self
|
||||
end
|
||||
@ -128,7 +122,7 @@ function Builder:_build_folder(node, padding, git_hl, git_icons_tbl)
|
||||
end
|
||||
|
||||
local foldername_hl = "NvimTreeFolderName"
|
||||
if self.special_map[node.absolute_path] then
|
||||
if vim.tbl_contains(self.special_files, node.absolute_path) or vim.tbl_contains(self.special_files, node.name) then
|
||||
foldername_hl = "NvimTreeSpecialFolderName"
|
||||
elseif node.open then
|
||||
foldername_hl = "NvimTreeOpenedFolderName"
|
||||
@ -183,12 +177,12 @@ function Builder:_highlight_opened_files(node, offset, icon_length, git_icons_le
|
||||
local from = offset
|
||||
local to = offset
|
||||
|
||||
if self.open_file_highlight == "icon" then
|
||||
if self.highlight_opened_files == "icon" then
|
||||
to = from + icon_length
|
||||
elseif self.open_file_highlight == "name" then
|
||||
elseif self.highlight_opened_files == "name" then
|
||||
from = offset + icon_length + git_icons_length
|
||||
to = from + #node.name
|
||||
elseif self.open_file_highlight == "all" then
|
||||
elseif self.highlight_opened_files == "all" then
|
||||
to = from + icon_length + git_icons_length + #node.name
|
||||
end
|
||||
|
||||
@ -209,7 +203,7 @@ function Builder:_build_file(node, padding, git_highlight, git_icons_tbl)
|
||||
local col_start = offset + #icon + git_icons_length
|
||||
local col_end = col_start + #node.name
|
||||
|
||||
if self.special_map[node.absolute_path] or self.special_map[node.name] then
|
||||
if vim.tbl_contains(self.special_files, node.absolute_path) or vim.tbl_contains(self.special_files, node.name) then
|
||||
self:_insert_highlight("NvimTreeSpecialFile", col_start, col_end)
|
||||
elseif node.executable then
|
||||
self:_insert_highlight("NvimTreeExecFile", col_start, col_end)
|
||||
@ -217,7 +211,7 @@ function Builder:_build_file(node, padding, git_highlight, git_icons_tbl)
|
||||
self:_insert_highlight("NvimTreeImageFile", col_start, col_end)
|
||||
end
|
||||
|
||||
local should_highlight_opened_files = self.open_file_highlight and vim.fn.bufloaded(node.absolute_path) > 0
|
||||
local should_highlight_opened_files = self.highlight_opened_files and vim.fn.bufloaded(node.absolute_path) > 0
|
||||
if should_highlight_opened_files then
|
||||
self:_highlight_opened_files(node, offset, #icon, git_icons_length)
|
||||
end
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
local _icons = require "nvim-tree.renderer.icon-config"
|
||||
local utils = require "nvim-tree.utils"
|
||||
|
||||
local M = {
|
||||
SIGN_GROUP = "NvimTreeGitSigns",
|
||||
}
|
||||
|
||||
local function build_icons_table()
|
||||
local i = M.icon_state.icons.git_icons
|
||||
local function build_icons_table(i)
|
||||
return {
|
||||
["M "] = { { icon = i.staged, hl = "NvimTreeGitStaged" } },
|
||||
[" M"] = { { icon = i.unstaged, hl = "NvimTreeGitDirty" } },
|
||||
@ -85,7 +83,7 @@ local function get_icons_(node)
|
||||
|
||||
local icons = M.git_icons[git_status]
|
||||
if not icons then
|
||||
if vim.g.nvim_tree_git_hl ~= 1 then
|
||||
if not M.config.highlight_git then
|
||||
warn_status(git_status)
|
||||
end
|
||||
return nil
|
||||
@ -126,8 +124,7 @@ local git_hl = {
|
||||
[" A"] = "none",
|
||||
}
|
||||
|
||||
function M.setup_signs()
|
||||
local i = M.icon_state.icons.git_icons
|
||||
function M.setup_signs(i)
|
||||
vim.fn.sign_define("NvimTreeGitDirty", { text = i.unstaged, texthl = "NvimTreeGitDirty" })
|
||||
vim.fn.sign_define("NvimTreeGitStaged", { text = i.staged, texthl = "NvimTreeGitStaged" })
|
||||
vim.fn.sign_define("NvimTreeGitMerge", { text = i.unmerged, texthl = "NvimTreeGitMerge" })
|
||||
@ -146,22 +143,20 @@ local function get_highlight_(node)
|
||||
return git_hl[git_status]
|
||||
end
|
||||
|
||||
M.get_icons = nil_
|
||||
M.get_highlight = nil_
|
||||
function M.setup(opts)
|
||||
M.config = opts.renderer
|
||||
|
||||
M.icon_state = _icons.get_config()
|
||||
M.git_icons = build_icons_table()
|
||||
M.git_icons = build_icons_table(opts.renderer.icons.glyphs.git)
|
||||
|
||||
function M.reload()
|
||||
M.icon_state = _icons.get_config()
|
||||
M.git_icons = build_icons_table()
|
||||
M.setup_signs(opts.renderer.icons.glyphs.git)
|
||||
|
||||
if M.icon_state.show_git_icon then
|
||||
if opts.renderer.icons.show.git then
|
||||
M.get_icons = get_icons_
|
||||
else
|
||||
M.get_icons = nil_
|
||||
end
|
||||
if vim.g.nvim_tree_git_hl == 1 then
|
||||
|
||||
if opts.renderer.highlight_git then
|
||||
M.get_highlight = get_highlight_
|
||||
else
|
||||
M.get_highlight = nil_
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
local icon_config = require "nvim-tree.renderer.icon-config"
|
||||
|
||||
local M = { i = {} }
|
||||
|
||||
local function config_symlinks()
|
||||
M.i.symlink = #M.icons.symlink > 0 and M.icons.symlink .. M.padding or ""
|
||||
M.i.symlink_arrow = vim.g.nvim_tree_symlink_arrow or " ➛ "
|
||||
M.i.symlink = #M.config.glyphs.symlink > 0 and M.config.glyphs.symlink .. M.config.padding or ""
|
||||
M.i.symlink_arrow = M.config.symlink_arrow
|
||||
end
|
||||
|
||||
local function empty()
|
||||
@ -14,30 +12,30 @@ end
|
||||
local function get_folder_icon(open, is_symlink, has_children)
|
||||
local n
|
||||
if is_symlink and open then
|
||||
n = M.icons.folder_icons.symlink_open
|
||||
n = M.config.glyphs.folder.symlink_open
|
||||
elseif is_symlink then
|
||||
n = M.icons.folder_icons.symlink
|
||||
n = M.config.glyphs.folder.symlink
|
||||
elseif open then
|
||||
if has_children then
|
||||
n = M.icons.folder_icons.open
|
||||
n = M.config.glyphs.folder.open
|
||||
else
|
||||
n = M.icons.folder_icons.empty_open
|
||||
n = M.config.glyphs.folder.empty_open
|
||||
end
|
||||
else
|
||||
if has_children then
|
||||
n = M.icons.folder_icons.default
|
||||
n = M.config.glyphs.folder.default
|
||||
else
|
||||
n = M.icons.folder_icons.empty
|
||||
n = M.config.glyphs.folder.empty
|
||||
end
|
||||
end
|
||||
return n .. M.padding
|
||||
return n .. M.config.padding
|
||||
end
|
||||
|
||||
local function get_file_icon_default()
|
||||
local hl_group = "NvimTreeFileIcon"
|
||||
local icon = M.icons.default
|
||||
local icon = M.config.glyphs.default
|
||||
if #icon > 0 then
|
||||
return icon .. M.padding, hl_group
|
||||
return icon .. M.config.padding, hl_group
|
||||
else
|
||||
return ""
|
||||
end
|
||||
@ -45,11 +43,11 @@ end
|
||||
|
||||
local function get_file_icon_webdev(fname, extension)
|
||||
local icon, hl_group = M.devicons.get_icon(fname, extension)
|
||||
if not M.webdev_colors then
|
||||
if not M.config.webdev_colors then
|
||||
hl_group = "NvimTreeFileIcon"
|
||||
end
|
||||
if icon and hl_group ~= "DevIconDefault" then
|
||||
return icon .. M.padding, hl_group
|
||||
return icon .. M.config.padding, hl_group
|
||||
elseif string.match(extension, "%.(.*)") then
|
||||
-- If there are more extensions to the file, try to grab the icon for them recursively
|
||||
return get_file_icon_webdev(fname, string.match(extension, "%.(.*)"))
|
||||
@ -59,7 +57,7 @@ local function get_file_icon_webdev(fname, extension)
|
||||
end
|
||||
|
||||
local function config_file_icon()
|
||||
if M.configs.show_file_icon then
|
||||
if M.config.show.file then
|
||||
if M.devicons then
|
||||
M.get_file_icon = get_file_icon_webdev
|
||||
else
|
||||
@ -71,23 +69,23 @@ local function config_file_icon()
|
||||
end
|
||||
|
||||
local function config_folder_icon()
|
||||
if M.configs.show_folder_icon then
|
||||
if M.config.show.folder then
|
||||
M.get_folder_icon = get_folder_icon
|
||||
else
|
||||
M.get_folder_icon = empty
|
||||
end
|
||||
end
|
||||
|
||||
function M.reset_config(webdev_colors)
|
||||
M.configs = icon_config.get_config()
|
||||
M.icons = M.configs.icons
|
||||
M.padding = vim.g.nvim_tree_icon_padding or " "
|
||||
M.devicons = M.configs.has_devicons and require "nvim-web-devicons" or nil
|
||||
M.webdev_colors = webdev_colors
|
||||
|
||||
function M.reset_config()
|
||||
config_symlinks()
|
||||
config_file_icon()
|
||||
config_folder_icon()
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = opts.renderer.icons
|
||||
|
||||
M.devicons = pcall(require, "nvim-web-devicons") and require "nvim-web-devicons"
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -4,10 +4,10 @@ function M.get_padding(depth)
|
||||
return string.rep(" ", depth)
|
||||
end
|
||||
|
||||
local function get_padding_arrows(icon_state)
|
||||
local function get_padding_arrows()
|
||||
return function(depth, _, _, node)
|
||||
if node.nodes then
|
||||
local icon = icon_state.icons.folder_icons[node.open and "arrow_open" or "arrow_closed"]
|
||||
local icon = M.config.icons.glyphs.folder[node.open and "arrow_open" or "arrow_closed"]
|
||||
return string.rep(" ", depth - 2) .. icon .. " "
|
||||
end
|
||||
return string.rep(" ", depth)
|
||||
@ -33,10 +33,8 @@ local function get_padding_indent_markers(depth, idx, nodes_number, _, markers)
|
||||
end
|
||||
|
||||
function M.reload_padding_function()
|
||||
local icon_state = require("nvim-tree.renderer.icon-config").get_config()
|
||||
|
||||
if icon_state.show_folder_icon and icon_state.show_folder_arrows then
|
||||
M.get_padding = get_padding_arrows(icon_state)
|
||||
if M.config.icons.show.folder and M.config.icons.show.folder_arrow then
|
||||
M.get_padding = get_padding_arrows()
|
||||
end
|
||||
|
||||
if M.config.indent_markers.enable then
|
||||
@ -45,9 +43,7 @@ function M.reload_padding_function()
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = {
|
||||
indent_markers = opts.renderer.indent_markers,
|
||||
}
|
||||
M.config = opts.renderer
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.get_config()
|
||||
local show_icons = vim.g.nvim_tree_show_icons or { git = 1, folders = 1, files = 1, folder_arrows = 1 }
|
||||
local icons = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
git_icons = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
folder_icons = {
|
||||
arrow_closed = "",
|
||||
arrow_open = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
}
|
||||
|
||||
local user_icons = vim.g.nvim_tree_icons
|
||||
if user_icons then
|
||||
if user_icons.default then
|
||||
icons.default = user_icons.default
|
||||
icons.symlink = user_icons.default
|
||||
end
|
||||
if user_icons.symlink then
|
||||
icons.symlink = user_icons.symlink
|
||||
end
|
||||
for key, val in pairs(user_icons.git or {}) do
|
||||
if icons.git_icons[key] then
|
||||
icons.git_icons[key] = val
|
||||
end
|
||||
end
|
||||
for key, val in pairs(user_icons.folder or {}) do
|
||||
if icons.folder_icons[key] then
|
||||
icons.folder_icons[key] = val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local has_devicons = pcall(require, "nvim-web-devicons")
|
||||
return {
|
||||
show_file_icon = show_icons.files == 1,
|
||||
show_folder_icon = show_icons.folders == 1,
|
||||
show_git_icon = show_icons.git == 1,
|
||||
show_folder_arrows = show_icons.folder_arrows == 1,
|
||||
has_devicons = has_devicons,
|
||||
icons = icons,
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
@ -39,9 +39,7 @@ function M.render_hl(bufnr, hl)
|
||||
end
|
||||
|
||||
local function should_show_arrows()
|
||||
return not M.config.indent_markers.enable
|
||||
and icon_component.configs.show_folder_icon
|
||||
and icon_component.configs.show_folder_arrows
|
||||
return not M.config.indent_markers.enable and M.config.icons.show.folder and M.config.icons.show.folder_arrow
|
||||
end
|
||||
|
||||
local picture_map = {
|
||||
@ -51,16 +49,6 @@ local picture_map = {
|
||||
gif = true,
|
||||
}
|
||||
|
||||
local function get_special_files_map()
|
||||
return vim.g.nvim_tree_special_files
|
||||
or {
|
||||
["Cargo.toml"] = true,
|
||||
Makefile = true,
|
||||
["README.md"] = true,
|
||||
["readme.md"] = true,
|
||||
}
|
||||
end
|
||||
|
||||
function M.draw()
|
||||
local bufnr = view.get_bufnr()
|
||||
if not core.get_explorer() or not bufnr or not api.nvim_buf_is_loaded(bufnr) then
|
||||
@ -71,8 +59,7 @@ function M.draw()
|
||||
|
||||
local cursor = api.nvim_win_get_cursor(view.get_winnr())
|
||||
_padding.reload_padding_function()
|
||||
icon_component.reset_config(M.config.icons.webdev_colors)
|
||||
git.reload()
|
||||
icon_component.reset_config()
|
||||
|
||||
local lines, hl
|
||||
local signs = {}
|
||||
@ -81,12 +68,12 @@ function M.draw()
|
||||
else
|
||||
lines, hl, signs = Builder.new(core.get_cwd())
|
||||
:configure_initial_depth(should_show_arrows())
|
||||
:configure_root_modifier(vim.g.nvim_tree_root_folder_modifier)
|
||||
:configure_trailing_slash(vim.g.nvim_tree_add_trailing == 1)
|
||||
:configure_special_map(get_special_files_map())
|
||||
:configure_root_modifier(M.config.root_folder_modifier)
|
||||
:configure_trailing_slash(M.config.add_trailing)
|
||||
:configure_special_files(M.config.special_files)
|
||||
:configure_picture_map(picture_map)
|
||||
:configure_opened_file_highlighting(vim.g.nvim_tree_highlight_opened_files)
|
||||
:configure_git_icons_padding(vim.g.nvim_tree_icon_padding)
|
||||
:configure_opened_file_highlighting(M.config.highlight_opened_files)
|
||||
:configure_git_icons_padding(M.config.icons.padding)
|
||||
:configure_git_icons_placement(M.config.icons.git_placement)
|
||||
:configure_filter(live_filter.filter, live_filter.prefix)
|
||||
:build_header(view.is_root_folder_visible(core.get_cwd()))
|
||||
@ -112,13 +99,11 @@ function M.draw()
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = {
|
||||
indent_markers = opts.renderer.indent_markers,
|
||||
icons = opts.renderer.icons,
|
||||
}
|
||||
M.config = opts.renderer
|
||||
|
||||
_padding.setup(opts)
|
||||
git.setup_signs()
|
||||
git.setup(opts)
|
||||
icon_component.setup(opts)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Loading…
Reference in New Issue
Block a user