diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 86d1ed2bfe1..0e79a42bbed 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -63,108 +63,36 @@ body: value: | vim.cmd [[set runtimepath=$VIMRUNTIME]] vim.cmd [[set packpath=/tmp/nvt-min/site]] - local package_root = '/tmp/nvt-min/site/pack' - local install_path = package_root .. '/packer/start/packer.nvim' + local package_root = "/tmp/nvt-min/site/pack" + local install_path = package_root .. "/packer/start/packer.nvim" local function load_plugins() - require('packer').startup { + require("packer").startup { { - 'wbthomason/packer.nvim', - 'kyazdani42/nvim-tree.lua', - 'kyazdani42/nvim-web-devicons', + "wbthomason/packer.nvim", + "kyazdani42/nvim-tree.lua", + "kyazdani42/nvim-web-devicons", -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE }, config = { package_root = package_root, - compile_path = install_path .. '/plugin/packer_compiled.lua', + compile_path = install_path .. "/plugin/packer_compiled.lua", display = { non_interactive = true }, }, } end if vim.fn.isdirectory(install_path) == 0 then - print("Installing nvim-tree and dependencies.") - vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path } + print "Installing nvim-tree and dependencies." + vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path } end load_plugins() - require('packer').sync() + require("packer").sync() vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]] vim.opt.termguicolors = true vim.opt.cursorline = true - + -- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE _G.setup = function() - vim.g.nvim_tree_indent_markers = 0 - vim.g.nvim_tree_git_hl = 0 - vim.g.nvim_tree_highlight_opened_files = 0 - vim.g.nvim_tree_root_folder_modifier = ':~' - vim.g.nvim_tree_add_trailing = 0 - vim.g.nvim_tree_group_empty = 0 - vim.g.nvim_tree_icon_padding = ' ' - vim.g.nvim_tree_symlink_arrow = ' ➛ ' - vim.g.nvim_tree_respect_buf_cwd = 0 - vim.g.nvim_tree_create_in_closed_folder = 0 - vim.g.nvim_tree_special_files = { ["Cargo.toml"] = true, Makefile = true, ["README.md"] = true, ["readme.md"] = true, } - vim.g.nvim_tree_show_icons = { git = 1, folders = 1, files = 1, folder_arrows = 1 } - require'nvim-tree'.setup { - auto_close = false, - auto_reload_on_write = true, - disable_netrw = false, - hide_root_folder = false, - hijack_cursor = false, - hijack_netrw = true, - hijack_unnamed_buffer_when_opening = false, - ignore_buffer_on_setup = false, - open_on_setup = false, - open_on_tab = false, - sort_by = "name", - update_cwd = false, - hijack_directories = { - enable = true, - auto_open = true, - }, - update_focused_file = { - enable = false, - update_cwd = false, - ignore_list = {} - }, - ignore_ft_on_setup = {}, - system_open = { - cmd = nil, - args = {} - }, - diagnostics = { - enable = false, - show_on_dirs = false, - icons = { - hint = "", - info = "", - warning = "", - error = "", - } - }, - filters = { - dotfiles = false, - custom = {}, - exclude = {} - }, - git = { - enable = true, - ignore = true, - timeout = 400, - }, - actions = { - change_dir = { - enable = true, - global = false, - }, - open_file = { - quit_on_open = false, - resize_window = false, - window_picker = { - enable = true, - } - } - }, - } + require("nvim-tree").setup {} end validations: required: true diff --git a/README.md b/README.md index e82093cb601..9fb18158ab0 100644 --- a/README.md +++ b/README.md @@ -108,68 +108,76 @@ highlight NvimTreeFolderIcon guibg=blue ```lua -- init.lua --- following options are the default +-- empty setup using defaults: add your own options +require'nvim-tree'.setup { +} + +-- OR + +-- setup with all defaults -- each of these are documented in `:help nvim-tree.OPTION_NAME` require'nvim-tree'.setup { - disable_netrw = false, - hijack_netrw = true, - open_on_setup = false, - ignore_buffer_on_setup = false, - ignore_ft_on_setup = {}, - auto_close = false, +[//]: <> (BEGIN_DEFAULT_OPTS) + auto_close = false, auto_reload_on_write = true, - open_on_tab = false, - hijack_cursor = false, - update_cwd = false, + disable_netrw = false, + hide_root_folder = false, + hijack_cursor = false, + hijack_netrw = true, hijack_unnamed_buffer_when_opening = false, - hijack_directories = { + ignore_buffer_on_setup = false, + open_on_setup = false, + open_on_tab = false, + sort_by = "name", + update_cwd = false, + view = { + width = 30, + height = 30, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + mappings = { + custom_only = false, + list = { + -- user mappings go here + }, + }, + }, + hijack_directories = { enable = true, auto_open = true, }, + update_focused_file = { + enable = false, + update_cwd = false, + ignore_list = {}, + }, + ignore_ft_on_setup = {}, + system_open = { + cmd = nil, + args = {}, + }, diagnostics = { enable = false, + show_on_dirs = false, icons = { hint = "", info = "", warning = "", error = "", - } - }, - update_focused_file = { - enable = false, - update_cwd = false, - ignore_list = {} - }, - system_open = { - cmd = nil, - args = {} + }, }, filters = { dotfiles = false, - custom = {} + custom = {}, + exclude = {}, }, git = { enable = true, ignore = true, - timeout = 500, - }, - view = { - width = 30, - height = 30, - hide_root_folder = false, - side = 'left', - preserve_window_proportions = false, - mappings = { - custom_only = false, - list = {} - }, - number = false, - relativenumber = false, - signcolumn = "yes" - }, - trash = { - cmd = "trash", - require_confirm = true + timeout = 400, }, actions = { change_dir = { @@ -183,11 +191,15 @@ require'nvim-tree'.setup { enable = true, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", }, - buftype = { "nofile", "terminal", "help", }, - } - } - } + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, + }, + }, + }, + trash = { + cmd = "trash", + require_confirm = true, }, log = { enable = false, @@ -198,6 +210,7 @@ require'nvim-tree'.setup { git = false, }, }, +[//]: <> (END_DEFAULT_OPTS) } ``` diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 76d46d04026..3fb05ad337b 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -83,24 +83,49 @@ To configure the tree (and make it runnable), you should call the setup function. > - require'nvim-tree'.setup { - disable_netrw = false, - hijack_netrw = true, - open_on_setup = false, + require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS + auto_close = false, + auto_reload_on_write = true, + disable_netrw = false, + hide_root_folder = false, + hijack_cursor = false, + hijack_netrw = true, + hijack_unnamed_buffer_when_opening = false, ignore_buffer_on_setup = false, - ignore_ft_on_setup = {}, - hijack_directories = { + open_on_setup = false, + open_on_tab = false, + sort_by = "name", + update_cwd = false, + view = { + width = 30, + height = 30, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + mappings = { + custom_only = false, + list = { + -- user mappings go here + }, + }, + }, + hijack_directories = { enable = true, auto_open = true, }, - auto_close = false, - auto_reload_on_write = true, - open_on_tab = false, - sort_by = "name", - hijack_cursor = false, - update_cwd = false, - hijack_unnamed_buffer_when_opening = false, - diagnostics = { + update_focused_file = { + enable = false, + update_cwd = false, + ignore_list = {}, + }, + ignore_ft_on_setup = {}, + system_open = { + cmd = nil, + args = {}, + }, + diagnostics = { enable = false, show_on_dirs = false, icons = { @@ -108,41 +133,17 @@ function. info = "", warning = "", error = "", - } - }, - update_focused_file = { - enable = false, - update_cwd = false, - ignore_list = {} + }, }, - system_open = { - cmd = nil, - args = {} + filters = { + dotfiles = false, + custom = {}, + exclude = {}, }, git = { enable = true, ignore = true, - }, - view = { - width = 30, - height = 30, - side = 'left', - preserve_window_proportions = false, - number = false, - relativenumber = false, - signcolumn = "yes", - mappings = { - custom_only = false, - list = {} - } - }, - filters = { - dotfiles = false, - custom = {} - }, - trash = { - cmd = "trash", - require_confirm = true, + timeout = 400, }, actions = { change_dir = { @@ -150,28 +151,32 @@ function. global = false, }, open_file = { - quit_on_open = false, - resize_window = false, - window_picker = { - enable = true, - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", }, - buftype = { "nofile", "terminal", "help", }, - } - } + quit_on_open = false, + resize_window = false, + window_picker = { + enable = true, + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, + }, }, }, + trash = { + cmd = "trash", + require_confirm = true, + }, log = { - enable = false, - truncate = false, - types = { - all = false, - config = false, - git = false, - }, + enable = false, + truncate = false, + types = { + all = false, + config = false, + git = false, + }, }, - } + } -- END_DEFAULT_OPTS < As options are currently being migrated, configuration of global options in diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 4800ab1af9d..deba66825bc 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -333,7 +333,7 @@ local function setup_autocommands(opts) vim.cmd "augroup end" end -local DEFAULT_OPTS = { +local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS auto_close = false, auto_reload_on_write = true, disable_netrw = false, @@ -346,6 +346,21 @@ local DEFAULT_OPTS = { open_on_tab = false, sort_by = "name", update_cwd = false, + view = { + width = 30, + height = 30, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + mappings = { + custom_only = false, + list = { + -- user mappings go here + }, + }, + }, hijack_directories = { enable = true, auto_open = true, @@ -390,9 +405,18 @@ local DEFAULT_OPTS = { resize_window = false, window_picker = { enable = true, + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, }, }, }, + trash = { + cmd = "trash", + require_confirm = true, + }, log = { enable = false, truncate = false, @@ -402,7 +426,7 @@ local DEFAULT_OPTS = { git = false, }, }, -} +} -- END_DEFAULT_OPTS local function merge_options(conf) if conf and conf.update_to_buf_dir then diff --git a/lua/nvim-tree/actions/open-file.lua b/lua/nvim-tree/actions/open-file.lua index 02d9883b314..bb1478ca315 100644 --- a/lua/nvim-tree/actions/open-file.lua +++ b/lua/nvim-tree/actions/open-file.lua @@ -4,18 +4,7 @@ local lib = require "nvim-tree.lib" local utils = require "nvim-tree.utils" local view = require "nvim-tree.view" -local M = { - quit_on_open = false, - resize_window = false, - window_picker = { - enable = true, - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "nofile", "terminal", "help" }, - }, - }, -} +local M = {} local function get_split_cmd() local side = view.View.side @@ -235,7 +224,7 @@ function M.setup(opts) if opts.actions.open_file.window_picker.chars then opts.actions.open_file.window_picker.chars = tostring(opts.actions.open_file.window_picker.chars):upper() end - M.window_picker = vim.tbl_extend("force", M.window_picker, opts.actions.open_file.window_picker) + M.window_picker = opts.actions.open_file.window_picker end return M diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index 95495439637..f689659da57 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -348,18 +348,8 @@ function M.is_root_folder_visible() return core.get_cwd() ~= "/" and not M.View.hide_root_folder end -local DEFAULT_CONFIG = { - width = 30, - height = 30, - side = "left", - preserve_window_proportions = false, - number = false, - relativenumber = false, - signcolumn = "yes", -} - function M.setup(opts) - local options = vim.tbl_deep_extend("force", DEFAULT_CONFIG, opts.view or {}) + local options = opts.view or {} M.View.side = options.side M.View.width = options.width M.View.height = options.height diff --git a/update-default-opts.sh b/update-default-opts.sh new file mode 100755 index 00000000000..ec11437afcd --- /dev/null +++ b/update-default-opts.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# run after changing nvim-tree.lua DEFAULT_OPTS: scrapes and updates README.md, nvim-tree-lua.txt + +begin="BEGIN_DEFAULT_OPTS" +end="END_DEFAULT_OPTS" + +# scrape, indented at 2 +sed -n -e "/${begin}/,/${end}/{ /${begin}/d; /${end}/d; p; }" lua/nvim-tree.lua > /tmp/DEFAULT_OPTS.2.lua + +# indent some more +sed -e "s/^ / /" /tmp/DEFAULT_OPTS.2.lua > /tmp/DEFAULT_OPTS.6.lua + +# README.md indented at 2 +sed -i -e "/${begin}/,/${end}/{ /${begin}/{p; r /tmp/DEFAULT_OPTS.2.lua + }; /${end}/p; d }" README.md + +# help, indented at 6 +sed -i -e "/${begin}/,/${end}/{ /${begin}/{p; r /tmp/DEFAULT_OPTS.6.lua + }; /${end}/p; d }" doc/nvim-tree-lua.txt +