feat(#3310): minimum neovim version 0.10 (#3311)

* feat(#3310): minimum neovim version 0.10

* feat(#3310): minimum neovim version 0.10

* feat(#3310): minimum neovim version 0.10

* feat(#3310): minimum neovim version 0.10

* feat(#3310): minimum neovim version 0.10

* feat(#3310): minimum neovim version 0.10

* feat(#3310): minimum neovim version 0.10

* feat(#3310): minimum neovim version 0.10
This commit is contained in:
Alexander Courtis
2026-04-07 10:37:49 +10:00
committed by GitHub
parent 31503ad5d8
commit 7adc5679fe
39 changed files with 125 additions and 357 deletions

View File

@@ -132,10 +132,10 @@ Whenever new neovim API is introduced, please ensure that it is available in old
See `nvim-tree.setup` for the oldest supported version of neovim. If the API is not availble in that version, a backwards compatibility shim must be used e.g.
```lua
if vim.fn.has("nvim-0.10") == 1 then
modified = vim.api.nvim_get_option_value("modified", { buf = target_bufid })
if vim.fn.has("nvim-0.11") == 1 and vim.hl and vim.hl.range then
vim.hl.range(0, ns_id, details.hl_group, { 0, col }, { 0, details.end_col, }, {})
else
modified = vim.api.nvim_buf_get_option(target_bufid, "modified") ---@diagnostic disable-line: deprecated
vim.api.nvim_buf_add_highlight(0, ns_id, details.hl_group, 0, col, details.end_col) ---@diagnostic disable-line: deprecated
end
```

View File

@@ -51,7 +51,7 @@ markdown-toc --maxdepth=2 -i README.md
# Requirements
[neovim >=0.9.0](https://github.com/neovim/neovim/wiki/Installing-Neovim)
[Nvim >= 0.10](https://github.com/neovim/neovim/wiki/Installing-Neovim). At least `n - 0.1` stable Nvim compatibility is guaranteed. You may use a `compat-nvim-0.X` tag for earlier Nvim versions, however they will receive no updates or support.
[nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) is optional and used to display file icons. It requires a [patched font](https://www.nerdfonts.com/). Your terminal emulator must be configured to use that font, usually "Hack Nerd Font"

View File

@@ -52,7 +52,10 @@ Git Integration
Requirements
Nvim >= 0.9
Nvim >= 0.10.
At least `n - 0.1` stable Nvim compatibility is guaranteed.
You may use a `compat-nvim-0.X` tag for earlier Nvim versions, however
they will receive no updates or support.
==============================================================================
Quickstart *nvim-tree-quickstart*
@@ -1041,8 +1044,6 @@ Config *nvim-tree-config*
|nvim_tree.config.hijack_directories|
• {update_focused_file}? (`nvim_tree.config.update_focused_file`)
|nvim_tree.config.update_focused_file|
• {system_open}? (`nvim_tree.config.system_open`)
|nvim_tree.config.system_open|
• {git}? (`nvim_tree.config.git`)
|nvim_tree.config.git|
• {diagnostics}? (`nvim_tree.config.diagnostics`)
@@ -1498,30 +1499,6 @@ Config: update_focused_file *nvim-tree-config-update-focused-file*
==============================================================================
Config: system_open *nvim-tree-config-system-open*
*nvim_tree.config.system_open*
Open files or directories via the OS.
Nvim:
• `>=` 0.10 uses |vim.ui.open()| unless {cmd} is specified
• `<` 0.10 calls external {cmd}:
• UNIX: `xdg-open`
• macOS: `open`
• Windows: `cmd`
Once nvim-tree minimum Nvim version is updated to 0.10, this configuration
will no longer be necessary and will be removed.
Fields: ~
• {cmd}? (`string`) The open command itself
• {args}? (`string[]`, default: `{}` or `{ "/c", "start", '""' }` on
windows) Optional argument list. Leave empty for OS specific
default.
==============================================================================
Config: git *nvim-tree-config-git*
@@ -2154,10 +2131,6 @@ Following is the default configuration, see |nvim_tree.config| for details. >lua
},
exclude = false,
},
system_open = {
cmd = "",
args = {},
},
git = {
enable = true,
show_on_dirs = true,
@@ -2934,7 +2907,7 @@ run.cmd({node}) *nvim_tree.api.node.run.cmd()*
• {node} (`nvim_tree.api.Node?`) directory or file
run.system({node}) *nvim_tree.api.node.run.system()*
Execute |nvim_tree.config.system_open|.
Open with the system default handler: |vim.ui.open()|.
Parameters: ~
• {node} (`nvim_tree.api.Node?`) directory or file

View File

@@ -17,8 +17,9 @@ function M.setup(config_user)
local view_state = require("nvim-tree.view-state")
-- Nvim version check
if vim.fn.has("nvim-0.9") == 0 then
require("nvim-tree.notify").warn("nvim-tree.lua requires Neovim 0.9 or higher")
if vim.fn.has("nvim-0.10") == 0 then
require("nvim-tree.notify").warn(
"nvim-tree.lua requires Nvim >= 0.10. You may use a compat-nvim-0.X tag for earlier Nvim versions, however they will receive no updates or support.")
return
end

View File

@@ -271,7 +271,7 @@ nvim_tree.api.node.run = {}
function nvim_tree.api.node.run.cmd(node) end
---
---Execute [nvim_tree.config.system_open].
---Open with the system default handler: [vim.ui.open()].
---
---@param node? nvim_tree.api.Node directory or file
function nvim_tree.api.node.run.system(node) end

View File

@@ -87,9 +87,6 @@ error("Cannot require a meta file")
---[nvim_tree.config.update_focused_file]
---@field update_focused_file? nvim_tree.config.update_focused_file
---
---[nvim_tree.config.system_open]
---@field system_open? nvim_tree.config.system_open
---
---[nvim_tree.config.git]
---@field git? nvim_tree.config.git
---

View File

@@ -1,24 +0,0 @@
---@meta
error("Cannot require a meta file")
---Open files or directories via the OS.
---
---Nvim:
---- `>=` 0.10 uses [vim.ui.open()] unless {cmd} is specified
---- `<` 0.10 calls external {cmd}:
--- - UNIX: `xdg-open`
--- - macOS: `open`
--- - Windows: `cmd`
---
---Once nvim-tree minimum Nvim version is updated to 0.10, this configuration will no longer be necessary and will be removed.
---
---@class nvim_tree.config.system_open
---
---The open command itself
---@field cmd? string
---
---Optional argument list. Leave empty for OS specific default.
---(default: `{}` or `{ "/c", "start", '""' }` on windows)
---@field args? string[]

View File

@@ -19,7 +19,7 @@ function M.fn(path)
end
-- always match against the real path
local path_real = vim.loop.fs_realpath(path)
local path_real = vim.uv.fs_realpath(path)
if not path_real then
return
end

View File

@@ -25,23 +25,23 @@ local function search(search_dir, input_path)
local filter_status = explorer.filters:prepare()
handle, _ = vim.loop.fs_scandir(dir)
handle, _ = vim.uv.fs_scandir(dir)
if not handle then
return
end
realpath, _ = vim.loop.fs_realpath(dir)
realpath, _ = vim.uv.fs_realpath(dir)
if not realpath or vim.tbl_contains(realpaths_searched, realpath) then
return
end
table.insert(realpaths_searched, realpath)
name, _ = vim.loop.fs_scandir_next(handle)
name, _ = vim.uv.fs_scandir_next(handle)
while name do
path = dir .. "/" .. name
---@type uv.fs_stat.result|nil
stat, _ = vim.loop.fs_stat(path)
stat, _ = vim.uv.fs_stat(path)
if not stat then
break
end
@@ -59,7 +59,7 @@ local function search(search_dir, input_path)
end
end
name, _ = vim.loop.fs_scandir_next(handle)
name, _ = vim.uv.fs_scandir_next(handle)
end
end
@@ -74,14 +74,8 @@ function M.fn()
-- temporarily set &path
local bufnr = vim.api.nvim_get_current_buf()
local path_existed, path_opt
if vim.fn.has("nvim-0.10") == 1 then
path_existed, path_opt = pcall(vim.api.nvim_get_option_value, "path", { buf = bufnr })
vim.api.nvim_set_option_value("path", core.get_cwd() .. "/**", { buf = bufnr })
else
path_existed, path_opt = pcall(vim.api.nvim_buf_get_option, bufnr, "path") ---@diagnostic disable-line: deprecated
vim.api.nvim_buf_set_option(bufnr, "path", core.get_cwd() .. "/**") ---@diagnostic disable-line: deprecated
end
local path_existed, path_opt = pcall(vim.api.nvim_get_option_value, "path", { buf = bufnr })
vim.api.nvim_set_option_value("path", core.get_cwd() .. "/**", { buf = bufnr })
vim.ui.input({ prompt = "Search: ", completion = "file_in_path" }, function(input_path)
if not input_path or input_path == "" then
@@ -89,17 +83,9 @@ function M.fn()
end
-- reset &path
if path_existed then
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("path", path_opt, { buf = bufnr })
else
vim.api.nvim_buf_set_option(bufnr, "path", path_opt) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("path", path_opt, { buf = bufnr })
else
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("path", nil, { buf = bufnr })
else
vim.api.nvim_buf_set_option(bufnr, "path", nil) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("path", nil, { buf = bufnr })
end
-- strip trailing slash

View File

@@ -48,7 +48,7 @@ end
---@return boolean
---@return string|nil
local function do_copy(source, destination)
local source_stats, err = vim.loop.fs_stat(source)
local source_stats, err = vim.uv.fs_stat(source)
if not source_stats then
log.line("copy_paste", "do_copy fs_stat '%s' failed '%s'", source, err)
@@ -64,7 +64,7 @@ local function do_copy(source, destination)
if source_stats.type == "file" then
local success
success, err = vim.loop.fs_copyfile(source, destination)
success, err = vim.uv.fs_copyfile(source, destination)
if not success then
log.line("copy_paste", "do_copy fs_copyfile failed '%s'", err)
return false, err
@@ -72,7 +72,7 @@ local function do_copy(source, destination)
return true
elseif source_stats.type == "directory" then
local handle
handle, err = vim.loop.fs_scandir(source)
handle, err = vim.uv.fs_scandir(source)
if type(handle) == "string" then
return false, handle
elseif not handle then
@@ -81,14 +81,14 @@ local function do_copy(source, destination)
end
local success
success, err = vim.loop.fs_mkdir(destination, source_stats.mode)
success, err = vim.uv.fs_mkdir(destination, source_stats.mode)
if not success then
log.line("copy_paste", "do_copy fs_mkdir '%s' failed '%s'", destination, err)
return false, err
end
while true do
local name, _ = vim.loop.fs_scandir_next(handle)
local name, _ = vim.uv.fs_scandir_next(handle)
if not name then
break
end
@@ -228,7 +228,7 @@ function Clipboard:resolve_conflicts(conflict, destination, action, action_fn)
self:finish_paste(action)
return
end
if vim.loop.fs_stat(new_dest) then
if vim.uv.fs_stat(new_dest) then
self:resolve_conflicts({ { node = conflict[1].node, dest = new_dest } }, destination, action, action_fn)
else
do_paste_one(source, new_dest, action, action_fn)
@@ -285,7 +285,7 @@ function Clipboard:resolve_conflicts(conflict, destination, action, action_fn)
local extension = vim.fn.fnamemodify(item.node.name, ":e")
local new_name = extension ~= "" and (basename .. suffix .. "." .. extension) or (item.node.name .. suffix)
local new_dest = utils.path_join({ destination, new_name })
local stats = vim.loop.fs_stat(new_dest)
local stats = vim.uv.fs_stat(new_dest)
if stats then
table.insert(still_conflict, { node = item.node, dest = new_dest })
else
@@ -324,7 +324,7 @@ function Clipboard:do_paste(node, action, action_fn)
end
local destination = node.absolute_path
local stats, err, err_name = vim.loop.fs_stat(destination)
local stats, err, err_name = vim.uv.fs_stat(destination)
if not stats and err_name ~= "ENOENT" then
log.line("copy_paste", "do_paste fs_stat '%s' failed '%s'", destination, err)
notify.error("Could not " .. action .. " " .. notify.render_path(destination) .. " - " .. (err or "???"))
@@ -340,7 +340,7 @@ function Clipboard:do_paste(node, action, action_fn)
local conflict = {}
for _, _node in ipairs(clip) do
local dest = utils.path_join({ destination, _node.name })
local dest_stats = vim.loop.fs_stat(dest)
local dest_stats = vim.uv.fs_stat(dest)
if dest_stats then
table.insert(conflict, { node = _node, dest = dest })
else
@@ -374,7 +374,7 @@ local function do_cut(source, destination)
end
events._dispatch_will_rename_node(source, destination)
local success, errmsg = vim.loop.fs_rename(source, destination)
local success, errmsg = vim.uv.fs_rename(source, destination)
if not success then
log.line("copy_paste", "do_cut fs_rename failed '%s'", errmsg)
return false, errmsg

View File

@@ -13,12 +13,12 @@ local M = {}
---@param file string
local function create_and_notify(file)
events._dispatch_will_create_file(file)
local ok, fd = pcall(vim.loop.fs_open, file, "w", 420)
local ok, fd = pcall(vim.uv.fs_open, file, "w", 420)
if not ok or type(fd) ~= "number" then
notify.error("Couldn't create file " .. notify.render_path(file))
return
end
vim.loop.fs_close(fd)
vim.uv.fs_close(fd)
events._dispatch_file_created(file)
end
@@ -84,7 +84,7 @@ function M.fn(node)
if is_last_path_file and idx == num_nodes then
create_and_notify(path_to_create)
elseif not utils.file_exists(path_to_create) then
local success = vim.loop.fs_mkdir(path_to_create, 493)
local success = vim.uv.fs_mkdir(path_to_create, 493)
if not success then
notify.error("Could not create folder " .. notify.render_path(path_to_create))
is_error = true

View File

@@ -62,14 +62,14 @@ end
---@param cwd string
---@return boolean|nil
local function remove_dir(cwd)
local handle, err = vim.loop.fs_scandir(cwd)
local handle, err = vim.uv.fs_scandir(cwd)
if not handle then
notify.error(err)
return
end
while true do
local name, _ = vim.loop.fs_scandir_next(handle)
local name, _ = vim.uv.fs_scandir_next(handle)
if not name then
break
end
@@ -77,11 +77,11 @@ local function remove_dir(cwd)
local new_cwd = utils.path_join({ cwd, name })
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
local stat = vim.loop.fs_stat(new_cwd)
local stat = vim.uv.fs_stat(new_cwd)
-- TODO remove once 0.12 is the minimum neovim version
-- path incorrectly specified as an integer, fixed upstream for neovim 0.12 https://github.com/neovim/neovim/pull/33872
---@diagnostic disable-next-line: param-type-mismatch
local lstat = vim.loop.fs_lstat(new_cwd)
local lstat = vim.uv.fs_lstat(new_cwd)
local type = stat and stat.type or nil
-- Checks if file is a link file to ensure deletion of the symlink instead of the file it points to
@@ -93,7 +93,7 @@ local function remove_dir(cwd)
return false
end
else
local success = vim.loop.fs_unlink(new_cwd)
local success = vim.uv.fs_unlink(new_cwd)
if not success then
return false
end
@@ -101,7 +101,7 @@ local function remove_dir(cwd)
end
end
return vim.loop.fs_rmdir(cwd)
return vim.uv.fs_rmdir(cwd)
end
--- Remove a node, notify errors, dispatch events
@@ -118,7 +118,7 @@ function M.remove(node)
events._dispatch_folder_removed(node.absolute_path)
else
events._dispatch_will_remove_file(node.absolute_path)
local success = vim.loop.fs_unlink(node.absolute_path)
local success = vim.uv.fs_unlink(node.absolute_path)
if not success then
notify.error("Could not remove " .. notify_node)
return false

View File

@@ -74,14 +74,14 @@ function M.rename(node, to)
if idx == num_nodes then
events._dispatch_will_rename_node(node.absolute_path, to)
local success, err = vim.loop.fs_rename(node.absolute_path, to)
local success, err = vim.uv.fs_rename(node.absolute_path, to)
if not success then
notify.warn(err_fmt(notify_from, notify_to, err))
return
end
elseif not rename_file_exists(notify_from, path_to_create) then
local success = vim.loop.fs_mkdir(path_to_create, 493)
local success = vim.uv.fs_mkdir(path_to_create, 493)
if not success then
notify.error("Could not create folder " .. notify.render_path(path_to_create))
is_error = true

View File

@@ -38,12 +38,7 @@ local function usable_win_ids()
return vim.tbl_filter(function(id)
local bufid = vim.api.nvim_win_get_buf(id)
for option, v in pairs(config.g.actions.open_file.window_picker.exclude) do
local ok, option_value
if vim.fn.has("nvim-0.10") == 1 then
ok, option_value = pcall(vim.api.nvim_get_option_value, option, { buf = bufid })
else
ok, option_value = pcall(vim.api.nvim_buf_get_option, bufid, option) ---@diagnostic disable-line: deprecated
end
local ok, option_value = pcall(vim.api.nvim_get_option_value, option, { buf = bufid })
if ok and vim.tbl_contains(v, option_value) then
return false
@@ -105,24 +100,14 @@ local function pick_win_id()
if laststatus == 3 then
for _, win_id in ipairs(not_selectable) do
local ok_status, statusline
if vim.fn.has("nvim-0.10") == 1 then
ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = win_id })
else
ok_status, statusline = pcall(vim.api.nvim_win_get_option, win_id, "statusline") ---@diagnostic disable-line: deprecated
end
local ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = win_id })
win_opts_unselectable[win_id] = {
statusline = ok_status and statusline or "",
}
-- Clear statusline for windows not selectable
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("statusline", " ", { win = win_id })
else
vim.api.nvim_win_set_option(win_id, "statusline", " ") ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("statusline", " ", { win = win_id })
end
end
@@ -130,14 +115,8 @@ local function pick_win_id()
for _, id in ipairs(selectable) do
local char = config.g.actions.open_file.window_picker.chars:sub(i, i)
local ok_status, statusline, ok_hl, winhl
if vim.fn.has("nvim-0.10") == 1 then
ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = id })
ok_hl, winhl = pcall(vim.api.nvim_get_option_value, "winhl", { win = id })
else
ok_status, statusline = pcall(vim.api.nvim_win_get_option, id, "statusline") ---@diagnostic disable-line: deprecated
ok_hl, winhl = pcall(vim.api.nvim_win_get_option, id, "winhl") ---@diagnostic disable-line: deprecated
end
local ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = id })
local ok_hl, winhl = pcall(vim.api.nvim_get_option_value, "winhl", { win = id })
win_opts_selectable[id] = {
statusline = ok_status and statusline or "",
@@ -145,13 +124,8 @@ local function pick_win_id()
}
win_map[char] = id
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("statusline", "%=" .. char .. "%=", { win = id })
vim.api.nvim_set_option_value("winhl", "StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker", { win = id })
else
vim.api.nvim_win_set_option(id, "statusline", "%=" .. char .. "%=") ---@diagnostic disable-line: deprecated
vim.api.nvim_win_set_option(id, "winhl", "StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker") ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("statusline", "%=" .. char .. "%=", { win = id })
vim.api.nvim_set_option_value("winhl", "StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker", { win = id })
i = i + 1
if i > #config.g.actions.open_file.window_picker.chars then
@@ -170,11 +144,7 @@ local function pick_win_id()
-- Restore window options
for _, id in ipairs(selectable) do
for opt, value in pairs(win_opts_selectable[id]) do
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value(opt, value, { win = id })
else
vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value(opt, value, { win = id })
end
end
@@ -183,11 +153,7 @@ local function pick_win_id()
-- Ensure window still exists at this point
if vim.api.nvim_win_is_valid(id) then
for opt, value in pairs(win_opts_unselectable[id]) do
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value(opt, value, { win = id })
else
vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value(opt, value, { win = id })
end
end
end
@@ -341,12 +307,7 @@ local function open_in_new_window(filename, mode)
-- modified, and create new split if it is.
local target_bufid = vim.api.nvim_win_get_buf(target_winid)
local modified
if vim.fn.has("nvim-0.10") == 1 then
modified = vim.api.nvim_get_option_value("modified", { buf = target_bufid })
else
modified = vim.api.nvim_buf_get_option(target_bufid, "modified") ---@diagnostic disable-line: deprecated
end
local modified = vim.api.nvim_get_option_value("modified", { buf = target_bufid })
if modified then
if not mode:match("split$") then

View File

@@ -1,70 +1,9 @@
local notify = require("nvim-tree.notify")
local config = require("nvim-tree.config")
local M = {}
---@param node Node
local function user(node)
local cmd = config.g.system_open.cmd
local args = config.g.system_open.args
if #cmd == 0 then
if config.os.windows then
cmd = "cmd"
args = { "/c", "start", '""' }
elseif config.os.macos then
cmd = "open"
elseif config.os.unix then
cmd = "xdg-open"
end
end
if #cmd == 0 then
notify.warn("Cannot open file with system application. Unrecognized platform.")
return
end
local process = {
cmd = cmd,
args = args,
errors = "\n",
stderr = vim.loop.new_pipe(false),
}
table.insert(process.args, node.link_to or node.absolute_path)
local opts = {
args = process.args,
stdio = { nil, nil, process.stderr },
detached = true,
}
process.handle, process.pid = vim.loop.spawn(process.cmd, opts, function(code)
process.stderr:read_stop()
process.stderr:close()
process.handle:close()
if code ~= 0 then
notify.warn(string.format("system_open failed with return code %d: %s", code, process.errors))
end
end)
table.remove(process.args)
if not process.handle then
notify.warn(string.format("system_open failed to spawn command '%s': %s", process.cmd, process.pid))
return
end
vim.loop.read_start(process.stderr, function(err, data)
if err then
return
end
if data then
process.errors = process.errors .. data
end
end)
vim.loop.unref(process.handle)
end
---@param node Node
local function native(node)
function M.fn(node)
local _, err = vim.ui.open(node.link_to or node.absolute_path)
-- err only provided on opener executable not found hence logging path is not useful
@@ -73,14 +12,4 @@ local function native(node)
end
end
---@param node Node
function M.fn(node)
-- TODO #2430 always use native once 0.10 is the minimum neovim version
if vim.fn.has("nvim-0.10") == 1 and #config.g.system_open.cmd == 0 then
native(node)
else
user(node)
end
end
return M

View File

@@ -10,13 +10,7 @@ local M = {}
function M.fn(path, bufnr)
-- skip if current file is in ignore_list
if type(bufnr) == "number" then
local ft
if vim.fn.has("nvim-0.10") == 1 then
ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) or ""
else
ft = vim.api.nvim_buf_get_option(bufnr, "filetype") or "" ---@diagnostic disable-line: deprecated
end
local ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) or ""
for _, value in pairs(config.g.update_focused_file.update_root.ignore_list) do
if utils.str_find(path, value) or utils.str_find(ft, value) then

View File

@@ -73,12 +73,7 @@ function M.tab_enter()
if view.is_visible({ any_tabpage = true }) then
local bufname = vim.api.nvim_buf_get_name(0)
local ft
if vim.fn.has("nvim-0.10") == 1 then
ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) or ""
else
ft = vim.api.nvim_buf_get_option(0, "ft") ---@diagnostic disable-line: deprecated
end
local ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) or ""
for _, filter in ipairs(config.g.tab.sync.ignore) do
if bufname:match(filter) ~= nil or ft:match(filter) ~= nil then

View File

@@ -138,11 +138,7 @@ return function()
render_displays("other, long", displays_long, bufnr, l)
-- finalise and focus the buffer
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
else
vim.api.nvim_buf_set_option(bufnr, "modifiable", false) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
vim.cmd.buffer(bufnr)
end

View File

@@ -30,7 +30,7 @@ function M.global()
vim.api.nvim_create_autocmd("DirChanged", {
group = augroup_id,
callback = function()
require("nvim-tree.actions.tree.change-dir").fn(vim.loop.cwd())
require("nvim-tree.actions.tree.change-dir").fn(vim.uv.cwd())
end,
})
end

View File

@@ -173,10 +173,6 @@ M.d = { -- config-default-start
},
exclude = false,
},
system_open = {
cmd = "",
args = {},
},
git = {
enable = true,
show_on_dirs = true,

View File

@@ -22,9 +22,9 @@ function M.init(foldername)
local err, path
if foldername then
path, err = vim.loop.fs_realpath(foldername)
path, err = vim.uv.fs_realpath(foldername)
else
path, err = vim.loop.cwd()
path, err = vim.uv.cwd()
end
if path then
TreeExplorer = require("nvim-tree.explorer")({ path = path })

View File

@@ -177,7 +177,7 @@ function Filters:custom(path)
end
-- filter custom regexes
local relpath = utils.path_relative(path, vim.loop.cwd())
local relpath = utils.path_relative(path, vim.uv.cwd())
for pat, _ in pairs(self.ignore_list) do
if vim.fn.match(relpath, pat) ~= -1 or vim.fn.match(basename, pat) ~= -1 then
return true

View File

@@ -27,7 +27,7 @@ local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON
local find_file = require("nvim-tree.actions.finders.find-file")
---@class (exact) Explorer: RootNode
---@field uid_explorer number vim.loop.hrtime() at construction time
---@field uid_explorer number vim.uv.hrtime() at construction time
---@field opts table user options
---@field augroup_id integer
---@field current_tab integer
@@ -54,7 +54,7 @@ function Explorer:new(args)
name = "..",
})
self.uid_explorer = vim.loop.hrtime()
self.uid_explorer = vim.uv.hrtime()
self.augroup_id = vim.api.nvim_create_augroup("NvimTree_Explorer_" .. self.uid_explorer, {})
self.open = true
@@ -203,7 +203,7 @@ end
---@return Node[]?
function Explorer:reload(node, project)
local cwd = node.link_to or node.absolute_path
local handle = vim.loop.fs_scandir(cwd)
local handle = vim.uv.fs_scandir(cwd)
if not handle then
return
end
@@ -233,15 +233,17 @@ function Explorer:reload(node, project)
})
while true do
local name, _ = vim.loop.fs_scandir_next(handle)
local name, _ = vim.uv.fs_scandir_next(handle)
if not name then
break
end
local abs = utils.path_join({ cwd, name })
-- path incorrectly specified as an integer
local stat = vim.loop.fs_lstat(abs) ---@diagnostic disable-line param-type-mismatch
-- TODO remove once 0.12 is the minimum neovim version
-- path incorrectly specified as an integer, fixed upstream for neovim 0.12 https://github.com/neovim/neovim/pull/33872
---@diagnostic disable-next-line: param-type-mismatch
local stat = vim.uv.fs_lstat(abs)
local filter_reason = self.filters:should_filter_as_reason(abs, stat, filter_status)
if filter_reason == FILTER_REASON.none then
@@ -389,7 +391,7 @@ function Explorer:populate_children(handle, cwd, node, project, parent)
})
while true do
local name, _ = vim.loop.fs_scandir_next(handle)
local name, _ = vim.uv.fs_scandir_next(handle)
if not name then
break
end
@@ -399,8 +401,10 @@ function Explorer:populate_children(handle, cwd, node, project, parent)
if Watcher.is_fs_event_capable(abs) then
local profile = log.profile_start("populate_children %s", abs)
-- path incorrectly specified as an integer
local stat = vim.loop.fs_lstat(abs) ---@diagnostic disable-line param-type-mismatch
-- TODO remove once 0.12 is the minimum neovim version
-- path incorrectly specified as an integer, fixed upstream for neovim 0.12 https://github.com/neovim/neovim/pull/33872
---@diagnostic disable-next-line: param-type-mismatch
local stat = vim.uv.fs_lstat(abs)
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
@@ -436,7 +440,7 @@ end
---@return Node[]|nil
function Explorer:explore(node, project, parent)
local cwd = node.link_to or node.absolute_path
local handle = vim.loop.fs_scandir(cwd)
local handle = vim.uv.fs_scandir(cwd)
if not handle then
return
end

