I'm trying to convert my init.vim over to lua.
Also trying out "packer" plugin manager and using styua-nvim plugin to format lua code.
Followed instructions for packer and got it installed and loaded stylua-nvim plugin with pakcer. Loaded stylua with :PackerInstall
However, getting error: attempt to call global 'buf_set_keymap' (a nil value)
init.lua:
vim.cmd([[
source ~/.config/nvim/local_customizations.vim
source ~/.config/nvim/plugins.vim
]])
require('plugins')
HOME = os.getenv("HOME")
<snip>
local opts = { noremap=true, silent=true }
buf_set_keymap("n", "<leader>f", "<cmd>lua require('stylua-nvim').format_file()<CR>", opts)
Also tried:
buf_set_keymap("n", "<leader>f", "require('stylua-nvim').format_file()<CR>", opts)
But get same error.
Original instruction for stylua-nvim give this for config of keymap:
buf_set_keymap("n", "<leader>f", "<cmd>lua require("stylua-nvim").format_file()<CR>', opts)
But this looks to be wrong to me because the quotes are unmatched and throws an error:
Error while creating lua chunk: /Users/stevedondley/.config/nvim/init.lua:29: ')' expected near 'stylua'
Frustrating.