-
Notifications
You must be signed in to change notification settings - Fork 103
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
environmental variable for global config
#465
Comments
Thanks for the consolidated list of related issues. That is very helpful! |
So, any thoughts? |
To support this use case, I would propose reading the files in the other order:
That way, any project with its own |
Or, alternatively, the rule could be that if no |
Fine for me.
I wonder if always reading
We have this problem currently; or even worse, because not only do personal setting creep in, but also unchanged defaults from the editors (which aren't always the best). |
How about adding the This would maintain backwards compatibility for projects or settings maintaining a inheriting config setup and allow maintaining custom defaults? |
@florianb Isn't it essentially the same what I proposed? |
@Jorengarenar you're right - i should have written the second paragraph in a different way. I support your proposal - but i would like to put the variable name up for a discussion since it could be misleading what "EDITORCONFIG" in the contexts - where one faces it - means. I also think it's a good idea since
|
And as for single developers with multiple code bases this is just a way to start with a (inherited) config for file types. A editorconfig tool should then suggest to make these rules explicit (by taking them over into the projects definition) but you won't have the game anymore to start a project by collecting the rules you might need based on a file type expectation. |
@florianb Just checking --- are you supporting the "parent of I personally think
That reduces the risk of accidentally changing files during the transition period when not all cores/plugins support |
@cxw42 thank you for asking 🙏 - i'm a bit confused. Let me try to recap it in my words: Issue
Proposal (as i understood it)Introducing This would change:
Counterarguments
One could argument this shouldn't be an issue since the dev has to actively introduce the env variable referencing to the EditorConfig to apply.
I spend some thoughts on this issue and i don't see a good strategy to avoid this. My conclusionGiven i recapped everything right i guess i slightly changed my mind. In the former comments i think i underestimated the effect on asterisk-based rules. The point is if a global config drains in with a specific rule for let's say yaml files defining an indentation size of 4 instead of 2 - this would mess up working with the default requiring either to remove the referencing env var for that project, removing the explicit yaml rule from the default or creating an explicit rule for yaml files in the project. When i concluded this right i'd prefer to have a env variable acting as "root" file above If you're working on your own you might want to omit the use of local EditorConfigs at all and rely on your "global" referenced EditorConfig. Does this make sense? |
Let's consider an example: You work on a C++ project. As it is a well maintained repository, it does specify That's the current state of matter. Proposition of
* doesn't really matter whether it's from program's defaults or from some config file |
@florianb This sounds reasonable to me! |
I think this is the heart of the matter. EditorConfig's purpose is to prevent having to look at whitespace in diffs :D . (More specifically, to "maintain consistent coding styles for multiple developers working on the same project" per https://editorconfig.org.) A particular editor's default configuration is outside the scope of EditorConfig. In the example you give (Py file in a C++ project), I would do two things. I'll use Vim as my example because that's what I know :) .
Configuring an editor using an editorconfig-format fileIf I understand you correctly, you want to set your default per-filetype editor settings using editorconfig-format files rather than your editor's native configuration language. I think a plugin could implement that if you wanted. As long as the behaviour of the plugin is unchanged for files that match rules in |
Not one particular editor - I want to have one common default config for every editor I use.
That handles
Should I try forcing my personal preferences on three teams of people or engage them into pointless meetings to agree upon style for a language which probably will never be into the repo? And should I repeat this for every such project?
I want to have the same setting *regardless of which editor I open the file with, without needing to synchronize multiple configurations for that. If I want to change the exemplary tab size, I want to edit one file instead of five.
I can send a PR with this feature for editorconfig/editorconfig-vim even today, but who will do the same for plugins for other editors I use? And at this point, wouldn't it be easier to just standardize it anyway? |
I agree with @cxw42 that the proposal to use one
Since adding the environmental variable that skips Having said this, if you would like a spec that manages one configuration file that is automatically recognized by multiple editors on your system, I would say it's better to propose a new project. It can be more powerful, such as by compiling the single source of configuration to the configuration file of each editor on your system. But I personally doubt the effort would be worthy for such a project -- the overwhelming majority of people stick to at most 2 or 3 editors, which often intentionally need to diverge on their configuration. In the worst case, a manual sync won't be too difficult. |
If setting |
If you're working in a project having a "root" EditorConfig the creator of this config claims that this EditorConfig-File should be authoritative. If this EditorConfig misses any configuration of a new file i would consider adding properties for that file or removing the root-property. |
How about two environment variables?
|
I agree with this. Overriding a root=true project's settings defeats the purpose of editorconfig. I do not support the |
The settings set in |
Result:
|
Currently the it looks like this:
With the variables:
For the |
I feel like you'd like to "optimize" how to specify EditorConfig settings. I take one example, the Given the assumption this is a module of code standing alone you really should duplicate the And since this is not possible the If you introduce new files to a shared repository where the setting is wrong you should (in my opinion) aim for a fix of the config file - that's the way to negotiate that setting with the other collaborators. One shopuldn't override the settings for a repository, because it would cause a lot of troubles for all other collaborators - this iss the point about EC in general, isn't it? |
As far as I can tell, this idea (from above) is one the team can support:
@Jorengarenar is this of any value to you? If not, I do think @xuhdev's point about having your own project for editor defaults (as opposed to project settings) is worth considering, particularly given the effort you've put into this proposal! @xuhdev @florianb If this idea (root above |
Well, it's still a vast improvement over having a file in home directory, so even if unnecessarily limited, there is still value there.
My point was that EC is an ideal candidate for that already (down to the name). |
@Jorengarenar I don't see how EditorConfig is an ideal candidate. You are proposing to have a central place to save a configuration for all editors you use. As a matter of fact, as I said before:
This is already pretty straightforward to maintain if you maintain your own dotfiles. There isn't really much incentive to add significant complexity to EditorConfig for something that's already easy and clean to achieve. |
Because most editors have EC plugins which are capable of setting the settings? As I wrote at the very beginning:
Pseudocode:
That's essentially all I needed in editorconfig-vim.
I by no means am proposing to have the editors be fully configurable from EC, just the settings which are already supported. I really, really, really:
P.S. @florianb
I don't need to assume - if it's singular (even automatable) action, in corpororate environment it's doable to set everyone In case of open-source, nothing changes from current state as EC-defaults sit alongside vimrc/setting.json/... in mental model. |
I am sorry, i do not understand that argument: One is supposed to define one EditorConfig per repository. It is the responsibility of the repo maintainer to assure a proper EditorConfig exists. If one creates ten repositories per day and therefore needs to create dozens of EditorConfigs one might use a project template. The current EditorConfig approach aims to direct all effort devs might have with editor configuration to the single moment where a technology get's introduced (aka where the repository is initialized). (edit: Also i haven't seen the requirement of having different EditorConfigs per different Editor-technologies.) Given we try to change the "root"-rule behavior this will introduce a lot of pain because it will negate the fundamental assumption the creator of the root EditorConfig made: that her rules of whitespace handling apply. edit: reconsidering after the 2 new comments
|
Again: anything set in file There is virtually no change to how EditorConfig behaves currently. What changes is essentially an addition of reuse the already established mechanism to provide a solution for configuring defaults |
To me this request is quite straight forward. When there is a When you open an editor in a directory that doesn't have a Nothing more, nothing less. And as long as that is the behavior, it's fine with me and I might probably use it. As @xuhdev mentions when you only have one pc with a couple of editors, there is not much added value to this feature. But when you have 3 computers (like me: home win pc, home linux laptop, work win laptop, both windows using native git bash and wsl2) with multiple editor (VS, VSCode, N++, vim) it seems a useful feature. |
OK, let's just go only with |
So... did the voting take place? |
Not as far as I know. @xuhdev ? |
I don't think so. You are free to start voting. However, I personally disagree with the global config idea. What are the new scope of EditorConfig?Approving this feature request is not about a new feature -- it's a scope change of EditorConfig. It deviates from the objective of the project. The structure of the project does not bear in mind with personal settings across multiple editors or machines. Moving forward would open the step to enlarge the scope -- what would you change the mission statement "EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs" to? What are the future guideline to create new features? Implementation issue of environmental variableIf we decide to implement the environment variable proposal, the most elegant implementation brings structural changes to our core libraries -- this is no longer just adding a property; all core libraries must change their behavior and be careful with the consistency of this behavior. The spec is designed in a way that the core libraries should be modified at a minimal level with new features added, because changing core libraries are expensive and have many dependent editor plugins. My proposal to OP's issueTo me, the easiest solution -- if you would like to reuse anything that EditorConfig has defined -- is to create a compiler that compiles .editorconfig files to editor settings. It would be an EditorConfig dependent and won't affect EditorConfig itself. |
Responding to OP's argument of "EditorConfig is for multi-developer projects"Every project has a scope, because a scopeless project is also useless. Stated in the above, this scope is stated in the first sentence in the spec and is an integral part of it. The spec should be read as a whole. Adding an unrelated feature would require changing this statement. Despite the quotation, nothing in your "The Problem" section state the problem in relation to the company-blessed configuration idea. If we are interested in support the idea of company-blessed configuration, we should discuss the issue in that context, not in the context of synchronizing settings between multiple editors and machines of a single person. However, if you believe the scope of the project should be enlarged, it can be discussed but it must be well defined. The argument shouldn't be something like "this feature is useful". Hacking in a feature and call the scope "current scope + this feature" is not a good argument IMO.
|
root=true
Interesting point --- that had not occurred to me. It is true that if someone doesn't set We could, e.g., add a "Best current practices" section to the spec with tips like "always set optional features
I would recommend we not have such a document. It seems to me an invitation to Hyrum's Law issues. I agree with your point that "every such side feature would hurt future flexibility." At least if the spec is silent on a feature, we can evaluate a change only with respect to the spec and not also with respect to all possible combinations of optional features. |
The topic was raised on multiple occasions, but I do agree, there wasn't a sufficient reason provided.
The problem
Assume you are, for various reasons, using multiple code editors (e.g. Vim, Notepad++ and VS Code), on different machines.
In such case, if you want to change your default settings for one language or want to add setting for a new one, you need to edit multiple configs.
It's irritating on its own already, but undoubtedly one will once forgot to do it for one editor, what will cause minor, but nevertheless problems.
Solution
Some universal config... like EditorConfig. It is already de factor standard solution for such problem, the only thing missing is ability to point to global .editorconfig file of lowest priority.
Hence my proposition:
EDITORCONFIG
environmental variable.If it's set to valid file (responsibility of user), plugins will always read (even if
root=true
in project) the file pointed by it first, then apply settings given by more specific files (like in the root of project).If not set? Simply ignore.
Making it to behave similar to
PATH
variable is also something worth consideration as it won't add much more overhead and could be useful (perhaps it would be some solution to #236).Response to counterarguments
I've already read other issues, so I'll respond (or quote/paraphrase) to already provided alternatives and counterarguments against such feature
~/.editorconfig
Issue of polluting
$HOME
aside, yes, it does work most of the time (breaks when there'sroot=true
).But it isn't system wide solution, only works for files kept under home.
That's a problem, since I often work e.g. under
/media
directory.Another benefit of variable over file in home is that variable can be easily disabled (
EDITORCONFIG= editor ...
), while file needs to be moved and later restored.Variables are also usually good compromise for users striving for XDG Base Dir compliance without going into the rabbit hole of what to do under different systems.
Use hard links
It lack the convenience of global file and would effectively block creation of project specific .editorconfig
Copy "globals" as base for .editorconfig for each project
Not a bad idea, but what about project-less files? Like configs or quick temporary scripts?
EditorConfig is for multi-developer projects
It's the initial idea, yes. But making it an aide for single developer with multiple codebases wont hurt the cause, only enrich the project.
Global editorconfig is a dangerous thing to do. especially if you're contributing to lot of different projects, because doing so would enforce your local settings, which may malform the current project.
But I'm already doing that. Those are already set in editor settings, because nobody is creating new project for every secluded file.
Global .editorconfig ought to be of the lowest priority. Then the only difference it makes is the convenience for the user - instead of setting those in multiple configs for multiple editors, only in one universal, standardized file.
Related
.editorconfig
. sindresorhus/atom-editorconfig#137I hope this time we will work out a satisfying solution 😉
The text was updated successfully, but these errors were encountered: