diff --git a/lua/dep.lua b/lua/dep.lua index 098eff4..e876401 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -1,6 +1,7 @@ local logger = require('dep.log') local git = require('dep.git') local packager = require('dep.package') +local h = require('dep.helpers') -- all functions for convenience local M = {} @@ -45,7 +46,7 @@ end --- clean out old packages function M.clean() - vim.loop.fs_scandir( + h.uv.fs_scandir( packager.get_base_dir(), vim.schedule_wrap(function(err, handle) if err then @@ -54,7 +55,7 @@ function M.clean() local queue = {} while handle do - local name = vim.loop.fs_scandir_next(handle) + local name = h.uv.fs_scandir_next(handle) if name then queue[name] = packager.get_base_dir()..name else @@ -221,7 +222,7 @@ return function(opts) vim.opt_local.readonly = true -- 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 fullpath = vim.api.nvim_call_function( 'fnamemodify', { fname, ':p' }) diff --git a/lua/dep/helpers.lua b/lua/dep/helpers.lua new file mode 100644 index 0000000..7bd9273 --- /dev/null +++ b/lua/dep/helpers.lua @@ -0,0 +1,4 @@ +return { + -- vim.loop was depricated in nvim 0.10 + uv = vim.uv or vim.loop +} diff --git a/lua/dep/log.lua b/lua/dep/log.lua index a127d77..f045250 100644 --- a/lua/dep/log.lua +++ b/lua/dep/log.lua @@ -1,3 +1,5 @@ +local h = require('dep.helpers') + local logger = {} logger.stage_colors = { @@ -14,8 +16,8 @@ logger.stage_colors = { local function default_log_path() -- create cache directory and chmod it if it doesn't already exist local path = vim.fn.stdpath("cache") - if not vim.loop.fs_stat(path) then - vim.loop.fs_mkdir(path, 0x1ff) -- 0777 + if not h.uv.fs_stat(path) then + h.uv.fs_mkdir(path, 0x1ff) -- 0777 end return vim.fs.normalize(path).."/dep.log" @@ -37,8 +39,8 @@ function logger:setup(path) logger.path = path or default_log_path() local pipe - logger.handle = assert(vim.loop.fs_open(logger.path, "w", 0x1a4)) -- 0644 - pipe = vim.loop.new_pipe() + logger.handle = assert(h.uv.fs_open(logger.path, "w", 0x1a4)) -- 0644 + pipe = h.uv.new_pipe() pipe:open(logger.handle) return pipe @@ -90,7 +92,7 @@ function logger:cleanup(pipe, handle) pipe = nil end if handle then - vim.loop.fs_close(logger.handle) + h.uv.fs_close(logger.handle) handle = nil end end