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

Add Astro Support #6896

Merged
merged 18 commits into from
Feb 12, 2024
Merged

Add Astro Support #6896

merged 18 commits into from
Feb 12, 2024

Conversation

alvgaona
Copy link
Contributor

Attempt to add @astrojs/language-server and virchau13/tree-sitter-astro.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 27, 2024
@alvgaona
Copy link
Contributor Author

SCM files are left to be added.

@Princesseuh
Copy link

Princesseuh commented Jan 28, 2024

Hey, maintainer of the Astro language server here, you'll need to pass a path to a TypeScript install's typescript.js as an init param, see https://github.com/withastro/language-tools/blob/main/packages%2Fvscode%2Fsrc%2Fclient.ts#L60-L62

Let me know if there's any way I can assist, been liking Zed a fair amount recently 🫡

@alvgaona
Copy link
Contributor Author

alvgaona commented Jan 28, 2024

In spite of adding the queries, typescript, tsx, and css are not getting highlighted; only html 🤔 What am I missing here?

Screenshot 2024-01-28T18 01 29@2x

From the tree-sitter-astro repo:

Screenshot 2024-01-28T17 40 48

And these are defined in the Cargo.toml

  • zed/Cargo.toml

    Line 139 in 4fc0116

    tree-sitter-css = { git = "https://github.com/tree-sitter/tree-sitter-css", rev = "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" }
  • zed/Cargo.toml

    Line 153 in 4fc0116

    tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259" }

@alvgaona
Copy link
Contributor Author

alvgaona commented Jan 28, 2024

Ok, now the highlighting works for the frontmatter and interpolations. For some reason, CSS ain't behaving like any other .css or .html file.

Screenshot 2024-01-28T18 41 06

Diff

Screenshot 2024-01-28T18 39 41

@alvgaona alvgaona marked this pull request as ready for review January 28, 2024 19:00
@Princesseuh
Copy link

Can't really speak to the syntax highlighting and tree sitter issues, but the Astro LSP part looks great to me!

I'd suggest holding on for now because it's a bit buggy, but in the future, it should probably also install the Astro TypeScript plugin, for .astro imports inside .ts(x) files and cross-file moves / renames and stuff.

@alvgaona
Copy link
Contributor Author

From this comment, I think there's an issue with CSS highlighting within the <style> tag.

@Princesseuh
Copy link

From this comment, I think there's an issue with CSS highlighting within the <style> tag.

That was before Astro had its own treesitter plugin! The TSX treesitter plugin of course cannot highlight CSS (or script tags, for that matter), hence why there's an Astro specific plugin.

@alvgaona
Copy link
Contributor Author

From this comment, I think there's an issue with CSS highlighting within the <style> tag.

That was before Astro had its own treesitter plugin! The TSX treesitter plugin of course cannot highlight CSS (or script tags, for that matter), hence why there's an Astro specific plugin.

Oh, got it. Misinterpreted the message.

@alvgaona
Copy link
Contributor Author

alvgaona commented Jan 29, 2024

Can't really speak to the syntax highlighting and tree sitter issues, but the Astro LSP part looks great to me!

I'd suggest holding on for now because it's a bit buggy, but in the future, it should probably also install the Astro TypeScript plugin, for .astro imports inside .ts(x) files and cross-file moves / renames and stuff.

@Princesseuh when you say a bit buggy, do you mean that it's not suggesting autocompletion at all? I'm not getting HTML tag suggestions from the language server. In VScode same thing happens, and I think I have configured correctly.

@virchau13
Copy link

virchau13 commented Jan 30, 2024

@alvgaona You appear to be using the wrong tree-sitter injections; the ones in the tree-sitter-astro repository are outdated. (I should really update those...)

https://github.com/nvim-treesitter/nvim-treesitter/blob/e24dab6696aa2a6682a117e241adc32c38e93d53/queries/astro/injections.scm has the up-to-date injections.

@Princesseuh
Copy link

Can't really speak to the syntax highlighting and tree sitter issues, but the Astro LSP part looks great to me!

I'd suggest holding on for now because it's a bit buggy, but in the future, it should probably also install the Astro TypeScript plugin, for .astro imports inside .ts(x) files and cross-file moves / renames and stuff.

@Princesseuh when you say a bit buggy, do you mean that it's not suggesting autocompletion at all? I'm not getting HTML tag suggestions from the language server. In VScode same thing happens, and I think I have configured correctly.

I'm only talking about the TypeScript plugin in that message, which only works in .ts files and does not do any completions in anything, it allows .ts files to understand .astro files.

Completions for HTML tags should work, though if something doesn't work in VS Code, it's totally normal if it doesn't work in Zed (though it might be an issue)

@alvgaona
Copy link
Contributor Author

alvgaona commented Feb 1, 2024

@alvgaona You appear to be using the wrong tree-sitter injections; the ones in the tree-sitter-astro repository are outdated. (I should really update those...)

https://github.com/nvim-treesitter/nvim-treesitter/blob/e24dab6696aa2a6682a117e241adc32c38e93d53/queries/astro/injections.scm has the up-to-date injections.

