fix: replace vim.* "requires" with explicit calls to vim functions (#1701)
This commit is contained in:
committed by
GitHub
parent
6d6a44626d
commit
8cc369695b
@@ -12,19 +12,17 @@ local Builder = require "nvim-tree.renderer.builder"
|
||||
local live_filter = require "nvim-tree.live-filter"
|
||||
local marks = require "nvim-tree.marks"
|
||||
|
||||
local api = vim.api
|
||||
|
||||
local M = {
|
||||
last_highlights = {},
|
||||
}
|
||||
|
||||
local namespace_id = api.nvim_create_namespace "NvimTreeHighlights"
|
||||
local namespace_id = vim.api.nvim_create_namespace "NvimTreeHighlights"
|
||||
|
||||
local function _draw(bufnr, lines, hl, signs)
|
||||
api.nvim_buf_set_option(bufnr, "modifiable", true)
|
||||
api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
||||
vim.api.nvim_buf_set_option(bufnr, "modifiable", true)
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
||||
M.render_hl(bufnr, hl)
|
||||
api.nvim_buf_set_option(bufnr, "modifiable", false)
|
||||
vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
|
||||
vim.fn.sign_unplace(git.SIGN_GROUP)
|
||||
for _, sign in pairs(signs) do
|
||||
vim.fn.sign_place(0, git.SIGN_GROUP, sign.sign, bufnr, { lnum = sign.lnum, priority = 1 })
|
||||
@@ -32,12 +30,12 @@ local function _draw(bufnr, lines, hl, signs)
|
||||
end
|
||||
|
||||
function M.render_hl(bufnr, hl)
|
||||
if not bufnr or not api.nvim_buf_is_loaded(bufnr) then
|
||||
if not bufnr or not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
api.nvim_buf_clear_namespace(bufnr, namespace_id, 0, -1)
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, namespace_id, 0, -1)
|
||||
for _, data in ipairs(hl or M.last_highlights) do
|
||||
api.nvim_buf_add_highlight(bufnr, namespace_id, data[1], data[2], data[3], data[4])
|
||||
vim.api.nvim_buf_add_highlight(bufnr, namespace_id, data[1], data[2], data[3], data[4])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,13 +48,13 @@ local picture_map = {
|
||||
|
||||
function M.draw()
|
||||
local bufnr = view.get_bufnr()
|
||||
if not core.get_explorer() or not bufnr or not api.nvim_buf_is_loaded(bufnr) then
|
||||
if not core.get_explorer() or not bufnr or not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
local ps = log.profile_start "draw"
|
||||
|
||||
local cursor = api.nvim_win_get_cursor(view.get_winnr())
|
||||
local cursor = vim.api.nvim_win_get_cursor(view.get_winnr())
|
||||
icon_component.reset_config()
|
||||
|
||||
local lines, hl
|
||||
@@ -84,7 +82,7 @@ function M.draw()
|
||||
M.last_highlights = hl
|
||||
|
||||
if cursor and #lines >= cursor[1] then
|
||||
api.nvim_win_set_cursor(view.get_winnr(), cursor)
|
||||
vim.api.nvim_win_set_cursor(view.get_winnr(), cursor)
|
||||
end
|
||||
|
||||
if view.is_help_ui() then
|
||||
|
||||
Reference in New Issue
Block a user