Closed divramod closed 8 months ago
@divramod yep, it's possible now, just needed better documentation https://github.com/Robitx/gp.nvim#gpdone-autocommand-to-run-consequent-actions
hey hey @Robitx,
i tried it this way:
vim.api.nvim_create_autocmd({"GpDone"}, {
pattern = {"*.md", "*.ts"},
callback = function(event)
print(string.format('event fired: s', vim.inspect(event)))
end
})
but i am getting this error message after adding it, when starting vim now:
Error detected while processing /path/init.lua:
E5113: Error while calling lua chunk: /path/lua/user/autocommands.lua:21: unexpected event
stack traceback:
[C]: in function 'nvim_create_autocmd'
/path/lua/user/autocommands.lua:21: in main chunk
[C]: in function 'require'
/pathinit.lua:3: in function 'load'
/path/init.lua:8: in main chunk
[C]: in function 'require'
/path/init.lua:3: in function 'load'
/path/init.lua:11: in main chunk
Press ENTER or type command to continue
am i doing something wrong?
@divramod sorry that was blunder on my part, I took the vim.api.nvim_create_autocmd
example from neovim docs and edited it without testing.
Here is fixed example, I've just put into readme:
vim.api.nvim_create_autocmd({ "User" }, {
pattern = {"GpDone"},
callback = function(event)
print("event fired:\n", vim.inspect(event))
-- local b = event.buf
-- DO something
end,
})
which prints out:
event fired:
{
buf = 1,
event = "User",
file = "GpDone",
id = 99,
match = "GpDone"
}
I you'd like to limit it further, you could use vim.api.nvim_buf_get_option(buf, "filetype")
its working now! gracias!
hey hey,
i am still experimenting. can i somehow hook in after for example GpPrepend ran? i'd like to run my prettier on the file, because the code is not formatted properly.