chore: remove non-functional sides bottom/top
This commit is contained in:
@@ -185,7 +185,6 @@ Subsequent calls to setup will replace the previous configuration.
|
|||||||
adaptive_size = false,
|
adaptive_size = false,
|
||||||
centralize_selection = false,
|
centralize_selection = false,
|
||||||
width = 30,
|
width = 30,
|
||||||
height = 30,
|
|
||||||
hide_root_folder = false,
|
hide_root_folder = false,
|
||||||
side = "left",
|
side = "left",
|
||||||
preserve_window_proportions = false,
|
preserve_window_proportions = false,
|
||||||
@@ -632,7 +631,6 @@ Window / buffer setup.
|
|||||||
|
|
||||||
*nvim-tree.view.adaptive_size*
|
*nvim-tree.view.adaptive_size*
|
||||||
Resize the window on each draw based on the longest line.
|
Resize the window on each draw based on the longest line.
|
||||||
Only works when |nvim-tree.view.side| is `left` or `right`.
|
|
||||||
Type: `boolean`, Default: `false`
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
*nvim-tree.view.centralize_selection*
|
*nvim-tree.view.centralize_selection*
|
||||||
@@ -647,18 +645,10 @@ Window / buffer setup.
|
|||||||
*nvim-tree.view.width*
|
*nvim-tree.view.width*
|
||||||
Width of the window, can be a `%` string, a number representing columns or
|
Width of the window, can be a `%` string, a number representing columns or
|
||||||
a function.
|
a function.
|
||||||
Only works with `side` is `left` or `right`.
|
|
||||||
Type: `string | number | function`, Default: `30`
|
|
||||||
|
|
||||||
*nvim-tree.view.height*
|
|
||||||
Height of the window, can be `%` string or a number representing rows or a
|
|
||||||
function.
|
|
||||||
Only works with `side` is `top` or `bottom`
|
|
||||||
Type: `string | number | function`, Default: `30`
|
Type: `string | number | function`, Default: `30`
|
||||||
|
|
||||||
*nvim-tree.view.side*
|
*nvim-tree.view.side*
|
||||||
Side of the tree, can be `"left"`, `"right"`, `"bottom"`, `"top"`.
|
Side of the tree, can be `"left"`, `"right"`.
|
||||||
Note that bottom/top are not working correctly yet.
|
|
||||||
Type: `string`, Default: `"left"`
|
Type: `string`, Default: `"left"`
|
||||||
|
|
||||||
*nvim-tree.view.preserve_window_proportions*
|
*nvim-tree.view.preserve_window_proportions*
|
||||||
|
|||||||
@@ -445,7 +445,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
adaptive_size = false,
|
adaptive_size = false,
|
||||||
centralize_selection = false,
|
centralize_selection = false,
|
||||||
width = 30,
|
width = 30,
|
||||||
height = 30,
|
|
||||||
hide_root_folder = false,
|
hide_root_folder = false,
|
||||||
side = "left",
|
side = "left",
|
||||||
preserve_window_proportions = false,
|
preserve_window_proportions = false,
|
||||||
@@ -638,7 +637,6 @@ local FIELD_SKIP_VALIDATE = {
|
|||||||
|
|
||||||
local FIELD_OVERRIDE_TYPECHECK = {
|
local FIELD_OVERRIDE_TYPECHECK = {
|
||||||
width = { string = true, ["function"] = true, number = true },
|
width = { string = true, ["function"] = true, number = true },
|
||||||
height = { string = true, ["function"] = true, number = true },
|
|
||||||
remove_keymaps = { boolean = true, table = true },
|
remove_keymaps = { boolean = true, table = true },
|
||||||
on_attach = { ["function"] = true, string = true },
|
on_attach = { ["function"] = true, string = true },
|
||||||
sort_by = { ["function"] = true, string = true },
|
sort_by = { ["function"] = true, string = true },
|
||||||
|
|||||||
@@ -7,20 +7,6 @@ local view = require "nvim-tree.view"
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function get_split_side()
|
|
||||||
local side = view.View.side
|
|
||||||
if side == "right" then
|
|
||||||
return "aboveleft"
|
|
||||||
end
|
|
||||||
if side == "left" then
|
|
||||||
return "belowright"
|
|
||||||
end
|
|
||||||
if side == "top" then
|
|
||||||
return "bot"
|
|
||||||
end
|
|
||||||
return "top"
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_user_input_char()
|
local function get_user_input_char()
|
||||||
local c = vim.fn.getchar()
|
local c = vim.fn.getchar()
|
||||||
while type(c) ~= "number" do
|
while type(c) ~= "number" do
|
||||||
@@ -193,12 +179,11 @@ local function open_in_new_window(filename, mode, win_ids)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local do_split = mode == "split" or mode == "vsplit"
|
local do_split = mode == "split" or mode == "vsplit"
|
||||||
local split_side = get_split_side()
|
local split_side = (view.View.side == "right") and "aboveleft" or "belowright"
|
||||||
|
|
||||||
-- Target is invalid or window does not exist in current tabpage: create new window
|
-- Target is invalid or window does not exist in current tabpage: create new window
|
||||||
if not target_winid or not vim.tbl_contains(win_ids, target_winid) then
|
if not target_winid or not vim.tbl_contains(win_ids, target_winid) then
|
||||||
local split_cmd = view.is_vertical() and "vsplit" or "split"
|
vim.cmd(split_side .. " vsplit")
|
||||||
vim.cmd(split_side .. " " .. split_cmd)
|
|
||||||
target_winid = api.nvim_get_current_win()
|
target_winid = api.nvim_get_current_win()
|
||||||
lib.target_winid = target_winid
|
lib.target_winid = target_winid
|
||||||
|
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ local function create_buffer(bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_size()
|
local function get_size()
|
||||||
local width_or_height = M.is_vertical() and "width" or "height"
|
local size = M.View.width
|
||||||
local size = M.View[width_or_height]
|
|
||||||
if type(size) == "number" then
|
if type(size) == "number" then
|
||||||
return size
|
return size
|
||||||
elseif type(size) == "function" then
|
elseif type(size) == "function" then
|
||||||
@@ -116,8 +115,6 @@ end
|
|||||||
local move_tbl = {
|
local move_tbl = {
|
||||||
left = "H",
|
left = "H",
|
||||||
right = "L",
|
right = "L",
|
||||||
bottom = "J",
|
|
||||||
top = "K",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- setup_tabpage sets up the initial state of a tab
|
-- setup_tabpage sets up the initial state of a tab
|
||||||
@@ -239,8 +236,7 @@ local function grow()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.grow_from_content()
|
function M.grow_from_content()
|
||||||
local is_left_or_right = M.View.side == "left" or M.View.side == "right"
|
if M.View.adaptive_size then
|
||||||
if M.View.adaptive_size and is_left_or_right then
|
|
||||||
grow()
|
grow()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -276,11 +272,7 @@ function M.resize(size)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local new_size = get_size()
|
local new_size = get_size()
|
||||||
if M.is_vertical() then
|
a.nvim_win_set_width(M.get_winnr(), new_size)
|
||||||
a.nvim_win_set_width(M.get_winnr(), new_size)
|
|
||||||
else
|
|
||||||
a.nvim_win_set_height(M.get_winnr(), new_size)
|
|
||||||
end
|
|
||||||
|
|
||||||
events._dispatch_on_tree_resize(new_size)
|
events._dispatch_on_tree_resize(new_size)
|
||||||
|
|
||||||
@@ -353,10 +345,6 @@ function M.focus(winnr, open_if_closed)
|
|||||||
a.nvim_set_current_win(wnr)
|
a.nvim_set_current_win(wnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.is_vertical()
|
|
||||||
return M.View.side == "left" or M.View.side == "right"
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Restores the state of a NvimTree window if it was initialized before.
|
--- Restores the state of a NvimTree window if it was initialized before.
|
||||||
function M.restore_tab_state()
|
function M.restore_tab_state()
|
||||||
local tabpage = a.nvim_get_current_tabpage()
|
local tabpage = a.nvim_get_current_tabpage()
|
||||||
@@ -442,7 +430,7 @@ function M.setup(opts)
|
|||||||
local options = opts.view or {}
|
local options = opts.view or {}
|
||||||
M.View.adaptive_size = options.adaptive_size
|
M.View.adaptive_size = options.adaptive_size
|
||||||
M.View.centralize_selection = options.centralize_selection
|
M.View.centralize_selection = options.centralize_selection
|
||||||
M.View.side = options.side
|
M.View.side = (options.side == "right") and "right" or "left"
|
||||||
M.View.width = options.width
|
M.View.width = options.width
|
||||||
M.View.height = options.height
|
M.View.height = options.height
|
||||||
M.View.initial_width = get_size()
|
M.View.initial_width = get_size()
|
||||||
|
|||||||
Reference in New Issue
Block a user