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

Doesn't respect /.editorconfig #238

Open
divVerent opened this issue Jun 4, 2024 · 5 comments
Open

Doesn't respect /.editorconfig #238

divVerent opened this issue Jun 4, 2024 · 5 comments
Labels

Comments

@divVerent
Copy link

divVerent commented Jun 4, 2024

On systems where I also need to edit files outside my home a lot, I made /.editorconfig a symlink to my homedir's .editorconfig file.

This, however, does not work because of this line in autoload/editorconfig_core/ini.vim:

let l:config_dirname = fnamemodify(a:config_filename, ':p:h') . '/'

The reason is that for /.editorconfig, this produces //.

Changing it to only append the slash if there is none already fixes it:

let l:config_dirname = fnamemodify(a:config_filename, ':p:h:s?/*$?/?')

Not sure if that's the greatest solution, but it definitely is one that works.

@cxw42
Copy link
Member

cxw42 commented Jun 4, 2024

This seems very related to editorconfig/editorconfig#465 . Until a decision is made on that issue, this could be implemented as a plug-in option. However, core behaviour has to be unchanged when that option is not set.

I personally think handling this use case via the above-linked issue would be best, so I suggest you voice your support in that issue.

@divVerent
Copy link
Author

divVerent commented Jun 4, 2024

I strongly disagree that this has to wait for the $EDITORCONFIG proposal.

This is a clear bug as it differs from the editorconfig command line utility, which does interpret the /.editorconfig system wide file already (note that I was not talking about ~/.editorconfig or maybe a hypothetical /etc/editorconfig).

The reason why I absolutely need it is that at my company /companyname is a global mountpoint and I can't place an .editorconfig file in there (and even if I could, that's basically a network share so such a file would apply to all employees, not just me) - and all our sources I edit are within that directory. Placing a file in /.editorconfig works fine with the editorconfig tool, but not this vim extension - that's basically my problem. I could mount the same thing also elsewhere and place an .editorconfig file along the way, however that'd break lots of existing tooling that generates the "standard" paths with the "standard" mountpoint.

@divVerent
Copy link
Author

And it's actually more funny - editorconfig-vim does read the /.editorconfig file and parses global options from there, but it does NOT match any [**/companyname/**] or similar sections, because while building the match expression it generates a regex that only matches paths starting with // - which no normalized unix path does. The editorconfig utility does not have this issue.

@cxw42
Copy link
Member

cxw42 commented Jun 4, 2024

Oh, it wasn't clear to me this was a report of existing behaviour different from editorconfig-core-c. Thanks for the additional detail!

@cxw42 cxw42 added Bug and removed Enhancement labels Jun 4, 2024
@divVerent
Copy link
Author

As for implementation, I am really not happy about the :s?/*$?/? line noise... but could not find a much cleaner way to do this in vim script.

I wonder if there really is no builtin function to put a / at the end of a path if there is none yet. Or maybe the better way is to not use :h but instead just replace away the .editorconfig at the end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants