#1050 #1068 various default options tweaks (#1074)

This commit is contained in:
Alexander Courtis
2022-03-18 21:35:15 +11:00
committed by GitHub
parent ecbe3ade95
commit 20797a8d74
7 changed files with 189 additions and 219 deletions

View File

@@ -63,108 +63,36 @@ body:
value: | value: |
vim.cmd [[set runtimepath=$VIMRUNTIME]] vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]] vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = '/tmp/nvt-min/site/pack' local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. '/packer/start/packer.nvim' local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins() local function load_plugins()
require('packer').startup { require("packer").startup {
{ {
'wbthomason/packer.nvim', "wbthomason/packer.nvim",
'kyazdani42/nvim-tree.lua', "kyazdani42/nvim-tree.lua",
'kyazdani42/nvim-web-devicons', "kyazdani42/nvim-web-devicons",
-- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
}, },
config = { config = {
package_root = package_root, package_root = package_root,
compile_path = install_path .. '/plugin/packer_compiled.lua', compile_path = install_path .. "/plugin/packer_compiled.lua",
display = { non_interactive = true }, display = { non_interactive = true },
}, },
} }
end end
if vim.fn.isdirectory(install_path) == 0 then if vim.fn.isdirectory(install_path) == 0 then
print("Installing nvim-tree and dependencies.") print "Installing nvim-tree and dependencies."
vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path } vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end end
load_plugins() load_plugins()
require('packer').sync() require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]] vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true vim.opt.termguicolors = true
vim.opt.cursorline = true vim.opt.cursorline = true
-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE -- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function() _G.setup = function()
vim.g.nvim_tree_indent_markers = 0 require("nvim-tree").setup {}
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,
}
}
},
}
end end
validations: validations:
required: true required: true

View File

