This reverts commit 5bbd3a0a91.
This commit is contained in:
@@ -117,6 +117,7 @@ require'nvim-tree'.setup {
|
|||||||
require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = true,
|
||||||
disable_netrw = false,
|
disable_netrw = false,
|
||||||
|
hide_root_folder = false,
|
||||||
hijack_cursor = false,
|
hijack_cursor = false,
|
||||||
hijack_netrw = true,
|
hijack_netrw = true,
|
||||||
hijack_unnamed_buffer_when_opening = false,
|
hijack_unnamed_buffer_when_opening = false,
|
||||||
@@ -129,7 +130,6 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
|||||||
view = {
|
view = {
|
||||||
width = 30,
|
width = 30,
|
||||||
height = 30,
|
height = 30,
|
||||||
hide_root_folder = false,
|
|
||||||
side = "left",
|
side = "left",
|
||||||
preserve_window_proportions = false,
|
preserve_window_proportions = false,
|
||||||
number = false,
|
number = false,
|
||||||
@@ -166,7 +166,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
|||||||
},
|
},
|
||||||
ignore_ft_on_setup = {},
|
ignore_ft_on_setup = {},
|
||||||
system_open = {
|
system_open = {
|
||||||
cmd = "",
|
cmd = nil,
|
||||||
args = {},
|
args = {},
|
||||||
},
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ function.
|
|||||||
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
|
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = true,
|
||||||
disable_netrw = false,
|
disable_netrw = false,
|
||||||
|
hide_root_folder = false,
|
||||||
hijack_cursor = false,
|
hijack_cursor = false,
|
||||||
hijack_netrw = true,
|
hijack_netrw = true,
|
||||||
hijack_unnamed_buffer_when_opening = false,
|
hijack_unnamed_buffer_when_opening = false,
|
||||||
@@ -98,7 +99,6 @@ function.
|
|||||||
view = {
|
view = {
|
||||||
width = 30,
|
width = 30,
|
||||||
height = 30,
|
height = 30,
|
||||||
hide_root_folder = false,
|
|
||||||
side = "left",
|
side = "left",
|
||||||
preserve_window_proportions = false,
|
preserve_window_proportions = false,
|
||||||
number = false,
|
number = false,
|
||||||
@@ -135,7 +135,7 @@ function.
|
|||||||
},
|
},
|
||||||
ignore_ft_on_setup = {},
|
ignore_ft_on_setup = {},
|
||||||
system_open = {
|
system_open = {
|
||||||
cmd = "",
|
cmd = nil,
|
||||||
args = {},
|
args = {},
|
||||||
},
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
@@ -311,10 +311,10 @@ Here is a list of the options available in the setup call:
|
|||||||
*nvim-tree.system_open*
|
*nvim-tree.system_open*
|
||||||
- |system_open|: configuration options for the system open command
|
- |system_open|: configuration options for the system open command
|
||||||
|
|
||||||
- |system_open.cmd|: the command to run, leaving empty should work but
|
- |system_open.cmd|: the command to run, leaving nil should work but
|
||||||
useful if you want to override the default command with another one.
|
useful if you want to override the default command with another one.
|
||||||
type: `string`
|
type: `string`
|
||||||
default: `""`
|
default: `nil`
|
||||||
|
|
||||||
- |system_open.args|: the command arguments as a list
|
- |system_open.args|: the command arguments as a list
|
||||||
type: `{string}`
|
type: `{string}`
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ end
|
|||||||
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = true,
|
||||||
disable_netrw = false,
|
disable_netrw = false,
|
||||||
|
hide_root_folder = false,
|
||||||
hijack_cursor = false,
|
hijack_cursor = false,
|
||||||
hijack_netrw = true,
|
hijack_netrw = true,
|
||||||
hijack_unnamed_buffer_when_opening = false,
|
hijack_unnamed_buffer_when_opening = false,
|
||||||
@@ -323,7 +324,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
view = {
|
view = {
|
||||||
width = 30,
|
width = 30,
|
||||||
height = 30,
|
height = 30,
|
||||||
hide_root_folder = false,
|
|
||||||
side = "left",
|
side = "left",
|
||||||
preserve_window_proportions = false,
|
preserve_window_proportions = false,
|
||||||
number = false,
|
number = false,
|
||||||
@@ -360,7 +360,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
},
|
},
|
||||||
ignore_ft_on_setup = {},
|
ignore_ft_on_setup = {},
|
||||||
system_open = {
|
system_open = {
|
||||||
cmd = "",
|
cmd = nil,
|
||||||
args = {},
|
args = {},
|
||||||
},
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
@@ -429,50 +429,16 @@ local function merge_options(conf)
|
|||||||
return vim.tbl_deep_extend("force", DEFAULT_OPTS, conf or {})
|
return vim.tbl_deep_extend("force", DEFAULT_OPTS, conf or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function validate_options(conf)
|
|
||||||
local msg
|
|
||||||
|
|
||||||
local function validate(user, def, prefix)
|
|
||||||
if type(user) ~= "table" or type(def) ~= "table" or not next(def) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(user) do
|
|
||||||
local invalid
|
|
||||||
if def[k] == nil then
|
|
||||||
invalid = string.format("unknown option: %s%s", prefix, k)
|
|
||||||
elseif type(v) ~= type(def[k]) then
|
|
||||||
invalid = string.format("invalid option: %s%s expected: %s actual: %s", prefix, k, type(def[k]), type(v))
|
|
||||||
end
|
|
||||||
|
|
||||||
if invalid then
|
|
||||||
if msg then
|
|
||||||
msg = string.format("%s | %s", msg, invalid)
|
|
||||||
else
|
|
||||||
msg = string.format("%s", invalid)
|
|
||||||
end
|
|
||||||
user[k] = nil
|
|
||||||
else
|
|
||||||
validate(v, def[k], prefix .. k .. ".")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
validate(conf, DEFAULT_OPTS, "")
|
|
||||||
|
|
||||||
if msg then
|
|
||||||
utils.warn(msg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.setup(conf)
|
function M.setup(conf)
|
||||||
legacy.migrate_legacy_options(conf or {})
|
legacy.migrate_legacy_options(conf or {})
|
||||||
|
|
||||||
validate_options(conf)
|
|
||||||
|
|
||||||
local opts = merge_options(conf)
|
local opts = merge_options(conf)
|
||||||
local netrw_disabled = opts.disable_netrw or opts.hijack_netrw
|
local netrw_disabled = opts.disable_netrw or opts.hijack_netrw
|
||||||
|
|
||||||
|
if opts.auto_close then
|
||||||
|
utils.warn "auto close feature has been removed, see note in the README (tips & reminder section)"
|
||||||
|
end
|
||||||
|
|
||||||
_config.update_focused_file = opts.update_focused_file
|
_config.update_focused_file = opts.update_focused_file
|
||||||
_config.open_on_setup = opts.open_on_setup
|
_config.open_on_setup = opts.open_on_setup
|
||||||
_config.open_on_setup_file = opts.open_on_setup_file
|
_config.open_on_setup_file = opts.open_on_setup_file
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ local M = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function M.fn(node)
|
function M.fn(node)
|
||||||
if #M.config.system_open.cmd == 0 then
|
if not M.config.system_open.cmd then
|
||||||
require("nvim-tree.utils").warn "Cannot open file with system application. Unrecognized platform."
|
require("nvim-tree.utils").warn "Cannot open file with system application. Unrecognized platform."
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -53,7 +53,7 @@ end
|
|||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
M.config.system_open = opts or {}
|
M.config.system_open = opts or {}
|
||||||
|
|
||||||
if #M.config.system_open.cmd == 0 then
|
if not M.config.system_open.cmd then
|
||||||
if M.config.is_windows then
|
if M.config.is_windows then
|
||||||
M.config.system_open = {
|
M.config.system_open = {
|
||||||
cmd = "cmd",
|
cmd = "cmd",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ local M = {}
|
|||||||
-- TODO update git.io/JPhyt when adding a migration
|
-- TODO update git.io/JPhyt when adding a migration
|
||||||
|
|
||||||
-- migrate the g: to o if the user has not specified that when calling setup
|
-- migrate the g: to o if the user has not specified that when calling setup
|
||||||
local g_migrations = {
|
local migrations = {
|
||||||
nvim_tree_disable_netrw = function(o)
|
nvim_tree_disable_netrw = function(o)
|
||||||
if o.disable_netrw == nil then
|
if o.disable_netrw == nil then
|
||||||
o.disable_netrw = vim.g.nvim_tree_disable_netrw ~= 0
|
o.disable_netrw = vim.g.nvim_tree_disable_netrw ~= 0
|
||||||
@@ -178,7 +178,22 @@ local g_migrations = {
|
|||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function refactored(opts)
|
function M.migrate_legacy_options(opts)
|
||||||
|
local msg = nil
|
||||||
|
|
||||||
|
-- g: options
|
||||||
|
for g, m in pairs(migrations) do
|
||||||
|
if vim.fn.exists("g:" .. g) ~= 0 then
|
||||||
|
m(opts)
|
||||||
|
msg = (msg and msg .. ", " or "Following options were moved to setup, see git.io/JPhyt: ") .. g
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if msg then
|
||||||
|
require("nvim-tree.utils").warn(msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- regular opts
|
||||||
if opts.view then
|
if opts.view then
|
||||||
if opts.view.mappings then
|
if opts.view.mappings then
|
||||||
if opts.view.mappings.list then
|
if opts.view.mappings.list then
|
||||||
@@ -192,31 +207,4 @@ local function refactored(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function removed(opts)
|
|
||||||
if opts.auto_close then
|
|
||||||
utils.warn "auto close feature has been removed, see note in the README (tips & reminder section)"
|
|
||||||
opts.auto_close = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.migrate_legacy_options(opts)
|
|
||||||
-- g: options
|
|
||||||
local msg
|
|
||||||
for g, m in pairs(g_migrations) do
|
|
||||||
if vim.fn.exists("g:" .. g) ~= 0 then
|
|
||||||
m(opts)
|
|
||||||
msg = (msg and msg .. ", " or "Following options were moved to setup, see git.io/JPhyt: ") .. g
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if msg then
|
|
||||||
utils.warn(msg)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- silently move
|
|
||||||
refactored(opts)
|
|
||||||
|
|
||||||
-- warn and delete
|
|
||||||
removed(opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user