citry-lsp 0.1.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 (36) hide show
  1. citry_lsp-0.1.0/LICENSE +22 -0
  2. citry_lsp-0.1.0/PKG-INFO +149 -0
  3. citry_lsp-0.1.0/README.md +119 -0
  4. citry_lsp-0.1.0/citry_lsp/__init__.py +23 -0
  5. citry_lsp-0.1.0/citry_lsp/__main__.py +26 -0
  6. citry_lsp-0.1.0/citry_lsp/app_worker.py +519 -0
  7. citry_lsp-0.1.0/citry_lsp/catalog.py +639 -0
  8. citry_lsp-0.1.0/citry_lsp/engine.py +9783 -0
  9. citry_lsp-0.1.0/citry_lsp/formatting.py +376 -0
  10. citry_lsp-0.1.0/citry_lsp/project.py +1011 -0
  11. citry_lsp-0.1.0/citry_lsp/protocol.py +73 -0
  12. citry_lsp-0.1.0/citry_lsp/py.typed +1 -0
  13. citry_lsp-0.1.0/citry_lsp/regions.py +370 -0
  14. citry_lsp-0.1.0/citry_lsp/semantic.py +767 -0
  15. citry_lsp-0.1.0/citry_lsp/server.py +1424 -0
  16. citry_lsp-0.1.0/citry_lsp/type_analysis.py +912 -0
  17. citry_lsp-0.1.0/citry_lsp/uri.py +52 -0
  18. citry_lsp-0.1.0/citry_lsp.egg-info/PKG-INFO +149 -0
  19. citry_lsp-0.1.0/citry_lsp.egg-info/SOURCES.txt +34 -0
  20. citry_lsp-0.1.0/citry_lsp.egg-info/dependency_links.txt +1 -0
  21. citry_lsp-0.1.0/citry_lsp.egg-info/entry_points.txt +2 -0
  22. citry_lsp-0.1.0/citry_lsp.egg-info/requires.txt +2 -0
  23. citry_lsp-0.1.0/citry_lsp.egg-info/top_level.txt +1 -0
  24. citry_lsp-0.1.0/pyproject.toml +50 -0
  25. citry_lsp-0.1.0/setup.cfg +4 -0
  26. citry_lsp-0.1.0/tests/test_catalog.py +336 -0
  27. citry_lsp-0.1.0/tests/test_engine.py +5129 -0
  28. citry_lsp-0.1.0/tests/test_formatting.py +421 -0
  29. citry_lsp-0.1.0/tests/test_jetbrains_template.py +54 -0
  30. citry_lsp-0.1.0/tests/test_lsp_distribution_artifacts.py +170 -0
  31. citry_lsp-0.1.0/tests/test_project.py +652 -0
  32. citry_lsp-0.1.0/tests/test_regions.py +76 -0
  33. citry_lsp-0.1.0/tests/test_semantic.py +2065 -0
  34. citry_lsp-0.1.0/tests/test_server.py +1919 -0
  35. citry_lsp-0.1.0/tests/test_type_analysis.py +989 -0
  36. citry_lsp-0.1.0/tests/test_uri.py +55 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Juro Oravec
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.4
2
+ Name: citry-lsp
3
+ Version: 0.1.0
4
+ Summary: Language server for Citry component templates
5
+ Author-email: Juro Oravec <juraj.oravec.josefson@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://citry.dev
8
+ Project-URL: Repository, https://github.com/citry-dev/citry
9
+ Project-URL: Changelog, https://github.com/citry-dev/citry/blob/main/packages/py/citry_lsp/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/citry-dev/citry/issues
11
+ Keywords: citry,language server,lsp,templates,html
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Plugins
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: <4.0,>=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: citry[analysis-ty]<0.5,>=0.4.0
28
+ Requires-Dist: pygls==2.1.1
29
+ Dynamic: license-file
30
+
31
+ # Citry language server
32
+
33
+ `citry-lsp` brings Citry template diagnostics, completion, hover, navigation,
34
+ symbols, references, and formatting to editors that support the Language Server
35
+ Protocol.
36
+
37
+ It understands templates written inside Python, standalone `citry-html`
38
+ documents, and template files owned by registered components. It can work
39
+ without loading an app, while a project-aware installation also understands
40
+ your registered components and their Python declarations.
41
+
42
+ ## Install in your project
43
+
44
+ Install the server in the same Python environment as the Citry project:
45
+
46
+ ```console
47
+ python -m pip install citry-lsp
48
+ ```
49
+
50
+ The 0.1.x server supports Citry 0.4.x and Python 3.10 through 3.14. It installs
51
+ the compatible Citry runtime, pygls, and the supported `ty` analyzer
52
+ automatically.
53
+
54
+ Your editor should launch this command over stdio:
55
+
56
+ ```console
57
+ citry-lsp
58
+ ```
59
+
60
+ For an isolated syntax-only process, use:
61
+
62
+ ```console
63
+ uvx --from citry-lsp citry-lsp
64
+ ```
65
+
66
+ The isolated form cannot import the project app, so it deliberately omits
67
+ registry-backed component knowledge.
68
+
69
+ ## Choose how much project knowledge to load
70
+
71
+ Without a project target, the server reports `syntax-only` mode. Parser
72
+ diagnostics, Citry structural completion, lexical `c-for` and `c-fill`
73
+ bindings, first-party hover help, and structural formatting remain available.
74
+ The server does not guess which user components exist.
75
+
76
+ For component-aware features, the editor supplies a `module:attribute` target
77
+ through its `citry.app` setting:
78
+
79
+ ```json
80
+ {
81
+ "citry.app": "my_project.web:app"
82
+ }
83
+ ```
84
+
85
+ The target may be a configured `Citry` instance or a `ComponentLibrary`:
86
+
87
+ ```json
88
+ {
89
+ "citry.app": "citry_ui:__citry_library__"
90
+ }
91
+ ```
92
+
93
+ The server imports that target in a bounded worker process. Import errors,
94
+ invalid targets, crashes, and timeouts produce one visible status message and
95
+ fall back to syntax-only behavior without corrupting the editor connection.
96
+
97
+ Registry mode adds:
98
+
99
+ - component, input, slot, and typed slot-data completion and hover;
100
+ - navigation to component classes, schema fields, inferred data keys, and
101
+ template bindings;
102
+ - `TemplateData`, `JsData`, and `CssData` checks across Python, templates,
103
+ Alpine expressions, JavaScript, and CSS;
104
+ - Events handler and `$c-props` checks;
105
+ - Fluent message, key, argument, formatter, and translation navigation;
106
+ - project lint settings and component-aware diagnostics.
107
+
108
+ Each workspace folder should run its own server process so it can use that
109
+ folder's Python interpreter and registry target.
110
+
111
+ ## Type-aware template expressions
112
+
113
+ The server uses the `ty` executable installed in the selected project
114
+ environment. Proven template roots receive Python member and call completion,
115
+ hover, definitions, signature help, narrowing, and source-mapped diagnostics.
116
+
117
+ If `ty` is missing, has the wrong version, exits, or times out, the server shows
118
+ one degradation notice and keeps parser diagnostics and Citry-owned root
119
+ features active.
120
+
121
+ ## Formatting
122
+
123
+ Protocol v1 formats `citry-html` documents and parser-proven templates inside
124
+ Python through Citry's shared structural formatter. Registry-proven ordinary
125
+ HTML template files can be formatted through the explicit Citry request without
126
+ registering Citry as the formatter for every HTML document.
127
+
128
+ Clients may also negotiate `citry/formatComponentAssets` and
129
+ `citry/formatEmbedded` for one atomic template, JavaScript, and CSS formatting
130
+ operation. Stale or malformed client responses produce no edit.
131
+
132
+ ## Compatibility
133
+
134
+ The server advertises language-server version 0.1.0, Citry 0.4.x, component
135
+ catalog v1, and client protocol v1. It refuses incompatible client protocols or
136
+ Citry series instead of returning results based on a contract it does not
137
+ understand.
138
+
139
+ The console command accepts pygls development transports:
140
+
141
+ ```console
142
+ citry-lsp --tcp --host 127.0.0.1 --port 2087
143
+ ```
144
+
145
+ Use stdio for normal editor integration.
146
+
147
+ For editor setup and troubleshooting, see the
148
+ [Citry IDE guide](https://citry.dev/ide/vscode/). Report problems through the
149
+ [Citry issue tracker](https://github.com/citry-dev/citry/issues).
@@ -0,0 +1,119 @@
1
+ # Citry language server
2
+
3
+ `citry-lsp` brings Citry template diagnostics, completion, hover, navigation,
4
+ symbols, references, and formatting to editors that support the Language Server
5
+ Protocol.
6
+
7
+ It understands templates written inside Python, standalone `citry-html`
8
+ documents, and template files owned by registered components. It can work
9
+ without loading an app, while a project-aware installation also understands
10
+ your registered components and their Python declarations.
11
+
12
+ ## Install in your project
13
+
14
+ Install the server in the same Python environment as the Citry project:
15
+
16
+ ```console
17
+ python -m pip install citry-lsp
18
+ ```
19
+
20
+ The 0.1.x server supports Citry 0.4.x and Python 3.10 through 3.14. It installs
21
+ the compatible Citry runtime, pygls, and the supported `ty` analyzer
22
+ automatically.
23
+
24
+ Your editor should launch this command over stdio:
25
+
26
+ ```console
27
+ citry-lsp
28
+ ```
29
+
30
+ For an isolated syntax-only process, use:
31
+
32
+ ```console
33
+ uvx --from citry-lsp citry-lsp
34
+ ```
35
+
36
+ The isolated form cannot import the project app, so it deliberately omits
37
+ registry-backed component knowledge.
38
+
39
+ ## Choose how much project knowledge to load
40
+
41
+ Without a project target, the server reports `syntax-only` mode. Parser
42
+ diagnostics, Citry structural completion, lexical `c-for` and `c-fill`
43
+ bindings, first-party hover help, and structural formatting remain available.
44
+ The server does not guess which user components exist.
45
+
46
+ For component-aware features, the editor supplies a `module:attribute` target
47
+ through its `citry.app` setting:
48
+
49
+ ```json
50
+ {
51
+ "citry.app": "my_project.web:app"
52
+ }
53
+ ```
54
+
55
+ The target may be a configured `Citry` instance or a `ComponentLibrary`:
56
+
57
+ ```json
58
+ {
59
+ "citry.app": "citry_ui:__citry_library__"
60
+ }
61
+ ```
62
+
63
+ The server imports that target in a bounded worker process. Import errors,
64
+ invalid targets, crashes, and timeouts produce one visible status message and
65
+ fall back to syntax-only behavior without corrupting the editor connection.
66
+
67
+ Registry mode adds:
68
+
69
+ - component, input, slot, and typed slot-data completion and hover;
70
+ - navigation to component classes, schema fields, inferred data keys, and
71
+ template bindings;
72
+ - `TemplateData`, `JsData`, and `CssData` checks across Python, templates,
73
+ Alpine expressions, JavaScript, and CSS;
74
+ - Events handler and `$c-props` checks;
75
+ - Fluent message, key, argument, formatter, and translation navigation;
76
+ - project lint settings and component-aware diagnostics.
77
+
78
+ Each workspace folder should run its own server process so it can use that
79
+ folder's Python interpreter and registry target.
80
+
81
+ ## Type-aware template expressions
82
+
83
+ The server uses the `ty` executable installed in the selected project
84
+ environment. Proven template roots receive Python member and call completion,
85
+ hover, definitions, signature help, narrowing, and source-mapped diagnostics.
86
+
87
+ If `ty` is missing, has the wrong version, exits, or times out, the server shows
88
+ one degradation notice and keeps parser diagnostics and Citry-owned root
89
+ features active.
90
+
91
+ ## Formatting
92
+
93
+ Protocol v1 formats `citry-html` documents and parser-proven templates inside
94
+ Python through Citry's shared structural formatter. Registry-proven ordinary
95
+ HTML template files can be formatted through the explicit Citry request without
96
+ registering Citry as the formatter for every HTML document.
97
+
98
+ Clients may also negotiate `citry/formatComponentAssets` and
99
+ `citry/formatEmbedded` for one atomic template, JavaScript, and CSS formatting
100
+ operation. Stale or malformed client responses produce no edit.
101
+
102
+ ## Compatibility
103
+
104
+ The server advertises language-server version 0.1.0, Citry 0.4.x, component
105
+ catalog v1, and client protocol v1. It refuses incompatible client protocols or
106
+ Citry series instead of returning results based on a contract it does not
107
+ understand.
108
+
109
+ The console command accepts pygls development transports:
110
+
111
+ ```console
112
+ citry-lsp --tcp --host 127.0.0.1 --port 2087
113
+ ```
114
+
115
+ Use stdio for normal editor integration.
116
+
117
+ For editor setup and troubleshooting, see the
118
+ [Citry IDE guide](https://citry.dev/ide/vscode/). Report problems through the
119
+ [Citry issue tracker](https://github.com/citry-dev/citry/issues).
@@ -0,0 +1,23 @@
1
+ """Citry language-server package and protocol declarations."""
2
+
3
+ from citry_lsp.protocol import (
4
+ CATALOG_SCHEMA_VERSION,
5
+ EMBEDDED_FORMATTING_VERSION,
6
+ FORMAT_COMPONENT_ASSETS_METHOD,
7
+ FORMAT_EMBEDDED_METHOD,
8
+ FORMAT_TEMPLATES_METHOD,
9
+ PROTOCOL_VERSION,
10
+ SERVER_VERSION,
11
+ SUPPORTED_CITRY_SERIES,
12
+ )
13
+
14
+ __all__ = [
15
+ "CATALOG_SCHEMA_VERSION",
16
+ "EMBEDDED_FORMATTING_VERSION",
17
+ "FORMAT_COMPONENT_ASSETS_METHOD",
18
+ "FORMAT_EMBEDDED_METHOD",
19
+ "FORMAT_TEMPLATES_METHOD",
20
+ "PROTOCOL_VERSION",
21
+ "SERVER_VERSION",
22
+ "SUPPORTED_CITRY_SERIES",
23
+ ]
@@ -0,0 +1,26 @@
1
+ """Console entry point for the Citry language server."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+ from typing import TYPE_CHECKING
7
+
8
+ from pygls.cli import start_server
9
+
10
+ from citry_lsp.server import server
11
+
12
+ if TYPE_CHECKING:
13
+ from collections.abc import Sequence
14
+
15
+
16
+ def main(argv: Sequence[str] | None = None) -> int:
17
+ """Start stdio by default, or a pygls development transport."""
18
+ start_server(server, list(sys.argv[1:] if argv is None else argv))
19
+ return 0
20
+
21
+
22
+ if __name__ == "__main__":
23
+ raise SystemExit(main())
24
+
25
+
26
+ __all__ = ["main"]