mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
refactor: use ctx table for lua autocmd callback
This commit is contained in:
parent
78baf8d015
commit
c3f8d75ece
@ -42,9 +42,8 @@ api.nvim_create_augroup("packer_auto_compile", {
|
||||
api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
pattern = "*/nvim/lua/plugins.lua",
|
||||
group = "packer_auto_compile",
|
||||
callback = function()
|
||||
local fpath = fn.expand("<afile>")
|
||||
local cmd = "source " .. fpath
|
||||
callback = function(ctx)
|
||||
local cmd = "source " .. ctx.file
|
||||
vim.cmd(cmd)
|
||||
vim.cmd("PackerCompile")
|
||||
end
|
||||
@ -58,10 +57,8 @@ api.nvim_create_augroup("auto_create_dir", {
|
||||
api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
pattern = "*",
|
||||
group = "auto_create_dir",
|
||||
callback = function()
|
||||
local fpath = fn.expand('<afile>')
|
||||
local dir = fn.fnamemodify(fpath, ":p:h")
|
||||
|
||||
callback = function(ctx)
|
||||
local dir = fn.fnamemodify(ctx.file, ":p:h")
|
||||
utils.may_create_dir(dir)
|
||||
end
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user