Skip to content

Commit 7adc567

Browse files
authored
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
1 parent 31503ad commit 7adc567

39 files changed

+125
-357
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ Whenever new neovim API is introduced, please ensure that it is available in old
132132
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.
133133

134134
```lua
135-
if vim.fn.has("nvim-0.10") == 1 then
136-
modified = vim.api.nvim_get_option_value("modified", { buf = target_bufid })
135+
if vim.fn.has("nvim-0.11") == 1 and vim.hl and vim.hl.range then
136+
vim.hl.range(0, ns_id, details.hl_group, { 0, col }, { 0, details.end_col, }, {})
137137
else
138-
modified = vim.api.nvim_buf_get_option(target_bufid, "modified") ---@diagnostic disable-line: deprecated
138+
vim.api.nvim_buf_add_highlight(0, ns_id, details.hl_group, 0, col, details.end_col) ---@diagnostic disable-line: deprecated
139139
end
140140
```
141141

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ markdown-toc --maxdepth=2 -i README.md
5151

5252
# Requirements
5353

54-
[neovim >=0.9.0](https://github.com/neovim/neovim/wiki/Installing-Neovim)
54+
[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.
5555

5656
[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"
5757

doc/nvim-tree-lua.txt

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ Git Integration
5252

5353
Requirements
5454

55-
Nvim >= 0.9
55+
Nvim >= 0.10.
56+
At least `n - 0.1` stable Nvim compatibility is guaranteed.
57+
You may use a `compat-nvim-0.X` tag for earlier Nvim versions, however
58+
they will receive no updates or support.
5659

5760
==============================================================================
5861
Quickstart *nvim-tree-quickstart*
@@ -1041,8 +1044,6 @@ Config *nvim-tree-config*
10411044
|nvim_tree.config.hijack_directories|
10421045
• {update_focused_file}? (`nvim_tree.config.update_focused_file`)
10431046
|nvim_tree.config.update_focused_file|
1044-
• {system_open}? (`nvim_tree.config.system_open`)
1045-
|nvim_tree.config.system_open|
10461047
{git}? (`nvim_tree.config.git`)
10471048
|nvim_tree.config.git|
10481049
{diagnostics}? (`nvim_tree.config.diagnostics`)
@@ -1498,30 +1499,6 @@ Config: update_focused_file *nvim-tree-config-update-focused-file*
14981499

14991500

15001501

1501-
==============================================================================
1502-
Config: system_open *nvim-tree-config-system-open*
1503-
1504-
*nvim_tree.config.system_open*
1505-
Open files or directories via the OS.
1506-
1507-
Nvim:
1508-
`>=` 0.10 uses |vim.ui.open()| unless {cmd} is specified
1509-
`<` 0.10 calls external {cmd}:
1510-
• UNIX: `xdg-open`
1511-
• macOS: `open`
1512-
• Windows: `cmd`
1513-
1514-
Once nvim-tree minimum Nvim version is updated to 0.10, this configuration
1515-
will no longer be necessary and will be removed.
1516-
1517-
Fields: ~
1518-
{cmd}? (`string`) The open command itself
1519-
{args}? (`string[]`, default: `{}` or `{ "/c", "start", '""' }` on
1520-
windows) Optional argument list. Leave empty for OS specific
1521-
default.
1522-
1523-
1524-
15251502
==============================================================================
15261503
Config: git *nvim-tree-config-git*
15271504

@@ -2154,10 +2131,6 @@ Following is the default configuration, see |nvim_tree.config| for details. >lua
21542131
},
21552132
exclude = false,
21562133
},
2157-
system_open = {
2158-
cmd = "",
2159-
args = {},
2160-
},
21612134
git = {
21622135
enable = true,
21632136
show_on_dirs = true,
@@ -2934,7 +2907,7 @@ run.cmd({node}) *nvim_tree.api.node.run.cmd()*
29342907
{node} (`nvim_tree.api.Node?`) directory or file
29352908

29362909
run.system({node}) *nvim_tree.api.node.run.system()*
2937-
Execute |nvim_tree.config.system_open|.
2910+
Open with the system default handler: |vim.ui.open()|.
29382911

29392912
Parameters: ~
29402913
{node} (`nvim_tree.api.Node?`) directory or file

lua/nvim-tree.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ function M.setup(config_user)
1717
local view_state = require("nvim-tree.view-state")
1818

1919
-- Nvim version check
20-
if vim.fn.has("nvim-0.9") == 0 then
21-
require("nvim-tree.notify").warn("nvim-tree.lua requires Neovim 0.9 or higher")
20+
if vim.fn.has("nvim-0.10") == 0 then
21+
require("nvim-tree.notify").warn(
22+
"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.")
2223
return
2324
end
2425

lua/nvim-tree/_meta/api/node.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ nvim_tree.api.node.run = {}
271271
function nvim_tree.api.node.run.cmd(node) end
272272

273273
---
274-
---Execute [nvim_tree.config.system_open].
274+
---Open with the system default handler: [vim.ui.open()].
275275
---
276276
---@param node? nvim_tree.api.Node directory or file
277277
function nvim_tree.api.node.run.system(node) end

lua/nvim-tree/_meta/config.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ error("Cannot require a meta file")
8787
---[nvim_tree.config.update_focused_file]
8888
---@field update_focused_file? nvim_tree.config.update_focused_file
8989
---
90-
---[nvim_tree.config.system_open]
91-
---@field system_open? nvim_tree.config.system_open
92-
---
9390
---[nvim_tree.config.git]
9491
---@field git? nvim_tree.config.git
9592
---

lua/nvim-tree/_meta/config/system_open.lua

Lines changed: 0 additions & 24 deletions
This file was deleted.

lua/nvim-tree/actions/finders/find-file.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function M.fn(path)
1919
end
2020

2121
-- always match against the real path
22-
local path_real = vim.loop.fs_realpath(path)
22+
local path_real = vim.uv.fs_realpath(path)
2323
if not path_real then
2424
return
2525
end

lua/nvim-tree/actions/finders/search-node.lua

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ local function search(search_dir, input_path)
2525

2626
local filter_status = explorer.filters:prepare()
2727

28-
handle, _ = vim.loop.fs_scandir(dir)
28+
handle, _ = vim.uv.fs_scandir(dir)
2929
if not handle then
3030
return
3131
end
3232

33-
realpath, _ = vim.loop.fs_realpath(dir)
33+
realpath, _ = vim.uv.fs_realpath(dir)
3434
if not realpath or vim.tbl_contains(realpaths_searched, realpath) then
3535
return
3636
end
3737
table.insert(realpaths_searched, realpath)
3838

39-
name, _ = vim.loop.fs_scandir_next(handle)
39+
name, _ = vim.uv.fs_scandir_next(handle)
4040
while name do
4141
path = dir .. "/" .. name
4242

4343
---@type uv.fs_stat.result|nil
44-
stat, _ = vim.loop.fs_stat(path)
44+
stat, _ = vim.uv.fs_stat(path)
4545
if not stat then
4646
break
4747
end
@@ -59,7 +59,7 @@ local function search(search_dir, input_path)
5959
end
6060
end
6161

62-
name, _ = vim.loop.fs_scandir_next(handle)
62+
name, _ = vim.uv.fs_scandir_next(handle)
6363
end
6464
end
6565

@@ -74,32 +74,18 @@ function M.fn()
7474
-- temporarily set &path
7575
local bufnr = vim.api.nvim_get_current_buf()
7676

77-
local path_existed, path_opt
78-
if vim.fn.has("nvim-0.10") == 1 then
79-
path_existed, path_opt = pcall(vim.api.nvim_get_option_value, "path", { buf = bufnr })
80-
vim.api.nvim_set_option_value("path", core.get_cwd() .. "/**", { buf = bufnr })
81-
else
82-
path_existed, path_opt = pcall(vim.api.nvim_buf_get_option, bufnr, "path") ---@diagnostic disable-line: deprecated
83-
vim.api.nvim_buf_set_option(bufnr, "path", core.get_cwd() .. "/**") ---@diagnostic disable-line: deprecated
84-
end
77+
local path_existed, path_opt = pcall(vim.api.nvim_get_option_value, "path", { buf = bufnr })
78+
vim.api.nvim_set_option_value("path", core.get_cwd() .. "/**", { buf = bufnr })
8579

8680
vim.ui.input({ prompt = "Search: ", completion = "file_in_path" }, function(input_path)
8781
if not input_path or input_path == "" then
8882
return
8983
end
9084
-- reset &path
9185
if path_existed then
92-
if vim.fn.has("nvim-0.10") == 1 then
93-
vim.api.nvim_set_option_value("path", path_opt, { buf = bufnr })
94-
else
95-
vim.api.nvim_buf_set_option(bufnr, "path", path_opt) ---@diagnostic disable-line: deprecated
96-
end
86+
vim.api.nvim_set_option_value("path", path_opt, { buf = bufnr })
9787
else
98-
if vim.fn.has("nvim-0.10") == 1 then
99-
vim.api.nvim_set_option_value("path", nil, { buf = bufnr })
100-
else
101-
vim.api.nvim_buf_set_option(bufnr, "path", nil) ---@diagnostic disable-line: deprecated
102-
end
88+
vim.api.nvim_set_option_value("path", nil, { buf = bufnr })
10389
end
10490

10591
-- strip trailing slash

lua/nvim-tree/actions/fs/clipboard.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ end
4848
---@return boolean
4949
---@return string|nil
5050
local function do_copy(source, destination)
51-
local source_stats, err = vim.loop.fs_stat(source)
51+
local source_stats, err = vim.uv.fs_stat(source)
5252

5353
if not source_stats then
5454
log.line("copy_paste", "do_copy fs_stat '%s' failed '%s'", source, err)
@@ -64,15 +64,15 @@ local function do_copy(source, destination)
6464

6565
if source_stats.type == "file" then
6666
local success
67-
success, err = vim.loop.fs_copyfile(source, destination)
67+
success, err = vim.uv.fs_copyfile(source, destination)
6868
if not success then
6969
log.line("copy_paste", "do_copy fs_copyfile failed '%s'", err)
7070
return false, err
7171
end
7272
return true
7373
elseif source_stats.type == "directory" then
7474
local handle
75-
handle, err = vim.loop.fs_scandir(source)
75+
handle, err = vim.uv.fs_scandir(source)
7676
if type(handle) == "string" then
7777
return false, handle
7878
elseif not handle then
@@ -81,14 +81,14 @@ local function do_copy(source, destination)
8181
end
8282

8383
local success
84-
success, err = vim.loop.fs_mkdir(destination, source_stats.mode)
84+
success, err = vim.uv.fs_mkdir(destination, source_stats.mode)
8585
if not success then
8686
log.line("copy_paste", "do_copy fs_mkdir '%s' failed '%s'", destination, err)
8787
return false, err
8888
end
8989

9090
while true do
91-
local name, _ = vim.loop.fs_scandir_next(handle)
91+
local name, _ = vim.uv.fs_scandir_next(handle)
9292
if not name then
9393
break
9494
end
@@ -228,7 +228,7 @@ function Clipboard:resolve_conflicts(conflict, destination, action, action_fn)
228228
self:finish_paste(action)
229229
return
230230
end
231-
if vim.loop.fs_stat(new_dest) then
231+
if vim.uv.fs_stat(new_dest) then
232232
self:resolve_conflicts({ { node = conflict[1].node, dest = new_dest } }, destination, action, action_fn)
233233
else
234234
do_paste_one(source, new_dest, action, action_fn)
@@ -285,7 +285,7 @@ function Clipboard:resolve_conflicts(conflict, destination, action, action_fn)
285285
local extension = vim.fn.fnamemodify(item.node.name, ":e")
286286
local new_name = extension ~= "" and (basename .. suffix .. "." .. extension) or (item.node.name .. suffix)
287287
local new_dest = utils.path_join({ destination, new_name })
288-
local stats = vim.loop.fs_stat(new_dest)
288+
local stats = vim.uv.fs_stat(new_dest)
289289
if stats then
290290
table.insert(still_conflict, { node = item.node, dest = new_dest })
291291
else
@@ -324,7 +324,7 @@ function Clipboard:do_paste(node, action, action_fn)
324324
end
325325

326326
local destination = node.absolute_path
327-
local stats, err, err_name = vim.loop.fs_stat(destination)
327+
local stats, err, err_name = vim.uv.fs_stat(destination)
328328
if not stats and err_name ~= "ENOENT" then
329329
log.line("copy_paste", "do_paste fs_stat '%s' failed '%s'", destination, err)
330330
notify.error("Could not " .. action .. " " .. notify.render_path(destination) .. " - " .. (err or "???"))
@@ -340,7 +340,7 @@ function Clipboard:do_paste(node, action, action_fn)
340340
local conflict = {}
341341
for _, _node in ipairs(clip) do
342342
local dest = utils.path_join({ destination, _node.name })
343-
local dest_stats = vim.loop.fs_stat(dest)
343+
local dest_stats = vim.uv.fs_stat(dest)
344344
if dest_stats then
345345
table.insert(conflict, { node = _node, dest = dest })
346346
else
@@ -374,7 +374,7 @@ local function do_cut(source, destination)
374374
end
375375

376376
events._dispatch_will_rename_node(source, destination)
377-
local success, errmsg = vim.loop.fs_rename(source, destination)
377+
local success, errmsg = vim.uv.fs_rename(source, destination)
378378
if not success then
379379
log.line("copy_paste", "do_cut fs_rename failed '%s'", errmsg)
380380
return false, errmsg

0 commit comments

Comments
 (0)