Skip to content

Document Neovim integration using clangd and ccls - #408

Open
Amaan-Kazi wants to merge 2 commits into
platformio:developfrom
Amaan-Kazi:develop
Open

Document Neovim integration using clangd and ccls#408
Amaan-Kazi wants to merge 2 commits into
platformio:developfrom
Amaan-Kazi:develop

Conversation

@Amaan-Kazi

Copy link
Copy Markdown

This pull request adds documentation for using PlatformIO with Neovim.
Including Project Generation, Language Server Configuration and generating the compilation database.

In particular, i have documented the use of --query-driver when using clangd, this is a requirement when cross compiling, especially for embedded toolchains.

I can create a PR in the platformio-web repo to add Neovim to the list of IDEs on integration page

@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ivankravets

Copy link
Copy Markdown
Member

@Amaan-Kazi , does it make sense to reflect in the docs the nvim-pio plugin by @batoaqaa?

@batoaqaa

Copy link
Copy Markdown

@Amaan-Kazi , does it make sense to reflect in the docs the nvim-pio plugin by @batoaqaa?

nvim-pio is a neovim plugin that is to neovim as platformio exetension to vs code, in addition it supports/integrates clangd lsp.

nvim-pio aslo will install platformio if not installed, you can try/see nvim-pio sandbox video in nvim-pio github.

@Amaan-Kazi

Copy link
Copy Markdown
Author

@Amaan-Kazi , does it make sense to reflect in the docs the nvim-pio plugin by @batoaqaa?

Yes, we can make a section like "Community Plugins"

I am currently only aware of these 2 Neovim plugins in relation to PlatformIO

nvim-pio aslo will install platformio if not installed, you can try/see nvim-pio sandbox video in nvim-pio github.

I haven't had the chance to test out the plugin yet, but ill be doing so soon

@Amaan-Kazi

Copy link
Copy Markdown
Author

The nvim-pio plugin works pretty well overall
I was able to use it with pretty minimal configuration

From my testing, the plugin only overwrites some of the clangd setup when in a PlatformIO project so thats good since if someone has other C/C++ projects that dont use PlatformIO, then they will need to configure clangd anyway.
Also some of the code seems AI generated, but it is actively maintained.

nvim-platformio.lua works well as a simple Neovim wrapper over PlatformIO cli commands. the core features are functional so it seems stable.

@batoaqaa

Copy link
Copy Markdown

The nvim-pio plugin works pretty well overall I was able to use it with pretty minimal configuration

From my testing, the plugin only overwrites some of the clangd setup when in a PlatformIO project so thats good since if someone has other C/C++ projects that dont use PlatformIO, then they will need to configure clangd anyway. Also some of the code seems AI generated, but it is actively maintained.

nvim-platformio.lua works well as a simple Neovim wrapper over PlatformIO cli commands. the core features are functional so it seems stable.

I contributed to nvim-platformio.lua which as you mentioned a perfect focused Neovim wrapper over PlatformIO cli commands.

nvim-pio has gone further to do:

  • Auto install the dependencies. mason, mason-lspconfig, clangd if you opted for that in config. This is automating what Document Neovim integration using clangd and ccls #408 is adding to documentation for clangd.
  • Auto discovers and binds toolchain, firmware library locations, and pin point --query-driver to the board toolchain bin folder and configure/enable clangd lsp accordingly for env.
  • Clangd diagnostic Filtration Interface: Provides a dynamic selecting utility via :ClangdFilter to instantly toggle specific syntax warnings or static alerts.
  • Auto compiler flags neutralization: Intercepts and strips non-standard bare-metal toolchain argument options (such as -mlongcalls) that destabilize desktop language servers.
  • Auto install platformio framework if missing also can repair/reinstall it if needed.
  • Create template files /src /include per board installed
  • maintains .nvimpio folder (similar to .vscode) that contains idedata for each env[], also maintains the active env so it will auto run commands like 'pio run -t compiledb -e env_name'. Also, you can switch between envs.
  • Auto generates/maintains compile_commands.json file whenever new board installed or platform.ini file changed (i.e. when library added/removed)
  • nvim-pio has terminal class (not toggleterm) which has it is own parser for sequencing nvim-pio commands. show/hide key maps for cli and serial monitor.
  • check :h nvimpio

@Amaan-Kazi

Copy link
Copy Markdown
Author

I contributed to nvim-platformio.lua which as you mentioned a perfect focused Neovim wrapper over PlatformIO cli commands.

nvim-pio has gone further to do:

  • Auto install the dependencies. mason, mason-lspconfig, clangd if you opted for that in config. This is automating what Document Neovim integration using clangd and ccls #408 is adding to documentation for clangd.
  • Auto discovers and binds toolchain, firmware library locations, and pin point --query-driver to the board toolchain bin folder and configure/enable clangd lsp accordingly for env.
  • Clangd diagnostic Filtration Interface: Provides a dynamic selecting utility via :ClangdFilter to instantly toggle specific syntax warnings or static alerts.
  • Auto compiler flags neutralization: Intercepts and strips non-standard bare-metal toolchain argument options (such as -mlongcalls) that destabilize desktop language servers.
  • Auto install platformio framework if missing also can repair/reinstall it if needed.
  • Create template files /src /include per board installed
  • maintains .nvimpio folder (similar to .vscode) that contains idedata for each env[], also maintains the active env so it will auto run commands like 'pio run -t compiledb -e env_name'. Also, you can switch between envs.
  • Auto generates/maintains compile_commands.json file whenever new board installed or platform.ini file changed (i.e. when library added/removed)
  • nvim-pio has terminal class (not toggleterm) which has it is own parser for sequencing nvim-pio commands. show/hide key maps for cli and serial monitor.
  • check :h nvimpio

@ivankravets should I add both the plugins to a Community Plugins section?

And I also went through platformio/platformio-core#5188
I have gotten arduino-language-server to work on Neovim, should i add that to the docs? It is more relevant to document it in Arduino CLI / IDE but I guess this can help someone migrating from Arduino IDE to PlatformIO

Which of the 11 different gpio_reg.h's should you be taken to? Well, you have to know what you're building for, right? So you just crank off a pio run -t compiledb -e target . Oh, wait. That doesn't put it in .pio/build/foo or something; it gets clobbered on each run. You can't really use compile_commands.json at all, really, since it uses an implicit path instead of the compiler it actaully lists.

Is it possible to make SCons always write the full compiler paths in compile_commands.json when we run pio run -t compiledb. Because I ran into the same issue as well when having multiple ESP32 toolchains installed

We can avoid overwriting compile_commands.json at every run using the COMPILATIONDB_PATH environment variable for each environment using extra script

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants