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

Disable auto-pairing for ' in Rust #1347

Closed
Omnikar opened this issue Dec 23, 2021 · 4 comments · Fixed by #1624
Closed

Disable auto-pairing for ' in Rust #1347

Omnikar opened this issue Dec 23, 2021 · 4 comments · Fixed by #1624
Labels
A-core Area: Helix core improvements A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@Omnikar
Copy link
Contributor

Omnikar commented Dec 23, 2021

Is it possible for auto-pairing for ' to be disabled for Rust specifically? As it's quite annoying for lifetimes, and IMO adding the closing ' manually for character literals is much less of a hassle than manually removing the closing ' for lifetimes.

@archseer
Copy link
Member

So this was a TODO in the original implementation that @dead10ck removed in 94535fa#diff-50a1c8d85a9ae0f5840c9cf42a8de23831e9fa1c8454573136cdeb2deb0f48ddL50 so I assumed it was resolved? If not we should disable '

@Omnikar
Copy link
Contributor Author

Omnikar commented Dec 24, 2021

// TODO: special handling for lifetimes in rust: if preceeded by & or < don't auto close '
// for example "&'a mut", or "fn<'a>"

This definitely doesn't encapsulate everywhere where lifetimes can appear. I'd more think that, rather than this sort of incredibly specific special case, auto pairing ' should be completely disabled for Rust.

@dead10ck
Copy link
Member

dead10ck commented Dec 24, 2021

So this was a TODO in the original implementation that @dead10ck removed in 94535fa#diff-50a1c8d85a9ae0f5840c9cf42a8de23831e9fa1c8454573136cdeb2deb0f48ddL50 so I assumed it was resolved? If not we should disable '

Ah, I think I deleted that todo by mistake; I had meant to put it at the top in the consolidated list of todo's, but I must have missed that one, sorry about that.

This problem can't be solved currently without completely disabling auto pairing ' for every language, which would be kind of unfortunate. It's worth noting that there are lots of languages that have single-quoted strings, like Python and bash to name but two; Rust is the only language I know of with this problem.

This issue can only be addressed by #992, which is on my to do list; I've just been trying to order things by my own impression of what would give the best quality of life improvements for the largest common denominator. I'm currently working on delete removing auto pairs, and I planned on doing the language config stuff after that.

If we wanted a quick and dirty fix, we could make a global auto pairs config option to let people choose what they want to pair globally, and follow it up with the more complicated per language config. Though this would mean quickly introducing and then deprecating a config option.

@archseer what do you think?

Edit: come to think of it, maybe it wouldn't have to be thrown away. The global option could serve as the default that all languages inherit without explicit config, and for documents without a supported language. And it wouldn't be too difficult I don't think.

The only thing I've been pondering is whether the auto pairs hook should move into term so it has access to Editor for the config, or if the pairs should just be passed into the hook function.

@kirawi kirawi added A-core Area: Helix core improvements A-helix-term Area: Helix term improvements C-enhancement Category: Improvements labels Dec 24, 2021
@dead10ck
Copy link
Member

Just as a heads up, I've started work on a global config option like I mentioned above.

@sudormrfbin sudormrfbin linked a pull request Feb 7, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Helix core improvements A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants