-
Notifications
You must be signed in to change notification settings - Fork 98
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: request autocompletion without typing a letter #310
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me overall. just would like to double check if we really need to instantiate the tree sitter parser with every request 😢. can't we just mutate the tree?
also: we will have a bunch of conflicts, and a few things will need to be handled differently. but no issues, just that we should merge yours first so I can fix the merge conflicts with mine.
sql.push(c); | ||
} | ||
|
||
let mut parser = tree_sitter::Parser::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt there a way to modify the tree sitter tree instead of reparsing the string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can pass the passer down to here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think editing the node isn to possible, so maybe we should try to pass the existing tree sitter parser down.
So far, we were relying on complete tree-sitter trees for autocompletion.
This works fine if you type the first letter of a node, say:
select * from u|
Now, the
u
is considered a table node, and we can look for tables.But this PR makes it such that we can also request completions if we haven't typed the
u
yet.It does so by checking whether the tree is valid and, if not, injecting a token to fix the tree-sitter tree.
Additionally, in the case of
select * from |
, the workspace would consider the cursor to be outside the statement. I added a little offset so the cursor still matches a statement if it's 2 characters after the last token.