Skip to content

Commit 2da6177

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

12 files changed

Lines changed: 33 additions & 146 deletions

File tree

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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/node/open-file.lua

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ local function usable_win_ids()
3838
return vim.tbl_filter(function(id)
3939
local bufid = vim.api.nvim_win_get_buf(id)
4040
for option, v in pairs(config.g.actions.open_file.window_picker.exclude) do
41-
local ok, option_value
42-
if vim.fn.has("nvim-0.10") == 1 then
43-
ok, option_value = pcall(vim.api.nvim_get_option_value, option, { buf = bufid })
44-
else
45-
ok, option_value = pcall(vim.api.nvim_buf_get_option, bufid, option) ---@diagnostic disable-line: deprecated
46-
end
41+
local ok, option_value = pcall(vim.api.nvim_get_option_value, option, { buf = bufid })
4742

4843
if ok and vim.tbl_contains(v, option_value) then
4944
return false
@@ -105,53 +100,32 @@ local function pick_win_id()
105100

106101
if laststatus == 3 then
107102
for _, win_id in ipairs(not_selectable) do
108-
local ok_status, statusline
109-
110-
if vim.fn.has("nvim-0.10") == 1 then
111-
ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = win_id })
112-
else
113-
ok_status, statusline = pcall(vim.api.nvim_win_get_option, win_id, "statusline") ---@diagnostic disable-line: deprecated
114-
end
103+
local ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = win_id })
115104

116105
win_opts_unselectable[win_id] = {
117106
statusline = ok_status and statusline or "",
118107
}
119108

120109
-- Clear statusline for windows not selectable
121-
if vim.fn.has("nvim-0.10") == 1 then
122-
vim.api.nvim_set_option_value("statusline", " ", { win = win_id })
123-
else
124-
vim.api.nvim_win_set_option(win_id, "statusline", " ") ---@diagnostic disable-line: deprecated
125-
end
110+
vim.api.nvim_set_option_value("statusline", " ", { win = win_id })
126111
end
127112
end
128113

129114
-- Setup UI
130115
for _, id in ipairs(selectable) do
131116
local char = config.g.actions.open_file.window_picker.chars:sub(i, i)
132117

133-
local ok_status, statusline, ok_hl, winhl
134-
if vim.fn.has("nvim-0.10") == 1 then
135-
ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = id })
136-
ok_hl, winhl = pcall(vim.api.nvim_get_option_value, "winhl", { win = id })
137-
else
138-
ok_status, statusline = pcall(vim.api.nvim_win_get_option, id, "statusline") ---@diagnostic disable-line: deprecated
139-
ok_hl, winhl = pcall(vim.api.nvim_win_get_option, id, "winhl") ---@diagnostic disable-line: deprecated
140-
end
118+
local ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = id })
119+
local ok_hl, winhl = pcall(vim.api.nvim_get_option_value, "winhl", { win = id })
141120

142121
win_opts_selectable[id] = {
143122
statusline = ok_status and statusline or "",
144123
winhl = ok_hl and winhl or "",
145124
}
146125
win_map[char] = id
147126

148-
if vim.fn.has("nvim-0.10") == 1 then
149-
vim.api.nvim_set_option_value("statusline", "%=" .. char .. "%=", { win = id })
150-
vim.api.nvim_set_option_value("winhl", "StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker", { win = id })
151-
else
152-
vim.api.nvim_win_set_option(id, "statusline", "%=" .. char .. "%=") ---@diagnostic disable-line: deprecated
153-
vim.api.nvim_win_set_option(id, "winhl", "StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker") ---@diagnostic disable-line: deprecated
154-
end
127+
vim.api.nvim_set_option_value("statusline", "%=" .. char .. "%=", { win = id })
128+
vim.api.nvim_set_option_value("winhl", "StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker", { win = id })
155129

