@postgres-language-server/cli 0.0.0 → 0.16.0
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.
- package/README.md +57 -0
- package/bin/postgres-language-server +73 -0
- package/package.json +45 -8
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Postgres Language Server
|
|
4
|
+
|
|
5
|
+
A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling.
|
|
6
|
+
|
|
7
|
+
Docs: [pgtools.dev](https://pgtools.dev/)
|
|
8
|
+
|
|
9
|
+
Install: [instructions](https://pgtools.dev/#installation)
|
|
10
|
+
|
|
11
|
+
- [CLI releases](https://github.com/supabase-community/postgres-language-server/releases)
|
|
12
|
+
- [VSCode](https://marketplace.visualstudio.com/items?itemName=Supabase.postgrestools)
|
|
13
|
+
- [Neovim](https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#postgres_lsp)
|
|
14
|
+
- [Zed](https://github.com/LoamStudios/zed-postgres-language-server)
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
LSP Demo | CLI Demo
|
|
18
|
+
:-------------------------:|:-------------------------:
|
|
19
|
+
 | 
|
|
20
|
+
|
|
21
|
+
This project provides a toolchain for Postgres development, built on Postgres' own parser `libpg_query` to ensure 100% syntax compatibility. It is built on a Server-Client architecture with a transport-agnostic design. This means all features can be accessed not only through the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/), but also through other interfaces like a CLI, HTTP APIs, or a WebAssembly module. The goal is to make all the great Postgres tooling out there as accessible as possible, and to build anything that is missing ourselves.
|
|
22
|
+
|
|
23
|
+
The following features are implemented:
|
|
24
|
+
- Autocompletion
|
|
25
|
+
- Syntax Error Highlighting
|
|
26
|
+
- Type-checking (via `EXPLAIN` error insights)
|
|
27
|
+
- Linter, inspired by [Squawk](https://squawkhq.com)
|
|
28
|
+
|
|
29
|
+
Our current focus is on refining and enhancing these core features while building a robust and easily accessible infrastructure. For future plans and opportunities to contribute, please check out the issues and discussions. Any contributions are welcome!
|
|
30
|
+
|
|
31
|
+
## Contributors
|
|
32
|
+
|
|
33
|
+
- [psteinroe](https://github.com/psteinroe)
|
|
34
|
+
- [juleswritescode](https://github.com/juleswritescode)
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
### Using Nix
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
nix develop
|
|
42
|
+
docker-compose up -d
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Using Docker
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
docker-compose up -d
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Acknowledgements
|
|
52
|
+
|
|
53
|
+
A big thanks to the following projects, without which this project wouldn't have been possible:
|
|
54
|
+
|
|
55
|
+
- [libpg_query](https://github.com/pganalyze/libpg_query): For extracting the Postgres' parser
|
|
56
|
+
- [Biome](https://github.com/biomejs/biome): For implementing a toolchain infrastructure we could copy from
|
|
57
|
+
- [Squawk](https://github.com/sbdchd/squawk): For the linter inspiration
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { platform, arch, env } = process;
|
|
3
|
+
|
|
4
|
+
const PLATFORMS = {
|
|
5
|
+
win32: {
|
|
6
|
+
x64: "@postgres-language-server/cli-x86_64-windows-msvc/postgres-language-server.exe",
|
|
7
|
+
arm64: "@postgres-language-server/cli-aarch64-windows-msvc/postgres-language-server.exe",
|
|
8
|
+
},
|
|
9
|
+
darwin: {
|
|
10
|
+
x64: "@postgres-language-server/cli-x86_64-apple-darwin/postgres-language-server",
|
|
11
|
+
arm64: "@postgres-language-server/cli-aarch64-apple-darwin/postgres-language-server",
|
|
12
|
+
},
|
|
13
|
+
linux: {
|
|
14
|
+
x64: "@postgres-language-server/cli-x86_64-linux-gnu/postgres-language-server",
|
|
15
|
+
arm64: "@postgres-language-server/cli-aarch64-linux-gnu/postgres-language-server",
|
|
16
|
+
},
|
|
17
|
+
"linux-musl": {
|
|
18
|
+
x64: "@postgres-language-server/cli-x86_64-linux-musl/postgres-language-server",
|
|
19
|
+
// no arm64 build for musl
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function isMusl() {
|
|
24
|
+
let stdout;
|
|
25
|
+
try {
|
|
26
|
+
stdout = execSync("ldd --version", {
|
|
27
|
+
stdio: [
|
|
28
|
+
"ignore", // stdin
|
|
29
|
+
"pipe", // stdout – glibc systems print here
|
|
30
|
+
"pipe", // stderr – musl systems print here
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
} catch (err) {
|
|
34
|
+
stdout = err.stderr;
|
|
35
|
+
}
|
|
36
|
+
if (typeof stdout === 'string' && stdout.indexOf("musl") > -1) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getPlatform() {
|
|
43
|
+
if (platform === "linux") {
|
|
44
|
+
return isMusl() ? "linux-musl" : "linux";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return platform;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const binPath = env.PGLS_BINARY || PLATFORMS?.[getPlatform()]?.[arch];
|
|
51
|
+
|
|
52
|
+
if (binPath) {
|
|
53
|
+
const result = require("child_process").spawnSync(
|
|
54
|
+
require.resolve(binPath),
|
|
55
|
+
process.argv.slice(2),
|
|
56
|
+
{
|
|
57
|
+
shell: false,
|
|
58
|
+
stdio: "inherit",
|
|
59
|
+
env,
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (result.error) {
|
|
64
|
+
throw result.error;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process.exitCode = result.status;
|
|
68
|
+
} else {
|
|
69
|
+
console.error(
|
|
70
|
+
"The Postgres Language Server CLI package doesn't ship with prebuilt binaries for your platform yet. Please file an issue in the main repository."
|
|
71
|
+
);
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postgres-language-server/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"postgres-language-server": "bin/postgres-language-server"
|
|
6
|
+
},
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/supabase-community/postgres-language-server.git",
|
|
10
|
+
"directory": "packages/@postgres-language-server/cli"
|
|
11
|
+
},
|
|
12
|
+
"author": "Supabase Community",
|
|
13
|
+
"contributors": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Philipp Steinrötter",
|
|
16
|
+
"url": "https://github.com/psteinroe"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Julian Domke",
|
|
20
|
+
"url": "https://github.com/juleswritescode"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT or Apache-2.0",
|
|
24
|
+
"description": "A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling.",
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/postgres-language-server",
|
|
27
|
+
"schema.json",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20"
|
|
7
32
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"provenance": true
|
|
35
|
+
},
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"@postgres-language-server/cli-x86_64-windows-msvc": "0.16.0",
|
|
38
|
+
"@postgres-language-server/cli-aarch64-windows-msvc": "0.16.0",
|
|
39
|
+
"@postgres-language-server/cli-x86_64-apple-darwin": "0.16.0",
|
|
40
|
+
"@postgres-language-server/cli-aarch64-apple-darwin": "0.16.0",
|
|
41
|
+
"@postgres-language-server/cli-x86_64-linux-gnu": "0.16.0",
|
|
42
|
+
"@postgres-language-server/cli-aarch64-linux-gnu": "0.16.0",
|
|
43
|
+
"@postgres-language-server/cli-x86_64-linux-musl": "0.16.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "bun test"
|
|
47
|
+
}
|
|
48
|
+
}
|