-
Notifications
You must be signed in to change notification settings - Fork 16
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
Extension Point to customize preferences for any editor #9
Comments
In the long-term I think exposing an extension point is the right way to go. Currently configuring the indentation behavior requires knowing about the config settings of various editors: setPreference("org.eclipse.ui.editors", "spacesForTabs", "true");
setPreference("org.eclipse.jdt.core", "org.eclipse.jdt.core.formatter.tabulation.char", "space");
setPreference("org.eclipse.wst.xml.core", "indentationChar", "space");
setPreference("org.eclipse.ant.ui", "formatter_tab_char", "false"); This approach has the following limitations:
Moving the responsibility to the plugin that owns the editor will be more robust and easier to maintain. What the extension point should look like is not clear to me though because not all editorconfig properties are supported yet. In particular, I am not sure whether properties will always require custom behavior for different editors. For example, the way I have been planning on implementing "trailing whitespace" and "final newline" is to use the same approach as Anyedit - detect file save events and rewrite the file content. When more of the properties have been implemented we will have a better idea of what the relationship between this plugin and the various editor plugins should be. |
Well, there are 2 issues here:
Part 1 is unlilely to come from anywhere except from So when |
@paulvi I agree. Do you have any ideas how to achieve "part 1"? AFAIK this is not possible in a plugin and needs to come from Eclipse core. |
The big problem with the existing Eclipse Editor is that preferences (like format) is for the whole editor of the project. With editorconfig you can have several .editorconfig files in the same project. So editor of the same project can have different preferences. I'm afraid that this feature is not possible -( |
@angelozerr to be clear you mean specifying settings for all editors is not possible right? There is nothing stopping us declaring an extension point which editors can optionally use to access the .editorconfig settings. |
I mean that Eclipse Editor like XML, JSDT, etc Editor uses preferences from
With editorconfig you can have file preferences according this specification :
I'm afraid that we cannot support that with Eclipse. |
Forgive my ignorance as I have never implemented an Eclipse editor, but surely an editor can source preferences from anywhere, not just global and project settings. If we create an extension point that exposes the editorconfig preferences then editors can opt-in to use our preferences instead of the gloabal ones. The way I see this panning out is that authors of editors who wish to add support for editorconfig can simply add it to their own plugin instead waiting on us to add support for yet another editor. Doing it that way would also offer a smoother experience as the global settings would not need be abused (which causes the jarring experience when switching between editors that are both visible and have different editorconfig tab width settings). We will need to continue to rely on global preference hacks for any editors that do not consume our extension point. |
@ncjones I have studied how to support with clean mean .editorconfig inside https://github.com/angelozerr/typescript.java an Eclipse plugin for TypeScript. The challenge is:
I have found a solution and if you like my idea, I will create a PR. The basic idea is to use an instance of The editorconfig plugin try to retrieve the eclipse preferences from the editor with getAdapter method like this:
And my TypeScript Editor implements getAdapter like this:
After that when editorconfig property must be applyed, it applies property of the instance of IEclipsePreference of global preferences if the editor doesn't return the eclipse preferences
What do you think about this idea? If you like it, I will create a PR with this idea. The only thing is that now the apply of the editorconfig is done by EditorFileConfig and not by EditorConfigEditorActivationHandler. So now you have eclipse dependencies IEclipsePreference inside EditorFileConfig (core package, but is it a problem?) |
@mickaelistria what do you think about my idea with
I have suggested this idea too at https://bugs.eclipse.org/bugs/show_bug.cgi?id=463071#c9 |
This conversation is deriving strongly from its initial purpose. I opened #30 for easier tracking of styling individual editors. |
@angelozerr really good work! Setting config per editor would be a big improvement. Will leave this issue as is because I still believe editors should be able to depend on this plugin to source configuration. |
I have created an new discussion about extension point at #37 |
No description provided.
The text was updated successfully, but these errors were encountered: