Command not found when using { bang = true }

Hey y’all. Finally migrating my many years old init.vim to lua so that I can take advantage of some of the new features in neovim. One issue I’ve run into very early on is that a common netrw command Sexplore is available but the bang version Sexplore! is not.

when configured like so:

vim.keymap.set("n", "<leader>n", vim.cmd.Sexplore)
vim.keymap.set("n", "<leader>v", vim.cmd.Sexplore{ bang = true })

the Sexplore keymap works but the bang version throws this error on startup:

E5113: Error while calling lua chunk: ~/.config/nvim/lua/remap.lua:7:
 Command not found: Sexplore

I’m currently working around the issue via:

vim.keymap.set("n", "<leader>v", ":Sexplore!<CR>")

but I’d love to understand what’s going on here and where I can go to see a full list of available commands. If the issue is that the command is provided by the plugin (and not available on vim.cmd), then I’m unsure why the non banged version is working.

no idea if this is helpful, but it looks like you’re missing a comma on the second line after vim.cmd.Sexplore.

When there’s a table/string after a function then it will call that function with the table/string.
This means that vim.cmd.Sexplore{bang=true} runs Secplore when the keybinding is defined.
One way to mitigate this problem is by setting it inside a function:

vim.keymap.set("n", "<leader>v", function() vim.cmd.Sexplore{ bang = true } end)