options: Add bracepairs to control the start and end character of the pairs#2857
options: Add bracepairs to control the start and end character of the pairs#2857JoeKar wants to merge 1 commit intomicro-editor:masterfrom
bracepairs to control the start and end character of the pairs#2857Conversation
|
Yes it should probably be configurable based on language. For languages where < and > are used as both comparison operators and template parameters (C++, Rust) maybe we should err on the side of not enabling it? Do you know what other editors like VS Code do in this situation? |
I will give it a try.
Sounds a bit more complicated and maybe something in the future in case the configurable brace pairs are available.
Since VSCode is language driven by default it has his config available per language. |
85cc100 to
92ad383
Compare
bracepairs to control the start and end character of the pairs
| "backup": true, | ||
| "backupdir": "", | ||
| "basename": false, | ||
| "bracepairs": []interface{}{"()", "{}", "[]"}, |
There was a problem hiding this comment.
I had a lot of trouble to get it somehow working with the default and a user-defined configuration in case it was defined as []string{"()", "{}", "[]"}, because then the whole type conversion kicks in.
| } | ||
|
|
||
| func validateBracePairs(option string, value interface{}) error { | ||
| _, ok := value.([]interface{}) |
There was a problem hiding this comment.
Again, value.([]string) was too tricky so far.
| _, ok := value.([]interface{}) | ||
|
|
||
| if !ok { | ||
| return errors.New("Expected slice of strings") |
There was a problem hiding this comment.
...and thus error message doesn't fit exactly, because now it expects slice of interfaces.
Did you meant it uses LSP? |
|
No, I was referring to the Language Configuration Guide. So VSCode or more precisely his configuration can define all that stuff per language. |
Looks like a good thing for micro! |
This helps in e.g. HTMLs and CPPs (templates), but can create some unexpected underlines in case of shift operations in e.g. C(PP)s.
Maybe a better option is to make them configurable. What do you think about?