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

Update to use tree-sitter-teal for partial parsing #25

Merged
merged 13 commits into from
Nov 29, 2024

Conversation

FourierTransformer
Copy link
Collaborator

@FourierTransformer FourierTransformer commented Nov 29, 2024

Main Changes

  • Switched to using tree-sitter-teal to do parsing of any potentially valid code. The nice thing about using the tree-sitter is that it handles incomplete documents really well, and then you can extract tokens in a predictable way.
  • It uses the idea of pulling out the tokens as a list and then iterating forward using Teal's symbols_in_scope (fully explained here: Update backend calls for hover, completion, and definition #22 (comment)) to handle completion, hover, go to definition, and signature help.
    • Tree-sitter solves the self problem I encountered before, by just going up the tree, I can easily determine what self refers to and use that while looking in the symbol table.
  • It handles completion when the user is at a :, ., or (, and also before it.
    • Properly handles filtering functions with self by matching the original type on : or seeing if the first arg is self
    • If you're typing if foo, the language server can show all symbols that are in scope while typing foo.
  • Added LSP completion item kind to the completion results (results in symbols showing up during completion)
  • Shows record/enums/polymorphic information on hover
  • Also show type info when hovering on bar in foo.bar
  • Switched to using Markdown for the hover and function signature help. It looks a bit nicer, and when teal is more widespread will highlight correctly
  • Small perf changes

Packaging Issues

  • I'm using ltreesitter for loading the teal tree-sitter grammar, but it requires the tree sitter lib installed on the system as well as the teal.so from the grammar to be present.
    • Both of these make it a little hard to just luarocks install the langauge server and get things going. This should probably be required before releasing the next version

closes #6 #19 #23 #24

@FourierTransformer FourierTransformer merged commit 2dad2a7 into teal-language:main Nov 29, 2024
4 checks passed
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.

make textDocument/hover smarter
1 participant