View File

@@ -189,13 +189,8 @@ local function create_overlay(self)
style = "minimal",
})
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("modifiable", true, { buf = overlay_bufnr })
vim.api.nvim_set_option_value("filetype", "NvimTreeFilter", { buf = overlay_bufnr })
else
vim.api.nvim_buf_set_option(overlay_bufnr, "modifiable", true) ---@diagnostic disable-line: deprecated
vim.api.nvim_buf_set_option(overlay_bufnr, "filetype", "NvimTreeFilter") ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("modifiable", true, { buf = overlay_bufnr })
vim.api.nvim_set_option_value("filetype", "NvimTreeFilter", { buf = overlay_bufnr })
vim.api.nvim_buf_set_lines(overlay_bufnr, 0, -1, false, { self.filter })
vim.cmd("startinsert")

View File

@@ -138,7 +138,6 @@ function M.reload_project(toplevel, path, callback)
end
GitRunner:run(args)
else
-- TODO #1974 use callback once async/await is available
reload_git_project(toplevel, path, project, GitRunner:run(args))
end
end
@@ -173,7 +172,7 @@ function M.get_toplevel(path)
return nil
end
local stat, _ = vim.loop.fs_stat(path)
local stat, _ = vim.uv.fs_stat(path)
if not stat or stat.type ~= "directory" then
return nil
end

