-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Enable config for auto-pairs #992
Comments
I wonder if this should affect the existing match? |
I suppose it should overwrite (if any) the hard-coded pairs.. |
If folks don't mind a kind of slow pace, I'd like to take a crack at this and #1014. I've been looking over the basics of the code base, and I think I'm at a place now where I could work on this. I just don't have a ton of free time, so it may be days between bits of work. If anyone sees this and gets impatient, please feel free to go your own way independent of me. |
I wonder if this would be more appropriate as a language config. There are some languages that have unusual pairings, especially templating languages like Jinja's The latter might have some interesting cases to consider. The Rust lifetime annotations in particular are a good case study. The simple obvious lexical way we could avoid an unwanted auto closure, which is mentioned in the comments already, would be to check if it's preceded by a [[language]]
name = "rust"
scope = "source.rust"
...
[auto-pairs]
"(" = ")"
'"' = '"'
'<' = '>'
"'" = { close = "'", except_prefixes = ["<", "&"]
... But this wouldn't completely cover all cases where it could happen, e.g. it would not help fn foo<F: Display + 'a>(f: F) { ... } So I wonder if it wouldn't be possible to make use of tree-sitter to help be aware of meaningful context, so instead of saying "except when preceded by these tokens", we could say "except when inside a generic type parameter or a reference type", and it could look something like: [auto-pairs]
"(" = ")"
'"' = '"'
'<' = '>'
...
[auto-pairs."'"]
close = "'"
except_when_inside = ["type_parameters", "reference_type"] If this seems like a good idea, I'll probably try the lexical option first, as that seems like it might be easier, but the second might also be useful. |
Describe your feature request
I feel it would be better if we could add our own set of auto-pairs in config.toml..
Eg:
"auto-pairs" = { ["<", ">"], ["'", "'"] }
or something like the above.
It would be helpful for those who use such combinations regularly.
The text was updated successfully, but these errors were encountered: