Hi there, I need help with porting the Vimscript autocmd
to vim.api.nvim_create_autocmd
, all my plugin upgrade works fine except the Goyo
autocmd:
-- Enable the relative number when going into `GOYO` mode!
function Goyo_enter()
-- Enable hybird number (Absoluate and relative number)
vim.wo.number = true
vim.wo.relativenumber = true
print(">>> GoyoEnter trigged.")
end
function Goyo_leave()
print(">>> GoyoLeave trigged.")
end
--[[
This setting works fine:)
This setting works fine:)
This setting works fine:)
--]]
--vim.cmd([[
-- autocmd! User GoyoEnter :call luaeval('Goyo_enter()')
-- autocmd! User GoyoLeave :call luaeval('Goyo_leave()')
--]])
--[[
This setting doesn't work :(
This setting doesn't work :(
This setting doesn't work :(
This setting doesn't work :(
--]]
local GoyoGroup = vim.api.nvim_create_augroup('GoyoGroup', { clear = true })
vim.api.nvim_create_autocmd('GoyoEnter', {
--command = ":call luaeval('Goyo_enter()')",
callback = Goyo_enter,
group = GoyoGroup
})
vim.api.nvim_create_autocmd('GoyoLeave', {
--command = ":call luaeval('Goyo_leave()')",
callback = Goyo_leave,
group = GoyoGroup
})
As you can see above, the old autocmd
use User custom event
(I check the :h events
), but I still can’t figure out how to make it works in Lua setup:) If I make a change like this:
-- vim.api.nvim_create_augroup('GoyoGroup', { clear = true })
-- --> to
vim.api.nvim_create_augroup('User', { clear = true })
Then all another plugins can’t work at all with the error I have idea what’s happening:) Any idea is welcome, many thanks:)