View File

@@ -125,9 +125,9 @@ end
---@param callback function|nil
function GitRunner:run_git_job(callback)
local handle, pid
local stdout = vim.loop.new_pipe(false)
local stderr = vim.loop.new_pipe(false)
local timer = vim.loop.new_timer()
local stdout = vim.uv.new_pipe(false)
local stderr = vim.uv.new_pipe(false)
local timer = vim.uv.new_timer()
if stdout == nil or stderr == nil or timer == nil then
return
@@ -150,7 +150,7 @@ function GitRunner:run_git_job(callback)
-- don't close the handle when killing as it will leave a zombie
if rc == -1 then
pcall(vim.loop.kill, pid, "sigkill")
pcall(vim.uv.kill, pid, "sigkill")
elseif handle then
handle:close()
end
@@ -164,7 +164,7 @@ function GitRunner:run_git_job(callback)
log.line("git", "running job with timeout %dms", self.timeout)
log.line("git", "git %s", table.concat(utils.array_remove_nils(spawn_options.args), " "))
handle, pid = vim.loop.spawn(
handle, pid = vim.uv.spawn(
"git",
spawn_options,
vim.schedule_wrap(function(rc)
@@ -196,8 +196,8 @@ function GitRunner:run_git_job(callback)
self:log_raw_output(data)
end
vim.loop.read_start(stdout, vim.schedule_wrap(manage_stdout))
vim.loop.read_start(stderr, vim.schedule_wrap(manage_stderr))
vim.uv.read_start(stdout, vim.schedule_wrap(manage_stdout))
vim.uv.read_start(stderr, vim.schedule_wrap(manage_stderr))
end
---@private

View File

@@ -25,12 +25,8 @@ end
---@return string stdout
---@return integer exit code
local function system(cmd)
if vim.fn.has("nvim-0.10") == 1 then
local obj = vim.system(cmd):wait(config.g.git.timeout)
return obj.stdout or "", obj.code
else
return vim.fn.system(cmd), vim.v.shell_error
end
local obj = vim.system(cmd):wait(config.g.git.timeout)
return obj.stdout or "", obj.code
end
--- Retrieve the git toplevel directory

View File

@@ -203,12 +203,7 @@ local function open()
-- populate it
vim.api.nvim_buf_set_lines(M.bufnr, 0, -1, false, lines)
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("modifiable", false, { buf = M.bufnr })
else
vim.api.nvim_buf_set_option(M.bufnr, "modifiable", false) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("modifiable", false, { buf = M.bufnr })
-- highlight it
for _, args in ipairs(hl_range_args) do

View File

@@ -146,6 +146,13 @@ local function removed_config(u)
)
end
u["create_in_closed_folder"] = nil
if u.system_open then
require("nvim-tree.notify").warn(
"system_open has been removed, now uses the system default handler: vim.ui.open()"
)
u["system_open"] = nil
end
end
---Migrate legacy config in place.

View File

@@ -47,13 +47,8 @@ local function should_hijack_current_buf()
local bufname = vim.api.nvim_buf_get_name(bufnr)
local bufmodified, ft
if vim.fn.has("nvim-0.10") == 1 then
bufmodified = vim.api.nvim_get_option_value("modified", { buf = bufnr })
ft = vim.api.nvim_get_option_value("ft", { buf = bufnr })
else
bufmodified = vim.api.nvim_buf_get_option(bufnr, "modified") ---@diagnostic disable-line: deprecated
ft = vim.api.nvim_buf_get_option(bufnr, "ft") ---@diagnostic disable-line: deprecated
end
bufmodified = vim.api.nvim_get_option_value("modified", { buf = bufnr })
ft = vim.api.nvim_get_option_value("ft", { buf = bufnr })
local should_hijack_unnamed = config.g.hijack_unnamed_buffer_when_opening and bufname == "" and not bufmodified and ft == ""
local should_hijack_dir = bufname ~= "" and vim.fn.isdirectory(bufname) == 1 and config.g.hijack_directories.enable
@@ -100,7 +95,7 @@ function M.open(opts)
if opts.path then
core.init(opts.path)
else
local cwd, err = vim.loop.cwd()
local cwd, err = vim.uv.cwd()
if not cwd then
notify.error(string.format("current working directory unavailable: %s", err))
return

View File

@@ -59,7 +59,7 @@ end
function M.profile_start(fmt, ...)
local profile = {}
if M.enabled("profile") then
profile.start = vim.loop.hrtime()
profile.start = vim.uv.hrtime()
profile.tag = string.format((fmt or "???"), ...)
M.line("profile", "START %s", profile.tag)
end
@@ -71,7 +71,7 @@ end
---@param profile Profile returned from profile_start
function M.profile_end(profile)
if M.enabled("profile") and type(profile) == "table" then
local millis = profile.start and math.modf((vim.loop.hrtime() - profile.start) / 1000000) or -1
local millis = profile.start and math.modf((vim.uv.hrtime() - profile.start) / 1000000) or -1
M.line("profile", "END %s %dms", profile.tag or "", millis)
end
end

View File

@@ -22,8 +22,8 @@ local DirectoryNode = Node:extend()
function DirectoryNode:new(args)
DirectoryNode.super.new(self, args)
local handle = vim.loop.fs_scandir(args.absolute_path)
local has_children = handle and vim.loop.fs_scandir_next(handle) ~= nil or false
local handle = vim.uv.fs_scandir(args.absolute_path)
local has_children = handle and vim.uv.fs_scandir_next(handle) ~= nil or false
self.type = "directory"

View File

@@ -17,15 +17,15 @@ function M.create(args)
if args.fs_stat.type == "directory" then
-- directory must be readable and enumerable
if vim.loop.fs_access(args.absolute_path, "R") and Watcher.is_fs_event_capable(args.absolute_path) then
if vim.uv.fs_access(args.absolute_path, "R") and Watcher.is_fs_event_capable(args.absolute_path) then
return DirectoryNode(args)
end
elseif args.fs_stat.type == "file" then
return FileNode(args)
elseif args.fs_stat.type == "link" then
-- link target path and stat must resolve
local link_to = vim.loop.fs_realpath(args.absolute_path)
local link_to_stat = link_to and vim.loop.fs_stat(link_to)
local link_to = vim.uv.fs_realpath(args.absolute_path)
local link_to_stat = link_to and vim.uv.fs_stat(link_to)
if not link_to or not link_to_stat then
return
end

View File

@@ -2,7 +2,7 @@ local Class = require("nvim-tree.classic")
---Abstract Node class.
---@class (exact) Node: nvim_tree.Class
---@field uid_node number vim.loop.hrtime() at construction time
---@field uid_node number vim.uv.hrtime() at construction time
---@field type "file" | "directory" | "link" uv.fs_stat.result.type
---@field explorer Explorer
---@field absolute_path string
@@ -26,7 +26,7 @@ local Node = Class:extend()
---@protected
---@param args NodeArgs
function Node:new(args)
self.uid_node = vim.loop.hrtime()
self.uid_node = vim.uv.hrtime()
self.explorer = args.explorer
self.absolute_path = args.absolute_path
self.executable = false

View File

@@ -37,20 +37,12 @@ end
---@param extmarks table[] extra marks for right icon placement
---@param virtual_lines table[] virtual lines for hidden count display
function Renderer:_draw(bufnr, lines, hl_range_args, signs, extmarks, virtual_lines)
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })
else
vim.api.nvim_buf_set_option(bufnr, "modifiable", true) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
self:render_hl(bufnr, hl_range_args)
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
else
vim.api.nvim_buf_set_option(bufnr, "modifiable", false) ---@diagnostic disable-line: deprecated
end
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
vim.fn.sign_unplace(SIGN_GROUP)
for i, sign_name in pairs(signs) do

