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

Ligatures in Rust Attributes #1

Closed
mitsuhiko opened this issue Feb 29, 2020 · 12 comments
Closed

Ligatures in Rust Attributes #1

mitsuhiko opened this issue Feb 29, 2020 · 12 comments
Assignees

Comments

@mitsuhiko
Copy link

Rust uses attributes to add meta information to functions, structs etc. These can be declared in two ways: #[meta] attach to the next item or #![meta] to the previous.

Example:

#[allow(some_lint)]
fn test() {
    #![deny(some_other_lint)]
}

Looks like:

image

I would prefer if the first ligature was not a thing.

@bebraw
Copy link
Contributor

bebraw commented Mar 1, 2020

I wonder what's the best way to achieve this. I suppose the target would be to still have other ligatures working still, correct? I wonder if that means that we'll have to disable this ligature altogether.

@okonet What's the use case for this specific ligature? Do you see value in having it included?

@okonet
Copy link

okonet commented Mar 1, 2020

Not really. I think we can drop it easily.

@bgever
Copy link

bgever commented Apr 23, 2020

The custom behavior could be configured by the user using stylistic sets like FiraCode does:
https://github.com/tonsky/FiraCode/wiki/How-to-enable-stylistic-sets

I personally like this #[ ligature, as it brings more focus to the content of the annotation. In fact, maybe #![ could be turned into a ligature as well, similar to !=. 😄

However, it would be nice to align the open and close brackets:

image

@MarcusSterz
Copy link

However, it would be nice to align the open and close brackets:

Thanks for pointing it out!
Thing is: the regular brackets ([{ are vertically placed to fit best with upper and lower case text, the lig bracket are aligned to be viewed best in combination with the other symbols (center aligned). Question is if we sacrifice the better alignment of the regular brackets for this. Maybe find a compromise for both situations. Thoughts? @bebraw @okonet

@okonet
Copy link

okonet commented Apr 23, 2020

I think aligning all brackets and sacrifice the alignment in ligatures should be fine.

@okonet
Copy link

okonet commented Dec 4, 2020

We can also tackle this in stylistic set. See https://github.com/MonoLisaFont/font/issues/1

@bebraw
Copy link
Contributor

bebraw commented Jan 4, 2021

I think #50 is related to this. Since we're talking about Rust-related group of characters, I suppose a good thing to do would be to handle characters like ..=, .=, .. in it so that they make sense.

Can someone that's using Rust comment on the issue regarding which characters should have ligatures there? I am primarily interested in how a stylistic set should be implemented for it and what the ideal experience for the language should be like.

@MarcusSterz
Copy link

@bebraw Is there a comprehensive list regarding Rust Attributes?

@bebraw
Copy link
Contributor

bebraw commented Apr 6, 2021

@mitsuhiko Are there specific ligatures that should be added to improve the UX with Rust? How can we make the typeface better for Rust users?

As mentioned above, one option is that we'll provide a Rust specific stylistic set that's specifically designed for the language. I know at least VS Code lets you enable it specifically for Rust.

@danwards
Copy link

danwards commented Apr 3, 2023

Hello! Hoping there's still some interest related to Rust-specific features.

There's a complete list of operators in use on the official documentation which may be useful: https://doc.rust-lang.org/book/appendix-02-operators.html

In regards to #50: I've never seen .= used within the language but matching .. and ..=, even as a stylistic set, would be fantastic. They both represent ranges of data and are used almost interchangeably within code. It feels a bit strange, personally, seeing how different they look.

Something else that I noticed in the playground is that $() causes the () to not match, which may relate to the discussion of bracket alignment earlier on this issue. Specifically, $() is used within Rust's macro system frequently.

image

Beyond that, everything I've seen so far feels like it fits very well for Rust!

@bebraw
Copy link
Contributor

bebraw commented Nov 17, 2023

There's a prerelease containing Rust specific ligatures available now. These might have to go behind a specific stylistic set in case they are too specific for other languages.

@bebraw
Copy link
Contributor

bebraw commented Dec 15, 2023

Included in 2.012. The exact ligatures added are +=, -=, *=, %=, &=, &^, and &^=.

@bebraw bebraw closed this as completed Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants