Closed paulross80 closed 3 months ago
In theory clangd automatically finds the compile_commands.json
file in the directory/parent directory of the source files, but I don't know much about how the search works, so I can't help you much there.
command = { "clangd", "--background-index --compile-commands-dir=build" }
You need to split the parameters like this:
command = { "clangd", "--background-index", "--compile-commands-dir=build" }
Also, please don't edit config.lua
directly, but use your user module:
local lspconfig = require "plugins.lsp.config"
lspconfig.clangd.setup({
command = { "clangd", "--background-index", "--compile-commands-dir=build" },
verbose = true
})
I'll try splitting the parameters User module. Can you please tell me what file is that?
User module. Can you please tell me what file is that?
Click on the gear icon in the bottom left. If it opens a file, that's the user module. If it opens the settings GUI, in "Core", expand "General", click on "User Module".
If it opens a file, that's the user module
Found it, thanks. I've pasted your code in that file, saved and restarted litexl. No errors
It still doesn't understand what -fmodules-ts
and importing modules are
The directory specified here: "--compile-commands-dir=build"
should be relative to the project root, right?
Today I've tried pasting the code in the project module, using core:open-project-module
command
local lspconfig = require "plugins.lsp.config"
lspconfig.clangd.setup({
command = { "clangd", "--background-index", "--compile-commands-dir=~/Programming/xmake/test1" },
verbose = false
})
After saving the file, restarted with core:restart
Even using the full path to the compile commands file, still doesn't work as expected. What else can I try to fix it?
What happens if you run the LSP server manually? Does it warn about a bad config?
For example try with clangd --log=verbose --check=/path/to/a/source/file
.
It works. The problem was that my project uses C++20 modules. Clang does support them, but clangd doesn't. Thanks for your help!
Glad that you found the problem!
Hello. I'm trying to use lite-xl editor (latest version 2.1.5, installed using fedora dnf) with the IDE plugin, that includes this lsp plugin. I'm using xmake as my build tool. I made a C++23 project with modules just to test some things. I ask xmake to generate the
compile_commands.json
file, like this:xmake project -k compile_commands
It works. But when I open Lite XL, some clangd errors appear, like it doesn't understand my code. I have also created a .clangd file in the project root with this content:
I restart lite xl but the same problem persists. I have noticed that QtCreator uses this parameter for clangd:
--compile-commands-dir=
, so I edited the config.lua from this plugin to add that parameter:config.zip
But since I have edited this config file, every time I open litexl, it says "[LSP]: clangd was shutdown, revise your configuration" How can I fix this?