View File

@@ -164,12 +164,7 @@ function M.rename_loaded_buffers(old_path, new_path)
vim.api.nvim_buf_set_name(buf, new_path .. buf_name:sub(#old_path + 1))
-- to avoid the 'overwrite existing file' error message on write for
-- normal files
local buftype
if vim.fn.has("nvim-0.10") == 1 then
buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
else
buftype = vim.api.nvim_buf_get_option(buf, "buftype") ---@diagnostic disable-line: deprecated
end
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
if buftype == "" then
vim.api.nvim_buf_call(buf, function()
@@ -190,7 +185,7 @@ end
---@return boolean
function M.file_exists(path)
if not (config.os.windows or config.os.wsl) then
local _, error = vim.loop.fs_stat(path)
local _, error = vim.uv.fs_stat(path)
return error == nil
end
@@ -210,14 +205,14 @@ function M.file_exists(path)
local parent = vim.fn.fnamemodify(path, ":h")
local filename = vim.fn.fnamemodify(path, ":t")
local handle = vim.loop.fs_scandir(parent)
local handle = vim.uv.fs_scandir(parent)
if not handle then
-- File can not exist if its parent directory does not exist
return false
end
while true do
local name, _ = vim.loop.fs_scandir_next(handle)
local name, _ = vim.uv.fs_scandir_next(handle)
if not name then
break
end
@@ -336,7 +331,7 @@ function M.debounce(context, timeout, callback)
timer_stop_close(debouncer.timer)
end
local timer = vim.loop.new_timer()
local timer = vim.uv.new_timer()
if not timer then
return
end
@@ -447,7 +442,7 @@ function M.is_executable(absolute_path)
--- executable detection on windows is buggy and not performant hence it is disabled
return false
else
return vim.loop.fs_access(absolute_path, "X") or false
return vim.uv.fs_access(absolute_path, "X") or false
end
end

View File

@@ -85,27 +85,14 @@ end
local function set_window_options_and_buffer()
pcall(vim.api.nvim_command, "buffer " .. M.get_bufnr())
if vim.fn.has("nvim-0.10") == 1 then
local eventignore = vim.api.nvim_get_option_value("eventignore", {})
vim.api.nvim_set_option_value("eventignore", "all", {})
local eventignore = vim.api.nvim_get_option_value("eventignore", {})
vim.api.nvim_set_option_value("eventignore", "all", {})
for k, v in pairs(view_state.Active.winopts) do
vim.api.nvim_set_option_value(k, v, { scope = "local" })
end
vim.api.nvim_set_option_value("eventignore", eventignore, {})
else
local eventignore = vim.api.nvim_get_option("eventignore") ---@diagnostic disable-line: deprecated
vim.api.nvim_set_option("eventignore", "all") ---@diagnostic disable-line: deprecated
-- #3009 vim.api.nvim_win_set_option does not set local scope without explicit winid.
-- Revert to opt_local instead of propagating it through for just the 0.10 path.
for k, v in pairs(view_state.Active.winopts) do
vim.opt_local[k] = v
end
vim.api.nvim_set_option("eventignore", eventignore) ---@diagnostic disable-line: deprecated
for k, v in pairs(view_state.Active.winopts) do
vim.api.nvim_set_option_value(k, v, { scope = "local" })
end
vim.api.nvim_set_option_value("eventignore", eventignore, {})
end
---@return vim.api.keyset.win_config

View File

@@ -66,7 +66,7 @@ function Event:start()
local rc, _, name
self.fs_event, _, name = vim.loop.new_fs_event()
self.fs_event, _, name = vim.uv.new_fs_event()
if not self.fs_event then
self.fs_event = nil
notify.warn(string.format("Could not initialize an fs_event watcher for path %s : %s", self.path, name))
@@ -262,7 +262,7 @@ function M.is_fs_event_capable(path)
return true
end
local fs_event = vim.loop.new_fs_event()
local fs_event = vim.uv.new_fs_event()
if not fs_event then
return false
end

View File

@@ -22,7 +22,6 @@ local srcs_config = {
{ helptag = "nvim-tree-config-renderer", section = "Config: renderer", path = base .. "_meta/config/renderer.lua", },
{ helptag = "nvim-tree-config-hijack-directories", section = "Config: hijack_directories", path = base .. "_meta/config/hijack_directories.lua", },
{ helptag = "nvim-tree-config-update-focused-file", section = "Config: update_focused_file", path = base .. "_meta/config/update_focused_file.lua", },
{ helptag = "nvim-tree-config-system-open", section = "Config: system_open", path = base .. "_meta/config/system_open.lua", },
{ helptag = "nvim-tree-config-git", section = "Config: git", path = base .. "_meta/config/git.lua", },
{ helptag = "nvim-tree-config-diagnostics", section = "Config: diagnostics", path = base .. "_meta/config/diagnostics.lua", },
{ helptag = "nvim-tree-config-modified", section = "Config: modified", path = base .. "_meta/config/modified.lua", },