When I try to run the following code in my conf or under :luado

vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, {
  pattern  = {"*.t"},
  callback = function () vim.bo.filetype = 'perl' end

I get the following error,

attempt to call field 'nvim_create_autocmd' (a nil value)

I can see nvim_create_autocmd documented here; I am assuming this error is because my version of Neovim doesn't support this api function. I can re-create this error with :luado,

:luado vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, { pattern  = {"*.t" }, callback = function () vim.bo.filetype = 'perl' end })

How can I see what functions my Neovim supports?

  • Could it be a version difference? Always try your local :help first to make sure it matches your system
    – D. Ben Knoble
    Commented Apr 7, 2022 at 15:44
  • 1
    :echo api_info().functions->map("v:val.name")->filter("v:val=~'^nvim_create'")
    – Matt
    Commented Apr 7, 2022 at 16:45
  • @Matt that is really cool, if you answer with just that I'll fix it up and mark it as chosen. Nice! Commented Apr 7, 2022 at 17:05

1 Answer 1


You can see what is supported through the Lua API with the metadata provided by vim.fn.api_info, but it won't be very useful nor readable. It returns a dictionary. From the docs to api_info(), you can make it readble by wrapping it in :lua print(vim.inspect( thing )), like this

:lua print(vim.inspect( vim.fn.api_info() ))

You're only interested in the functions supported not the error types and other stuff, so you can use

:lua print(vim.inspect( vim.fn.api_info().functions ))

Another method to do this is with api_info(), and provided by @Matt. Here he maps over it to get just the function names, and then filters to find only the names that are prefixed with nvim_create.

:echo api_info().functions->map("v:val.name")->filter("v:val=~'^nvim_create'")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.