Skip to content

Commit b9b8210

Browse files
committed
feat(#3310): minimum neovim version 0.10
1 parent 2da6177 commit b9b8210

3 files changed

Lines changed: 5 additions & 76 deletions

File tree

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

lua/nvim-tree.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ 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
20+
if vim.fn.has("nvim-0.10") == 0 then
2121
require("nvim-tree.notify").warn("nvim-tree.lua requires Neovim 0.9 or higher")
2222
return
2323
end
Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,9 @@
11
local notify = require("nvim-tree.notify")
2-
local config = require("nvim-tree.config")
32

43
local M = {}
54

65
---@param node Node
7-
local function user(node)
8-
local cmd = config.g.system_open.cmd
9-
local args = config.g.system_open.args
10-
11-
if #cmd == 0 then
12-
if config.os.windows then
13-
cmd = "cmd"
14-
args = { "/c", "start", '""' }
15-
elseif config.os.macos then
16-
cmd = "open"
17-
elseif config.os.unix then
18-
cmd = "xdg-open"
19-
end
20-
end
21-
22-
if #cmd == 0 then
23-
notify.warn("Cannot open file with system application. Unrecognized platform.")
24-
return
25-
end
26-
27-
local process = {
28-
cmd = cmd,
29-
args = args,
30-
errors = "\n",
31-
stderr = vim.loop.new_pipe(false),
32-
}
33-
table.insert(process.args, node.link_to or node.absolute_path)
34-
35-
local opts = {
36-
args = process.args,
37-
stdio = { nil, nil, process.stderr },
38-
detached = true,
39-
}
40-
41-
process.handle, process.pid = vim.loop.spawn(process.cmd, opts, function(code)
42-
process.stderr:read_stop()
43-
process.stderr:close()
44-
process.handle:close()
45-
if code ~= 0 then
46-
notify.warn(string.format("system_open failed with return code %d: %s", code, process.errors))
47-
end
48-
end)
49-
50-
table.remove(process.args)
51-
if not process.handle then
52-
notify.warn(string.format("system_open failed to spawn command '%s': %s", process.cmd, process.pid))
53-
return
54-
end
55-
vim.loop.read_start(process.stderr, function(err, data)
56-
if err then
57-
return
58-
end
59-
if data then
60-
process.errors = process.errors .. data
61-
end
62-
end)
63-
vim.loop.unref(process.handle)
64-
end
65-
66-
---@param node Node
67-
local function native(node)
6+
function M.fn(node)
687
local _, err = vim.ui.open(node.link_to or node.absolute_path)
698

709
-- err only provided on opener executable not found hence logging path is not useful
@@ -73,14 +12,4 @@ local function native(node)
7312
end
7413
end
7514

76-
---@param node Node
77-
function M.fn(node)
78-
-- TODO #2430 always use native once 0.10 is the minimum neovim version
79-
if vim.fn.has("nvim-0.10") == 1 and #config.g.system_open.cmd == 0 then
80-
native(node)
81-
else
82-
user(node)
83-
end
84-
end
85-
8615
return M

0 commit comments

Comments
 (0)