Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hover): POC for inline hover with rust #150

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qvalentin
Copy link

@qvalentin qvalentin commented Apr 21, 2024

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:

fn main() {
    sqlx::query("select * FROM tags").fetch_all(&mut conn).await;
}

image

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant