Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,10 @@ longest line.
Type: `string | number | fun(): number|string`
Default: `-1`

*nvim-tree.view.width.include_root*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of anything else that could be added in the future? I am asking because we could have an enum nvim-tree.view.width.include instead of multiple include_*.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. As things stand, with include_root = true all lines in the buffer will be considered.

We could start excluding something, e.g. use only either folders/files to compute the width, but it is becoming very niche and not overly useful IMHO

Include root folder when computing width.
Type: `boolean`, Default: `false`

*nvim-tree.view.width.padding*
Extra padding to the right.
Type: `number | fun(): number|string`
Expand Down Expand Up @@ -3323,6 +3327,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree.view.side|
|nvim-tree.view.signcolumn|
|nvim-tree.view.width|
|nvim-tree.view.width.include_root|
|nvim-tree.view.width.max|
|nvim-tree.view.width.min|
|nvim-tree.view.width.padding|
Expand Down
1 change: 1 addition & 0 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ local ACCEPTED_TYPES = {
"table",
min = { "string", "function", "number" },
max = { "string", "function", "number" },
include_root = { "boolean" },
padding = { "function", "number" },
},
},
Expand Down
4 changes: 3 additions & 1 deletion lua/nvim-tree/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local M = {}

local DEFAULT_MIN_WIDTH = 30
local DEFAULT_MAX_WIDTH = -1
local DEFAULT_INCLUDE_ROOT = false
local DEFAULT_PADDING = 1

M.View = {
Expand Down Expand Up @@ -303,7 +304,7 @@ function M.open(options)
end

local function grow()
local starts_at = M.is_root_folder_visible(require("nvim-tree.core").get_cwd()) and 1 or 0
local starts_at = (M.is_root_folder_visible(require("nvim-tree.core").get_cwd()) and M.View.include_root) and 1 or 0
local lines = vim.api.nvim_buf_get_lines(M.get_bufnr(), starts_at, -1, false)
-- number of columns of right-padding to indicate end of path
local padding = get_size(M.View.padding)
Expand Down Expand Up @@ -600,6 +601,7 @@ function M.configure_width(width)
M.View.adaptive_size = true
M.View.width = width.min or DEFAULT_MIN_WIDTH
M.View.max_width = width.max or DEFAULT_MAX_WIDTH
M.View.include_root = width.include_root or DEFAULT_INCLUDE_ROOT
M.View.padding = width.padding or DEFAULT_PADDING
elseif width == nil then
if M.config.width ~= nil then
Expand Down
Loading