editorconfig-vim
editorconfig-vim copied to clipboard
Doesn't Respect ~/.editorconfig
For some reason, when opening a file .editorconfig is only loaded if I am in a directory which has a .editorconfig file.
Example:
$ pwd ~/ $ [ -f .editorconfig ] && echo 1 1 $ vi ~/folder/file.ext
everything works as expect.
$ pwd ~/folder $ [ -f .editorconfig ] && echo 1
$ vi file.ext
~/.editorconfig is not loaded and I don't get the proper settings.
Relevant lines in .vimrc
let g:EditorConfig_core_mode = 'external_command' let g:EditorConfig_exclude_patterns = ['fugitive://.*']
My .editorconfig file
top-most EditorConfig file
root = true
[*] end_of_line = lf char_set = utf-8 trim_trailing_whitespace = true indent_style = space indent_size = 4 tab_width = 4 max_line_length = 80
[.pentadactylrc] trim_trailing_whitespace = false
[*.{c,C}] indent_size = 2 tab_width = 2
[*.tex] indent_size = 2 tab_width = 2
[compile,*.mk,Makefile] indent_style = tab
Actually it is more complicated than I stated above and very strange. Let me describe my setup.
$ pwd ~/ $ ls -l .editorconfig lrwxrwxrwx 1 erich erich 22 Jan 12 12:28 .editorconfig -> dotfiles/.editorconfig
Okay, so then from home
$ vi ~/folder/file.ext
and editorconfig doesn't work as expected. But
$ editorconfig $HOME/folder/file.ext end_of_line=lf char_set=utf-8 trim_trailing_whitespace=true indent_style=space indent_size=4 tab_width=4 max_line_length=80
Now
$ cd dotfiles $ vi ~/folder/file.ext
and things work as expected. Okay, so I think I know what is wrong so
$ cd $ rm .editorconfig $ cp dotfiles/.editorconfig . $ vi ~/folder/file.ext
and things work. So then I try
$ cd folder $ vi file.ext
and things still don't work, but
$ cd ~/folder $ editorconfig $HOME/folder/file.ext end_of_line=lf char_set=utf-8 trim_trailing_whitespace=true indent_style=space indent_size=4 tab_width=4 max_line_length=80
And last thing; adding
let g:EditorConfig_verbose = 1
to .vimrc does nothing.
@erichlf Thanks for your inspection into the issue. From what you've reported, it looks like this is an issue of the plugin (not the EditorConfig executable).
I think I need a few more details:
- Do you have an
.editorconfig
file in~/folder
? - Can you try to disable other plugins and then test this again?
- This shouldn't matter, but just in case: what is your
autochdir
option?
- No there is no .editorconfig in ~/folder.
- Disabling all other plugins didn't help.
- I never set this and can't figure out how to check if it is set, by something else.
Some more useful details for you.
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:59) Included patches: 1-52 Modified by [email protected] Compiled by buildd@ Huge version with GTK2 GUI. Features included (+) or not (-): +acl +farsi +mouse_netterm +syntax +arabic +file_in_path +mouse_sgr +tag_binary +autocmd +find_in_path -mouse_sysmouse +tag_old_static +balloon_eval +float +mouse_urxvt -tag_any_white +browse +folding +mouse_xterm +tcl ++builtin_terms -footer +multi_byte +terminfo +byte_offset +fork() +multi_lang +termresponse +cindent +gettext -mzscheme +textobjects +clientserver -hangul_input +netbeans_intg +title +clipboard +iconv +path_extra +toolbar +cmdline_compl +insert_expand +perl +user_commands +cmdline_hist +jumplist +persistent_undo +vertsplit +cmdline_info +keymap +postscript +virtualedit +comments +langmap +printer +visual +conceal +libcall +profile +visualextra +cryptv +linebreak +python +viminfo +cscope +lispindent -python3 +vreplace +cursorbind +listcmds +quickfix +wildignore +cursorshape +localmap +reltime +wildmenu +dialog_con_gui +lua +rightleft +windows +diff +menu +ruby +writebackup +digraphs +mksession +scrollbind +X11 +dnd +modify_fname +signs -xfontset -ebcdic +mouse +smartindent +xim +emacs_tags +mouseshape -sniff +xsmp_interact +eval +mouse_dec +startuptime +xterm_clipboard +ex_extra +mouse_gpm +statusline -xterm_save +extra_search -mouse_jsbterm -sun_workshop +xpm system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" system gvimrc file: "$VIM/gvimrc" user gvimrc file: "$HOME/.gvimrc" 2nd user gvimrc file: "~/.vim/gvimrc" system menu file: "$VIMRUNTIME/menu.vim" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/harfbuzz -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -I/usr/include/tcl8.6 -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lglib-2.0 -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.18/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm -L/usr/lib
I have updated to latest commit eb09b17, but this didn't help.
@erichlf Since I still cannot reproduce your issue, I've updated the source code to be more "verbose" when the verbose mode is turned on. Can you test the case where it does not work with the latest version, please? Thanks!
Okay, a little more testing. The issue is apparently related to symbolic links, but not in the way I thought. Here are the specific details:
$ ls -l Documents lrwxrwxrwx 1 erich erich 24 Aug 25 21:35 Documents -> /media/Media/erichs.Docs $ cd Documents/HomeWork/R-Programming/ProgrammingAssignment1 $ vi complete.R "complete.R" 26L, 910C Applying EditorConfig on file ""/media/Media/erichs.Docs/HomeWork/R-Programming/ProgrammingAssignment1/complete.R Output from EditorConfig core executable: []
and things aren't working as expected. So, let's try something
$ cd /media/Media/erich.Docs/HomeWork/R-Programming/ProgrammingAssignment1 $ vi complete.R "complete.R" 26L, 910C Applying EditorConfig on file ""/media/Media/erichs.Docs/HomeWork/R-Programmingq/ProgrammingAssignment1/complete.R Output from EditorConfig core executable: []
and things are still not working. So, let's try something else
$ cd $ cp -r Documents/HomeWork/R-Programming/ProgrammingAssignment1 . $ cd ProgrammingAssignment1 $ vi complete.R "complete.R" 26L, 910C Applying EditorConfig on file ""/home/erich/ProgrammingAssignment1/complete.R Output from EditorConfig core executable: ['end_of_line=lf', 'char_set=utf-8', 'trim_trailing_whitespace=true', 'indent_style=space', 'indent_size=4', 'tab_width=4', 'max_line_length=80'] and now things are working!
Interesting that I get the following though:
$ cd dotfiles/ $ vi ~/Documents/Homework/R-Programmingq/ProgrammingAssignment1/complete.R "~/Documents/HomeWork/R-Programming/ProgrammingAssignment1/complete.R" 26L, 910C Applying EditorConfig on file ""/home/erich/Documents/HomeWork/R-Programming/ProgrammingAssignment1/complete.R Output from EditorConfig core executable: ['end_of_line=lf', 'char_set=utf-8', 'trim_trailing_whitespace=true', 'indent_style=space', 'indent_size=4', 'tab_width=4', 'max_line_length=80'] and things work as expected.
Or better yet:
$ cd $ vi ~/Documents/Homework/R-Programmingq/ProgrammingAssignment1/complete.R "~/Documents/HomeWork/R-Programming/ProgrammingAssignment1/complete.R" 26L, 910C Applying EditorConfig on file ""/home/erich/Documents/HomeWork/R-Programming/ProgrammingAssignment1/complete.R Output from EditorConfig core executable: ['end_of_line=lf', 'char_set=utf-8', 'trim_trailing_whitespace=true', 'indent_style=space', 'indent_size=4', 'tab_width=4', 'max_line_length=80'] and things work as expected.
So when using a symbolic link the address gets changed and this is screwing things up somehow.
Okay, I tested one last thing
$ editorconfig ~/Documents/HomeWork/R-Programming/ProgrammingAssignment1/complete.R end_of_line=lf char_set=utf-8 trim_trailing_whitespace=true indent_style=space indent_size=4 tab_width=4 max_line_length=80 $ editorconfig /media/Media/erich.Docs/HomeWork/R-Programming/ProgrammingAssignment1/complete.R
And apparently this is a bug with editorconfig, so I will post to their issue tracker.
~/.editorconfig
is not supposed to be system wide. It only affects subdirs of ~
. Your first example (in the original issue) does not look working properly. Maybe we can focus on those examples?
It would be nice if symbolic links to get mapped to the true directory.
@erichlf I think it would be a bit surprising if the symbolic links are solved to "true" paths --- people creates symbolic links with the point to modify the path to access the file.
I guess the problem is that when it finds the path it doesn't care about the symbolic link. So even though there is a symbolic link which allows for
$ cd Documents/Homework/R-Programming/ProgrammingAssignment1/ $ vi complete.R
editorconfig doesn't know how I got there, so it thinks it is in /media/Media/erich.Docs/Homework/R-Programming/ProgrammingAssignment1/. This makes sense because path in any programming language would report that location.
@erichlf It's not true that "any programming language would report that location", in most cases you can decide whether to resolve the symlink in a general programming framework.
However unfortunately, in Vim, this is a limitation. You can view more details here. Since the symlink is resolved at the time Vim opens it, the plugin can really do nothing about it---the information has already been lost.
Let me know if you a way to let Vim not resolve the symlink automatically.
Maybe the top response here: http://stackoverflow.com/questions/708700/getting-the-logical-path-in-vim-when-theres-a-symlink
However, maybe a bind mount is really what I should be using.
I have another idea-- how about creating an option for default config file? If there is no .editorconfig in the directory tree call editorconfig -f g:EditorConfig_formatFile or something.
As a last resort, we could add the global .editorconfig (i.e. ~/.editorconfig) as the last item of the array (path_list
) returned in get_filenames
?
~/.editorconfig is not supposed to be system wide. It only affects subdirs of ~.
I must say this really goes against expectations... I just spent two hours ripping my hair out because I had wrongly assumed that ~/.editorconfig
was special, like with other config files. Do you think there's a chance that a suggestion to change this behavior in the spec (i.e., make ~/.editorconfig
special) might succeed? Or has there been prior discussion in which this has been rejected for some reason?
got same error, on emacs respect ~/.editorconfig
,but on vim doesn't respect.
Same problem here, though I don't use special symlinks or anything. What I wanted/intended to do; is set indent_size
to tab in the local repo editorconfig, and in my homedir I set tab_width to 8. (e.g. the whole, let the user choose their own tab size, and don't force it through editorconfig. So either I'm doing it wrong, or editorconfig doesn't honor/support this. Adding tab_width to the local file does make it work as expected, so it really doesn't seem to pick up my system one.
As a work-around for me, it would be nice if I can set the tab_width in my .vimrc of course, but I don't think the plugin uses any options from there, so that means that because of this issue, I can't really do what I want :(