wafer-lsp 0.1.13__py3-none-any.whl
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.
- wafer_lsp/__init__.py +1 -0
- wafer_lsp/__main__.py +9 -0
- wafer_lsp/analyzers/__init__.py +0 -0
- wafer_lsp/analyzers/compiler_integration.py +16 -0
- wafer_lsp/analyzers/docs_index.py +36 -0
- wafer_lsp/handlers/__init__.py +30 -0
- wafer_lsp/handlers/code_action.py +48 -0
- wafer_lsp/handlers/code_lens.py +48 -0
- wafer_lsp/handlers/completion.py +6 -0
- wafer_lsp/handlers/diagnostics.py +41 -0
- wafer_lsp/handlers/document_symbol.py +176 -0
- wafer_lsp/handlers/hip_diagnostics.py +303 -0
- wafer_lsp/handlers/hover.py +251 -0
- wafer_lsp/handlers/inlay_hint.py +245 -0
- wafer_lsp/handlers/semantic_tokens.py +224 -0
- wafer_lsp/handlers/workspace_symbol.py +87 -0
- wafer_lsp/languages/README.md +195 -0
- wafer_lsp/languages/__init__.py +17 -0
- wafer_lsp/languages/converter.py +88 -0
- wafer_lsp/languages/detector.py +107 -0
- wafer_lsp/languages/parser_manager.py +33 -0
- wafer_lsp/languages/registry.py +120 -0
- wafer_lsp/languages/types.py +37 -0
- wafer_lsp/parsers/__init__.py +36 -0
- wafer_lsp/parsers/base_parser.py +9 -0
- wafer_lsp/parsers/cuda_parser.py +95 -0
- wafer_lsp/parsers/cutedsl_parser.py +114 -0
- wafer_lsp/parsers/hip_parser.py +688 -0
- wafer_lsp/server.py +58 -0
- wafer_lsp/services/__init__.py +38 -0
- wafer_lsp/services/analysis_service.py +22 -0
- wafer_lsp/services/docs_service.py +40 -0
- wafer_lsp/services/document_service.py +20 -0
- wafer_lsp/services/hip_docs.py +806 -0
- wafer_lsp/services/hip_hover_service.py +412 -0
- wafer_lsp/services/hover_service.py +237 -0
- wafer_lsp/services/language_registry_service.py +26 -0
- wafer_lsp/services/position_service.py +77 -0
- wafer_lsp/utils/__init__.py +0 -0
- wafer_lsp/utils/lsp_helpers.py +79 -0
- wafer_lsp-0.1.13.dist-info/METADATA +60 -0
- wafer_lsp-0.1.13.dist-info/RECORD +44 -0
- wafer_lsp-0.1.13.dist-info/WHEEL +4 -0
- wafer_lsp-0.1.13.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
|
|
3
|
+
from lsprotocol.types import Position
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PositionService:
|
|
7
|
+
|
|
8
|
+
def get_word_at_position(self, content: str, position: Position) -> str:
|
|
9
|
+
lines = content.split("\n")
|
|
10
|
+
if position.line >= len(lines):
|
|
11
|
+
return ""
|
|
12
|
+
|
|
13
|
+
line = lines[position.line]
|
|
14
|
+
if position.character >= len(line):
|
|
15
|
+
return ""
|
|
16
|
+
|
|
17
|
+
start = position.character
|
|
18
|
+
while start > 0 and (line[start - 1].isalnum() or line[start - 1] == "_" or line[start - 1] == "."):
|
|
19
|
+
start -= 1
|
|
20
|
+
|
|
21
|
+
end = position.character
|
|
22
|
+
while end < len(line) and (line[end].isalnum() or line[end] == "_" or line[end] == "."):
|
|
23
|
+
end += 1
|
|
24
|
+
|
|
25
|
+
return line[start:end]
|
|
26
|
+
|
|
27
|
+
def get_decorator_at_position(self, content: str, position: Position) -> tuple[str, int] | None:
|
|
28
|
+
lines = content.split("\n")
|
|
29
|
+
if position.line >= len(lines):
|
|
30
|
+
return None
|
|
31
|
+
|
|
32
|
+
line = lines[position.line]
|
|
33
|
+
line_stripped = line.strip()
|
|
34
|
+
|
|
35
|
+
if not line_stripped.startswith("@"):
|
|
36
|
+
return None
|
|
37
|
+
|
|
38
|
+
at_pos = line.find("@")
|
|
39
|
+
if at_pos != -1 and position.character < at_pos:
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
tree = ast.parse(line_stripped, mode="eval")
|
|
44
|
+
if isinstance(tree.body, ast.Attribute):
|
|
45
|
+
if isinstance(tree.body.value, ast.Name):
|
|
46
|
+
decorator_name = f"{tree.body.value.id}.{tree.body.attr}"
|
|
47
|
+
for i in range(position.line + 1, len(lines)):
|
|
48
|
+
next_line = lines[i].strip()
|
|
49
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
50
|
+
return (decorator_name, i)
|
|
51
|
+
elif isinstance(tree.body, ast.Name):
|
|
52
|
+
decorator_name = tree.body.id
|
|
53
|
+
for i in range(position.line + 1, len(lines)):
|
|
54
|
+
next_line = lines[i].strip()
|
|
55
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
56
|
+
return (decorator_name, i)
|
|
57
|
+
except SyntaxError:
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
if "@cute.kernel" in line_stripped:
|
|
61
|
+
decorator_name = "cute.kernel"
|
|
62
|
+
for i in range(position.line + 1, len(lines)):
|
|
63
|
+
next_line = lines[i].strip()
|
|
64
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
65
|
+
return (decorator_name, i)
|
|
66
|
+
elif "@cute.struct" in line_stripped:
|
|
67
|
+
decorator_name = "cute.struct"
|
|
68
|
+
for i in range(position.line + 1, len(lines)):
|
|
69
|
+
next_line = lines[i].strip()
|
|
70
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
71
|
+
return (decorator_name, i)
|
|
72
|
+
|
|
73
|
+
return None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def create_position_service() -> PositionService:
|
|
77
|
+
return PositionService()
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
|
|
3
|
+
from lsprotocol.types import Position, Range
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_word_at_position(content: str, position: Position) -> str:
|
|
7
|
+
lines = content.split("\n")
|
|
8
|
+
if position.line >= len(lines):
|
|
9
|
+
return ""
|
|
10
|
+
|
|
11
|
+
line = lines[position.line]
|
|
12
|
+
if position.character >= len(line):
|
|
13
|
+
return ""
|
|
14
|
+
|
|
15
|
+
start = position.character
|
|
16
|
+
while start > 0 and (line[start - 1].isalnum() or line[start - 1] == "_" or line[start - 1] == "."):
|
|
17
|
+
start -= 1
|
|
18
|
+
|
|
19
|
+
end = position.character
|
|
20
|
+
while end < len(line) and (line[end].isalnum() or line[end] == "_" or line[end] == "."):
|
|
21
|
+
end += 1
|
|
22
|
+
|
|
23
|
+
return line[start:end]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_decorator_at_position(content: str, position: Position) -> tuple[str, int] | None:
|
|
27
|
+
lines = content.split("\n")
|
|
28
|
+
if position.line >= len(lines):
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
line = lines[position.line]
|
|
32
|
+
line_stripped = line.strip()
|
|
33
|
+
|
|
34
|
+
if not line_stripped.startswith("@"):
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
at_pos = line.find("@")
|
|
38
|
+
if at_pos != -1 and position.character < at_pos:
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
tree = ast.parse(line_stripped, mode="eval")
|
|
43
|
+
if isinstance(tree.body, ast.Attribute):
|
|
44
|
+
if isinstance(tree.body.value, ast.Name):
|
|
45
|
+
decorator_name = f"{tree.body.value.id}.{tree.body.attr}"
|
|
46
|
+
for i in range(position.line + 1, len(lines)):
|
|
47
|
+
next_line = lines[i].strip()
|
|
48
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
49
|
+
return (decorator_name, i)
|
|
50
|
+
elif isinstance(tree.body, ast.Name):
|
|
51
|
+
decorator_name = tree.body.id
|
|
52
|
+
for i in range(position.line + 1, len(lines)):
|
|
53
|
+
next_line = lines[i].strip()
|
|
54
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
55
|
+
return (decorator_name, i)
|
|
56
|
+
except SyntaxError:
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
if "@cute.kernel" in line_stripped:
|
|
60
|
+
decorator_name = "cute.kernel"
|
|
61
|
+
for i in range(position.line + 1, len(lines)):
|
|
62
|
+
next_line = lines[i].strip()
|
|
63
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
64
|
+
return (decorator_name, i)
|
|
65
|
+
elif "@cute.struct" in line_stripped:
|
|
66
|
+
decorator_name = "cute.struct"
|
|
67
|
+
for i in range(position.line + 1, len(lines)):
|
|
68
|
+
next_line = lines[i].strip()
|
|
69
|
+
if next_line.startswith("def ") or next_line.startswith("class "):
|
|
70
|
+
return (decorator_name, i)
|
|
71
|
+
|
|
72
|
+
return None
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def create_range(start_line: int, start_char: int, end_line: int, end_char: int) -> Range:
|
|
76
|
+
return Range(
|
|
77
|
+
start=Position(line=start_line, character=start_char),
|
|
78
|
+
end=Position(line=end_line, character=end_char),
|
|
79
|
+
)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wafer-lsp
|
|
3
|
+
Version: 0.1.13
|
|
4
|
+
Summary: Language Server Protocol server for GPU programming languages
|
|
5
|
+
Author-email: Wafer <support@wafer.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: c++,cuda,cutedsl,gpu,language-server,lsp
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Classifier: Topic :: Text Editors :: Integrated Development Environments (IDE)
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Requires-Dist: lsprotocol>=2024.0.0
|
|
17
|
+
Requires-Dist: pygls>=1.0.0
|
|
18
|
+
Requires-Dist: wafer-core
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# Wafer LSP
|
|
25
|
+
|
|
26
|
+
Language Server Protocol server for CuTeDSL (Python GPU programming).
|
|
27
|
+
|
|
28
|
+
**Beta Feature**: Currently only available when Beta Mode is enabled in VS Code settings.
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- **Hover Information**: Shows kernel and layout information with compiler analysis when hovering over CuTeDSL code
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install wafer-lsp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### VS Code Extension
|
|
43
|
+
|
|
44
|
+
The LSP server is integrated into the `wevin-extension` VS Code extension. It starts automatically when Beta Mode is enabled.
|
|
45
|
+
|
|
46
|
+
### Standalone
|
|
47
|
+
|
|
48
|
+
For Neovim or other editors:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m wafer_lsp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Supported Languages
|
|
55
|
+
|
|
56
|
+
- **CuTeDSL**: Python files with `@cute.kernel` decorators
|
|
57
|
+
|
|
58
|
+
## Architecture
|
|
59
|
+
|
|
60
|
+
The LSP server uses a modular language registry system. Currently supports CuTeDSL only. See `languages/README.md` for details on adding more languages.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
wafer_lsp/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
|
|
2
|
+
wafer_lsp/__main__.py,sha256=6J_zJGlexw3ASzI-MRpCzMwzaq_hTdIe12JWg97pLRQ,112
|
|
3
|
+
wafer_lsp/server.py,sha256=ZGFXghuPdKJH7aLhrYvOiKp6zfOdtoqWavdtDwg8Bk4,1938
|
|
4
|
+
wafer_lsp/analyzers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
wafer_lsp/analyzers/compiler_integration.py,sha256=SLyIZXk52nKP1b04s9Wo77cRLFn5auc4jGRo59Vl9Wc,341
|
|
6
|
+
wafer_lsp/analyzers/docs_index.py,sha256=hrrBgPzIM_mJewCzHyw-2YEWdIchuB3SAMXI8PhtDq0,1309
|
|
7
|
+
wafer_lsp/handlers/__init__.py,sha256=tPFuceRrlCkyW7N5BSRZJY7IMx9Etb6D5c54pZZHJ-w,926
|
|
8
|
+
wafer_lsp/handlers/code_action.py,sha256=PTWs4X3CkfprMmzqC3cg7uEWdfivNNH9thU4E-c6ztQ,1411
|
|
9
|
+
wafer_lsp/handlers/code_lens.py,sha256=mhdJtbS2LMNHGOirJbXUfatqhqMBess5wndfBBOLnok,1301
|
|
10
|
+
wafer_lsp/handlers/completion.py,sha256=qz36GIJXu2fG6K-FdbFNGCCTYSpyV5A6-WOHHNne7QI,142
|
|
11
|
+
wafer_lsp/handlers/diagnostics.py,sha256=zSaBYdZCqBK2Nb2WhCyQfKDATf8nsj6jMv-K1lvxnQc,1137
|
|
12
|
+
wafer_lsp/handlers/document_symbol.py,sha256=H9rehZlbJKZ-2ueyvTYvz0_-0xfiGaAEPXSWbp76JUk,6465
|
|
13
|
+
wafer_lsp/handlers/hip_diagnostics.py,sha256=YFaSBuwBb7DJNWhBQpwVzYDJvA0KmMV5X9aEEk4X8eM,10923
|
|
14
|
+
wafer_lsp/handlers/hover.py,sha256=F3vweiSHcFlF66qvneJkX02hTq3iaxfXK2h9EkufL7w,8788
|
|
15
|
+
wafer_lsp/handlers/inlay_hint.py,sha256=HW-AFeWps2VbEGPMTAG9KHyiT1s2JS81F71BXq7rwoA,7765
|
|
16
|
+
wafer_lsp/handlers/semantic_tokens.py,sha256=JNJetP7Flh6yxNFzkGM3Ho9D4HaHsVSmoXdgcJnJtZM,7447
|
|
17
|
+
wafer_lsp/handlers/workspace_symbol.py,sha256=YGSkf6doChh1BjVezEQFgIsI2NsQHhOjLchoF5bfBK4,2934
|
|
18
|
+
wafer_lsp/languages/README.md,sha256=hLBqOBvKSqeCrNH9Wrr6XAHa8eBnd81IargPDurodU8,5527
|
|
19
|
+
wafer_lsp/languages/__init__.py,sha256=5cXQkPRsh4JLyZd2QubvTxvuip10695Hb2zjyGF6Frc,472
|
|
20
|
+
wafer_lsp/languages/converter.py,sha256=LPKJfkUV-rNXyJg7Tr5AZ1AlREKH4ulfjDHWlUNvyXU,2487
|
|
21
|
+
wafer_lsp/languages/detector.py,sha256=7FDQZlnfnkI7DCeySzecIarYnNLINlIRgRkCj7L3SQY,4235
|
|
22
|
+
wafer_lsp/languages/parser_manager.py,sha256=RBYS0w2wIRkKlrEDYvMEGKbsTkOSEpfUB3fjH_9X0Hk,945
|
|
23
|
+
wafer_lsp/languages/registry.py,sha256=Ka9WDURUniqUAZDpdrQtRTLLzS36n4hq2dIwqj_AFdc,3703
|
|
24
|
+
wafer_lsp/languages/types.py,sha256=c22sDECraXHvazqJSF7WC1ntFNyf9Mbx60EXA9jrbWk,624
|
|
25
|
+
wafer_lsp/parsers/__init__.py,sha256=yh41cxz8Siuv0doHXnhuSY-JPoN82XtqDiOrbJAGeEg,709
|
|
26
|
+
wafer_lsp/parsers/base_parser.py,sha256=RQjk5QOHrS398CrUGP2ZtSsisSl6Kh0KgWLPssSv8ss,176
|
|
27
|
+
wafer_lsp/parsers/cuda_parser.py,sha256=X2EX8gFcZCK8-lSsedby1-vSgYsl2CHLxRxzwr5yIlI,2621
|
|
28
|
+
wafer_lsp/parsers/cutedsl_parser.py,sha256=1r2gdAuwFrp4fQQNEQCRpkwtfunus-hq4h92j2MZyFE,3711
|
|
29
|
+
wafer_lsp/parsers/hip_parser.py,sha256=nJdwsyTWxdeRJkLMHzUC_4px2fWvtwxd5FgdqOvIXAU,26465
|
|
30
|
+
wafer_lsp/services/__init__.py,sha256=lMMuCBSMfKQeTlUnSo82tXuMGN9rmeoTmCfUigZReL0,1191
|
|
31
|
+
wafer_lsp/services/analysis_service.py,sha256=J6jcg0YQZh9iQYyOXO9bF5NqaJDfnIKhwssCLNcUJjA,619
|
|
32
|
+
wafer_lsp/services/docs_service.py,sha256=ltjkPuQ4DUmuc95AZVfQ6GSWgpjKqv_6-Luh2CFPocQ,1393
|
|
33
|
+
wafer_lsp/services/document_service.py,sha256=gdQ-leIUSK7tiffFsi4UsseIyBx2TO_WIlBPFh57GU8,559
|
|
34
|
+
wafer_lsp/services/hip_docs.py,sha256=mmbFy89Jpj3KUXLO_0M73f0zrkiIw6omtqwCva0Y7Jw,40442
|
|
35
|
+
wafer_lsp/services/hip_hover_service.py,sha256=zbnjdsU6jlCIJh38EDM0sGnLr8I7VKbLABaULJxcXwE,14112
|
|
36
|
+
wafer_lsp/services/hover_service.py,sha256=Zby2lhMO4US2IVTAVuU-ntkRKWrrR7HEjWdlGFSRQj4,9743
|
|
37
|
+
wafer_lsp/services/language_registry_service.py,sha256=qvMR9oI1pUrSv09Q-WRF5-sEu2Nma2fZeUhdydIWaqg,864
|
|
38
|
+
wafer_lsp/services/position_service.py,sha256=Nx-_AuBEr_yUXjAYPfJ_wmeGM_Gy5vbIUW163GqblCU,2831
|
|
39
|
+
wafer_lsp/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
wafer_lsp/utils/lsp_helpers.py,sha256=pXYvm_gJiJ_TAwwyGxhqvWJQx6CBecYK1c6tVY7gUF8,2739
|
|
41
|
+
wafer_lsp-0.1.13.dist-info/METADATA,sha256=F0NGET532pP9BssFunp3FRIqUw_yvaIH_qsFmxWJ6eA,1742
|
|
42
|
+
wafer_lsp-0.1.13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
43
|
+
wafer_lsp-0.1.13.dist-info/entry_points.txt,sha256=XHcM0QZy6GzCYY2ajejqL0tZ2X6y6zYWP0Lg1egxGW4,54
|
|
44
|
+
wafer_lsp-0.1.13.dist-info/RECORD,,
|