Skip to content

Commit 3d23432

Browse files
committed
feat: include_root option
1 parent 1eda256 commit 3d23432

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

doc/nvim-tree-lua.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,10 @@ longest line.
822822
Type: `string | number | fun(): number|string`
823823
Default: `-1`
824824

825+
*nvim-tree.view.width.include_root*
826+
Include root folder when computing width.
827+
Type: `boolean`, Default: `false`
828+
825829
*nvim-tree.view.width.padding*
826830
Extra padding to the right.
827831
Type: `number | fun(): number|string`
@@ -3323,6 +3327,7 @@ highlight group is not, hard linking as follows: >
33233327
|nvim-tree.view.side|
33243328
|nvim-tree.view.signcolumn|
33253329
|nvim-tree.view.width|
3330+
|nvim-tree.view.width.include_root|
33263331
|nvim-tree.view.width.max|
33273332
|nvim-tree.view.width.min|
33283333
|nvim-tree.view.width.padding|

lua/nvim-tree.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ local ACCEPTED_TYPES = {
553553
"table",
554554
min = { "string", "function", "number" },
555555
max = { "string", "function", "number" },
556+
include_root = { "boolean" },
556557
padding = { "function", "number" },
557558
},
558559
},

lua/nvim-tree/view.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local M = {}
1212

1313
local DEFAULT_MIN_WIDTH = 30
1414
local DEFAULT_MAX_WIDTH = -1
15+
local DEFAULT_INCLUDE_ROOT = false
1516
local DEFAULT_PADDING = 1
1617

1718
M.View = {
@@ -303,7 +304,7 @@ function M.open(options)
303304
end
304305

305306
local function grow()
306-
local starts_at = M.is_root_folder_visible(require("nvim-tree.core").get_cwd()) and 1 or 0
307+
local starts_at = (M.is_root_folder_visible(require("nvim-tree.core").get_cwd()) and M.View.include_root) and 1 or 0
307308
local lines = vim.api.nvim_buf_get_lines(M.get_bufnr(), starts_at, -1, false)
308309
-- number of columns of right-padding to indicate end of path
309310
local padding = get_size(M.View.padding)
@@ -600,6 +601,7 @@ function M.configure_width(width)
600601
M.View.adaptive_size = true
601602
M.View.width = width.min or DEFAULT_MIN_WIDTH
602603
M.View.max_width = width.max or DEFAULT_MAX_WIDTH
604+
M.View.include_root = width.include_root or DEFAULT_INCLUDE_ROOT
603605
M.View.padding = width.padding or DEFAULT_PADDING
604606
elseif width == nil then
605607
if M.config.width ~= nil then

0 commit comments

Comments
 (0)