solidlsp: recognize Arduino .ino files as C++#1534
Open
hampsterx wants to merge 1 commit into
Open
Conversation
.ino sketches are C++ but were absent from the CPP and CPP_CCLS
source-file matchers, so Serena refused symbol operations on them
("Cannot extract symbols ... Active languages"). Add .ino to both
matchers, plus a server-independent unit test.
Note: clangd cannot infer a compile job from the .ino extension by
itself, so a project still needs to declare the language (a .clangd
with CompileFlags Add: [-xc++], or a compile DB). With that in place
clangd returns the full document-symbol tree for a sketch.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
.ino(Arduino sketch) files are C++, but they were absent from theCPPandCPP_CCLSsource-file matchers inLanguage.get_source_fn_matcher(). So Serena routed them to no language server and rejected every symbol operation with:even with
cppconfigured as a project language. This adds.inoto both matchers.Why the matcher alone isn't the whole story (and that's fine)
clangd builds its compile command from the filename, and the clang driver doesn't recognise
.ino, so on its own clangd reportsfe_expected_compiler_job("Unable to handle compilation, expected exactly one compiler job") and returns no AST. The project just needs to declare the language, the same as any non-standard C++ extension. A.clangdin the source tree does it:With that present, clangd returns the full document-symbol tree. Verified against a real 1872-line ESP32 sketch: hard-rejected by the matcher before (0 symbols), 204 symbols after. Without this matcher change no project config can help, because the file never reaches clangd.
Changes
.inoadded to theCPP(clangd) andCPP_CCLS(ccls) matchers, with a comment pointing at the.clangd/-xc++requirement..ino(any case) matches for both languages, ordinary.cppstill matches, and unrelated files don't.Test plan
test_source_fn_matcher_includes_inoassertions verified (parametrized overCPPandCPP_CCLS):.ino/.INO/ path-qualified.inomatch,.cppstill matches,.mdis rejected.didOpen(languageIdcpp) +documentSymbolon a real.inoreturns 204 symbols when a.clangdsupplies-xc++, and reproducesfe_expected_compiler_jobwithout it.pytest -m cppsuite not run in this environment; the new test is independent of the language-server fixtures.