sgur / vim-editorconfig

Yet another EditorConfig (http://editorconfig.org) plugin for vim written in vimscript only
MIT License
185 stars 13 forks source link

Rules defined for filenames with a leading . are not loaded #40

Open iamFIREcracker opened 5 years ago

iamFIREcracker commented 5 years ago

Rules defined for filenames with a leading . are not loaded up by the plugin.

My .editorconfig:

[*]
indent_size = 2
tab_width = 2

[.vimrc]
indent_size = 4
tab_width = 4

When I edit my .vimrc file, and run verbose set shiftwidth I get the following:

  shiftwidth=2
        Last set from ~/my-env/dotfiles/.vim/pack/bundle/start/vim-editorconfig/autoload/editorconfig/indent_size.vim line 16

With the following .editorconfig instead (no more .):

[*]
indent_size = 2
tab_width = 2

[vimrc]
indent_size = 4
tab_width = 4

settings are loaded up just fine:

  shiftwidth=4
        Last set from ~/my-env/dotfiles/.vim/pack/bundle/start/vim-editorconfig/autoload/editorconfig/indent_size.vim line 16

Is this expected?

arp242 commented 5 years ago

This is a problem with more than just .vimrc; e.g. something like %file also won't work.

The root cause is that in s:filter_matched() the regexp '.vimrc' =~ '\<\.vimrc$' gets run. Since . is not considered to be the "first char of a word" the match fails.

I think the \< is there to make sure that a path of foo/bar/foo.vim will match just against foo.vim? In that case, something like [^/] should also work.

I'm not sure what the purpose of the \< is in this case? Removing it seems to fix it, but I presume it wasn't added for the fun of it.