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 Sway language #6275

Merged
merged 9 commits into from
Mar 2, 2023
Merged

Add Sway language #6275

merged 9 commits into from
Mar 2, 2023

Conversation

sdankel
Copy link
Contributor

@sdankel sdankel commented Feb 4, 2023

Description

Sway is a Rust-like programming language for smart contracts.

The examples are from the official sway examples (Apache license).

Color

I chose the same color used by Rust, since Sway is based on Rust syntax.

Popularity

It's hard to tell exactly how many repositories are using sway because of the current limitations of github search. Using sourcegraph, I can see that there are at least 910 sway projects on github (each sway project must have a Forc.toml in it's root directory).

Based on the temporary requirements outlined in #5756, I believe there are over 2000 sway files, as sway projects usually have multiple .sw files, (example).

There are 9,312 files with the .sw extension, but some of these are not sway files. .sw is also used for Signed Word Audio Files. Those are already correctly highlighted by github as XML (example) or not highlighted (example). Added heuristics for sway files to disambiguate.

Checklist:

@sdankel sdankel marked this pull request as ready for review February 4, 2023 03:26
@sdankel sdankel requested a review from a team as a code owner February 4, 2023 03:26
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

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

It's hard to tell exactly how many repositories are using sway because of the current limitations of github search. Using sourcegraph, I can see that there are at least 910 sway projects on github (each sway project must have a Forc.toml in it's root directory).

You're in luck. The new beta search can take your exact heuristic and tell us 😁.

This search results in 2.7k files and from it we can see there are a few heavy influencers, so if we exclude the 4 most prominent users from a quick look, we're down to 2.3k which appear to be well spread across repos so I think we're good to include this language.

Buuuuuttttt, as you've pointed out:

There are 9,312 files with the .sw extension, but some of these are not sway files. .sw is also used for Signed Word Audio Files. Those are already correctly highlighted by github as XML (example) or not highlighted (example). Added heuristics for sway files to disambiguate.

As this will be the only language Linguist knows about with this extension, your heuristic won't be used. In order to get the heuristic to correctly identify the Sway files, you'll need to add .sw to at least another language. As you have clearly identified XML files, we can add .sw to XML's list of extensions and add a sample.

So with that in mind...

  1. Please add .sw and a sample to XML
  2. Update the heuristic test to be sure it doesn't misclassify the XML file as Sway
  3. Replace your samples with more real world looking uses of the language from the examples you got these from. These samples look like contrived demonstrations of the syntax rather than illustrations of real world usage.

lib/linguist/heuristics.yml Outdated Show resolved Hide resolved
@sdankel sdankel requested review from lildude and Alhadis and removed request for lildude and Alhadis February 24, 2023 21:07
@lildude lildude changed the title Add sway language Add Sway language Feb 27, 2023
@sdankel sdankel requested review from lildude and Alhadis and removed request for lildude February 27, 2023 22:27
@lildude
Copy link
Member

lildude commented Feb 28, 2023

Looking good. One final thing, could you please state in the OP the motivation/influence/inspiration for the colour you've chosen. I plan to add this to the template to help give some clarity in future if/when peeps submit a PR to change a language's colour.

@sdankel sdankel requested review from lildude and removed request for Alhadis February 28, 2023 23:45
@sdankel
Copy link
Contributor Author

sdankel commented Feb 28, 2023

Looking good. One final thing, could you please state in the OP the motivation/influence/inspiration for the colour you've chosen. I plan to add this to the template to help give some clarity in future if/when peeps submit a PR to change a language's colour.

Done ✅

@lildude lildude merged commit 592bbed into github-linguist:master Mar 2, 2023
@sdankel sdankel deleted the sophie/sway branch March 6, 2023 21:04
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants