Configuring C++ flags in SourceKit-LSP

I'm working on a small C++ project with a simple Makefile but no CMake. I'm trying to use SourceKit-LSP with Sublime, but I'm getting a ton of errors because it's parsing all .h files as C code instead of C++ and it doesn't have the right include paths.

What options are available for configuring C++ features of LSP? Clangd has .clangd files, compile_flags.txt and compile_commands.json. The last one is meant to be autogenerated from something like CMake files. I tried using .clangd and compile_flags.txt and they didn't seem to work.

We currently support compile_commands.json but not compile_flags.txt. It should be straightforward to add support for compile_flags.txt if someone wants to work on it. And/or feel free to file a bug to bugs.swift.org requesting this and I can try to take a look soon.

I'm not sure if we would ever want to directly support .clangd, but we could also consider adding an option to sourcekit-lsp that lets us fallback to letting clangd handle the build settings itself and skip our own build system entirely. That might be a bit harder to untangle from assumptions we make about how the build system flow works though.

Thanks for encouragement Ben! I just opened a PR for this, in case someone ends up here.

1 Like
Terms of Service

Privacy Policy

Cookie Policy