legesher-language-server 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. legesher_language_server-0.2.0/LICENSE +190 -0
  2. legesher_language_server-0.2.0/PKG-INFO +384 -0
  3. legesher_language_server-0.2.0/README.md +349 -0
  4. legesher_language_server-0.2.0/legesher_language_server/__init__.py +50 -0
  5. legesher_language_server-0.2.0/legesher_language_server/__main__.py +140 -0
  6. legesher_language_server-0.2.0/legesher_language_server/config.py +333 -0
  7. legesher_language_server-0.2.0/legesher_language_server/document.py +195 -0
  8. legesher_language_server-0.2.0/legesher_language_server/enhanced_intelligence.py +1018 -0
  9. legesher_language_server-0.2.0/legesher_language_server/incremental_translator.py +244 -0
  10. legesher_language_server-0.2.0/legesher_language_server/logging_setup.py +335 -0
  11. legesher_language_server-0.2.0/legesher_language_server/providers/__init__.py +39 -0
  12. legesher_language_server-0.2.0/legesher_language_server/providers/completion.py +516 -0
  13. legesher_language_server-0.2.0/legesher_language_server/providers/diagnostic.py +525 -0
  14. legesher_language_server-0.2.0/legesher_language_server/providers/hover.py +730 -0
  15. legesher_language_server-0.2.0/legesher_language_server/providers/semantic_tokens.py +391 -0
  16. legesher_language_server-0.2.0/legesher_language_server/server.py +956 -0
  17. legesher_language_server-0.2.0/legesher_language_server/source_map.py +340 -0
  18. legesher_language_server-0.2.0/legesher_language_server/type_alias_generator.py +313 -0
  19. legesher_language_server-0.2.0/legesher_language_server/utils/__init__.py +5 -0
  20. legesher_language_server-0.2.0/legesher_language_server/utils/error_templates.py +404 -0
  21. legesher_language_server-0.2.0/legesher_language_server/utils/keyword_docs.py +1333 -0
  22. legesher_language_server-0.2.0/legesher_language_server/utils/python_names.py +12 -0
  23. legesher_language_server-0.2.0/pyproject.toml +160 -0
  24. legesher_language_server-0.2.0/tests/__init__.py +1 -0
  25. legesher_language_server-0.2.0/tests/benchmarks/README.md +64 -0
  26. legesher_language_server-0.2.0/tests/benchmarks/__init__.py +1 -0
  27. legesher_language_server-0.2.0/tests/benchmarks/test_baseline_performance.py +122 -0
  28. legesher_language_server-0.2.0/tests/benchmarks/test_cache_performance.py +473 -0
  29. legesher_language_server-0.2.0/tests/conftest.py +246 -0
  30. legesher_language_server-0.2.0/tests/fixtures/__init__.py +1 -0
  31. legesher_language_server-0.2.0/tests/fixtures/language_packs/invalid/empty_file.yml +0 -0
  32. legesher_language_server-0.2.0/tests/fixtures/language_packs/invalid/invalid_mappings.yml +9 -0
  33. legesher_language_server-0.2.0/tests/fixtures/language_packs/invalid/malformed_yaml.yml +9 -0
  34. legesher_language_server-0.2.0/tests/fixtures/language_packs/invalid/missing_keywords.yml +7 -0
  35. legesher_language_server-0.2.0/tests/fixtures/language_packs/invalid/missing_language.yml +7 -0
  36. legesher_language_server-0.2.0/tests/fixtures/language_packs/invalid/missing_target.yml +6 -0
  37. legesher_language_server-0.2.0/tests/fixtures/language_packs/invalid/null_content.yml +1 -0
  38. legesher_language_server-0.2.0/tests/fixtures/language_packs/mixed/empty_keywords.yml +9 -0
  39. legesher_language_server-0.2.0/tests/fixtures/language_packs/mixed/partial_pack.yml +9 -0
  40. legesher_language_server-0.2.0/tests/fixtures/language_packs/valid/base_ar.yml +63 -0
  41. legesher_language_server-0.2.0/tests/fixtures/language_packs/valid/base_es.yml +72 -0
  42. legesher_language_server-0.2.0/tests/fixtures/language_packs/valid/inherited_es.yml +13 -0
  43. legesher_language_server-0.2.0/tests/fixtures/mock_output_channel.py +88 -0
  44. legesher_language_server-0.2.0/tests/fixtures/stub_langserver.py +164 -0
  45. legesher_language_server-0.2.0/tests/manual_error_handling.py +213 -0
  46. legesher_language_server-0.2.0/tests/test_clean_environment.py +348 -0
  47. legesher_language_server-0.2.0/tests/test_completion_provider.py +810 -0
  48. legesher_language_server-0.2.0/tests/test_config.py +243 -0
  49. legesher_language_server-0.2.0/tests/test_diagnostic_provider.py +1050 -0
  50. legesher_language_server-0.2.0/tests/test_document.py +172 -0
  51. legesher_language_server-0.2.0/tests/test_document_language.py +822 -0
  52. legesher_language_server-0.2.0/tests/test_document_splitlines.py +72 -0
  53. legesher_language_server-0.2.0/tests/test_edge_cases.py +235 -0
  54. legesher_language_server-0.2.0/tests/test_enhanced_intelligence_error_handling.py +113 -0
  55. legesher_language_server-0.2.0/tests/test_enhanced_intelligence_status.py +303 -0
  56. legesher_language_server-0.2.0/tests/test_enhanced_intelligence_transport.py +950 -0
  57. legesher_language_server-0.2.0/tests/test_forwarded_builtins.py +236 -0
  58. legesher_language_server-0.2.0/tests/test_forwarded_diagnostic_severity.py +171 -0
  59. legesher_language_server-0.2.0/tests/test_forwarded_positions.py +313 -0
  60. legesher_language_server-0.2.0/tests/test_hover_provider.py +582 -0
  61. legesher_language_server-0.2.0/tests/test_keyword_docs_error_handling.py +93 -0
  62. legesher_language_server-0.2.0/tests/test_logging_setup.py +681 -0
  63. legesher_language_server-0.2.0/tests/test_proxy_engine_parity.py +134 -0
  64. legesher_language_server-0.2.0/tests/test_semantic_tokens_provider.py +679 -0
  65. legesher_language_server-0.2.0/tests/test_server.py +356 -0
  66. legesher_language_server-0.2.0/tests/test_source_map.py +411 -0
  67. legesher_language_server-0.2.0/tests/test_source_map_offset_gap.py +41 -0
  68. legesher_language_server-0.2.0/tests/test_translator_source_map.py +128 -0
  69. legesher_language_server-0.2.0/tests/test_type_alias_generator.py +319 -0
  70. legesher_language_server-0.2.0/tests/test_version.py +132 -0
  71. legesher_language_server-0.2.0/tests/timing.py +26 -0
  72. legesher_language_server-0.2.0/tests/utils/__init__.py +1 -0
  73. legesher_language_server-0.2.0/tests/utils/test_error_templates.py +645 -0
  74. legesher_language_server-0.2.0/tests/utils/test_parameter_translation.py +310 -0
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025-2026 Madison (Pfaff) Edgar and Legesher Contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,384 @@
1
+ Metadata-Version: 2.1
2
+ Name: legesher-language-server
3
+ Version: 0.2.0
4
+ Summary: Language Server Protocol implementation for multilingual Python programming
5
+ Keywords: legesher,multilingual,programming,lsp,language-server
6
+ Author-Email: "Madison (Pfaff) Edgar" <7844510+madiedgar@users.noreply.github.com>
7
+ License: Apache-2.0
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Project-URL: Homepage, https://legesher.io
17
+ Project-URL: Documentation, https://docs.legesher.io
18
+ Project-URL: Repository, https://github.com/legesher/legesher
19
+ Project-URL: Changelog, https://github.com/legesher/legesher/blob/main/libs/language-server/CHANGELOG.md
20
+ Project-URL: Issues, https://github.com/legesher/legesher/issues
21
+ Requires-Python: <4.0,>=3.10
22
+ Requires-Dist: pygls<3.0.0,>=2.0.0
23
+ Requires-Dist: pydantic>=2.5.0
24
+ Requires-Dist: lru-dict>=1.3.0
25
+ Requires-Dist: pyyaml>=6.0.0
26
+ Requires-Dist: legesher-i18n<1.0.0,>=0.22.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
29
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
30
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
31
+ Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
32
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
33
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
34
+ Description-Content-Type: text/markdown
35
+
36
+ # Legesher Language Server
37
+
38
+ > Language Server Protocol implementation for multilingual Python programming
39
+
40
+ **Status**: Pre-Beta | **Python**: 3.10-3.14 | **Languages**: 56 | **Version**: see `pyproject.toml`
41
+
42
+ ## Overview
43
+
44
+ The Legesher Language Server provides LSP support for coding in Python using your native language. It
45
+ enables real-time IDE features like hover tooltips, code completion, and diagnostics - all translated to
46
+ your preferred language.
47
+
48
+ ### What's Included
49
+
50
+ ✅ **Complete LSP Server** (pygls 2.0, Python 3.13 compatible)
51
+
52
+ - Language server using `pygls 2.0` framework
53
+ - Document state management with version tracking
54
+ - Configuration system with Pydantic validation
55
+ - Complete LSP lifecycle support
56
+
57
+ ✅ **Four Complete Providers**
58
+
59
+ - **Hover Provider** (CORE-357): Translated docstrings, keyword docs, cultural comments with LRU caching
60
+ - **Completion Provider** (CORE-358): Localized keywords, builtins, user symbols with fuzzy matching
61
+ - **Diagnostic Provider** (CORE-359): Translated error messages (41 templates, 17 error types)
62
+ - **Semantic Tokens Provider** (CORE-450): Syntax highlighting for translated keywords
63
+
64
+ ✅ **Enhanced Python intelligence** (CORE-360)
65
+
66
+ - EnhancedIntelligenceProxy for real-time code translation
67
+ - Caching with LanguagePackLoader (CORE-446)
68
+ - Thread-safe position mapping
69
+
70
+ ## Quick Start
71
+
72
+ ### Installation
73
+
74
+ ```bash
75
+ # Using uv
76
+ uv pip install -e .
77
+
78
+ # Using pip
79
+ pip install -e .
80
+ ```
81
+
82
+ ### Usage
83
+
84
+ ```bash
85
+ # Start server with Spanish
86
+ legesher-lsp --target-lang es
87
+
88
+ # With Python version specified
89
+ legesher-lsp --target-lang fr --python-version 3.11
90
+
91
+ # With debug logging
92
+ legesher-lsp --target-lang es --log-level DEBUG
93
+
94
+ # Use environment variables
95
+ export LEGESHER_TARGET_LANG=es
96
+ legesher-lsp
97
+ ```
98
+
99
+ ### In an editor
100
+
101
+ The server speaks LSP over stdio, so any LSP client can start `legesher-lsp`.
102
+ The Legesher VS Code extension runs it by default: its `legesher.serverCommand`
103
+ setting is `legesher-lsp`, so the command has to be on the `PATH` VS Code sees,
104
+ or the setting has to hold its full path.
105
+
106
+ ### Configuration
107
+
108
+ **Environment Variables:**
109
+
110
+ - `LEGESHER_SOURCE_LANG` - Source code language (default: `en`)
111
+ - `LEGESHER_TARGET_LANG` - Target display language (default: `es`)
112
+ - `LEGESHER_PYTHON_VERSION` - Python version (auto-detected if not set)
113
+ - `LEGESHER_CACHE_SIZE` - Translation cache size (default: 1000)
114
+ - `LEGESHER_CACHE_TTL` - Cache TTL in seconds (default: 3600)
115
+ - `LEGESHER_LOG_LEVEL` - Logging level (default: INFO)
116
+
117
+ **CLI Arguments:**
118
+
119
+ ```bash
120
+ legesher-lsp --help
121
+ ```
122
+
123
+ ### Logging
124
+
125
+ The server logs through the LSP's `window/logMessage` notification, so each
126
+ line reaches your editor's output channel at the severity it was written at.
127
+ stderr carries only what happens before a client connects, or what would
128
+ otherwise be lost.
129
+
130
+ Nothing verbose is logged by default, and no JSON-RPC payload is: those
131
+ payloads carry text out of the file you are editing. Set the client's trace
132
+ level to see more. In VS Code that is `legesher.trace.server`:
133
+
134
+ - `off` (default): the server's own messages, warnings and errors. No text out
135
+ of your file is logged at this level, though an error can still name the
136
+ document's path and the position that failed.
137
+ - `messages`: adds the server's debug detail, and some of that detail is read
138
+ out of your file, including the identifier under the cursor, the hover text
139
+ rendered for it, the source line of a syntax error, the path of every
140
+ document you open, change or close, and whatever the bundled Pyright backend
141
+ writes to its own stderr.
142
+ - `verbose`: adds full LSP payloads on top, so whole documents and every
143
+ request and response body go into the log as well.
144
+
145
+ `LEGESHER_LOG_LEVEL=DEBUG` raises verbosity from the first line, before a
146
+ client has connected to ask for it. It reaches the same debug lines `messages`
147
+ does, so it carries the same caveat.
148
+
149
+ ## Architecture
150
+
151
+ ```text
152
+ ┌─────────────────────┐
153
+ │ IDE/Editor │
154
+ │ (VS Code, Zed) │
155
+ └──────────┬──────────┘
156
+ │ LSP (stdio)
157
+ ┌──────────▼──────────┐
158
+ │ Language Server │
159
+ │ ├─ Server │
160
+ │ ├─ DocumentManager │
161
+ │ ├─ Config │
162
+ │ └─ Providers │
163
+ └──────────┬──────────┘
164
+ │
165
+ ┌──────────▼──────────┐
166
+ │ legesher-i18n │
167
+ │ (language packs) │
168
+ └─────────────────────┘
169
+ ```
170
+
171
+ See [ARCHITECTURE.md](ARCHITECTURE.md) for detailed architecture documentation.
172
+
173
+ ## Features
174
+
175
+ ### Hover Provider (CORE-357)
176
+
177
+ Translates Python docstrings and provides keyword documentation in the target language.
178
+
179
+ **Status:** ✅ Complete
180
+
181
+ **Features:**
182
+
183
+ - Docstring translation for functions, classes, modules
184
+ - Keyword documentation in target language
185
+ - Cultural comments for context
186
+ - Fast caching for repeated hovers
187
+
188
+ ### Completion Provider (CORE-358)
189
+
190
+ Provides localized code completion suggestions.
191
+
192
+ **Status:** ✅ Complete
193
+
194
+ **Features:**
195
+
196
+ - Localized Python keywords
197
+ - Translated built-in functions
198
+ - User-defined symbols with context
199
+ - Fuzzy matching for better UX
200
+
201
+ ### Diagnostic Provider (CORE-359)
202
+
203
+ Translates Python error messages while preserving code identifiers.
204
+
205
+ **Status:** ✅ Complete. The provider is registered on `textDocument/diagnostic` and parses the document for
206
+ syntax errors before translating the message.
207
+
208
+ **Features:**
209
+
210
+ - 41 error message templates covering 17 Python error types
211
+ - Translated messages for English, Spanish, and Arabic. Other languages get the untranslated CPython message
212
+ - Variable name preservation
213
+ - Template-based translation with caching
214
+
215
+ **Error Types With Templates:**
216
+
217
+ - AssertionError, AttributeError, FileNotFoundError, ImportError, IndentationError
218
+ - IndexError, KeyError, KeyboardInterrupt, ModuleNotFoundError, NameError
219
+ - RecursionError, RuntimeError, StopIteration, SyntaxError, TypeError
220
+ - ValueError, ZeroDivisionError
221
+
222
+ **Example Translation:**
223
+
224
+ The diagnostic carries the message body only; the exception type name is not prefixed.
225
+
226
+ English: `expected ':'`
227
+ Spanish: `se esperaba ':'`
228
+ Arabic: `متوقع ':'`
229
+
230
+ A message with no matching template is passed through in English rather than half-translated. For the
231
+ localized *type* names, see the language packs, which `legesher-runtime` uses when rendering tracebacks.
232
+
233
+ ## Migration Notes
234
+
235
+ ### pygls 2.0 Migration (CORE-448)
236
+
237
+ **Migration completed**: 2025-11-29
238
+
239
+ The language server has been successfully migrated from pygls 1.3.1 to pygls 2.0.0, resolving Python 3.13
240
+ compatibility issues and enabling full integration testing.
241
+
242
+ **Key Changes:**
243
+
244
+ - **Import path updated**: `from pygls.server import LanguageServer` → `from pygls.lsp.server import LanguageServer`
245
+ - **Python 3.13 support**: pygls 2.0 fixes bound method compatibility issues with Python 3.13
246
+ - **Handler signatures**: No changes required - existing handler signatures remain compatible
247
+ - **Test coverage**: Increased from 21% to 70% by un-skipping integration tests
248
+ - **Dependencies**: Also upgraded `lsprotocol` from 2023.0.1 to 2025.0.0
249
+
250
+ **What Works:**
251
+
252
+ ✅ All LSP lifecycle methods (initialize, shutdown, didOpen, didChange, didClose)
253
+ ✅ Hover provider with Spanish/Arabic keyword translations
254
+ ✅ Completion provider with 67+ keyword and builtin suggestions
255
+ ✅ Diagnostic provider with translated error messages
256
+ ✅ Python 3.13 compatibility verified
257
+
258
+ **Breaking Changes:**
259
+
260
+ None for users. This is an internal dependency upgrade with no API changes.
261
+
262
+ **For Contributors:**
263
+
264
+ If you encounter import errors with `pygls.server.LanguageServer`, update to use `pygls.lsp.server.LanguageServer`.
265
+
266
+ ## Development
267
+
268
+ ### Running Tests
269
+
270
+ ```bash
271
+ # All tests with coverage
272
+ pytest tests/ -v --cov=legesher_language_server --cov-report=term-missing
273
+
274
+ # Specific test file
275
+ pytest tests/test_config.py -v
276
+
277
+ # With debug output
278
+ pytest tests/ -v -s --log-cli-level=DEBUG
279
+ ```
280
+
281
+ ### Test Coverage
282
+
283
+ Most modules have a matching test module under `tests/`. Two do not: `incremental_translator.py` is
284
+ exercised only indirectly, through the `enhanced_intelligence` tests, and `__main__.py` has no test at all.
285
+ Run the suite with coverage to see the current numbers rather than trusting a figure written down here:
286
+
287
+ ```bash
288
+ pytest tests/ --cov=legesher_language_server --cov-report=term-missing
289
+ ```
290
+
291
+ ### Code Quality
292
+
293
+ ```bash
294
+ # Type checking
295
+ mypy legesher_language_server/
296
+
297
+ # Linting
298
+ ruff check legesher_language_server/
299
+
300
+ # Format
301
+ ruff format legesher_language_server/
302
+ ```
303
+
304
+ ## LSP Methods Supported
305
+
306
+ | Method | Status | Issue |
307
+ |--------|--------|-------|
308
+ | `initialize` | ✅ Implemented | CORE-356 |
309
+ | `initialized` | ✅ Implemented | CORE-356 |
310
+ | `shutdown` | ✅ Implemented | CORE-356 |
311
+ | `textDocument/didOpen` | ✅ Implemented | CORE-356 |
312
+ | `textDocument/didChange` | ✅ Implemented | CORE-356 |
313
+ | `textDocument/didClose` | ✅ Implemented | CORE-356 |
314
+ | `textDocument/hover` | ✅ Implemented | CORE-357 |
315
+ | `textDocument/completion` | ✅ Implemented | CORE-358 |
316
+ | `textDocument/diagnostic` | ✅ Implemented | CORE-359 |
317
+ | `textDocument/semanticTokens/full` | ✅ Implemented | CORE-450 |
318
+ | `legesher/status` (request) | ✅ Implemented | CORE-1886, CORE-1976 |
319
+ | `legesher/documentLanguage` (notification) | ✅ Implemented | CORE-1976 |
320
+
321
+ `legesher/documentLanguage` carries `{uri, language}`: the language one document
322
+ is written in. The server answers every request about that document in its
323
+ language, and falls back to the configured file language for a document it has
324
+ not been told about. `legesher/status` reports whether enhanced intelligence is
325
+ running and, under `documents`, the language each open document is served in,
326
+ with the reason when no pack can serve it.
327
+
328
+ ## For VS Code Extension Developers
329
+
330
+ The [Legesher VS Code extension](../vs-code/README.md) does this, and any other LSP client would do the same:
331
+
332
+ 1. Start `legesher-lsp` as a child process
333
+ 2. Connect via stdio transport
334
+ 3. Configure the source, file and working languages via initialization params
335
+ 4. Send `legesher/documentLanguage` for each document just before its `didOpen`,
336
+ and again when the language you resolve for it changes
337
+ 5. Handle LSP requests/responses
338
+ 6. Render translated content in custom UI
339
+
340
+ Example VS Code client configuration:
341
+
342
+ ```typescript
343
+ const serverOptions: ServerOptions = {
344
+ command: 'legesher-lsp',
345
+ args: ['--target-lang', targetLang],
346
+ options: { env: { LEGESHER_LOG_LEVEL: 'DEBUG' } }
347
+ };
348
+ ```
349
+
350
+ ## Dependencies
351
+
352
+ ### Runtime
353
+
354
+ - `pygls>=2.0.0,<3.0.0` - LSP framework (**Updated to v2.0** - CORE-448)
355
+ - `pydantic>=2.5.0` - Configuration validation
356
+ - `lru-dict>=1.3.0` - LRU caching
357
+ - `pyyaml>=6.0.0` - Language pack YAML loading
358
+ - `legesher-i18n` - Language pack loading
359
+
360
+ ### Development
361
+
362
+ - `pytest>=7.4.0`
363
+ - `pytest-asyncio>=0.21.0`
364
+ - `pytest-cov>=4.1.0`
365
+ - `mypy>=1.5.0`
366
+ - `ruff>=0.1.0`
367
+
368
+ ## Contributing
369
+
370
+ This package is part of the Legesher monorepo. See the [main README](../../README.md) for contribution guidelines.
371
+
372
+ ## License
373
+
374
+ Apache License 2.0 - see [LICENSE](LICENSE).
375
+
376
+ ## Related Documentation
377
+
378
+ - [Architecture Documentation](ARCHITECTURE.md)
379
+ - [Test Quick Reference](TEST_QUICK_REFERENCE.md)
380
+ - [Monorepo README](../../README.md)
381
+
382
+ ---
383
+
384
+ **Part of the Legesher Project** | [legesher.io](https://legesher.io)