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
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
37 changes: 5 additions & 32 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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*

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/_meta/api/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions lua/nvim-tree/_meta/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down
24 changes: 0 additions & 24 deletions lua/nvim-tree/_meta/config/system_open.lua

This file was deleted.

2 changes: 1 addition & 1 deletion lua/nvim-tree/actions/finders/find-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 9 additions & 23 deletions lua/nvim-tree/actions/finders/search-node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -74,32 +74,18 @@ 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
return
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
Expand Down
20 changes: 10 additions & 10 deletions lua/nvim-tree/actions/fs/clipboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -64,15 +64,15 @@ 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
end
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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 "???"))
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lua/nvim-tree/actions/fs/create-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Loading
Loading