Compare commits

...

8 Commits

Author SHA1 Message Date
github-actions[bot]
d529a99f88 chore(master): release nvim-tree 1.10.0 (#3021)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-01-13 15:41:35 +11:00
phanium
39bc630816 fix: hijack directory "BufEnter", "BufNewFile" events are nested (#3044)
Co-authored-by: Alexander Courtis <alex@courtis.org>
2025-01-13 15:39:10 +11:00
Lev Yuvenskiy
aae01853dd fix(#3041): use vim.diagnostic.get for updating diagnostics (#3042)
* fix(#3041): use vim.diagnostic.get for updating diagnostics

* fix(#3041): remove unnecessary @type

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
2025-01-13 15:15:48 +11:00
fdgdgerg
68fc4c20f5 feat(api): add node.open.vertical_no_picker, node.open.horizontal_no_picker (#3031)
* test

* add splits with no window pickers

removed the 1 buffer per file limitation

test

test2

* no-picker for splits

* help vertical/horizontal_no_picker

* revert whitespace changes

---------

Co-authored-by: JoeDaBu <joegbu@gmail.com>
Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-12-22 09:35:48 +11:00
Šimon Mandlík
f7b76cd1a7 fix(#3015): dynamic width no longer truncates on right_align icons (#3022) 2024-12-14 08:54:18 +11:00
Alexander Courtis
c3d9b1779f docs: notify users with a fs.inotify.max_user_watches message on EMFILE event (#3028)
* docs: notify users with a fs.inotify.max_user_watches message on EMFILE event

* type safety for newly created vim.v.event type
2024-12-13 10:39:46 +11:00
ShyRobin
db8d7ac1f5 fix(#3018): error when focusing nvim-tree when in terminal mode (#3019)
fix: Can't re-enter normal mode from terminal mode

Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-12-08 12:05:33 +11:00
Jie Liu
6b4be1dc0c fix: view.width functions may return strings (#3020)
* Fix get_size() function when size is a function return string

* update view.width help

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-12-08 11:45:32 +11:00
10 changed files with 77 additions and 14 deletions

View File

@@ -1,3 +1,3 @@
{ {
".": "1.9.0" ".": "1.10.0"
} }

View File

@@ -1,5 +1,22 @@
# Changelog # Changelog
## [1.10.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.9.0...nvim-tree-v1.10.0) (2025-01-13)
### Features
* **api:** add node.open.vertical_no_picker, node.open.horizontal_no_picker ([#3031](https://github.com/nvim-tree/nvim-tree.lua/issues/3031)) ([68fc4c2](https://github.com/nvim-tree/nvim-tree.lua/commit/68fc4c20f5803444277022c681785c5edd11916d))
### Bug Fixes
* **#3015:** dynamic width no longer truncates on right_align icons ([#3022](https://github.com/nvim-tree/nvim-tree.lua/issues/3022)) ([f7b76cd](https://github.com/nvim-tree/nvim-tree.lua/commit/f7b76cd1a75615c8d6254fc58bedd2a7304eb7d8))
* **#3018:** error when focusing nvim-tree when in terminal mode ([#3019](https://github.com/nvim-tree/nvim-tree.lua/issues/3019)) ([db8d7ac](https://github.com/nvim-tree/nvim-tree.lua/commit/db8d7ac1f524fc6f808764b29fa695c51e014aa6))
* **#3041:** use vim.diagnostic.get for updating diagnostics ([#3042](https://github.com/nvim-tree/nvim-tree.lua/issues/3042)) ([aae0185](https://github.com/nvim-tree/nvim-tree.lua/commit/aae01853ddbd790d1efd6ff04ff96cf38c02c95f))
* Can't re-enter normal mode from terminal mode ([db8d7ac](https://github.com/nvim-tree/nvim-tree.lua/commit/db8d7ac1f524fc6f808764b29fa695c51e014aa6))
* hijack directory "BufEnter", "BufNewFile" events are nested ([#3044](https://github.com/nvim-tree/nvim-tree.lua/issues/3044)) ([39bc630](https://github.com/nvim-tree/nvim-tree.lua/commit/39bc63081605c1d4b974131ebecaea11e8a8595f))
* view.width functions may return strings ([#3020](https://github.com/nvim-tree/nvim-tree.lua/issues/3020)) ([6b4be1d](https://github.com/nvim-tree/nvim-tree.lua/commit/6b4be1dc0cd4d5d5b8e8b56b510a75016e99746f))
## [1.9.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.8.0...nvim-tree-v1.9.0) (2024-12-07) ## [1.9.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.8.0...nvim-tree-v1.9.0) (2024-12-07)

View File

@@ -800,22 +800,22 @@ Width of the window: can be a `%` string, a number representing columns, a
function or a table. function or a table.
A table indicates that the view should be dynamically sized based on the A table indicates that the view should be dynamically sized based on the
longest line. longest line.
Type: `string | number | table | function()` returning a number Type: `string | number | table | fun(): number|string`
Default: `30` Default: `30`
*nvim-tree.view.width.min* *nvim-tree.view.width.min*
Minimum dynamic width. Minimum dynamic width.
Type: `string | number | function()` returning a number Type: `string | number | fun(): number|string`
Default: `30` Default: `30`
*nvim-tree.view.width.max* *nvim-tree.view.width.max*
Maximum dynamic width, -1 for unbounded. Maximum dynamic width, -1 for unbounded.
Type: `string | number | function()` returning a number Type: `string | number | fun(): number|string`
Default: `-1` Default: `-1`
*nvim-tree.view.width.padding* *nvim-tree.view.width.padding*
Extra padding to the right. Extra padding to the right.
Type: `number | function()` returning a number Type: `number | fun(): number|string`
Default: `1` Default: `1`
*nvim-tree.view.float* *nvim-tree.view.float*
@@ -2025,9 +2025,19 @@ node.open.no_window_picker({node})
node.open.vertical({node}) *nvim-tree-api.node.open.vertical()* node.open.vertical({node}) *nvim-tree-api.node.open.vertical()*
|nvim-tree-api.node.edit()|, file will be opened in a new vertical split. |nvim-tree-api.node.edit()|, file will be opened in a new vertical split.
*nvim-tree-api.node.open.vertical_no_picker()*
node.open.vertical_no_picker({node})
|nvim-tree-api.node.vertical()|, window picker will never be used as per
|nvim-tree.actions.open_file.window_picker.enable| `false`
node.open.horizontal({node}) *nvim-tree-api.node.open.horizontal()* node.open.horizontal({node}) *nvim-tree-api.node.open.horizontal()*
|nvim-tree-api.node.edit()|, file will be opened in a new horizontal split. |nvim-tree-api.node.edit()|, file will be opened in a new horizontal split.
*nvim-tree-api.node.open.horizontal_no_picker()*
node.open.horizontal_no_picker({node})
|nvim-tree-api.node.horizontal()|, window picker will never be used as per
|nvim-tree.actions.open_file.window_picker.enable| `false`
*nvim-tree-api.node.open.toggle_group_empty()* *nvim-tree-api.node.open.toggle_group_empty()*
node.open.toggle_group_empty({node}) node.open.toggle_group_empty({node})
Toggle |nvim-tree.renderer.group_empty| for a specific folder. Toggle |nvim-tree.renderer.group_empty| for a specific folder.
@@ -3189,6 +3199,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree-api.node.open.drop()| |nvim-tree-api.node.open.drop()|
|nvim-tree-api.node.open.edit()| |nvim-tree-api.node.open.edit()|
|nvim-tree-api.node.open.horizontal()| |nvim-tree-api.node.open.horizontal()|
|nvim-tree-api.node.open.horizontal_no_picker()|
|nvim-tree-api.node.open.no_window_picker()| |nvim-tree-api.node.open.no_window_picker()|
|nvim-tree-api.node.open.preview()| |nvim-tree-api.node.open.preview()|
|nvim-tree-api.node.open.preview_no_picker()| |nvim-tree-api.node.open.preview_no_picker()|
@@ -3197,6 +3208,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree-api.node.open.tab_drop()| |nvim-tree-api.node.open.tab_drop()|
|nvim-tree-api.node.open.toggle_group_empty()| |nvim-tree-api.node.open.toggle_group_empty()|
|nvim-tree-api.node.open.vertical()| |nvim-tree-api.node.open.vertical()|
|nvim-tree-api.node.open.vertical_no_picker()|
|nvim-tree-api.node.run.cmd()| |nvim-tree-api.node.run.cmd()|
|nvim-tree-api.node.run.system()| |nvim-tree-api.node.run.system()|
|nvim-tree-api.node.show_info_popup()| |nvim-tree-api.node.show_info_popup()|

View File

@@ -190,7 +190,7 @@ local function setup_autocommands(opts)
end end
if opts.hijack_directories.enable then if opts.hijack_directories.enable then
create_nvim_tree_autocmd({ "BufEnter", "BufNewFile" }, { callback = M.open_on_directory }) create_nvim_tree_autocmd({ "BufEnter", "BufNewFile" }, { callback = M.open_on_directory, nested = true })
end end
if opts.view.centralize_selection then if opts.view.centralize_selection then
@@ -199,6 +199,10 @@ local function setup_autocommands(opts)
callback = function() callback = function()
vim.schedule(function() vim.schedule(function()
vim.api.nvim_buf_call(0, function() vim.api.nvim_buf_call(0, function()
local is_term_mode = vim.api.nvim_get_mode().mode == "t"
if is_term_mode then
return
end
vim.cmd([[norm! zz]]) vim.cmd([[norm! zz]])
end) end)
end) end)

View File

@@ -235,9 +235,8 @@ end
local function get_target_winid(mode) local function get_target_winid(mode)
local target_winid local target_winid
if not M.window_picker.enable or mode == "edit_no_picker" or mode == "preview_no_picker" then if not M.window_picker.enable or string.find(mode, "no_picker") then
target_winid = lib.target_winid target_winid = lib.target_winid
-- first available window -- first available window
if not vim.tbl_contains(vim.api.nvim_tabpage_list_wins(0), target_winid) then if not vim.tbl_contains(vim.api.nvim_tabpage_list_wins(0), target_winid) then
target_winid = first_win_id() target_winid = first_win_id()
@@ -280,6 +279,11 @@ local function open_in_new_window(filename, mode)
return return
end end
local position = string.find(mode, "no_picker")
if position then
mode = string.sub(mode, 0, position - 2)
end
-- non-floating, non-nvim-tree windows -- non-floating, non-nvim-tree windows
local win_ids = vim.tbl_filter(function(id) local win_ids = vim.tbl_filter(function(id)
local config = vim.api.nvim_win_get_config(id) local config = vim.api.nvim_win_get_config(id)

View File

@@ -25,7 +25,7 @@ end
---@param new_tabpage integer ---@param new_tabpage integer
---@return boolean ---@return boolean
local function is_window_event(new_tabpage) local function is_window_event(new_tabpage)
local is_event_scope_window = vim.v.event.scope == "window" or vim.v.event.changed_window local is_event_scope_window = vim.v.event.scope == "window" or vim.v.event.changed_window or false
return is_event_scope_window and new_tabpage == M.current_tab return is_event_scope_window and new_tabpage == M.current_tab
end end

View File

@@ -255,7 +255,9 @@ Api.node.open.tab_drop = wrap_node(open_or_expand_or_dir_up("tab_drop"))
Api.node.open.replace_tree_buffer = wrap_node(open_or_expand_or_dir_up("edit_in_place")) Api.node.open.replace_tree_buffer = wrap_node(open_or_expand_or_dir_up("edit_in_place"))
Api.node.open.no_window_picker = wrap_node(open_or_expand_or_dir_up("edit_no_picker")) Api.node.open.no_window_picker = wrap_node(open_or_expand_or_dir_up("edit_no_picker"))
Api.node.open.vertical = wrap_node(open_or_expand_or_dir_up("vsplit")) Api.node.open.vertical = wrap_node(open_or_expand_or_dir_up("vsplit"))
Api.node.open.vertical_no_picker = wrap_node(open_or_expand_or_dir_up("vsplit_no_picker"))
Api.node.open.horizontal = wrap_node(open_or_expand_or_dir_up("split")) Api.node.open.horizontal = wrap_node(open_or_expand_or_dir_up("split"))
Api.node.open.horizontal_no_picker = wrap_node(open_or_expand_or_dir_up("split_no_picker"))
Api.node.open.tab = wrap_node(open_or_expand_or_dir_up("tabnew")) Api.node.open.tab = wrap_node(open_or_expand_or_dir_up("tabnew"))
Api.node.open.toggle_group_empty = wrap_node(open_or_expand_or_dir_up("toggle_group_empty", true)) Api.node.open.toggle_group_empty = wrap_node(open_or_expand_or_dir_up("toggle_group_empty", true))
Api.node.open.preview = wrap_node(open_or_expand_or_dir_up("preview")) Api.node.open.preview = wrap_node(open_or_expand_or_dir_up("preview"))

View File

@@ -128,8 +128,7 @@ function M.update_lsp(ev)
local profile_event = log.profile_start("DiagnosticChanged event") local profile_event = log.profile_start("DiagnosticChanged event")
---@type vim.Diagnostic[] local diagnostics = vim.diagnostic.get(ev.buf)
local diagnostics = ev.data.diagnostics
-- use the buffer from the event, as ev.data.diagnostics will be empty on resolved diagnostics -- use the buffer from the event, as ev.data.diagnostics will be empty on resolved diagnostics
local bufname = uniformize_path(vim.api.nvim_buf_get_name(ev.buf)) local bufname = uniformize_path(vim.api.nvim_buf_get_name(ev.buf))

View File

@@ -119,7 +119,7 @@ local function get_size(size)
if type(size) == "number" then if type(size) == "number" then
return size return size
elseif type(size) == "function" then elseif type(size) == "function" then
return size() return get_size(size())
end end
local size_as_number = tonumber(size:sub(0, -2)) local size_as_number = tonumber(size:sub(0, -2))
local percent_as_decimal = size_as_number / 100 local percent_as_decimal = size_as_number / 100
@@ -321,8 +321,19 @@ local function grow()
max_width = get_width(M.View.max_width) - padding max_width = get_width(M.View.max_width) - padding
end end
for _, l in pairs(lines) do local ns_id = vim.api.nvim_get_namespaces()["NvimTreeExtmarks"]
for line_nr, l in pairs(lines) do
local count = vim.fn.strchars(l) local count = vim.fn.strchars(l)
-- also add space for right-aligned icons
local extmarks = vim.api.nvim_buf_get_extmarks(M.get_bufnr(), ns_id, { line_nr, 0 }, { line_nr, -1 }, { details = true })
for _, extmark in ipairs(extmarks) do
local virt_texts = extmark[4].virt_text
if virt_texts then
for _, virt_text in ipairs(virt_texts) do
count = count + vim.fn.strchars(virt_text[1])
end
end
end
if resizing_width < count then if resizing_width < count then
resizing_width = count resizing_width = count
end end

View File

@@ -4,6 +4,8 @@ local utils = require("nvim-tree.utils")
local Class = require("nvim-tree.classic") local Class = require("nvim-tree.classic")
local MESSAGE_EMFILE = "fs.inotify.max_user_watches exceeded, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Troubleshooting"
local FS_EVENT_FLAGS = { local FS_EVENT_FLAGS = {
-- inotify or equivalent will be used; fallback to stat has not yet been implemented -- inotify or equivalent will be used; fallback to stat has not yet been implemented
stat = false, stat = false,
@@ -75,6 +77,18 @@ function Event:start()
local event_cb = vim.schedule_wrap(function(err, filename) local event_cb = vim.schedule_wrap(function(err, filename)
if err then if err then
log.line("watcher", "event_cb '%s' '%s' FAIL : %s", self.path, filename, err) log.line("watcher", "event_cb '%s' '%s' FAIL : %s", self.path, filename, err)
-- do nothing if watchers have already been disabled
if not M.config.filesystem_watchers.enable then
return
end
-- EMFILE is catastrophic
if name == "EMFILE" then
M.disable_watchers(MESSAGE_EMFILE)
return
end
local message = string.format("File system watcher failed (%s) for path %s, halting watcher.", err, self.path) local message = string.format("File system watcher failed (%s) for path %s, halting watcher.", err, self.path)
if err == "EPERM" and (utils.is_windows or utils.is_wsl) then if err == "EPERM" and (utils.is_windows or utils.is_wsl) then
-- on directory removal windows will cascade the filesystem events out of order -- on directory removal windows will cascade the filesystem events out of order
@@ -94,7 +108,7 @@ function Event:start()
rc, _, name = self.fs_event:start(self.path, FS_EVENT_FLAGS, event_cb) rc, _, name = self.fs_event:start(self.path, FS_EVENT_FLAGS, event_cb)
if rc ~= 0 then if rc ~= 0 then
if name == "EMFILE" then if name == "EMFILE" then
M.disable_watchers("fs.inotify.max_user_watches exceeded, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Troubleshooting") M.disable_watchers(MESSAGE_EMFILE)
else else
notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self.path, name)) notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self.path, name))
end end