Reputation: 318
I'm using LazyVim as a bootstrap config.
On top of that I have very few changes. However, I'm not able to get lsp working for c++. LSP is working fine because it is working for Lua files. So, that leaves me suspecting my LSP config.
The behavior is that Neovim is using Visual Studio headers when I do go to definition. Whereas the project was compiled using mingw.
My init file:
-- init.lua
-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")
local nvim_lsp = require('lspconfig')
nvim_lsp.clangd.setup {
cmd = {'clangd', '--background-index', '--compile-commands-dir', 'D:/systemc/excersies/build'},
init_options = {
clangdFileStatus = true,
clangdSemanticHighlighting = true
},
filetypes = {'c', 'cpp', 'cxx', 'cc'},
root_dir = function() vim.fn.getcwd() end,
settings = {
['clangd'] = {
['compilationDatabasePath'] = 'build',
['fallbackFlags'] = {'-std=c++17'}
}
}
}
Upvotes: 3
Views: 9264
Reputation: 1309
However, I'm not able to get lsp working for c++.
What exactly do you mean with "(...) not able to get lsp working for c++."? Is there an error message?
I assume, that it works, but not fully, because maybe you cannot make use of goto definition
and stuff like that.
In this case, install bear
and run it in your project directory (as the README says):
bear -- make # if you'd simply invoke `make` to build your project
this should create a json file for you and clangd
should fully work then.
Upvotes: -1