Skip to content

Commit 0682b5d

Browse files
committed
use api instead of vim.api
1 parent ab7d565 commit 0682b5d

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

lua/nvim-tree.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ end
7373

7474
function M.tab_change()
7575
if view.is_visible { any_tabpage = true } then
76-
local bufname = vim.api.nvim_buf_get_name(0)
76+
local bufname = api.nvim_buf_get_name(0)
7777
if bufname:match "Neogit" ~= nil or bufname:match "--graph" ~= nil then
7878
return
7979
end
@@ -156,7 +156,7 @@ end
156156

157157
local prev_line
158158
function M.place_cursor_on_node()
159-
local l = vim.api.nvim_win_get_cursor(0)[1]
159+
local l = api.nvim_win_get_cursor(0)[1]
160160
if l == prev_line then
161161
return
162162
end
@@ -255,27 +255,27 @@ local function manage_netrw(disable_netrw, hijack_netrw)
255255
end
256256

257257
local function setup_vim_commands()
258-
vim.api.nvim_create_user_command("NvimTreeOpen", function(res)
258+
api.nvim_create_user_command("NvimTreeOpen", function(res)
259259
M.open(res.args)
260260
end, { nargs = "?", complete = "dir" })
261-
vim.api.nvim_create_user_command("NvimTreeClose", view.close, {})
262-
vim.api.nvim_create_user_command("NvimTreeToggle", function()
261+
api.nvim_create_user_command("NvimTreeClose", view.close, {})
262+
api.nvim_create_user_command("NvimTreeToggle", function()
263263
M.toggle(false)
264264
end, {})
265-
vim.api.nvim_create_user_command("NvimTreeFocus", M.focus, {})
266-
vim.api.nvim_create_user_command("NvimTreeRefresh", reloaders.reload_explorer, {})
267-
vim.api.nvim_create_user_command("NvimTreeClipboard", copy_paste.print_clipboard, {})
268-
vim.api.nvim_create_user_command("NvimTreeFindFile", function()
265+
api.nvim_create_user_command("NvimTreeFocus", M.focus, {})
266+
api.nvim_create_user_command("NvimTreeRefresh", reloaders.reload_explorer, {})
267+
api.nvim_create_user_command("NvimTreeClipboard", copy_paste.print_clipboard, {})
268+
api.nvim_create_user_command("NvimTreeFindFile", function()
269269
M.find_file(true)
270270
end, {})
271-
vim.api.nvim_create_user_command("NvimTreeFindFileToggle", function()
271+
api.nvim_create_user_command("NvimTreeFindFileToggle", function()
272272
M.toggle(true)
273273
end, {})
274-
vim.api.nvim_create_user_command("NvimTreeResize", function(res)
274+
api.nvim_create_user_command("NvimTreeResize", function(res)
275275
M.resize(res.args)
276276
end, { nargs = 1 })
277-
vim.api.nvim_create_user_command("NvimTreeCollapse", collapse_all.fn, {})
278-
vim.api.nvim_create_user_command("NvimTreeCollapseKeepBuffers", function()
277+
api.nvim_create_user_command("NvimTreeCollapse", collapse_all.fn, {})
278+
api.nvim_create_user_command("NvimTreeCollapseKeepBuffers", function()
279279
collapse_all.fn(true)
280280
end, {})
281281
end
@@ -289,10 +289,10 @@ function M.change_dir(name)
289289
end
290290

291291
local function setup_autocommands(opts)
292-
local augroup_id = vim.api.nvim_create_augroup("NvimTree", {})
292+
local augroup_id = api.nvim_create_augroup("NvimTree", {})
293293
local function create_nvim_tree_autocmd(name, custom_opts)
294294
local default_opts = { group = augroup_id }
295-
vim.api.nvim_create_autocmd(name, vim.tbl_extend("force", default_opts, custom_opts))
295+
api.nvim_create_autocmd(name, vim.tbl_extend("force", default_opts, custom_opts))
296296
end
297297

298298
-- reset highlights when colorscheme is changed

lua/nvim-tree/actions/file-popup.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ function M.toggle_file_info(node)
7272

7373
setup_window(node)
7474

75-
vim.api.nvim_create_autocmd("CursorMoved", {
76-
group = vim.api.nvim_create_augroup("NvimTreeRemoveFilePopup", {}),
75+
a.nvim_create_autocmd("CursorMoved", {
76+
group = a.nvim_create_augroup("NvimTreeRemoveFilePopup", {}),
7777
callback = M.close_popup,
7878
})
7979
end

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ function M.fn(mode, filename)
258258
if not buf_loaded then
259259
vim.bo.bufhidden = "delete"
260260

261-
vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI" }, {
262-
group = vim.api.nvim_create_augroup("RemoveBufHidden", {}),
263-
buffer = vim.api.nvim_get_current_buf(),
261+
api.nvim_create_autocmd({ "TextChanged", "TextChangedI" }, {
262+
group = api.nvim_create_augroup("RemoveBufHidden", {}),
263+
buffer = api.nvim_get_current_buf(),
264264
callback = function()
265265
vim.bo.bufhidden = ""
266266
end,

0 commit comments

Comments
 (0)