Recently I configured my nvim to use lsp. I add a couple of keymaps for my languages such as pressing ctrl-d goes to the definition of the function where the cursor is. This work good for every language but for c++ and I don't know why. It seems to me that c++ has it owns keymaps but I don't know how to replace them.
This is my lsp_config.lua file:
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"bashls",
"clangd",
"hls",
"elp",
"pyright"
}
})
local on_attach = function(_, _)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, {})
vim.keymap.set('n', '<leader>co', vim.lsp.buf.code_action, {})
vim.keymap.set('n', '<C-d>', vim.lsp.buf.definition, {})
vim.keymap.set('n', '<C-i>', vim.lsp.buf.implementation, {})
vim.keymap.set('n', '<C-r>', require('telescope.builtin').lsp_references, {})
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {})
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require("lspconfig")
lspconfig.tsserver.setup({
capabilities = capabilities
})
lspconfig.html.setup({
capabilities = capabilities
})
lspconfig.lua_ls.setup({
capabilities = capabilities
})
end
require("lspconfig").lua_ls.setup {
on_attach = on_attach
}
require("lspconfig").bashls.setup {
on_attach = on_attach
}
require("lspconfig").clangd.setup {
on_attach = on_attach
}
require("lspconfig").hls.setup {
on_attach = on_attach
}
require("lspconfig").elp.setup {
on_attach = on_attach
}
require("lspconfig").pyright.setup {
on_attach = on_attach
}
I try to change the keymaps expecting it will solve the problem or searching another specific server for c++ but it seems to me that this is not the solution. I've also tried installing g++-12 but it doesn't work either.