python-fragments 0.3__tar.gz → 0.4__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.
- {python_fragments-0.3 → python_fragments-0.4}/PKG-INFO +1 -1
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/lifecycle.py +33 -23
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/server.py +7 -0
- {python_fragments-0.3 → python_fragments-0.4}/pyproject.toml +1 -1
- {python_fragments-0.3 → python_fragments-0.4}/python_fragments.egg-info/PKG-INFO +1 -1
- {python_fragments-0.3 → python_fragments-0.4}/README.md +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/__init__.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/ast_nodes.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/cli.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/grammar.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/html/__init__.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/html/elements.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/loader.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/__init__.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/completion.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/definition.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/file_state.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/hover.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/pyright.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/rename.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/lsp/semantic_tokens.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/source.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/fragments/transpiler.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/python_fragments.egg-info/SOURCES.txt +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/python_fragments.egg-info/dependency_links.txt +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/python_fragments.egg-info/entry_points.txt +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/python_fragments.egg-info/requires.txt +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/python_fragments.egg-info/top_level.txt +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/setup.cfg +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/tests/test_grammar.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/tests/test_pyright.py +0 -0
- {python_fragments-0.3 → python_fragments-0.4}/tests/test_source_map.py +0 -0
|
@@ -6,7 +6,7 @@ from lsprotocol import types
|
|
|
6
6
|
|
|
7
7
|
from fragments import grammar
|
|
8
8
|
from fragments.lsp.pyright import PyrightClient
|
|
9
|
-
from fragments.lsp.server import FragmentsServer, _TOKEN_MODIFIERS, _TOKEN_TYPES, _build_file_state, _parse_error_to_diagnostic, server
|
|
9
|
+
from fragments.lsp.server import FragmentsServer, _TOKEN_MODIFIERS, _TOKEN_TYPES, _build_file_state, _converter, _parse_error_to_diagnostic, server
|
|
10
10
|
|
|
11
11
|
_DEBOUNCE_SECONDS = 0.15
|
|
12
12
|
|
|
@@ -56,18 +56,19 @@ async def did_open(language_server: FragmentsServer, params: types.DidOpenTextDo
|
|
|
56
56
|
language_server._republish_diagnostics(document.uri)
|
|
57
57
|
language_server._files[document.uri] = state
|
|
58
58
|
|
|
59
|
-
if language_server._pyright:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
59
|
+
if not language_server._pyright:
|
|
60
|
+
return
|
|
61
|
+
language_server._pyright.notify(
|
|
62
|
+
"textDocument/didOpen",
|
|
63
|
+
{
|
|
64
|
+
"textDocument": {
|
|
65
|
+
"uri": document.uri,
|
|
66
|
+
"languageId": document.language_id,
|
|
67
|
+
"version": document.version,
|
|
68
|
+
"text": content_for_pyright,
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
)
|
|
71
72
|
|
|
72
73
|
|
|
73
74
|
@server.feature(types.TEXT_DOCUMENT_DID_CHANGE)
|
|
@@ -86,14 +87,15 @@ def did_change(language_server: FragmentsServer, params: types.DidChangeTextDocu
|
|
|
86
87
|
state, content_for_pyright = await asyncio.get_running_loop().run_in_executor(None, _build_file_state, text)
|
|
87
88
|
language_server._parse_errors[uri] = None
|
|
88
89
|
language_server._files[uri] = state
|
|
89
|
-
if language_server._pyright:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
90
|
+
if not language_server._pyright:
|
|
91
|
+
return
|
|
92
|
+
language_server._pyright.notify(
|
|
93
|
+
"textDocument/didChange",
|
|
94
|
+
{
|
|
95
|
+
"textDocument": {"uri": uri, "version": params.text_document.version},
|
|
96
|
+
"contentChanges": [{"text": content_for_pyright}],
|
|
97
|
+
},
|
|
98
|
+
)
|
|
97
99
|
except grammar.ParsingError as error:
|
|
98
100
|
language_server._parse_errors[uri] = _parse_error_to_diagnostic(text, error)
|
|
99
101
|
language_server._republish_diagnostics(uri)
|
|
@@ -112,5 +114,13 @@ def did_close(language_server: FragmentsServer, params: types.DidCloseTextDocume
|
|
|
112
114
|
if existing:
|
|
113
115
|
existing.cancel()
|
|
114
116
|
|
|
115
|
-
if language_server._pyright:
|
|
116
|
-
|
|
117
|
+
if not language_server._pyright:
|
|
118
|
+
return
|
|
119
|
+
language_server._pyright.notify("textDocument/didClose", {"textDocument": {"uri": uri}})
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@server.feature(types.WORKSPACE_DID_CHANGE_WATCHED_FILES)
|
|
123
|
+
def did_change_watched_files(language_server: FragmentsServer, params: types.DidChangeWatchedFilesParams) -> None:
|
|
124
|
+
if not language_server._pyright:
|
|
125
|
+
return
|
|
126
|
+
language_server._pyright.notify("workspace/didChangeWatchedFiles", _converter.unstructure(params))
|
|
@@ -49,6 +49,12 @@ class FragmentsServer(LanguageServer):
|
|
|
49
49
|
config = {**(config or {}), "pythonPath": sys.executable, "defaultInterpreterPath": sys.executable}
|
|
50
50
|
result.append(config) # type: ignore[arg-type]
|
|
51
51
|
return result
|
|
52
|
+
if message["method"] == "client/registerCapability":
|
|
53
|
+
await self.client_register_capability_async(_converter.structure(message["params"], types.RegistrationParams))
|
|
54
|
+
return {}
|
|
55
|
+
if message["method"] == "client/unregisterCapability":
|
|
56
|
+
await self.client_unregister_capability_async(_converter.structure(message["params"], types.UnregistrationParams))
|
|
57
|
+
return {}
|
|
52
58
|
return None
|
|
53
59
|
|
|
54
60
|
async def _publish_diagnostics(self, params: dict[str, Any]) -> None:
|
|
@@ -122,6 +128,7 @@ def _build_file_state(text: str) -> tuple[_FileState | None, str]:
|
|
|
122
128
|
|
|
123
129
|
def main() -> None:
|
|
124
130
|
from fragments.lsp import completion, definition, hover, lifecycle, rename, semantic_tokens # noqa: F401
|
|
131
|
+
|
|
125
132
|
server.start_io()
|
|
126
133
|
|
|
127
134
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-fragments"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4"
|
|
8
8
|
description = "Modern HTML template rendering in Python"
|
|
9
9
|
authors = [{ name = "The Running Algorithm", email = "services@therunningalgorithm.info" }]
|
|
10
10
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fragments-0.3 → python_fragments-0.4}/python_fragments.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|