@virchau13 for some reason, those injections aren't working either. I'll keep looking into it.

@Princesseuh
Copy link

Princesseuh commented Feb 5, 2024

Tried this locally and it works pretty nicely, awesome work! With Zed's UI being otherwise so fast, it really highlights the performance issue the Astro language server can sometimes have in some contexts, but that's definitely not your fault (it's mine, ha)

@alvgaona
Copy link
Contributor Author

alvgaona commented Feb 5, 2024

Tried this locally and it works pretty nicely, awesome work! With Zed's UI being otherwise so fast, it really highlights the performance issue the Astro language server can sometimes have in some contexts, but that's definitely not your fault (it's mine, ha)

Beautiful. Glad you tried it!

@alvgaona
Copy link
Contributor Author

alvgaona commented Feb 8, 2024

@virchau13 I installed nvim-treesitter and enabled astro in the configuration. CSS isn't getting highlighted either; same behavior as in Zed.

Screenshot 2024-02-08T18 23 12

EDIT: this was cause due to missing CSS and SCSS parsers in neovim. Dismiss the message.

@virchau13
Copy link

virchau13 commented Feb 9, 2024

@alvgaona You may be missing the css parser dependency. Try following https://github.com/virchau13/tree-sitter-astro#troubleshooting.

@alvgaona
Copy link
Contributor Author

alvgaona commented Feb 9, 2024

@alvgaona You may be missing the css parser dependency. Try following https://github.com/virchau13/tree-sitter-astro#troubleshooting.

You're so right. In nvim works when I install the css and scss parsers. 😮‍💨

@maxhoffmann maxhoffmann mentioned this pull request Feb 10, 2024
1 task
Copy link
Collaborator

@maxbrunsfeld maxbrunsfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I left a few questions.

@alvgaona
Copy link
Contributor Author

Added the file icon for Astro. Does the size look ok to y'all?

Screenshot 2024-02-11T00 43 16@2x

@alvgaona
Copy link
Contributor Author

alvgaona commented Feb 11, 2024

@alvgaona You may be missing the css parser dependency. Try following https://github.com/virchau13/tree-sitter-astro#troubleshooting.

You're so right. In nvim works when I install the css and scss parsers. 😮‍💨

However, tried several injections for CSS in Zed and none is kicking in for Astro files. I don't understand the difference between Svelte, HTML and Vue injections, TBH 💢

@iamnbutler
Copy link
Member

Thanks for working on this! I spent a bit of time to redraw the Astro icon to closer align with the rest of our file icons.

I've just started picking up Astro and it seems really cool – I'll see if there are any other refinements I can help out with.

CleanShot 2024-02-12 at 12 34 03@2x

@maxbrunsfeld
Copy link
Collaborator

Thanks for making those adjustments @alvgaona. And that icon looks sweet @iamnbutler.

This will ship in Zed 0.123.

@maxbrunsfeld maxbrunsfeld merged commit 2e7db57 into zed-industries:main Feb 12, 2024
6 checks passed
@alvgaona
Copy link
Contributor Author

Thanks for working on this! I spent a bit of time to redraw the Astro icon to closer align with the rest of our file icons.

I've just started picking up Astro and it seems really cool – I'll see if there are any other refinements I can help out with.

CleanShot 2024-02-12 at 12 34 03@2x

Thanks a lot! Looks awesome now.

@alvgaona alvgaona deleted the astro-language-server branch February 12, 2024 19:02
@romu70
Copy link

romu70 commented Feb 15, 2024

Hi. Is this already available in zed?

@bennetbo
Copy link
Contributor

Hi. Is this already available in zed?

@romu70 Looks like it is in Zed Preview v0.123.1 (and will probably land in stable next Wednesday)
Release notes & Download

@ajguyot
Copy link

ajguyot commented Feb 17, 2024

Thanks so much for all of this work! Just tried this out in the preview and highlighting is working great, Astro files are finally usable in Zed 🎉

Not sure if this is the place to ask, but are completions planned for this as well? Would be awesome to get code completion within each area of the Astro files.

@Princesseuh
Copy link

Thanks so much for all of this work! Just tried this out in the preview and highlighting is working great, Astro files are finally usable in Zed 🎉

Not sure if this is the place to ask, but are completions planned for this as well? Would be awesome to get code completion within each area of the Astro files.

Completions should normally already work, as this also includes the Astro language server

@BryanSchuetz
Copy link

Running 0.123.1 /.2 I don't seem to get completions in .astro file. I get the syntax highlighting—which is great. I've also noticed that typescript warnings and errors that show up in .astro files in VSCode with the astro extension don't show up in .astro files in Zed. Have I missed a config step somewhere? Or should it be enough to just be running this pre-release?

@alvgaona alvgaona mentioned this pull request Feb 21, 2024
1 task
@jakob-fiegerl
Copy link

jakob-fiegerl commented Mar 28, 2024

Currently running 0.128.3. Got the same issue as @BryanSchuetz
Is there any plan for autocompletion in .astro files?

@BryanSchuetz
Copy link

See this issue for more: #8186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants