Commit 1353ef9
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 Codex1 parent 122780f commit 1353ef9
2 files changed
Lines changed: 83 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
119 | 140 | | |
120 | 141 | | |
121 | 142 | | |
| |||
258 | 279 | | |
259 | 280 | | |
260 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
261 | 301 | | |
262 | 302 | | |
263 | 303 | | |
| |||
656 | 696 | | |
657 | 697 | | |
658 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
659 | 741 | | |
660 | 742 | | |
661 | 743 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
0 commit comments