|
|
|
|
|
by juleswritescode
447 days ago
|
|
co-author here: The most interesting part is probably the parsing of SQL files. The first issue is that the Postgres parser is complex and always changing, so you can't really roll your own parser to parse SQL.
The second is that the parser only works with valid and complete SQL statements, but an LSP should help you with those that are invalid or incomplete. The simple solution is to actually use two parsers – the original libpg_query that's used by Postgres itself, and tree-sitter for incomplete statements, and merge the parsed results.
With that, you can both get a workable AST for diagnostics and tree-sitters CST for autocompletion, for example. |
|