-
Notifications
You must be signed in to change notification settings - Fork 194
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
Provide .editorconfig support #877
Comments
@angelozerr do you think you can prepare a PR for this to contribute the code to eclipse? I'll then open a CQ for this, |
The edition part seems to require TM4E. Do we want Platform to start depending on TM4E ? I personally wouldn't mind, but I think it should be discussed a bit more broadly. |
some questions: |
At first I would like to say that ec4e is based on https://github.com/ec4j/ec4j an editorconfig parser that I have implemented which can provide the required information that we need for IDE (AST offsets of section, fault tolerant parser,etc) compared to https://github.com/editorconfig/editorconfig-core-java which don't give the capability to give some offsets. The official site https://editorconfig.org/ references today the ec4j. The ec4e should work well with Generic Editor but not correctly with old editor. Here a demo where you can see wizard in action, codemining to show number of files which matche the section, syntax validation of .editorconfig and the most important apply of setting for matched files:
Indeed, perhaps TM4E should take care of that?
It is the .editorconfig which should have the priority. But any improvement are possible.
Again, it is the .editorconfig which should have the priority. But any improvement are possible.
No.
ec4j provide some abstract resource class to retrieve .editorconfig. ec4e implement them with Eclipse API IResource https://github.com/angelozerr/ec4e/tree/master/org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/internal/resource |
I'm not sure it's a good idea to have more circular dependencies in the platform via TM4E. Ssuch an addition would force Java 17 BREE into the platform, which is yet another issue to consider carefully. |
Build is already Java 17, EPP is already Java 17, so having one bundle (we don't need to put the code into an exiting plugin) would not change much?
@mickaelistria already mentioned one might be able to not use TM4E beside that, if we just have an |
Having circular dependency between tm4e and platform.releng build is a total no-go. Java 17 is not an issue for me (it's probably time to admit that Java 11 support other than producing Java 11 bytecode is of zero interest for my company team now). |
Maybe we have a different understanding of a "circular dependency" but for me a circular dependency is where Anyways @angelozerr can you explain where TM4E is used and if it can be either optional or replaced with other techniques? |
It's a releng "circular dependency" between p2 repos - platform -> tm4e -> platform
|
We have some circular dependencies already IIRC. The EMF edit plug-in IIRC. |
The whole platform build is a "circular dependency" ;-) Beside that, no one forces us to use the latest snapshot repository of TM4E ... we can simply use the latest release of TM4E, of course then might only use features of TM4E - 1 but this should not be an issue here... |
Please, the fact that we have many issues doesn't mean we should add more! Let's agree to not make platform build worse than its current terrible state. |
So to move the discussion in the right direction - TM4E is used for the editor of .editorconfig files which means that applying/supporting existing .editorconfig files can go in without the requirement on TM4E and I propose the discussion to go towards that goal. Having smart editor for .editorconfig files can stay separate. |
Even though I don't know how it works, but Eclipse sometimes recommend me to install things from the marketplace for "unknown" extensions. So if we can integrate the |
Marketplace entry that has a tag fileextension_editorconfig should be everything needed for MPC to suggest installing the editor. |
Dont worry I can remove TM4E which provides syntax coloration and some features with langage configuration wich provides machine bracket for .editorconfig file but the other factures like validation codemining complerion for .editorconfig is not linked to TM4E. The only required dépendance is ec4j which is on maven central. Keep in mind the apply of .editorconfig works correctly with only generic editor and not with some editor like jdt java editor. More I need to use java reflection to add a custom IPreferenceStore to generic editor which is not very clean. To be clean generic editor should provide perhaps an extension point to add an ipreferencestore |
For .editorconfig syntax coloration I think TM4E should provide the textmate for .editorconfig file. |
I have just one question for ec4j dependency, can I create a PR with plusieurs which have à lib folder which contains ec4j jar? We could manage that properly in an another PR? What do you think about that? |
It's fine to have first draft with ec4j being internal dependency. Before accepting we should have it added to the target platform referring to the maven artifact directly. |
You can add maven dependencies directly to the target and use is like any regular bundle, so no need for workaround like lib folders! |
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
I have created a draft PR at eclipse-platform/eclipse.platform.text#89 without TM4E but we need to do some PR before, see eclipse-platform/eclipse.platform.text#89 (comment) |
Imho having .editorconfig support consists of several things. The first level is parsing the file and applying the correct settings from it to the editor. The next step is acting on those preferences: while I think the indent_style and indent_size do map on existing, workspace-level settings (that are currently already taken into account in most of not all editors), settings like I for one would expect that if Eclipse would support .editorconfig, it would also mean that all the settings one can set via .editorconfig would also be supported in all editors (although personally I'd be ok with just support in the generic editor) Third level would be rich editing support for .editorconfig files |
Per definition, .editorconfig overrides workspace- and project-level settings: it defines settings on a per-fileType basis, looking for the closets applicable settings by looking for the closets .editorconfig file (containing relevant settings) from the current filled location up through its parent directory structure, until either matching settings have been found or a .editorconfig file is encountered that has |
It is an important question, should .editorconfig works with any editor or with just genereic editor? The answer will determine where the extension point which create and add an IPreferenceStore into the editor (in texteditor extension point or in genereric extension point). |
Just assume I have an editor that supports Grahical editing of a binary file format, has "trim_trailing_whitespace" any meaning? |
By the way, as far as I know no one prevents others to also looking at the generic editor extension point later on... |
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
I don't think that this is mandatory, any editor can ignore these defaults these are just resources settings. Still it would be useful if there would be an extension point to inform the user about that these settings are overridden somewhere else. |
I agree with your all comments, but to be honnest with you I could not do that in the same PR and I'm not sure that I will have time to implement all of your ideas. My main goal is to provide .editorconfig basicly and after we could improve it step by step. |
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
Fixes #87 Signed-off-by: azerr <[email protected]>
To provide a clean API to contribute to generic editor with custom preferences store (with extension point), I need thoses 2 PRs: |
I don't think Eclipse Platform will ever provide ECJ support directly, but instead would expect it to be provided by another plugin from another project. So I'm closing the issue here. |
@angelozerr are you still interested in bringing editorconfig support to eclipse? I just got hit by the problem that an project uses editorconfig and it interferes with my usual settings so I need to manually reformat the code (and be careful Eclipse don't break it). And as many things have changed over time (e.g. Java 17 is no issue anymore at all) I think it might make sense to pick up this again. I also reviewed a bit the code you shared here, the PR and the github repository and I think we have different topics that can be addressed independently:
|
This is a very basic proof-of-concept for a way to support editor config to make java formatter integrate with this so called cross-ide way to specify formatter settings. See eclipse-platform/eclipse.platform.ui#877
I now added a very basic proof-of-concept that already works very well in my setup that simply overrides the tab char: |
Even if the topic is super interesting, unfortunately I will have no time to do that again -(
https://github.com/angelozerr/ec4j is my repository I used when I have created this project. I have created this project because the only official project which .editorconfig parser in Java was https://github.com/editorconfig/editorconfig-core-java#readme was not It is the one reason why I have created this project and today the official project is https://github.com/ec4j/ec4j The very good news is that this parser is today mature and robust:
This project is based on https://github.com/angelozerr/ec4j and uses
But the most important thing is apply the editorconfig properties to a given editor (for standard editor and generic editor both). It is the hardest topic. I spend a lot of time to find a generic solution (used by generic editor orother component), And I think the first topic that you will need to work is eclipse-platform/eclipse.platform.text#130
It is the easy part and you could copy/paste ec4e inside Platform UI (without the textmate grammar)
The first job to do is to provide an extension point used by the AbstractTextEditor eclipse-platform/eclipse.platform.text#130 It is long and hard work, thanks so much @laeubi to work on this great features again! |
@laeubi I think the full PR that you should see is https://github.com/eclipse-platform/eclipse.platform.text/pull/109/files but it is working only with generic editor if I remember |
@laeubi about the editorconfig editor, you can see all features that I had implemented in https://github.com/angelozerr/ec4e/tree/master/org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/internal ( Those feature uses the ec4j parser which build an AST nodes. codemining support is very nice because it displays codeming before section and you can click on it to perform the Search UI to retrieve all files which matches the section. |
ec4j is available on maven central https://mvnrepository.com/artifact/org.ec4j you will need the ec4j core https://github.com/ec4j/ec4j The ec4j parser isvery robust because it uses the official test of editorconfig https://github.com/ec4j/ec4j/tree/master/core |
Today
.editorconfig
is supported directly in vscode, IJ, etcIt should be really nice that Eclipse IDE provides this support too. It exists a discussion at https://bugs.eclipse.org/bugs/show_bug.cgi?id=457046
And I implemented a long time ago https://github.com/angelozerr/ec4e which works with genereic editor but cannot apply all settings.
The text was updated successfully, but these errors were encountered: