Closed LDAP closed 1 year ago
@berteauxjb lets make a new issue for this.
Can you post your sublime-project file please?
Btw, you can also always run the LSP: Troubleshoot Server command to see which options are passed to the language server.
Here's the relevant parts in my project file:
{
"tab_size": 2,
"folders":
[
{
"path": "/home/jb/github/project",
"folder_exclude_patterns":
[
"build*",
],
}
],
"settings":
{
"LSP": {
"LSP-clangd": {
"initializationOptions": {
"clangd.compile-commands-dir": "/home/jb/github/project/build/project-relwithdebinfo/"
},
"enabled": true,
},
},
},
}
Thanks for the tip, I never realized that this was an option, much easier than reading the log panel :) BTW I noticed that I have two clangd servers showing up in the troubleshoot panel: LSP-clangd
and clangd
. One has the compile command arg but nothing else (not even a valid command), the other has everything else but not the compile command arg. Here's the server configuration I get for both of them:
I[10:59:46.844] Ubuntu clangd version 12.0.0-3ubuntu1~20.04.5
I[10:59:46.844] PID: 1474146
I[10:59:46.844] Working directory: /home/jb/github/project
I[10:59:46.844] argv[0]: /usr/bin/clangd-12
I[10:59:46.844] Starting LSP over stdin/stdout
[
"/usr/bin/clangd-12"
]
/usr/bin/clangd-12
source.c | source.c++ | source.objc | source.objc++ | source.cuda-c++
source.c | source.c++ | source.objc | source.objc++ | source.cuda-c++
{
"clangd": {
"all-scopes-completion": false,
"background-index": false,
"background-index-priority": null,
"clang-tidy": false,
"compile-commands-dir": null,
"completion-style": null,
"enable-config": false,
"fallback-style": null,
"function-arg-placeholders": false,
"header-insertion": null,
"header-insertion-decorators": false,
"limit-references": null,
"limit-results": null,
"log": null,
"malloc-trim": false,
"number-workers": null,
"path-mappings": null,
"pch-storage": null,
"pretty": false,
"project-root": null,
"query-driver": null,
"remote-index-address": null
},
"clangdFileStatus": false,
"custom_command": [],
"fallbackFlags": []
}
{}
{}
==================================================================================================
neither "command" nor "tcp_port" is provided; cannot start a language server
[]
- selector
- priority_selector
- init_options
```json
{
"clangd": {
"compile-commands-dir": "/home/jb/github/project/build/project-relwithdebinfo/"
}
}
{}
{}
There is your issue: They key in the sublime-project should be clangd
not LSP-clangd
:)
(This is to keep this package backward compatible for users that used the default configuration that shipped with the LSP plugin a while back.)
The intended way to set the compilation database path is via clangd.compile-commands-dir
, you just need to change the key.
Haha, yes now it works. Sorry about that! I got confused with LSP-pyright
that uses the same key as its name. Thanks a lot for your help :)
I added a section to the README
Hey @LDAP, thanks so much for looking into it! I can confirm that I can properly configure the system binary to use
clangd-12
. However I still have another issue that might be relevant to this PR.My
compile_commands.json
file is not at the root of the project, so I have to pass--compile-commands-dir
arg toclangd-12
. Since this path changes for each project, I have to have this setting in the.sublime-project
file. I saw you mentionedinitializationOptions
can now be overwritten per project, so I tried multiple things without success:initializationOptions
andclangd.compile-commands-dir
.initializationOptions
andcustom_command
. Thebinary
setting was set tocustom
in the LSP-clangd setting file.It seems like the plugin doesn't read any settings from the project file for
initializationOptions
. The JSON auto-completion also doesn't bring any options for any of the keys ininitializationOptions
(but works when used in the LSP-clangd setting file).Originally posted by @berteauxjb in https://github.com/sublimelsp/LSP-clangd/pull/11#issuecomment-1473525245