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

Swift syntax highlighting #6832

Closed
wants to merge 1 commit into from
Closed

Conversation

matyunya
Copy link

This PR adds Swift tree-sitter grammar built from https://github.com/alex-pinkus/tree-sitter-swift.

Here's example of syntax highlighting:

Screenshot 2024-01-27 at 10 35 34

Attempted to attach SourceKit LSP but it only returns empty responses.

Copy link

cla-bot bot commented Jan 27, 2024

We require contributors to sign our Contributor License Agreement, and we don't have @matyunya on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@matyunya
Copy link
Author

@cla-bot check

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

cla-bot bot commented Jan 27, 2024

The cla-bot has been summoned, and re-checked this pull request!

Copy link
Contributor

@mikayla-maki mikayla-maki left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! Unfortunately, I don't think we can merge this until we've discussed what to do about alex-pinkus/tree-sitter-swift#240

"async" @keyword
"await" @keyword
(where_keyword) @keyword
(parameter external_name: (simple_identifier) @parameter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, we do not use @parameter, see the theme/src/styles/syntax.rs file for a list of options.

@@ -0,0 +1,18 @@
(import_declaration (identifier) @definition.import)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think our tree sitter integration uses a locals file.

@@ -0,0 +1,51 @@
(class_declaration
Copy link
Contributor

@mikayla-maki mikayla-maki Jan 27, 2024

Choose a reason for hiding this comment

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

We do not use a tags query, however tags are analogous to the outline.scm queries we have.

@@ -0,0 +1,19 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

This query is also not applicable to zed.

@mikayla-maki mikayla-maki marked this pull request as draft January 27, 2024 01:55
@matyunya
Copy link
Author

Thank you for swift response! Will try to dive in.

@marcusziade
Copy link

We should determine which one is better

Cc @ceopaludetto

@marcusziade marcusziade mentioned this pull request Jan 27, 2024
@matyunya
Copy link
Author

On my way with faster/more correct grammar

@matyunya
Copy link
Author

btw, is it possible that the problem with initial load time has something to do with missing parser artefacts? I never noticed the particular problem as I included the artefacts in my fork before even trying to run it.

@marcusziade
Copy link

How did you include the artefacts?

@matyunya
Copy link
Author

Commited output of tree-sitter generate to the repo here.

@maxdeviant
Copy link
Member

Since this PR only adds syntax highlighting, we're able to offer this as an extension.

There is a Swift extension available already, although it's temporarily disabled while we work through a crash that it causes.

@maxdeviant maxdeviant closed this Feb 27, 2024
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.

5 participants