You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix lsp_servers[].file_patterns
Problem
While using `mcpls` in a C++ project I noticed that it always return
the following error when calling get references from a '.h' header file:
Error: tool call error: tool call failed for `mcpls/get_references`
Caused by:
tools/call failed: Mcp error: -32603: no LSP server configured for language: c
After reviewing the documentation and creating an mcpls.toml with the
following, it continued to not work
[[lsp_servers]]
language_id = "cpp"
command = "clangd"
args = ["--background-index", "--clang-tidy"]
file_patterns = ["**/*.cpp", "**/*.cc", "**/*.cxx", "**/*.hpp", "**/*.c", "**/*.h"]
# and/or with
[[lsp_servers]]
language_id = "c"
command = "clangd"
args = ["--background-index", "--clang-tidy"]
file_patterns = ["**/*.c", "**/*.h"]
With the above changing resulting in the language detection for matching
file patterns to "plaintext"
Error: tool call error: tool call failed for `mcpls/get_references`
Caused by:
tools/call failed: Mcp error: -32603: no LSP server configured for language: plaintext
What changed
- serve() now initializes the translator with an effective extension map
built from both workspace mappings and LSP server file patterns:
- crates/mcpls-core/src/lib.rs:114:114
- Added ServerConfig::build_effective_extension_map() to overlay
extensions inferred from file_patterns:
- crates/mcpls-core/src/config/mod.rs:287:287
- Added a small parser for simple glob extensions (e.g. **/*.h, *.c):
- crates/mcpls-core/src/config/mod.rs:123:123
Tests added
- Pattern-derived mapping overrides default extension mapping (.c/.h -> cpp):
- crates/mcpls-core/src/config/mod.rs:700:700
- Complex non-simple patterns are ignored safely:
- crates/mcpls-core/src/config/mod.rs:721:721
Verification
- New tests passed.
- Full mcpls-core unit/integration tests passed.
- Existing unrelated doctest failure remains in lsp/types.rs (pre-existing visibility issue).
Fix was implemented by Codex
* fix(config): polish file pattern extension mapping
Add direct unit coverage for extract_extension_from_pattern edge cases, including empty input, no-dot patterns, dotfiles, and multi-dot filenames.
Tighten the parser to reject dotfile basenames so hidden files like .gitignore do not get treated as language extensions.
Update the translator initialization test to assert against build_effective_extension_map(), which matches the runtime code path introduced by the earlier file_patterns fix.
Document the resulting C/C++ language detection behavior change in CHANGELOG.md.
* Update crates/mcpls-core/src/config/mod.rs
Co-authored-by: Andrei G <k05h31@gmail.com>
---------
Co-authored-by: Andrei G <k05h31@gmail.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
8
## [Unreleased]
9
+
### Changed
10
+
11
+
-**C/C++ file pattern language detection** - When `lsp_servers[].file_patterns` include simple extensions such as `**/*.c` or `**/*.h`, mcpls now derives extension-to-language mappings from those patterns and overlays them onto the workspace extension map. This changes the default behavior for matching C/C++ files to prefer the configured LSP server language instead of falling back to built-in mappings or `plaintext`.
0 commit comments