editorconfig / editorconfig-vim

EditorConfig plugin for Vim
http://editorconfig.org
Other
3.13k stars 137 forks source link

Custom location for .editorconfig #172

Open nkakouros opened 3 years ago

nkakouros commented 3 years ago

Is there a way to point to a random location for the .editorconfig file? In a project I work on, linter configuration files, editor configs, etc are present under resources/dev-helpers. It would be great to move the .editorconfig there as well.

cxw42 commented 3 years ago

There is not an easy way, unfortunately. This has been discussed --- I'll post the link if I can dig it up.

Partly this is by design: .editorconfig files are meant to accompany the source they govern. Partly it is related to symlink handling, which is a real can of worms.

You could certainly modify the core included in this plug-in to look in whatever location you wanted. However, I don't think that's something we would add to the released version of the plug-in.

Does that answer your question?

xuhdev commented 3 years ago

For some editor plugins that are calling an editorconfig executable, you may be able to specify editorconfig -f your-editorconfig-file-name as the command.

Having said these, I agree with @cxw42 , this is by design. EditorConfig is meant for projects to help maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. If every project uses a different .editorconfig file location, then this purpose would no longer be served.

xenoterracide commented 3 years ago

seems related, I would like to have a "default editorconfig" for vim. For sourcecode it's easy to put one in the root, but it seems that for vim I use it to edit config files all over the place, so... point to this if no other is found would be great.

cxw42 commented 3 years ago

Related discussion: https://github.com/editorconfig/editorconfig/issues/236 .

I would personally accept a PR that added an opt-in "fallback .editorconfig" as a plugin option. That would not require any core changes, as far as I know. The semantics would be something like "if no .editorconfig files are found, use the settings in file g:EditorConfigFallbackSettings". @xuhdev would that be OK with you?

xuhdev commented 3 years ago

I think this feature is OK. I would suggest a bit attention to the primary goal of the project:

EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs.

As long as this goal is not jeopardized, I think it's OK (e.g., remind users in the doc).

Additionally, @xenoterracide is adding the configuration to your .vimrc directly OK? It doesn't sound like you would need .editorconfig.

xenoterracide commented 3 years ago

I thought about that but the problem is I wanted it sort of a fallback option if it doesn't otherwise find a normal .editorconfig . I'm sure there's a way to hack around it so that I could do that but I definitely don't know how to do it off the top of my head. Unless those already act as fallback options and finding an editorconfig would override them. That wasn't clear from the documentation how that interaction would actually work I kind of assume that the VIM config would take precedence.