sqlakit-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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anton Ruhlov
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.
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: sqlakit-lsp
3
+ Version: 0.1.0
4
+ Summary: The language server for SQLAKit templates.
5
+ Keywords: sqlalchemy,sqlakit,lsp,language-server,sql
6
+ Author: Anton Ruhlov
7
+ Author-email: Anton Ruhlov <antonruhlov@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Database
19
+ Classifier: Topic :: Text Editors :: Integrated Development Environments (IDE)
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: sqlakit>=0.21.0,<0.22
22
+ Requires-Dist: pygls>=2.1,<3
23
+ Requires-Python: >=3.11
24
+ Project-URL: Repository, https://github.com/sqlakit/sqlakit-lsp
25
+ Project-URL: Documentation, https://github.com/sqlakit/sqlakit-lsp#readme
26
+ Description-Content-Type: text/markdown
27
+
28
+ # sqlakit-lsp
29
+
30
+ The language server for [SQLAKit](https://sqlakit.readthedocs.io/en/stable/)
31
+ templates. In a `.sql` template:
32
+
33
+ - the problems `sqlakit check` finds, as you type
34
+ - completion after `tpl.` and in `tpl.include('`, and a macro's arguments while
35
+ you write them
36
+ - on hover, the SQL a call writes, above the macro's signature and docstring
37
+ - go to definition, implementation and references of a macro or a template
38
+ - rename of a macro or a template across the project
39
+ - the macros' calls and the parameters coloured
40
+ - a parameter no call of the project passes, marked, with a quick fix for a
41
+ name close to one the calls pass
42
+ - **Show rendered SQL**, the whole template as the SQL it writes
43
+ - the outline of a template, and a search for a macro or a template
44
+
45
+ In Python, the template name in `db.sql("...")` completes and links to its
46
+ file, and a value the template does not read is marked.
47
+
48
+ ```console
49
+ $ pip install sqlakit-lsp
50
+ ```
51
+
52
+ Register `sqlakit-lsp` for `.sql` and `.py` files in your editor. It talks over
53
+ stdio. In Neovim 0.11:
54
+
55
+ ```lua
56
+ vim.lsp.config("sqlakit", {
57
+ cmd = { "sqlakit-lsp" },
58
+ filetypes = { "sql", "python" },
59
+ root_markers = { "pyproject.toml" },
60
+ })
61
+ vim.lsp.enable("sqlakit")
62
+ ```
63
+
64
+ Zed colours the macros' calls and the parameters of a template from the
65
+ server once its settings say `"semantic_tokens": "combined"`.
66
+
67
+ It reads the project the way `sqlakit check` does, from the `Templates(...)`
68
+ the code builds, without running it. [SQL
69
+ templates](https://sqlakit.readthedocs.io/en/stable/sql/#template-validation)
70
+ covers what it reads, and `[tool.sqlakit.templates]` for a project whose code
71
+ builds its paths in a way it can't follow.
72
+
73
+ ## Development
74
+
75
+ ```console
76
+ $ uv sync
77
+ $ uv run poe test
78
+ $ uv run poe lint
79
+ ```
@@ -0,0 +1,52 @@
1
+ # sqlakit-lsp
2
+
3
+ The language server for [SQLAKit](https://sqlakit.readthedocs.io/en/stable/)
4
+ templates. In a `.sql` template:
5
+
6
+ - the problems `sqlakit check` finds, as you type
7
+ - completion after `tpl.` and in `tpl.include('`, and a macro's arguments while
8
+ you write them
9
+ - on hover, the SQL a call writes, above the macro's signature and docstring
10
+ - go to definition, implementation and references of a macro or a template
11
+ - rename of a macro or a template across the project
12
+ - the macros' calls and the parameters coloured
13
+ - a parameter no call of the project passes, marked, with a quick fix for a
14
+ name close to one the calls pass
15
+ - **Show rendered SQL**, the whole template as the SQL it writes
16
+ - the outline of a template, and a search for a macro or a template
17
+
18
+ In Python, the template name in `db.sql("...")` completes and links to its
19
+ file, and a value the template does not read is marked.
20
+
21
+ ```console
22
+ $ pip install sqlakit-lsp
23
+ ```
24
+
25
+ Register `sqlakit-lsp` for `.sql` and `.py` files in your editor. It talks over
26
+ stdio. In Neovim 0.11:
27
+
28
+ ```lua
29
+ vim.lsp.config("sqlakit", {
30
+ cmd = { "sqlakit-lsp" },
31
+ filetypes = { "sql", "python" },
32
+ root_markers = { "pyproject.toml" },
33
+ })
34
+ vim.lsp.enable("sqlakit")
35
+ ```
36
+
37
+ Zed colours the macros' calls and the parameters of a template from the
38
+ server once its settings say `"semantic_tokens": "combined"`.
39
+
40
+ It reads the project the way `sqlakit check` does, from the `Templates(...)`
41
+ the code builds, without running it. [SQL
42
+ templates](https://sqlakit.readthedocs.io/en/stable/sql/#template-validation)
43
+ covers what it reads, and `[tool.sqlakit.templates]` for a project whose code
44
+ builds its paths in a way it can't follow.
45
+
46
+ ## Development
47
+
48
+ ```console
49
+ $ uv sync
50
+ $ uv run poe test
51
+ $ uv run poe lint
52
+ ```
@@ -0,0 +1,138 @@
1
+ [project]
2
+ name = "sqlakit-lsp"
3
+ version = "0.1.0"
4
+ description = "The language server for SQLAKit templates."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ keywords = [
9
+ "sqlalchemy",
10
+ "sqlakit",
11
+ "lsp",
12
+ "language-server",
13
+ "sql",
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Topic :: Database",
25
+ "Topic :: Text Editors :: Integrated Development Environments (IDE)",
26
+ "Typing :: Typed",
27
+ ]
28
+ requires-python = ">=3.11"
29
+ dependencies = [
30
+ "sqlakit>=0.21.0,<0.22",
31
+ "pygls>=2.1,<3",
32
+ ]
33
+
34
+ [[project.authors]]
35
+ name = "Anton Ruhlov"
36
+ email = "antonruhlov@gmail.com"
37
+
38
+ [project.scripts]
39
+ sqlakit-lsp = "sqlakit_lsp._cli:main"
40
+
41
+ [project.urls]
42
+ Repository = "https://github.com/sqlakit/sqlakit-lsp"
43
+ Documentation = "https://github.com/sqlakit/sqlakit-lsp#readme"
44
+
45
+ [build-system]
46
+ requires = ["uv_build>=0.11,<0.13"]
47
+ build-backend = "uv_build"
48
+
49
+ [tool.uv]
50
+ default-groups = ["dev"]
51
+
52
+ [tool.uv.build-backend]
53
+ module-name = "sqlakit_lsp"
54
+ module-root = ""
55
+
56
+ [tool.pytest.ini_options]
57
+ filterwarnings = [
58
+ "error",
59
+ "ignore:'asyncio.iscoroutinefunction' is deprecated:DeprecationWarning:pygls",
60
+ ]
61
+ norecursedirs = [
62
+ ".*",
63
+ "build",
64
+ "dist",
65
+ ]
66
+
67
+ [tool.ruff]
68
+ include = [
69
+ "sqlakit_lsp/**/*.py",
70
+ "tests/**/*.py",
71
+ "pyproject.toml",
72
+ ]
73
+
74
+ [tool.ruff.format]
75
+ docstring-code-format = true
76
+ docstring-code-line-length = 79
77
+
78
+ [tool.ruff.lint]
79
+ select = ["ALL"]
80
+ ignore = [
81
+ "CPY001",
82
+ "D1",
83
+ "D203",
84
+ "D213",
85
+ "E501",
86
+ "COM812",
87
+ "ISC001",
88
+ ]
89
+
90
+ [tool.ruff.lint.per-file-ignores]
91
+ "tests/**/*.py" = [
92
+ "S101",
93
+ "PLR2004",
94
+ "SLF001",
95
+ "PLC0415",
96
+ ]
97
+
98
+ [tool.ty.src]
99
+ include = [
100
+ "sqlakit_lsp/**/*",
101
+ "tests/**/*",
102
+ ]
103
+
104
+ [tool.poe.tasks.fmt]
105
+ help = "Format and auto-fix"
106
+ sequence = [
107
+ "ruff format",
108
+ "ruff check --fix",
109
+ ]
110
+ default_item_type = "cmd"
111
+
112
+ [tool.poe.tasks.test]
113
+ help = "Run the tests"
114
+ cmd = "pytest"
115
+
116
+ [tool.poe.tasks.lint]
117
+ help = "Lint + type-check"
118
+ sequence = [
119
+ "ruff format --check",
120
+ "ruff check",
121
+ "ty check",
122
+ "codespell",
123
+ ]
124
+ default_item_type = "cmd"
125
+
126
+ [tool.codespell]
127
+ skip = "./.venv,./uv.lock,./.git"
128
+
129
+ [dependency-groups]
130
+ dev = [
131
+ "pytest>=9.1.1",
132
+ "pytest-cov>=7.1.0",
133
+ "anyio>=4.14.2",
134
+ "ty>=0.0.80",
135
+ "ruff>=0.16.6",
136
+ "poethepoet>=0.48.0",
137
+ "codespell>=2.4.3",
138
+ ]
@@ -0,0 +1,113 @@
1
+ [project]
2
+ name = "sqlakit-lsp"
3
+ version = "0.1.0"
4
+ description = "The language server for SQLAKit templates."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Anton Ruhlov", email = "antonruhlov@gmail.com" }]
9
+ keywords = ["sqlalchemy", "sqlakit", "lsp", "language-server", "sql"]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Intended Audience :: Developers",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.11",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Programming Language :: Python :: 3.14",
19
+ "Topic :: Database",
20
+ "Topic :: Text Editors :: Integrated Development Environments (IDE)",
21
+ "Typing :: Typed",
22
+ ]
23
+ requires-python = ">=3.11"
24
+ dependencies = [
25
+ # The server reads the private modules of `sqlakit`, which a minor version
26
+ # may change.
27
+ "sqlakit>=0.21.0,<0.22",
28
+ "pygls>=2.1,<3",
29
+ ]
30
+
31
+ [project.scripts]
32
+ sqlakit-lsp = "sqlakit_lsp._cli:main"
33
+
34
+ [project.urls]
35
+ Repository = "https://github.com/sqlakit/sqlakit-lsp"
36
+ Documentation = "https://github.com/sqlakit/sqlakit-lsp#readme"
37
+
38
+ [build-system]
39
+ requires = ["uv_build>=0.11,<0.13"]
40
+ build-backend = "uv_build"
41
+
42
+ [tool.uv.build-backend]
43
+ module-name = "sqlakit_lsp"
44
+ module-root = ""
45
+
46
+ [tool.uv]
47
+ default-groups = ["dev"]
48
+
49
+ [dependency-groups]
50
+ dev = [
51
+ "pytest>=9.1.1",
52
+ "pytest-cov>=7.1.0",
53
+ "anyio>=4.14.2",
54
+ "ty>=0.0.80",
55
+ "ruff>=0.16.6",
56
+ "poethepoet>=0.48.0",
57
+ "codespell>=2.4.3",
58
+ ]
59
+
60
+ [tool.pytest.ini_options]
61
+ filterwarnings = [
62
+ "error",
63
+ # pygls on Python 3.14, until it moves to `inspect.iscoroutinefunction`.
64
+ "ignore:'asyncio.iscoroutinefunction' is deprecated:DeprecationWarning:pygls",
65
+ ]
66
+ norecursedirs = [".*", "build", "dist"]
67
+
68
+ [tool.ruff]
69
+ include = ["sqlakit_lsp/**/*.py", "tests/**/*.py", "pyproject.toml"]
70
+
71
+ [tool.ruff.format]
72
+ docstring-code-format = true
73
+ docstring-code-line-length = 79
74
+
75
+ [tool.ruff.lint]
76
+ select = ["ALL"]
77
+ ignore = [
78
+ "CPY001", # copyright notice in every file
79
+ "D1", # docstrings are not mandatory
80
+ "D203", # incompatible with D211
81
+ "D213", # incompatible with D212
82
+ "E501", # line length is enforced by the formatter
83
+ "COM812", # conflicts with the formatter
84
+ "ISC001", # conflicts with the formatter
85
+ ]
86
+
87
+ [tool.ruff.lint.per-file-ignores]
88
+ "tests/**/*.py" = [
89
+ "S101", # tests assert
90
+ "PLR2004", # and compare against the values they mean
91
+ "SLF001", # they read the internals they are testing
92
+ "PLC0415", # a test imports what it is about, where it is about it
93
+ ]
94
+
95
+ [tool.ty.src]
96
+ include = ["sqlakit_lsp/**/*", "tests/**/*"]
97
+
98
+ [tool.poe.tasks.fmt]
99
+ help = "Format and auto-fix"
100
+ sequence = ["ruff format", "ruff check --fix"]
101
+ default_item_type = "cmd"
102
+
103
+ [tool.poe.tasks.test]
104
+ help = "Run the tests"
105
+ cmd = "pytest"
106
+
107
+ [tool.poe.tasks.lint]
108
+ help = "Lint + type-check"
109
+ sequence = ["ruff format --check", "ruff check", "ty check", "codespell"]
110
+ default_item_type = "cmd"
111
+
112
+ [tool.codespell]
113
+ skip = "./.venv,./uv.lock,./.git"
@@ -0,0 +1,9 @@
1
+ """The language server for SQLAKit templates.
2
+
3
+ `sqlakit-lsp` runs it over standard input and output, for an editor to start.
4
+ It reads the project the way `sqlakit check` does, without running its code.
5
+ """
6
+
7
+ from ._server import serve
8
+
9
+ __all__ = ["serve"]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from ._cli import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,22 @@
1
+ """`sqlakit-lsp`, the command line."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ from importlib.metadata import version
7
+
8
+ from ._server import serve
9
+
10
+
11
+ def main(argv: list[str] | None = None) -> int:
12
+ """Serve an editor over standard input and output until it hangs up."""
13
+ parser = argparse.ArgumentParser(
14
+ prog="sqlakit-lsp",
15
+ description="The language server for SQLAKit templates, over stdio.",
16
+ )
17
+ parser.add_argument("--version", action="version", version=version("sqlakit-lsp"))
18
+ # Some editors pass it to every server: stdio is the only way this one talks.
19
+ parser.add_argument("--stdio", action="store_true", help=argparse.SUPPRESS)
20
+ parser.parse_args(argv)
21
+ serve() # pragma: no cover - run by an editor
22
+ return 0 # pragma: no cover