156130
i = i + 1
157131
if i > #config.g.actions.open_file.window_picker.chars then
@@ -170,11 +144,7 @@ local function pick_win_id()
170144
-- Restore window options
171145
for _, id in ipairs(selectable) do
172146
for opt, value in pairs(win_opts_selectable[id]) do
173-
if vim.fn.has("nvim-0.10") == 1 then
174-
vim.api.nvim_set_option_value(opt, value, { win = id })
175-
else
176-
vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated
177-
end
147+
vim.api.nvim_set_option_value(opt, value, { win = id })
178148
end
179149
end
180150

@@ -183,11 +153,7 @@ local function pick_win_id()
183153
-- Ensure window still exists at this point
184154
if vim.api.nvim_win_is_valid(id) then
185155
for opt, value in pairs(win_opts_unselectable[id]) do
186-
if vim.fn.has("nvim-0.10") == 1 then
187-
vim.api.nvim_set_option_value(opt, value, { win = id })
188-
else
189-
vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated
190-
end
156+
vim.api.nvim_set_option_value(opt, value, { win = id })
191157
end
192158
end
193159
end
@@ -341,12 +307,7 @@ local function open_in_new_window(filename, mode)
341307
-- modified, and create new split if it is.
342308
local target_bufid = vim.api.nvim_win_get_buf(target_winid)
343309

344-
local modified
345-
if vim.fn.has("nvim-0.10") == 1 then
346-
modified = vim.api.nvim_get_option_value("modified", { buf = target_bufid })
347-
else
348-
modified = vim.api.nvim_buf_get_option(target_bufid, "modified") ---@diagnostic disable-line: deprecated
349-
end
310+
local modified = vim.api.nvim_get_option_value("modified", { buf = target_bufid })
350311

351312
if modified then
352313
if not mode:match("split$") then

lua/nvim-tree/actions/tree/change-root.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ local M = {}
1010
function M.fn(path, bufnr)
1111
-- skip if current file is in ignore_list
1212
if type(bufnr) == "number" then
13-
local ft
14-
15-
if vim.fn.has("nvim-0.10") == 1 then
16-
ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) or ""
17-
else
18-
ft = vim.api.nvim_buf_get_option(bufnr, "filetype") or "" ---@diagnostic disable-line: deprecated
19-
end
13+
local ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) or ""
2014

2115
for _, value in pairs(config.g.update_focused_file.update_root.ignore_list) do
2216
if utils.str_find(path, value) or utils.str_find(ft, value) then

lua/nvim-tree/actions/tree/open.lua

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ function M.tab_enter()
7373
if view.is_visible({ any_tabpage = true }) then
7474
local bufname = vim.api.nvim_buf_get_name(0)
7575

76-
local ft
77-
if vim.fn.has("nvim-0.10") == 1 then
78-
ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) or ""
79-
else
80-
ft = vim.api.nvim_buf_get_option(0, "ft") ---@diagnostic disable-line: deprecated
81-
end
76+
local ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) or ""
8277

8378
for _, filter in ipairs(config.g.tab.sync.ignore) do
8479
if bufname:match(filter) ~= nil or ft:match(filter) ~= nil then

lua/nvim-tree/appearance/hi-test.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,7 @@ return function()
138138
render_displays("other, long", displays_long, bufnr, l)
139139

140140
-- finalise and focus the buffer
141-
if vim.fn.has("nvim-0.10") == 1 then
142-
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
143-
else
144-
vim.api.nvim_buf_set_option(bufnr, "modifiable", false) ---@diagnostic disable-line: deprecated
145-
end
141+
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
146142

147143
vim.cmd.buffer(bufnr)
148144
end

lua/nvim-tree/explorer/live-filter.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,8 @@ local function create_overlay(self)
189189
style = "minimal",
190190
})
191191

192-
if vim.fn.has("nvim-0.10") == 1 then
193-
vim.api.nvim_set_option_value("modifiable", true, { buf = overlay_bufnr })
194-
vim.api.nvim_set_option_value("filetype", "NvimTreeFilter", { buf = overlay_bufnr })
195-
else
196-
vim.api.nvim_buf_set_option(overlay_bufnr, "modifiable", true) ---@diagnostic disable-line: deprecated
197-
vim.api.nvim_buf_set_option(overlay_bufnr, "filetype", "NvimTreeFilter") ---@diagnostic disable-line: deprecated
198-
end
192+
vim.api.nvim_set_option_value("modifiable", true, { buf = overlay_bufnr })
193+
vim.api.nvim_set_option_value("filetype", "NvimTreeFilter", { buf = overlay_bufnr })
199194

