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

options: Add bracepairs to control the start and end character of the pairs #2857

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JoeKar
Copy link
Collaborator

@JoeKar JoeKar commented Jul 8, 2023

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?

@zyedidia
Copy link
Owner

zyedidia commented Jul 8, 2023

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?

@JoeKar
Copy link
Collaborator Author

JoeKar commented Jul 18, 2023

Yes it should probably be configurable based on language.

I will give it a try.

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?

Sounds a bit more complicated and maybe something in the future in case the configurable brace pairs are available.

Do you know what other editors like VS Code do in this situation?

Since VSCode is language driven by default it has his config available per language.

@JoeKar JoeKar changed the title buffer: Extend brace pairs by < & > options: Add bracepairs to control the start and end character of the pairs Jul 18, 2023
@@ -277,6 +278,7 @@ var defaultCommonSettings = map[string]interface{}{
"backup": true,
"backupdir": "",
"basename": false,
"bracepairs": []interface{}{"()", "{}", "[]"},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

@@ -462,6 +474,16 @@ func validateNonNegativeValue(option string, value interface{}) error {
return nil
}

func validateBracePairs(option string, value interface{}) error {
_, ok := value.([]interface{})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Again, value.([]string) was too tricky so far.

_, ok := value.([]interface{})

if !ok {
return errors.New("Expected slice of strings")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

...and thus error message doesn't fit exactly, because now it expects slice of interfaces.

@dustdfg
Copy link
Contributor

dustdfg commented May 2, 2024

Do you know what other editors like VS Code do in this situation?

Since VSCode is language driven by default it has his config available per language.

Did you meant it uses LSP?

@JoeKar
Copy link
Collaborator Author

JoeKar commented May 2, 2024

No, I was referring to the Language Configuration Guide. So VSCode or more precisely his configuration can define all that stuff per language.

@dustdfg
Copy link
Contributor

dustdfg commented May 2, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants