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

EditorConfig #8534

Closed
exalted opened this issue Jun 20, 2022 · 45 comments · Fixed by #19455
Closed

EditorConfig #8534

exalted opened this issue Jun 20, 2022 · 45 comments · Fixed by #19455
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label] setting Feedback for preferences, configuration, etc

Comments

@exalted
Copy link
Contributor

exalted commented Jun 20, 2022

EditorConfig is somewhat of an industry-standard these days. Although not a priority for me, you might want to take into consideration being compatible with existing EditorConfig configurations.

@joeldrapper
Copy link

joeldrapper commented Apr 5, 2023

I switch between a project that uses tabs and a project that uses spaces multiple times a day and I have to remember to jump into my Zed config and change the global setting each time.

@maxbrunsfeld
Copy link
Collaborator

For what it's worth, Zed now supports folder-specific configuration (via a .zed/settings.json file). https://docs.zed.dev/configuration/configuring-zed#folder-specific-settings

@maxbrunsfeld
Copy link
Collaborator

The reason we implemented that instead of EditorConfig, is that EditorConfig is pretty limited in what it can express, whereas with our own settings.json file, we can add local support for any Zed setting, in a way that is consistent with the global settings file. EditorConfig also uses an idiosyncratic, bespoke file format that is slightly different than TOML, whereas with settings.json, we can use the normal JSON autocomplete and in-editor diagnostics.

@rschiang
Copy link

rschiang commented Jun 21, 2023

Implementing .editorconfig is less of a user customization problem but more of a cross-editor collaboration issue.

I understand that it makes more sense to implement project-specific .zed/setting.json, but projects impose .editorconfig in their source code repo to enforce a coherent code style. As .editorconfig is almost an industrial standard now, Zed users would need to config each project manually every time if there are no builtin .editorconfig support.

@joeldrapper
Copy link

Supporting .zed/settings.json is great. I agree it would be nice to have .editorconfig support to save time when working with open-source projects, but it looks like this has been tagged as a potential plugin. I hope this means we'll soon be able to develop plugins for Zed.

@exalted
Copy link
Contributor Author

exalted commented Jun 21, 2023

Folder-specific configuration is handsome! 👏

However, for all the good reasons above, I'd still keep this issue open as something to consider to implement at some point in future.

@jabr
Copy link

jabr commented Sep 8, 2023

Lack of editorconfig support is now the only blocker for me to start using this as my default editor. I work with too many shared repos to "just" set up custom settings for each to mirror its editorconfig.

@BuonOmo
Copy link
Contributor

BuonOmo commented Sep 25, 2023

I got a really small ball rolling with this script (gist) that intents to generate a .zed/settings file from a local .editorconfig file.

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@steve-taylor
Copy link

If you're using Prettier, .editorconfig is still a nice to have, but you can live without it for now and configure Zed to format with Prettier upon saving:

{
  "formatter": {
    "external": {
      "command": "node_modules/.bin/prettier",
      "arguments": ["--stdin-filepath", "{buffer_path}"]
    }
  }
}

@exalted
Copy link
Contributor Author

exalted commented Jan 27, 2024

@steve-taylor sure, thanks.

@BuonOmo
Copy link
Contributor

BuonOmo commented Jan 27, 2024

There is already a lib that could handle the parsing: https://github.com/TheDaemoness/ec4rs. I don't know if it is well known enough for Zed, but might worth a shot. And now that Zed is OSS, maybe @TheDaemoness would even be interested in that contribution ?

@TheDaemoness
Copy link

If there's interest from the maintainers, I could look into integrating ec4rs into zed (as a plugin? Please advise).

@pzmosquito
Copy link

pzmosquito commented Feb 1, 2024

+1 for supporting .editorconfig. It's important for working with multiple projects and teams.

@nilskaspersson-imtf
Copy link

I would like to use Zed as my daily driver, and the lack of support for .editorconfig is the only thing preventing me from doing so.

@JosephTLyons JosephTLyons added the language An umbrella label for all programming languages syntax behaviors label Feb 26, 2024
@JosephTLyons JosephTLyons transferred this issue from zed-industries/zed Feb 26, 2024
@JosephTLyons JosephTLyons changed the title EditorConfig support EditorConfig Feb 26, 2024
@BuonOmo
Copy link
Contributor

BuonOmo commented Feb 26, 2024

@JosephTLyons do you plan on having rust interaction capable extensions ?

Also TBH it still feels like it should be out of the box to me (as it is in many places). This is kind of a standard, and it would help a lot to have it not being an extension to ensure people are following project guidelines correctly!

@Moshyfawn
Copy link
Member

Also TBH it still feels like it should be out of the box to me (as it is in many places).

The aim is to move the majority of languages to extensions, separating development and improvements from Zed. Then, pick multiple language extensions that can be used out of the box.

@JosephTLyons
Copy link
Collaborator

@JosephTLyons do you plan on having rust interaction capable extensions ?

Also TBH it still feels like it should be out of the box to me (as it is in many places). This is kind of a standard, and it would help a lot to have it not being an extension to ensure people are following project guidelines correctly!

It still could be a language we ship directly - we havent fully decided which languages will be ultimately shipped and which ones will be made into extensions - I just moved all language requests into this repo to clean up the issues in the Zed repo. We can always move things into Zed, if it makes sense.

@BuonOmo
Copy link
Contributor

BuonOmo commented Feb 27, 2024

I think there is a confusion here. The support of the editor config language is not the most important. What matters most is that it is used by zed to properly format the code. Hence I'm not sure it is about the language more than it is about the integration into Zed's settings.

I don't want to talk for everyone, but for me that's the most important part.

@bdougherty
Copy link

Yes, it's about supporting the editorconfig file for defining editor settings.

As far as the language goes, I'm pretty sure it is just standard ini.

@joeldrapper
Copy link

Yes, this issue is about making .editorconfig act like a .zed/settings.json file. Support for the INI language is, in my opinion, a much lower priority, and it’s not what this issue is about.

@Moshyfawn
Copy link
Member

I see what you're saying. The fact that it was moved to this extensions repo confused me. I'm not sure this can be made into a plugin if we're talking about Zed inheriting the .editorconfig config, but I might be wrong.

@JosephTLyons JosephTLyons transferred this issue from zed-industries/extensions Feb 28, 2024
@JosephTLyons
Copy link
Collaborator

JosephTLyons commented Feb 28, 2024

Ok, I understand this a bit more now. I've moved the issue back to the Zed repository. Thanks for bringing these details up (I've never messed with editorconfig myself).

@JosephTLyons JosephTLyons added editor Feedback for code editing, formatting, editor iterations, etc setting Feedback for preferences, configuration, etc labels Feb 28, 2024
@jabr
Copy link

jabr commented Jul 14, 2024

a workaround could be a .editorconfig -> .zed/settings.json script to help meanwhile.

BuonOmo posted such a script in a comment up above.

@jabr
Copy link

jabr commented Jul 14, 2024

Is it possible to write an extension for this feature ?

This kind of functionality can't currently be added through a Zed extension.

Extensions only allow adding grammars, languages, and themes.

@bersace
Copy link

bersace commented Jul 15, 2024

I got a really small ball rolling with this script (gist) that intents to generate a .zed/settings file from a local .editorconfig file.

I created a more elaborate solution at https://gitlab.com/bersace/zeditorconfig

$ go run gitlab.com/bersace/zeditorconfig@latest

This will handle braces, brackets and directory prefix.
It fallbacks language to file extension. Which works well for CSS, JSON, C, PHP, etc.

🇫🇷 Merci @BuonOmo pour le script original en Ruby, je m'en suis inspiré !

It's my first project wrote entirely using Zed & lazygit, under Linux. It's awesome !!

@PedroHLC
Copy link

PedroHLC commented Aug 2, 2024

Sorry guys, but .editorconfig fills like native for most text-editors and IDEs out there. No way I'm converting them all just to randomly edit a project in Zed. I have been using them since always and never had to care about an app not supporting them, until now:

