1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
jdhao
e57e747b26
Merge pull request #72 from jdhao/lua-au-ctx
refactor: use ctx table for lua autocmd callback
2022-08-21 18:21:22 +08:00
jdhao
c3f8d75ece refactor: use ctx table for lua autocmd callback 2022-08-21 18:20:21 +08:00

View File

@ -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
})