Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/solidlsp/ls_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ def get_source_fn_matcher(self) -> FilenameMatcher:
# OpenCL
".cl",
".clcpp",
# Arduino sketch: not in clang's extension table, but it is C++.
# Routing it here lets clangd serve symbols; the project must
# tell clangd it is C++ (a .clangd with CompileFlags Add: [-xc++],
# or a compile DB), since the clang driver can't infer a job from .ino.
".ino",
case_sensitive=False,
)
case self.CPP_CCLS:
Expand All @@ -375,6 +380,8 @@ def get_source_fn_matcher(self) -> FilenameMatcher:
# Objective-C
".m",
".mm",
# Arduino sketch (C++); see note in the CPP case above.
".ino",
case_sensitive=False,
)
case self.KOTLIN:
Expand Down
14 changes: 14 additions & 0 deletions test/solidlsp/cpp/test_cpp_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
_cpp_servers.append(Language.CPP_CCLS)


@pytest.mark.parametrize("language", [Language.CPP, Language.CPP_CCLS])
def test_source_fn_matcher_includes_ino(language: Language) -> None:
"""Arduino .ino sketches are C++ and must route to the C++ language server.

This is a pure matcher check; it needs no running language server.
"""
matcher = language.get_source_fn_matcher()
assert matcher.is_relevant_filename("sketch.ino")
assert matcher.is_relevant_filename("BLINK.INO") # case-insensitive
assert matcher.is_relevant_filename("/path/to/s3_camera.ino")
assert matcher.is_relevant_filename("main.cpp") # regression: ordinary C++ still matches
assert not matcher.is_relevant_filename("notes.md")


@pytest.mark.cpp
@pytest.mark.skipif(not _cpp_servers, reason="No C++ language server (clangd or ccls) available")
class TestCppLanguageServer:
Expand Down
Loading