You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-28Lines changed: 28 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# PostgresTools Extension for VS Code
1
+
# Postgres Language Server Extension for VS Code
2
2
3
-
The **PostgresTools extension for Visual Studio Code** brings PostgreSQL inline suggestions, linting, and type checks to VSCode and VSCode-based editors.
3
+
The **Postgres Language Server extension for Visual Studio Code** brings PostgreSQL inline suggestions, linting, and type checks to VSCode and VSCode-based editors.
4
4
5
5
It does so by implementing an LSP client and launching an LSP Server in the background.
6
6
@@ -12,16 +12,16 @@ The [Language Server Protocol](https://microsoft.github.io/language-server-proto
12
12
13
13
**First**, you need the LSP server binary. The [Postgres language server](https://github.com/supabase-community/postgres-language-server) is written in Rust and is therefore compiled to various binaries for various machines. You can set it up via one of five strategies. The extensions will check them in the following order:
14
14
15
-
- The `postgrestools.bin` VSCode setting can point to a binary with relative or absolute paths. You can use this if you want to download a specific binary from one of the [Postgres language server](https://github.com/supabase-community/postgres-language-server) releases and place it in your project.
16
-
-**Recommended**: If you use node, you can simply run `npm i -D @postgrestools/postgrestools@latest`. Once you restart the extension, it should look for the server binary in your `node_modules`.
17
-
- If you use node but you install your packages via Yarn Plug'n'Play, you can still install `@postgrestools/postgrestools`, and the extension will check your `.pnp.cjs` file for a binary.
18
-
- You can install the LSP server globally (e.g. via `brew` or by downloading a binary from the GitHub releases). Make sure that its binary is exposed in your $PATH – the extension will search it for a `postgrestools` on Darwin/Linux or a `postgrestools.exe` on Windows.
19
-
- If no LSP server binary can be found via the above strategies, you will be prompted to download a binary from `postgrestools`'s GitHub Releases. You can also do this later via the [Download Server Command](#useful-commands). Note that the above strategies will still take precedence.
15
+
- The `postgres-language-server.bin` VSCode setting can point to a binary with relative or absolute paths. You can use this if you want to download a specific binary from one of the [Postgres language server](https://github.com/supabase-community/postgres-language-server) releases and place it in your project.
16
+
-**Recommended**: If you use node, you can simply run `npm i -D @postgres-language-server/cli@latest`. Once you restart the extension, it should look for the server binary in your `node_modules`.
17
+
- If you use node but you install your packages via Yarn Plug'n'Play, you can still install `@postgres-language-server/cli`, and the extension will check your `.pnp.cjs` file for a binary.
18
+
- You can install the LSP server globally (e.g. via `brew` or by downloading a binary from the GitHub releases). Make sure that its binary is exposed in your $PATH – the extension will search it for a `postgres-language-server` on Darwin/Linux or a `postgres-language-server.exe` on Windows.
19
+
- If no LSP server binary can be found via the above strategies, you will be prompted to download a binary from the Postgres language server's GitHub Releases. You can also do this later via the [Download Server Command](#useful-commands). Note that the above strategies will still take precedence.
20
20
The found binary is copied to a temporary location in your VS Code extensions folder and run from there. When you restart the extension, the copied binary will be used, and the above places won't be searched.
21
21
22
22
## Setting Up Your Project
23
23
24
-
**Second**, you need a `postgrestools.jsonc` file at the root of your repository (or, use a custom file location and point to it via the `postgrestools.configFile` setting). You can find sane defaults in the [docs](https://pgtools.dev/#configuration).
24
+
**Second**, you need a `postgres-language-server.jsonc` file at the root of your repository (or, use a custom file location and point to it via the `postgres-language-server.configFile` setting). You can find sane defaults in the [docs](https://pgtools.dev/#configuration).
25
25
26
26
When you specify the `db` section, the LSP server will connect to your database and gather intel from there. This makes it possible to provide autocompletions and type checks.
27
27
@@ -43,57 +43,57 @@ Once you have [everything running locally](https://supabase.com/docs/guides/loca
43
43
44
44
It'll have the following format: `postgresql://<username>:<password>@<host>:<port>/<database>`.
45
45
46
-
If you extract the values, add them to your `postgrestools.jsonc` file, and restart the extension, you should be ready to go.
46
+
If you extract the values, add them to your `postgres-language-server.jsonc` file, and restart the extension, you should be ready to go.
47
47
48
48
You can also run the LSP server against your remote database, but this might lead to small latencies and a small performance overhead (the LSP server runs `prepare` statements against your database for the type checking).
49
49
50
50
You should find your remote database settings at `https://supabase.com/dashboard/project/<yourProjectId>/settings/database?showConnect=true`.
51
51
52
52
## Useful Commands
53
53
54
-
The extension adds seven commands to your VS Code Command Palette. They are all prefixed by `PostgresTools`.
54
+
The extension adds seven commands to your VS Code Command Palette. They are all prefixed by `Postgres Language Server`.
55
55
56
-
-`PostgresTools: Hard Reset (Delete All Temp and Global Binaries)` is your troubleshooting weapon. It will basically remove all binaries that were copied and downloaded _by the extension_ (not those you have installed or copied yourself). The extension will then again search for a server binary via the strategies mentioned in [the setup](#setting-up-the-lsp-server).
57
-
-`PostgresTools: Download Server` lets you select and download the server binary. It'll be the matching version for your machine. If you set `postgrestools.allowDownloadPrereleases` to true in yor VS Code settings, you'll be able to select prereleases.
58
-
-`PostgresTools: Get Current Version` will print the current version and the strategy with which the server binary was found.
59
-
-`PostgresTools: Start` and `PostgresTools: Stop` will stop or start the LSP server and the client.
60
-
-`PostgresTools: Restart` runs stop and start in succession.
61
-
-`PostgresTools: Copy Latest Server Logfile` copies the latest server log file to your currently opened repo. The log file is meant to be attached to GitHub issues, it can sometimes help us to debug.
56
+
-`Postgres Language Server: Hard Reset (Delete All Temp and Global Binaries)` is your troubleshooting weapon. It will basically remove all binaries that were copied and downloaded _by the extension_ (not those you have installed or copied yourself). The extension will then again search for a server binary via the strategies mentioned in [the setup](#setting-up-the-lsp-server).
57
+
-`Postgres Language Server: Download Server` lets you select and download the server binary. It'll be the matching version for your machine. If you set `postgres-language-server.allowDownloadPrereleases` to true in yor VS Code settings, you'll be able to select prereleases.
58
+
-`Postgres Language Server: Get Current Version` will print the current version and the strategy with which the server binary was found.
59
+
-`Postgres Language Server: Start` and `Postgres Language Server: Stop` will stop or start the LSP server and the client.
60
+
-`Postgres Language Server: Restart` runs stop and start in succession.
61
+
-`Postgres Language Server: Copy Latest Server Logfile` copies the latest server log file to your currently opened repo. The log file is meant to be attached to GitHub issues, it can sometimes help us to debug.
62
62
63
63
## Multi-Root Workspaces
64
64
65
65
You can use the extension in a multi-root workspace setting, but there are a few caveats:
66
66
67
-
- You should use at least version 0.8.0 of the binary. You can upgrade it in your `package.json` or run `PostgresTools: Hard Reset (..)`.
68
-
- You can specify a `postgrestools.bin` and a `postgrestools.configFile` in your `.code-workspace` file, but you need to use an absolute path. The binary and the setting will then be used for all your workspace folders.
69
-
- If you don't specify a config file, the binary will look for a `postgrestools.jsonc` file at the every workspace folder's root level. If the file isn't there, the extension will be disabled for the folder. The individual `configFile` settings of the folders are ignored.
67
+
- You should use at least version 0.8.0 of the binary. You can upgrade it in your `package.json` or run `Postgres Language Server: Hard Reset (..)`.
68
+
- You can specify a `postgres-language-server.bin` and a `postgres-language-server.configFile` in your `.code-workspace` file, but you need to use an absolute path. The binary and the setting will then be used for all your workspace folders.
69
+
- If you don't specify a config file, the binary will look for a `postgres-language-server.jsonc` file at the every workspace folder's root level. If the file isn't there, the extension will be disabled for the folder. The individual `configFile` settings of the folders are ignored.
70
70
- The binary will currently only change database connections when a new file is opened, not when you alternate focus between two files. So, you might get linting/completions from a different database than you'd expect. For now, you can simply reopen the file, but we'll fix this soon 🙌
71
71
72
72
## Troubleshooting
73
73
74
-
1. First, try restarting the extension via the `PostgresTools: Hard Reset (...)` command mentioned above.
75
-
2. Open your VS Code Terminal, select the tab `Output`, and select one of the `postgrestools` extensions on the right. You might see what went wrong in the logs.
76
-
3. If you want to open a GitHub issue, it can sometimes help us if you attach the LSP server log file. We provide the `PostgresTools: Copy Latest Server Logfile` command to make that as easy as possible.
74
+
1. First, try restarting the extension via the `Postgres Language Server: Hard Reset (...)` command mentioned above.
75
+
2. Open your VS Code Terminal, select the tab `Output`, and select one of the `postgres-language-server` extensions on the right. You might see what went wrong in the logs.
76
+
3. If you want to open a GitHub issue, it can sometimes help us if you attach the LSP server log file. We provide the `Postgres Language Server: Copy Latest Server Logfile` command to make that as easy as possible.
77
77
78
78
## FAQ
79
79
80
-
### I've installed the package via NPM but getting an `Error: Cannot find module '@postgrestools/cli-x86_64-windows-msvc/postgrestools.exe'`.
80
+
### I've installed the package via NPM but getting an `Error: Cannot find module '@postgres-language-server/cli-x86_64-windows-msvc/postgres-language-server.exe'`.
81
81
82
82
The platform-specific package is installed as an `optionalDependency`. If it can't be installed for whatever reason, `npm` won't complain. It's likely that something went wrong during the installation.
83
83
84
-
Another known issue is that npm installs the optional dependency at an unexpected location. It _should_ be located at `node_modules/@postgrestools/cli-aarch64-apple-darwin` (or another platform-specific package).
84
+
Another known issue is that npm installs the optional dependency at an unexpected location. It _should_ be located at `node_modules/@postgres-language-server/cli-aarch64-apple-darwin` (or another platform-specific package).
85
85
86
86
If you can't find the platform specific package, please just rerun `npm install` a couple of times.
87
87
88
-
If that still doesn't help, run `npm uninstall @postgrestools/postgrestools` and use the download server strategy mentioned [here.](#setting-up-the-lsp-server)
88
+
If that still doesn't help, run `npm uninstall @postgres-language-server/cli` and use the download server strategy mentioned [here.](#setting-up-the-lsp-server)
89
89
90
-
### Why am I prompted to install the PostgresTools binary?
90
+
### Why am I prompted to install the Postgres Language Server binary?
91
91
92
92
You will only be prompted if all other [strategies](#setting-up-the-lsp-server) fail. If you set out to use a different strategy, make sure the binary/node package is actually at the expected location:
93
93
94
-
- Using the `postgrestool.bin` setting -> Is the binary at the configured location?
94
+
- Using the `postgres-language-server.bin` setting -> Is the binary at the configured location?
95
95
- Using `npm` or `yarn` -> Are the `node_modules` installed correctly?
96
-
- Using the `PATH` environment variable -> Can you run `$ postgrestools --version`, is the binary at the expected location?
96
+
- Using the `PATH` environment variable -> Can you run `$ postgres-language-server --version`, is the binary at the expected location?
"description": "Allows selecting prereleases when downloading the binary via this extension",
130
+
"scope": "resource"
131
+
},
132
+
"postgres-language-server.allowVersionChecks": {
133
+
"type": "boolean",
134
+
"description": "If set, the extension will check periodically whether a new version for postgres-language-server is available and if so notify the user.",
135
+
"scope": "resource"
136
+
},
137
+
"postgres-language-server.configFile": {
138
+
"type": "string",
139
+
"description": "Path to the `postgres-language-server.jsonc` file. You don't need to set this if the file is on root level of your project.",
140
+
"scope": "resource"
141
+
},
142
+
"postgres-language-server.bin": {
143
+
"oneOf": [
144
+
{
145
+
"type": "string",
146
+
"description": "Path to the postgres-language-server Language Server binary",
147
+
"examples": [
148
+
"/path/to/postgres-language-server",
149
+
"./path/to/postgres-language-server"
150
+
]
151
+
},
152
+
{
153
+
"type": "object",
154
+
"description": "Platform-specific paths to the postgres-language-server Language Server binary",
0 commit comments