Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate "compile_commands.json" for LSP ready IDEs #3735

Closed
pvonmoradi opened this issue Nov 12, 2020 · 10 comments
Closed

Generate "compile_commands.json" for LSP ready IDEs #3735

pvonmoradi opened this issue Nov 12, 2020 · 10 comments

Comments

@pvonmoradi
Copy link

pvonmoradi commented Nov 12, 2020

The following command generates the requires files for LSP for plugins like coc-nvim:
pio project init --board my_board --ide vim --project-option "framework=arduino"
Problem is, after mutating the platformio.ini and adding libraries, the .ccls file is not kept updated.
How to make it so that all these auxiliary helper files get updated when project dependencies change? I was able to do it with
initing again.
Aside from that, I don't think the .ccls file should be dependent on project libs alone. Maybe the source does not use a library, so its deps should not be handled by ccls.

@ivankravets
Copy link
Member

Duplicate of #364

@ivankravets ivankravets marked this as a duplicate of #364 Nov 13, 2020
@pvonmoradi
Copy link
Author

pvonmoradi commented Nov 13, 2020

@ivankravets Thanks. So it is a known issue.
Is generating the compile_commands.json via the post: script and compiledb command, a good alternative? (meaning pointing LSPs to compile_commands.json instead of .ccls)
And how does VScode handle this issue?

@ivankravets ivankravets added this to the 5.0.4 milestone Nov 14, 2020
@ivankravets ivankravets changed the title The generated .ccls is not updated in builds Generate "compile_commands.json" for LSP ready IDEs Nov 14, 2020
@ivankravets
Copy link
Member

I updated the title. It is a very good idea to generate compile_commands.json for all compatible IDEs. Thanks!

@ivankravets ivankravets reopened this Nov 14, 2020
@pvonmoradi
Copy link
Author

@ivankravets But isn't this already implemented? https://docs.platformio.org/en/latest/integration/compile_commands.html
Or you mean you are planning the --ide switches to generate this in the project root?

@ivankravets
Copy link
Member

Yes, it makes sense to generate compile_commands.json in the root of project.

ivankravets added a commit that referenced this issue Nov 14, 2020
@ivankravets ivankravets modified the milestones: 5.0.4, 5.1.0, Backlog Nov 30, 2020
@yunuscukran
Copy link

Yes, it makes sense to generate compile_commands.json in the root of project.

From my experience, compile_commands.json being in the root is required to make clangd work properly. As far as ı can tell, this seems like a pre-req for the clangd integration at platformio/platformio-vscode-ide#1802.

Any timeline for this change?

@ivankravets
Copy link
Member

You can temporarily fix it on your side https://docs.platformio.org/en/latest/integration/compile_commands.html
Just override COMPILATIONDB_PATH.

@ivankravets
Copy link
Member

See updated docs https://docs.platformio.org/en/latest/integration/compile_commands.html

Key changes:

  1. The latest PlatformIO Core generates a compilation database in the project root
  2. The new build environment was added to include toolchain paths. See docs for details.

Please confirm that it works now upgrading to the latest development version of PIO Core using pio upgrade --dev. Thanks!

@pvonmoradi
Copy link
Author

pvonmoradi commented Apr 9, 2022

@ivankravets confirmed that pio run -t compiledb creates a compile_db.json which is dependent on libraries included in the project ini file. clang is able to jump to definition of library functions/methods.
Thanks.

@ivankravets
Copy link
Member

Happy coding with PlatformIO!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants