how to make helix work with c++ and cmake #5044
-
I'm trying to make a c++ app using cmake as the build system but it seems like helix is failing at understanding my include paths for some reason. Is there a way to get rid of those red dots without including headers with absolute path? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
I'm not very familiar with this myself but you should be able to setup CMake to emit this https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html, or use Bear |
Beta Was this translation helpful? Give feedback.
-
For small programs I keep a simple
For larger projects, I usually have a simple script which just runs |
Beta Was this translation helpful? Give feedback.
-
it's also not detecting my #include |
Beta Was this translation helpful? Give feedback.
-
In my case, I just added the following in my helix [[language]]
name = "cpp"
language-server = { command = "clangd", args=["--compile-commands-dir=compile_commands_directory"] } |
Beta Was this translation helpful? Give feedback.
-
So I come across this post when I was looking into trying out Helix for C/C++ programming. I have clangd and llbd-vscode working. But what now? Way back when I used Vim, I have a key bind of alt-m that would run ./build.sh %... % being the C file in question. The build script would have the compiler flags I wanted and the compiler I wanted to use and were I wanted the output file to go with its name all that. But I read Helix does not have % for filename. How do you do the same type of thing in Helix? is this were: [[language]] comes in? Right now I am doing ctrl-z running my build script then fg to go back to /helix. I am confused to say the least. So any help would be good. Thank for your time. |
Beta Was this translation helpful? Give feedback.
-
In my case no additional config was needed, the actual problem was this https://stackoverflow.com/questions/74785927/clangd-doesnt-recognize-standard-headers |
Beta Was this translation helpful? Give feedback.
For small programs I keep a simple
compile_flags.txt
in my $HOME directory which just lists common search paths (I'm on macOS so I need to specify paths to boost etc.) and my usual compile flags. It looks like this:For larger projects, I usually have a simple script which just runs
cmake
with-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
to generatecompile_commands.json
and then deletes the CMake cache.