feat(hover): POC for inline hover with rust #150
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello everyone,
This PR provides a POC for supporting inline SQL in other languages (as described in joe-re/sql-language-server#180).
The implementation is inspired by the tree sitter injections in nvim-tree-sitter where you can have syntax highlighting for inline languages.
The idea would be for the community to provide tree-sitter queries that define how certain parts of the code should be interpreted as SQL, as I did for rust in the POC.
The LSP can then remove all non-SQL code from a file and process only the SQL text.
The example allows the sqls hover function to be used on the following rust code:
With the proposed architecture of using queries, the feature could easily be extended to other languages and their SQL libraries, as tree-sitter already provides parsers for most languages.
Please note that adding tree-sitter as a dependency would require the project to be built using cgo.
Running multiple language servers at the same this is supported (at least for neovim) and it should cause no problem if sqls will just return nothing for all positions that are not inside SQL strings.
What do you think about this idea?