200195
vim.api.nvim_buf_set_lines(overlay_bufnr, 0, -1, false, { self.filter })
201196
vim.cmd("startinsert")

lua/nvim-tree/git/utils.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ end
2525
---@return string stdout
2626
---@return integer exit code
2727
local function system(cmd)
28-
if vim.fn.has("nvim-0.10") == 1 then
29-
local obj = vim.system(cmd):wait(config.g.git.timeout)
30-
return obj.stdout or "", obj.code
31-
else
32-
return vim.fn.system(cmd), vim.v.shell_error
33-
end
28+
local obj = vim.system(cmd):wait(config.g.git.timeout)
29+
return obj.stdout or "", obj.code
3430
end
3531

3632
--- Retrieve the git toplevel directory

lua/nvim-tree/help.lua

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,7 @@ local function open()
203203

204204
-- populate it
205205
vim.api.nvim_buf_set_lines(M.bufnr, 0, -1, false, lines)
206-
207-
if vim.fn.has("nvim-0.10") == 1 then
208-
vim.api.nvim_set_option_value("modifiable", false, { buf = M.bufnr })
209-
else
210-
vim.api.nvim_buf_set_option(M.bufnr, "modifiable", false) ---@diagnostic disable-line: deprecated
211-
end
206+
vim.api.nvim_set_option_value("modifiable", false, { buf = M.bufnr })
212207

213208
-- highlight it
214209
for _, args in ipairs(hl_range_args) do

lua/nvim-tree/lib.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,8 @@ local function should_hijack_current_buf()
4747
local bufname = vim.api.nvim_buf_get_name(bufnr)
4848

4949
local bufmodified, ft
50-
if vim.fn.has("nvim-0.10") == 1 then
51-
bufmodified = vim.api.nvim_get_option_value("modified", { buf = bufnr })
52-
ft = vim.api.nvim_get_option_value("ft", { buf = bufnr })
53-
else
54-
bufmodified = vim.api.nvim_buf_get_option(bufnr, "modified") ---@diagnostic disable-line: deprecated
55-
ft = vim.api.nvim_buf_get_option(bufnr, "ft") ---@diagnostic disable-line: deprecated
56-
end
50+
bufmodified = vim.api.nvim_get_option_value("modified", { buf = bufnr })
51+
ft = vim.api.nvim_get_option_value("ft", { buf = bufnr })
5752

5853
local should_hijack_unnamed = config.g.hijack_unnamed_buffer_when_opening and bufname == "" and not bufmodified and ft == ""
5954
local should_hijack_dir = bufname ~= "" and vim.fn.isdirectory(bufname) == 1 and config.g.hijack_directories.enable

lua/nvim-tree/renderer/init.lua

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,12 @@ end
3737
---@param extmarks table[] extra marks for right icon placement
3838
---@param virtual_lines table[] virtual lines for hidden count display
3939
function Renderer:_draw(bufnr, lines, hl_range_args, signs, extmarks, virtual_lines)
40-
if vim.fn.has("nvim-0.10") == 1 then
41-
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })
42-
else
43-
vim.api.nvim_buf_set_option(bufnr, "modifiable", true) ---@diagnostic disable-line: deprecated
44-
end
40+
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })
4541

4642
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
4743
self:render_hl(bufnr, hl_range_args)
4844

49-
if vim.fn.has("nvim-0.10") == 1 then
50-
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
51-
else
52-
vim.api.nvim_buf_set_option(bufnr, "modifiable", false) ---@diagnostic disable-line: deprecated
53-
end
45+
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
5446

5547
vim.fn.sign_unplace(SIGN_GROUP)
5648
for i, sign_name in pairs(signs) do

0 commit comments

Comments
 (0)