Closed jiriks74 closed 2 years ago
Hey, thanks for the PR!
From a quick look it seems like an additional build_flags
line would be added to the platformio.ini
each time the project is initialized..? That should be avoided as its called to reload the libraries etc. as well.
Ok, I'll take a look into that. Mybe some chech if the -Isrc -Ilib
already exists int the build flags?
I would check if build_flags
line exists and then if it has -Isrc -Ilib
in it. If it does not I'd either create the line or modify it with the flags.
I don't know Lua or Bash that much though. I'd research it and do it, if you'd help me to figure out a good way to parse it.
The biggest problem is when the build_flags
section is on multiple lines. I'd maybe rewrite it to be like this:
[default]
build_flags=
-Isrc
-Ilib
By writing it now:
We could just add a [default]
section. People could add their flags in their environments and the [default]
would make sure that the folders are included in all of them.
Would it be easier to make a section like this and then just check for it?
Why do these have to be added anyway? And what if the user wants them to be different? Does creating the compile_commands.json
not work when its missing or does vim simply not pick up on the directories then?
I guess the best way would be to make a note about needed settings in the platformio.ini
for clang to work and maybe make a separate command to add the needed lines (if at all).
For whatever reason if you don't add the -Ilib
and -Isrc
flags, platformio won't add those to the compile_commands.json
.
Now that I think of it, I could open an issue at their repo
So I added the commands to create the compile_commands.json
by default now and at least for my projects that seems to work fine out of the box with clangd. Thanks for the hint! Closing this.
You're welcome! I'm still resolving the lib
folder error with them though...
Also - could you add a compiledb
or compile_commands
?
From what I understand the file work on file by file basis, so if you create a new one, it won't work (I'll test it out in the evening) as the file is not in the compile_commands.json
. To make it work, you should run the pio run -t compiledb
command again and it would be really nice if it was in the Makefile.
Also adding some mentions on ClandD into the readme (apart from that it is one of the language servers) would be nice. If you're interested, I'd make a pull request so that you don't have to annoy yourself with it.
You can just call :PIOInit
to regenerate the file. It will also automatically be called when you install or remove a library as the files need to be updated as well then.
For the missing lib dir - I don't get that issue so maybe a simple warning that you might have to add this to your platformio.io in the README and docs will suffice.
I've added some things needed for clangd to work.
This allows people to use
AstroNvim
without any hassle as AstroNvim uses Mason to manage language servers and does not offerccls
.ccls
is not that trivial to configure with AstroNvim, so this is probably the best solution.The downside is that there are now 2 files for 2 language servers. You either use
ccls
and havecompile_commands.json
doing nothing or useclangd
and have.ccls
file that has no use.