'How to use neovim lsp keybindings?

I have neovim 0.6.1 configured with some LSPs and using the default configurations found here: https://github.com/neovim/nvim-lspconfig#suggested-configuration. Some of the key bindings such as vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) are not working.

The vim.lsp.buf.rename() command works correctly if I call it manually like :lua vim.lsp.buf.rename().

If I do :noremap <space>rn :lua vim.lsp.buf.rename()<CR> during a session the rename keybinding works correctly.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source