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
+8-6
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ The [Language Server Protocol](https://microsoft.github.io/language-server-proto
22
22
23
23
## Motivation
24
24
25
-
Despite the rising popularity of Postgres, support for the PL/pgSQL in IDEs and editors is limited. While there are some *generic* SQL Language Servers[^1] offering the Postgres syntax as a "flavor" within the parser, they usually fall short due to the ever-evolving and complex syntax of PostgreSQL. There are a few proprietary IDEs[^2] that work well, but the features are only available within the respective IDE.
25
+
Despite the rising popularity of Postgres, support for the PL/pgSQL in IDEs and editors is limited. While there are some _generic_ SQL Language Servers[^1] offering the Postgres syntax as a "flavor" within the parser, they usually fall short due to the ever-evolving and complex syntax of PostgreSQL. There are a few proprietary IDEs[^2] that work well, but the features are only available within the respective IDE.
26
26
27
27
This Language Server is designed to support Postgres, and only Postgres. The server uses [libpg_query](https://github.com/pganalyze/libpg_query), therefore leveraging the PostgreSQL source to parse the SQL code reliably. Using Postgres within a Language Server might seem unconventional, but it's the only reliable way of parsing all valid PostgreSQL queries. You can find a longer rationale on why This is the Way™ [here](https://pganalyze.com/blog/parse-postgresql-queries-in-ruby). While libpg_query was built to execute SQL, and not to build a language server, any shortcomings have been successfully mitigated in the `parser` crate. You can read the [commented source code](./crates/parser/src/lib.rs) for more details on the inner workings of the parser.
28
28
@@ -33,8 +33,10 @@ Once the parser is stable, and a robust and scalable data model is implemented,
33
33
This is a proof of concept for building both a concrete syntax tree and an abstract syntax tree from a potentially malformed PostgreSQL source code. The `postgres_lsp` crate was created to prove that it works end-to-end, and is just a very basic language server with semantic highlighting and error diagnostics. Before further feature development, we have to complete a bit of groundwork:
34
34
35
35
1._Finish the parser_
36
-
- The parser works, but the enum values for all the different syntax elements and internal conversations are manually written or copied, and, in some places, only cover a few elements required for a simple select statement. To have full coverage without possibilities for a copy and paste error, they should be generated from `pg_query.rs` source code. ([#4](https://github.com/supabase/postgres_lsp/pull/4))
37
-
- There are a few cases such as nested and named dollar quoted strings that cause the parser to fail due to limitations of the regex-based lexer. Nothing that is impossible to fix, or requires any fundamental change in the parser though.
36
+
- The parser works, but the enum values for all the different syntax elements and internal conversations are manually written or copied, and, in some places, only cover a few elements required for a simple select statement. To have full coverage without possibilities for a copy and paste error, they should be generated from `pg_query.rs` source code. ([#4](https://github.com/supabase/postgres_lsp/pull/4)) ✅
37
+
- There are a few cases such as nested and named dollar quoted strings that cause the parser to fail due to limitations of the regex-based lexer. Nothing that is impossible to fix, or requires any fundamental change in the parser though. ✅
38
+
- Add support for parsing function bodies ([#34](https://github.com/supabase/postgres_lsp/issues/34))
39
+
- Implement a custom parser to extract statements from a source and replace the [regexp-based approach](https://github.com/supabase/postgres_lsp/blob/2f06c49f914b331cf93ea52d9edde8722d27ad05/crates/parser/src/source_parser.rs#L78)
38
40
2._Implement a robust and scalable data model_
39
41
- This is still in a research phase
40
42
- A great rationale on the importance of the data model in a language server can be found [here](https://matklad.github.io/2023/05/06/zig-language-server-and-cancellation.html)
@@ -88,13 +90,13 @@ You'll need Cargo, Node, and npm installed.
88
90
89
91
If you are using VS Code, you can install both the server and the client extension by running:
90
92
91
-
```sh
93
+
```sh
92
94
cargo xtask install
93
95
```
94
96
95
97
If you're not using VS Code, you can install the server by running:
96
98
97
-
```sh
99
+
```sh
98
100
cargo xtask install --server
99
101
```
100
102
@@ -104,7 +106,7 @@ The server binary will be installed in `.cargo/bin`. Make sure that `.cargo/bin`
-[rust-analyzer](https://github.com/rust-lang/rust-analyzer) for implementing such a robust, well documented, and feature-rich language server. Great place to learn from.
110
112
-[squawk](https://github.com/sbdchd/squawk) and [pganalyze](https://pganalyze.com) for inspiring the use of libpg_query.
0 commit comments