fix: replace vim.* "requires" with explicit calls to vim functions (#1701)

This commit is contained in:
Alexander Courtis
2022-11-06 10:37:33 +11:00
committed by GitHub
parent 6d6a44626d
commit 8cc369695b
30 changed files with 263 additions and 321 deletions

View File

@@ -1,5 +1,3 @@
local uv = vim.loop
local log = require "nvim-tree.log"
local utils = require "nvim-tree.utils"
local git_utils = require "nvim-tree.git.utils"
@@ -74,7 +72,7 @@ function M.get_project_root(cwd)
return nil
end
local stat, _ = uv.fs_stat(cwd)
local stat, _ = vim.loop.fs_stat(cwd)
if not stat or stat.type ~= "directory" then
return nil
end

View File

@@ -1,4 +1,3 @@
local uv = vim.loop
local log = require "nvim-tree.log"
local utils = require "nvim-tree.utils"
@@ -60,9 +59,9 @@ end
function Runner:_run_git_job()
local handle, pid
local stdout = uv.new_pipe(false)
local stderr = uv.new_pipe(false)
local timer = uv.new_timer()
local stdout = vim.loop.new_pipe(false)
local stderr = vim.loop.new_pipe(false)
local timer = vim.loop.new_timer()
local function on_finish(rc)
self.rc = rc or 0
@@ -79,14 +78,14 @@ function Runner:_run_git_job()
handle:close()
end
pcall(uv.kill, pid)
pcall(vim.loop.kill, pid)
end
local opts = self:_getopts(stdout, stderr)
log.line("git", "running job with timeout %dms", self.timeout)
log.line("git", "git %s", table.concat(utils.array_remove_nils(opts.args), " "))
handle, pid = uv.spawn(
handle, pid = vim.loop.spawn(
"git",
opts,
vim.schedule_wrap(function(rc)
@@ -115,8 +114,8 @@ function Runner:_run_git_job()
self:_log_raw_output(data)
end
uv.read_start(stdout, vim.schedule_wrap(manage_stdout))
uv.read_start(stderr, vim.schedule_wrap(manage_stderr))
vim.loop.read_start(stdout, vim.schedule_wrap(manage_stdout))
vim.loop.read_start(stderr, vim.schedule_wrap(manage_stderr))
end
function Runner:_wait()