add helper file to deal with aliases
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
local logger = require('dep.log')
|
local logger = require('dep.log')
|
||||||
local git = require('dep.git')
|
local git = require('dep.git')
|
||||||
local packager = require('dep.package')
|
local packager = require('dep.package')
|
||||||
|
local h = require('dep.helpers')
|
||||||
|
|
||||||
-- all functions for convenience
|
-- all functions for convenience
|
||||||
local M = {}
|
local M = {}
|
||||||
@ -45,7 +46,7 @@ end
|
|||||||
|
|
||||||
--- clean out old packages
|
--- clean out old packages
|
||||||
function M.clean()
|
function M.clean()
|
||||||
vim.loop.fs_scandir(
|
h.uv.fs_scandir(
|
||||||
packager.get_base_dir(),
|
packager.get_base_dir(),
|
||||||
vim.schedule_wrap(function(err, handle)
|
vim.schedule_wrap(function(err, handle)
|
||||||
if err then
|
if err then
|
||||||
@ -54,7 +55,7 @@ function M.clean()
|
|||||||
local queue = {}
|
local queue = {}
|
||||||
|
|
||||||
while handle do
|
while handle do
|
||||||
local name = vim.loop.fs_scandir_next(handle)
|
local name = h.uv.fs_scandir_next(handle)
|
||||||
if name then
|
if name then
|
||||||
queue[name] = packager.get_base_dir()..name
|
queue[name] = packager.get_base_dir()..name
|
||||||
else
|
else
|
||||||
@ -221,7 +222,7 @@ return function(opts)
|
|||||||
vim.opt_local.readonly = true
|
vim.opt_local.readonly = true
|
||||||
|
|
||||||
-- make the log auto update while it's open
|
-- make the log auto update while it's open
|
||||||
local w = vim.uv.new_fs_event()
|
local w = h.uv.new_fs_event()
|
||||||
local function watch_file(fname)
|
local function watch_file(fname)
|
||||||
local fullpath = vim.api.nvim_call_function(
|
local fullpath = vim.api.nvim_call_function(
|
||||||
'fnamemodify', { fname, ':p' })
|
'fnamemodify', { fname, ':p' })
|
||||||
|
4
lua/dep/helpers.lua
Normal file
4
lua/dep/helpers.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
return {
|
||||||
|
-- vim.loop was depricated in nvim 0.10
|
||||||
|
uv = vim.uv or vim.loop
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
local h = require('dep.helpers')
|
||||||
|
|
||||||
local logger = {}
|
local logger = {}
|
||||||
|
|
||||||
logger.stage_colors = {
|
logger.stage_colors = {
|
||||||
@ -14,8 +16,8 @@ logger.stage_colors = {
|
|||||||
local function default_log_path()
|
local function default_log_path()
|
||||||
-- create cache directory and chmod it if it doesn't already exist
|
-- create cache directory and chmod it if it doesn't already exist
|
||||||
local path = vim.fn.stdpath("cache")
|
local path = vim.fn.stdpath("cache")
|
||||||
if not vim.loop.fs_stat(path) then
|
if not h.uv.fs_stat(path) then
|
||||||
vim.loop.fs_mkdir(path, 0x1ff) -- 0777
|
h.uv.fs_mkdir(path, 0x1ff) -- 0777
|
||||||
end
|
end
|
||||||
|
|
||||||
return vim.fs.normalize(path).."/dep.log"
|
return vim.fs.normalize(path).."/dep.log"
|
||||||
@ -37,8 +39,8 @@ function logger:setup(path)
|
|||||||
logger.path = path or default_log_path()
|
logger.path = path or default_log_path()
|
||||||
local pipe
|
local pipe
|
||||||
|
|
||||||
logger.handle = assert(vim.loop.fs_open(logger.path, "w", 0x1a4)) -- 0644
|
logger.handle = assert(h.uv.fs_open(logger.path, "w", 0x1a4)) -- 0644
|
||||||
pipe = vim.loop.new_pipe()
|
pipe = h.uv.new_pipe()
|
||||||
pipe:open(logger.handle)
|
pipe:open(logger.handle)
|
||||||
|
|
||||||
return pipe
|
return pipe
|
||||||
@ -90,7 +92,7 @@ function logger:cleanup(pipe, handle)
|
|||||||
pipe = nil
|
pipe = nil
|
||||||
end
|
end
|
||||||
if handle then
|
if handle then
|
||||||
vim.loop.fs_close(logger.handle)
|
h.uv.fs_close(logger.handle)
|
||||||
handle = nil
|
handle = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user