editorconfig / editorconfig-vim

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

Plugin doesn't catch files with shebang on first run #165

Closed alerque closed 3 years ago

alerque commented 3 years ago

I have some shell scripts without extensions. I've added a project level Editor Config file that calls these out by exact name and sets the indent style. The trouble is these settings are not applied when opening a file from the terminal:

.editorconfig

[myfile]
indent_style = tab

myfile

#!/bin/sh
echo

Opened with...

$ nvim myfile

...the indent style will be spaces because the shebang based file type detection ran after anything this plugin did. I can then run :e % to reload the buffer, and now the editorconfig settings are applied. The same is also true if launching with no file, then opening the file.

The problem also goes away if the shebang line is removed, i.e. the EditorConfig settings are properly applied to such files if the shebang doesn't interfere.

cxw42 commented 3 years ago

Thanks for reporting!

I know there are a number of open issues related to interactions of this type --- you are not alone!

alerque commented 3 years ago

I don't usually use vanilla vim for anything so don't have a working config, but running this suggests that it works out of the box on vanilla vim:

$ vim -N -u <(cat << EOF
filetype off
set rtp+=/home/caleb/.config/nvim/plugged/editorconfig-vim
filetype plugin indent on
syntax enable
EOF
) vcsh

Of course vcsh is the script I'm trying to edit and the $PWD has an .editorconfig with my settings. It seems to be loading on first open, although I'm confused now because the same test with NeoVIM seem to work too:

$ nvim -u <(cat << EOF
filetype off
set rtp+=/home/caleb/.config/nvim/plugged/editorconfig-vim
filetype plugin indent on
syntax enable
EOF
) vcsh

I'll have to sort through my other plugins to see if something is interfering.

cxw42 commented 3 years ago

Let us know what you find!

alerque commented 3 years ago

This actually traces to use in combination with vim-stdtabs. I'll close this issue because it looks like that plugin is doing the hijacking and this one does work on it's own and in combination with the 106 other plugins I use.

Similar answers might apply to other folks with similar problems. If not that plugin perhaps others or their own configs that do similar things blindly setting values for file types.

cxw42 commented 3 years ago

Thanks for checking and for letting us know! 106 is a lot :) .