Skip to content

Commit c5ad8b4

Browse files
committed
refactor(#2787): replace deprecated
1 parent 26632f4 commit c5ad8b4

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lua/nvim-tree.lua

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ local M = {
2626
function M.change_root(path, bufnr)
2727
-- skip if current file is in ignore_list
2828
if type(bufnr) == "number" then
29-
local ft = vim.api.nvim_buf_get_option(bufnr, "filetype") or ""
29+
local ft
30+
31+
if vim.fn.has "nvim-0.10" == 1 then
32+
ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) or ""
33+
else
34+
---@diagnostic disable-next-line: deprecated
35+
ft = vim.api.nvim_buf_get_option(bufnr, "filetype") or ""
36+
end
37+
3038
for _, value in pairs(_config.update_focused_file.update_root.ignore_list) do
3139
if utils.str_find(path, value) or utils.str_find(ft, value) then
3240
return
@@ -78,7 +86,15 @@ end
7886
function M.tab_enter()
7987
if view.is_visible { any_tabpage = true } then
8088
local bufname = vim.api.nvim_buf_get_name(0)
81-
local ft = vim.api.nvim_buf_get_option(0, "ft")
89+
90+
local ft
91+
if vim.fn.has "nvim-0.10" == 1 then
92+
ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) or ""
93+
else
94+
---@diagnostic disable-next-line: deprecated
95+
ft = vim.api.nvim_buf_get_option(0, "ft")
96+
end
97+
8298
for _, filter in ipairs(M.config.tab.sync.ignore) do
8399
if bufname:match(filter) ~= nil or ft:match(filter) ~= nil then
84100
return

0 commit comments

Comments
 (0)