╰─λ find ~/ -name '.editorconfig' -type f | wc -l
327

Nothing worse than opening a PR and the project leader telling you “your PR is breaking our indentation and EOF that we have enforced on .editorconfig, configure your IDE” -- something I have not encountered in years

@BuonOmo
Copy link
Contributor

BuonOmo commented Aug 7, 2024

I think there's enough traction on this... I'll open a PR during next week! If any of you would like to pair on that during the week, email me :)

@shellscape
Copy link

@BuonOmo looking forward to that!

BuonOmo added a commit to BuonOmo/zed that referenced this issue Aug 16, 2024
BuonOmo added a commit to BuonOmo/zed that referenced this issue Aug 16, 2024
BuonOmo added a commit to BuonOmo/zed that referenced this issue Aug 16, 2024
BuonOmo added a commit to BuonOmo/zed that referenced this issue Aug 16, 2024
BuonOmo added a commit to BuonOmo/zed that referenced this issue Aug 16, 2024
BuonOmo added a commit to BuonOmo/zed that referenced this issue Aug 16, 2024
BuonOmo added a commit to BuonOmo/zed that referenced this issue Aug 16, 2024
SomeoneToIgnore pushed a commit to BuonOmo/zed that referenced this issue Sep 2, 2024
SomeoneToIgnore pushed a commit to BuonOmo/zed that referenced this issue Sep 7, 2024
SomeoneToIgnore pushed a commit to BuonOmo/zed that referenced this issue Sep 17, 2024
SomeoneToIgnore pushed a commit to BuonOmo/zed that referenced this issue Sep 19, 2024
@dbarnett
Copy link

Just to summarize current status:

  • in the PR it looks like @SomeoneToIgnore has an open concern about how to handle multiplayer support / remote workflows
  • in August they said "It might take some time though, as LanguageSettings is quite a foundational thing in our codebase and there's another task I have to tackle first."

@SomeoneToIgnore
Copy link
Contributor

The PR in question: #16349
To add on top, the PR now has a great single player part prototype and a nice test to check the correctness of the feature.

Two main problems with it that it new plugin API now needs to pass a file path to get a language setting for, which was not the case before; and the fact that the PR changes the place to make a recursive FS lookup in a method, that is called during rendering, potentially up 120 times per second...

To make it closer to amortisized O(1) without any FS checks, quite a different code has to be written, even the one in the code of the feature, related to parsing and merging the actual files.

I've described a way to implement this in one of the comments to the PR #16349 (comment)

and this has to wait before ssh remoting feature forms into some public form, otherwise the development work related to that ssh remoting might change things a lot, as it already did since the time the PR was open.

SomeoneToIgnore added a commit that referenced this issue Oct 21, 2024
Closes #8534
Supersedes #16349

Potential concerns:
* we do not follow up to the `/` when looking for `.editorconfig`, only
up to the worktree root.
Seems fine for most of the cases, and the rest should be solved
generically later, as the same issue exists for settings.json
* `fn language` in `AllLanguageSettings` is very hot, called very
frequently during rendering. We accumulate and parse all `.editorconfig`
file contents beforehand, but have to go over globs and match these
against the path given + merge the properties still.
This does not seem to be very bad, but needs more testing and
potentially some extra caching.


Release Notes:

- Added .editorconfig support

---------

Co-authored-by: Ulysse Buonomo <[email protected]>
@Dev-cmyser
Copy link

it's already working ?

@Dev-cmyser
Copy link

How to use this ?
I can't find docs please help

@dwt
Copy link

dwt commented Jan 31, 2025

What are you struggling with? You probably did follow this manual - there was no extra step for me, it just worked.

@tednaaa
Copy link

tednaaa commented Jan 31, 2025

actually it should just work, but I faced with issue when for example there is 2 projects

foo/ # with .editorconfig
bar/ # without .editorconfig

if we open with zed project bar/ then open some file from project foo/ and format it, .editorconfig will not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label] setting Feedback for preferences, configuration, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.