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

Support EditorConfig #13056

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

Support EditorConfig #13056

wants to merge 1 commit into from

Conversation

the-mikedavis
Copy link
Member

@the-mikedavis the-mikedavis commented Mar 8, 2025

This adds support for EditorConfig to the core. This aims to be as minimal and direct of an integration as possible. This configures matching documents':

  • indent style (indent_size + indent_style + tab_width)
  • line ending (end_of_line)
  • encoding (charset)
  • whether a trailing line ending is added on save (insert_final_newline)

The other core option trim_trailing_whitespace is parsed out but not yet used (#8366). spelling_language is left for future work.

Closes #279
Closes #1777

This adds support for EditorConfig to the core. This aims to be as
minimal and direct of an integration as possible. This configures
matching documents':

* indent style (`indent_size` + `indent_style` + `tab_width`)
* line ending (`end_of_line`)
* encoding (`charset`)
* whether a trailing line ending is added on save (`insert_final_newline`)

The other core option `trim_trailing_whitespace` is parsed out but not
yet used. `spelling_language` is left for future work.
@senekor
Copy link
Contributor

senekor commented Mar 8, 2025

There is also the key max_line_length. For some reason it doesn't appear in the spec. But it's somewhat widely used, e.g. webpack, elastic, django, react and rust.

@TheDaemoness
Copy link

TheDaemoness commented Mar 8, 2025

As the author of the original EditorConfig PR that will be closed by this implementation, I feel obligated to note that this implementation is technically non-conformant with the EditorConfig 0.17.2 spec listed. Note, for instance, differences between https://docs.rs/globset/latest/globset/#syntax and https://editorconfig.org/#wildcards - EditorConfig calls for a {num1..num2} globbing style that is not supported by globset (which is why ec4rs doesn't use it).

But at this point, it has been three years, and if maintaining a slightly-incorrect implementation of EditorConfig in-tree that adds no additional dependencies is preferable, then at least the users will finally have some form of EditorConfig support.

@the-mikedavis
Copy link
Member Author

Yeah that's the tradeoff - I'd rather have something as minimal as possible even if it isn't strictly spec conformant with the glob flavor. In the wild all projects I've seen (https://github.com/editorconfig/editorconfig/wiki/Projects-Using-EditorConfig) use just the basics of the glob syntax.

@the-mikedavis
Copy link
Member Author

To properly support max_line_length we would need #2274

@senekor
Copy link
Contributor

senekor commented Mar 8, 2025

That seems nice, but it could be supported right now with the same behavior as the text-width configuration value. It would affect :reflow and soft-wrapping.

continue;
}
};
let is_root = ini.pairs.get("root").map(AsRef::as_ref) == Some("true");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let is_root = ini.pairs.get("root").map(AsRef::as_ref) == Some("true");
let is_root = ini.pairs.get("root").as_ref() == Some("true");

Isn't this possible?

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for EditorConfig
4 participants