make dep only require nvim 0.8, and make the lazy utils better
This commit is contained in:
@ -38,7 +38,7 @@ function M.registertree(speclist, overrides)
|
|||||||
|
|
||||||
-- if erroring print out the spec and the error
|
-- if erroring print out the spec and the error
|
||||||
if not ok then
|
if not ok then
|
||||||
error(string.format("%s (spec=%s)", err, vim.inspect(spec)))
|
error(string.format("(spec=%s)", vim.inspect(spec)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -226,7 +226,7 @@ return function(opts)
|
|||||||
local fullpath = vim.api.nvim_call_function(
|
local fullpath = vim.api.nvim_call_function(
|
||||||
'fnamemodify', { fname, ':p' })
|
'fnamemodify', { fname, ':p' })
|
||||||
w:start(fullpath, {}, vim.schedule_wrap(function(...)
|
w:start(fullpath, {}, vim.schedule_wrap(function(...)
|
||||||
vim.api.nvim_command('checktime')
|
vim.cmd('checktime')
|
||||||
w:stop()
|
w:stop()
|
||||||
watch_file(fname)
|
watch_file(fname)
|
||||||
end))
|
end))
|
||||||
|
@ -18,7 +18,7 @@ local function default_log_path()
|
|||||||
vim.loop.fs_mkdir(path, 0x1ff) -- 0777
|
vim.loop.fs_mkdir(path, 0x1ff) -- 0777
|
||||||
end
|
end
|
||||||
|
|
||||||
return vim.fs.joinpath(path, "/dep.log")
|
return vim.fs.normalize(path).."/dep.log"
|
||||||
end
|
end
|
||||||
|
|
||||||
--- attempt to format a string
|
--- attempt to format a string
|
||||||
|
@ -331,7 +331,7 @@ end
|
|||||||
--- set the base directory for packages
|
--- set the base directory for packages
|
||||||
---@param _base_dir string base directory
|
---@param _base_dir string base directory
|
||||||
function package.set_base_dir(_base_dir)
|
function package.set_base_dir(_base_dir)
|
||||||
base_dir = _base_dir
|
base_dir = vim.fs.normalize(_base_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- get the base directory for packages
|
--- get the base directory for packages
|
||||||
|
@ -54,6 +54,7 @@ function lazy:auto(event, opts)
|
|||||||
self:cleanup()
|
self:cleanup()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- create the auto command and save it
|
||||||
table.insert(self.auto_ids, vim.api.nvim_create_autocmd(event, opts))
|
table.insert(self.auto_ids, vim.api.nvim_create_autocmd(event, opts))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,12 +64,21 @@ end
|
|||||||
---@param opts vim.keymap.set.Opts? options
|
---@param opts vim.keymap.set.Opts? options
|
||||||
function lazy:keymap(mode, bind, opts)
|
function lazy:keymap(mode, bind, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
|
-- move the rerun arg to a seperate variable because keymap.set doesn't like
|
||||||
|
-- options it doesn't know of
|
||||||
|
local rerun = opts['rerun'] or true
|
||||||
|
opts['rerun'] = nil
|
||||||
|
|
||||||
vim.keymap.set(mode, bind, opts['callback'] or function()
|
vim.keymap.set(mode, bind, opts['callback'] or function()
|
||||||
|
-- register keymap unload
|
||||||
self:cleanup()
|
self:cleanup()
|
||||||
|
|
||||||
-- register keymap unload
|
-- call the keymap after the user has mapped it
|
||||||
local keys = vim.api.nvim_replace_termcodes(bind, true, false, true)
|
if rerun then
|
||||||
vim.api.nvim_feedkeys(keys, mode, false)
|
local keys = vim.api.nvim_replace_termcodes(bind, true, false, true)
|
||||||
|
vim.api.nvim_input(keys)
|
||||||
|
end
|
||||||
end, opts)
|
end, opts)
|
||||||
|
|
||||||
table.insert(self.keybind_ids, { ['mode'] = mode, ['bind'] = bind })
|
table.insert(self.keybind_ids, { ['mode'] = mode, ['bind'] = bind })
|
||||||
@ -77,16 +87,16 @@ end
|
|||||||
--- cleanup all the callbacks, and load the plugin
|
--- cleanup all the callbacks, and load the plugin
|
||||||
function lazy:cleanup()
|
function lazy:cleanup()
|
||||||
-- cleanup user commands
|
-- cleanup user commands
|
||||||
for _, v in pairs(self.command_ids) do
|
for _, command_id in pairs(self.command_ids) do
|
||||||
vim.api.nvim_del_user_command(v)
|
vim.api.nvim_del_user_command(command_id)
|
||||||
end
|
end
|
||||||
-- cleanup auto commands
|
-- cleanup auto commands
|
||||||
for _, v in pairs(self.auto_ids) do
|
for _, auto_id in pairs(self.auto_ids) do
|
||||||
vim.api.nvim_del_autocmd(v)
|
vim.api.nvim_del_autocmd(auto_id)
|
||||||
end
|
end
|
||||||
-- cleanup keymaps
|
-- cleanup keymaps
|
||||||
for _, v in pairs(self.keybind_ids) do
|
for _, keybind_id in pairs(self.keybind_ids) do
|
||||||
vim.keymap.del(v['mode'], v['bind'], {})
|
vim.keymap.del(keybind_id.mode, keybind_id.bind, {})
|
||||||
end
|
end
|
||||||
-- load the plugin
|
-- load the plugin
|
||||||
self:load()
|
self:load()
|
||||||
|
Reference in New Issue
Block a user