@@ -108,68 +108,76 @@ highlight NvimTreeFolderIcon guibg=blue
```lua ```lua
-- init.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` -- each of these are documented in `:help nvim-tree.OPTION_NAME`
require'nvim-tree'.setup { require'nvim-tree'.setup {
disable_netrw = false, [//]: <> (BEGIN_DEFAULT_OPTS)
hijack_netrw = true,
open_on_setup = false,
ignore_buffer_on_setup = false,
ignore_ft_on_setup = {},
auto_close = false, auto_close = false,
auto_reload_on_write = true, auto_reload_on_write = true,
open_on_tab = false, disable_netrw = false,
hide_root_folder = false,
hijack_cursor = false, hijack_cursor = false,
update_cwd = false, hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false, 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,
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 = { hijack_directories = {
enable = true, enable = true,
auto_open = true, auto_open = true,
}, },
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {},
},
ignore_ft_on_setup = {},
system_open = {
cmd = nil,
args = {},
},
diagnostics = { diagnostics = {
enable = false, enable = false,
show_on_dirs = false,
icons = { icons = {
hint = "", hint = "",
info = "", info = "",
warning = "", warning = "",
error = "", error = "",
}
}, },
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {}
},
system_open = {
cmd = nil,
args = {}
}, },
filters = { filters = {
dotfiles = false, dotfiles = false,
custom = {} custom = {},
exclude = {},
}, },
git = { git = {
enable = true, enable = true,
ignore = true, ignore = true,
timeout = 500, timeout = 400,
},
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
}, },
actions = { actions = {
change_dir = { change_dir = {
@@ -183,11 +191,15 @@ require'nvim-tree'.setup {
enable = true, enable = true,
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = { exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", }, filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help", }, buftype = { "nofile", "terminal", "help" },
} },
} },
} },
},
trash = {
cmd = "trash",
require_confirm = true,
}, },
log = { log = {
enable = false, enable = false,
@@ -198,6 +210,7 @@ require'nvim-tree'.setup {
git = false, git = false,
}, },
}, },
[//]: <> (END_DEFAULT_OPTS)
} }
``` ```

View File

@@ -83,23 +83,48 @@ To configure the tree (and make it runnable), you should call the setup
function. function.
> >
require'nvim-tree'.setup { require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
auto_close = false,
auto_reload_on_write = true,
disable_netrw = false, disable_netrw = false,
hide_root_folder = false,
hijack_cursor = false,
hijack_netrw = true, hijack_netrw = true,
open_on_setup = false, hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false, ignore_buffer_on_setup = false,
ignore_ft_on_setup = {}, 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 = { hijack_directories = {
enable = true, enable = true,
auto_open = true, auto_open = true,
}, },
auto_close = false, update_focused_file = {
auto_reload_on_write = true, enable = false,
open_on_tab = false,
sort_by = "name",
hijack_cursor = false,
update_cwd = false, update_cwd = false,
hijack_unnamed_buffer_when_opening = false, ignore_list = {},
},
ignore_ft_on_setup = {},
system_open = {
cmd = nil,
args = {},
},
diagnostics = { diagnostics = {
enable = false, enable = false,
show_on_dirs = false, show_on_dirs = false,
@@ -108,41 +133,17 @@ function.
info = "", info = "",
warning = "", warning = "",
error = "", error = "",
}
}, },
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {}
}, },
system_open = { filters = {
cmd = nil, dotfiles = false,
args = {} custom = {},
exclude = {},
}, },
git = { git = {
enable = true, enable = true,
ignore = true, ignore = true,
}, timeout = 400,
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,
}, },
actions = { actions = {
change_dir = { change_dir = {
@@ -156,12 +157,16 @@ function.
enable = true, enable = true,
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = { exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", }, filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help", }, buftype = { "nofile", "terminal", "help" },
}
}
}, },
}, },
},
},
trash = {
cmd = "trash",
require_confirm = true,
},
log = { log = {
enable = false, enable = false,
truncate = false, truncate = false,
@@ -171,7 +176,7 @@ function.
git = false, git = false,
}, },
}, },
} } -- END_DEFAULT_OPTS
< <
As options are currently being migrated, configuration of global options in As options are currently being migrated, configuration of global options in

View File

@@ -334,7 +334,7 @@ local function setup_autocommands(opts)
vim.cmd "augroup end" vim.cmd "augroup end"
end end
local DEFAULT_OPTS = { local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
auto_close = false, auto_close = false,
auto_reload_on_write = true, auto_reload_on_write = true,
disable_netrw = false, disable_netrw = false,
@@ -347,6 +347,21 @@ local DEFAULT_OPTS = {
open_on_tab = false, open_on_tab = false,
sort_by = "name", sort_by = "name",
update_cwd = false, 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 = { hijack_directories = {
enable = true, enable = true,
auto_open = true, auto_open = true,
@@ -391,9 +406,18 @@ local DEFAULT_OPTS = {
resize_window = false, resize_window = false,
window_picker = { window_picker = {
enable = true, enable = true,
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
}, },
}, },
}, },
},
trash = {
cmd = "trash",
require_confirm = true,
},
log = { log = {
enable = false, enable = false,
truncate = false, truncate = false,
@@ -403,7 +427,7 @@ local DEFAULT_OPTS = {
git = false, git = false,
}, },
}, },
} } -- END_DEFAULT_OPTS
local function merge_options(conf) local function merge_options(conf)
if conf and conf.update_to_buf_dir then if conf and conf.update_to_buf_dir then

View File

@@ -4,18 +4,7 @@ local lib = require "nvim-tree.lib"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local view = require "nvim-tree.view" local view = require "nvim-tree.view"
local M = { 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 function get_split_cmd() local function get_split_cmd()
local side = view.View.side local side = view.View.side
@@ -235,7 +224,7 @@ function M.setup(opts)
if opts.actions.open_file.window_picker.chars then 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() opts.actions.open_file.window_picker.chars = tostring(opts.actions.open_file.window_picker.chars):upper()
end 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 end
return M return M

View File

@@ -348,18 +348,8 @@ function M.is_root_folder_visible()
return core.get_cwd() ~= "/" and not M.View.hide_root_folder return core.get_cwd() ~= "/" and not M.View.hide_root_folder
end end
local DEFAULT_CONFIG = {
width = 30,
height = 30,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
}
function M.setup(opts) 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.side = options.side
M.View.width = options.width M.View.width = options.width
M.View.height = options.height M.View.height = options.height

21
update-default-opts.sh Executable file
View File

@@ -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