aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/api.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/api.txt')
-rw-r--r--runtime/doc/api.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 9e0002db48..5b045f80ff 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -3221,6 +3221,22 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()*
})
<
+ Lua functions receive a table with information about the
+ autocmd event as an argument. To use a function which itself
+ accepts another (optional) parameter, wrap the function in a
+ lambda:
+>
+ -- Lua function with an optional parameter.
+ -- The autocmd callback would pass a table as argument but this
+ -- function expects number|nil
+ local myluafun = function(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() end
+
+ vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
+ pattern = {"*.c", "*.h"},
+ callback = function() myluafun() end,
+ })
+<
+
Example using command: >
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.c", "*.h"},