chore: refacto setup part 1 (#603)

* chore: refacto setup part 1

refacto setup for code entrypoint
following options switched boolean values as options to the setup function:
- `nvim_tree_disable_netrw` -> `disable_netrw`
- `nvim_tree_hijack_netrw` -> `hijack_netrw`
- `nvim_tree_auto_open` -> `open_on_setup`
- `nvim_tree_auto_close` -> `auto_close`
- `nvim_tree_tab_open` -> `tab_open`
- `nvim-tree-update-cwd` -> `update_cwd`
- `nvim_tree_hijack_cursor` -> `hijack_cursor`
- `nvim_tree_system_open_command` -> `system_open.cmd`
- `nvim_tree_system_open_command_args` -> `system_open.args`
- `nvim_tree_follow` -> `update_focused_file.enable`
- `nvim_tree_follow_update_path` -> `update_focused_file.update_cwd`
Also added new option `update_focused_file.ignore_list` which will
ignore filepath or filetypes that matches one entry of the list when
updating the path if update_cwd is true.

* add deprecation warning

* update readme

* schedule on enter to avoid running before vim first buffer has loaded

* update docs

* correct typo

* rename tab open -> open on tab
This commit is contained in:
Kiyan
2021-09-25 16:43:39 +02:00
committed by GitHub
parent 67805502d2
commit a864b80baf
5 changed files with 329 additions and 196 deletions

View File

@@ -58,6 +58,107 @@ Print clipboard content for both cut and copy
Resize the NvimTree window to the given size. Example: `:NvimTreeresize 50`
resizes the window to the width of 50.
==============================================================================
SETUP *nvim-tree-setup*
To configure the tree (and make it runnable), you should call the setup
function.
>
require'nvim-tree'.setup {
disable_netrw = true,
hijack_netrw = true,
open_on_setup = false,
ignore_ft_on_setup = {},
auto_close = false,
open_on_tab = false,
hijack_cursor = false,
update_cwd = false,
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {}
},
system_open = {
cmd = nil,
args = {}
},
}
<
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:
- |disable_netrw|: completely disable netrw
type: `boolean`
default: `true`
- |hijack_netrw|: hijack netrw windows (overriden if |disable_netrw| is `true`)
type: `boolean`
default: `true`
- |open_on_setup|: will automatically open the tree when running setup if current
buffer is a directory, is empty or is unnamed.
type: `boolean`
default: `false`
- |ignore_ft_on_setup|: list of filetypes that will make |open_on_setup| not
open. You can use this option if you don't want the tree to open in some
scenarios (eg using vim startify).
type: `{string}`
default: `{}`
- |auto_close|: force closing neovim when the tree is the last window in the view.
type: `boolean`
default: `false`
- |open_on_tab|: opens the tree automatically when switching tabpage or opening a new
tabpage if the tree was previously open.
type: `boolean`
default: `false`
- |hijack_cursor|: keeps the cursor on the first letter of the filename when
moving in the tree.
type: `boolean`
default: `false`
- |update_cwd|: changes the tree root directory on `DirChanged` and refreshes
the tree.
type: `boolean`
default: `false`
- |update_focused_file|: update the focused file on `BufEnter`, un-collapses
the folders recursively until it finds the file
- |update_focused_file.enable|: enable this feature.
type: `boolean`
default: `false`
- |update_focused_file.update_cwd|: update the root directory of the tree to the one
of the folder containing the file if the file is not under the current root
directory. Only relevant when |update_focused_file.enable| is `true`
type: `boolean`
default: `false`
- |update_focused_file.ignore_list|: list of buffer names and filetypes that will not
update the root dir of the tree if the file isn't found under the current root
directory. Only relevant when |update_focused_file.update_cwd| is `true` and
|update_focused_file.enable| is `true`.
type: `{string}`
default: `{}`
- |system_open|: configuration options for the system open command
- |system_open.cmd|: the command to run, leaving nil should work but
useful if you want to override the default command with another one.
type: `string`
default: `nil`
- |system_open.args|: the command arguments as a list
type: `{string}`
default: `{}`
==============================================================================
OPTIONS *nvim-tree-options*
@@ -166,58 +267,12 @@ You can enable file highlight for git attributes by setting this property.
This can be used with or without the icons.
|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:nvim_tree_follow_update_path| *g:nvim_tree_follow_update_path*
Can be `0` or `1`. When `1`, will update the path of the current dir if the
file is not inside the tree. Works only with |g:nvim_tree_follow| = 1.
Default is 0
|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: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:nvim_tree_auto_ignore_ft| *g:nvim_tree_auto_ignore_ft*
Don't auto open the tree on specific filetypes.
Useful when you don't want to open tree on plugins like 'Startify'
Default is {}
>
example: let g.nvim_tree_auto_ignore_ft = {'startify', 'dashboard'}
|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: `edit`, `vsplit`, `split`, `tabnew`.
Default is 0
|g:nvim_tree_system_open_command| *g:nvim_tree_system_open_command*
A string containing the command used to open a file/folder with default system
application. If left unset it will be automatically filled with the right
command, depending on the operating system. If your operating system isn't
recognized or if you want to use another command you can edit it.
Default: depends on the operating system
|g:nvim_tree_system_open_command_args| *g:nvim_tree_system_open_command_args*
An array of strings containing the arguments to be passed to the command
specified in |g:nvim_tree_system_open_command|.
Default: unset if not using Windows
|g:nvim_tree_disable_keybindings| *g:nvim_tree_disable_keybindings*
Can be `0` or `1`. When `1`, will disable all keybindings by the plugin.
@@ -246,30 +301,12 @@ In what format to show root folder. See `:help filename-modifiers` for
available options.
Default is `:~`
|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:nvim_tree_auto_resize| *g:nvim_tree_auto_resize*
Can be 0 or 1. When 1, it will resize the tree to it's saved width
when opening a new file.
Default is 1
|g:nvim_tree_hijack_netrw| *g:nvim_tree_hijack_netrw*
Can be 0 or 1. When 1, disable netrw buffers when nvim-tree start but keeps
existing netrw functionnalities accross buffers (like `gx`).
1 by default.
|g:nvim_tree_disable_netrw| *g:nvim_tree_disable_netrw*
Can be 0 or 1. When 1, completely disable netrw and all related
functionnalities.
1 by default.
|g:nvim_tree_add_trailing| *g:nvim_tree_add_trailing*
Can be 0 or 1. When 1, appends a trailing slash to folder names.
@@ -324,12 +361,6 @@ selectable. The default table is
}
<
|g:nvim_tree_hijack_cursor| *g:nvim_tree_hijack_cursor*
Can be 0 or 1. 1 by default.
When 1, moving cursor in the tree will position the cursor at the start
of the file on the current line.
|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.
@@ -338,12 +369,6 @@ One space by default, used for rendering the space between the icon and the file
Defaults to ' ➛ '. Used as a separator between symlinks' source and target.
|g:nvim_tree_update_cwd|
Can be 0 or 1. 0 by default.
Will update the tree cwd when changing nvim's directory (DirChanged event).
WARNING: Behaves strangely with autochdir set.
|g:nvim_tree_respect_buf_cwd| *g:nvim_tree_respect_buf_cwd*
Can be 0 or 1. 0 by default.