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

E495 No autocommand file and W22 text found after endfunction #221

Open
reini-1 opened this issue Aug 9, 2023 · 4 comments
Open

E495 No autocommand file and W22 text found after endfunction #221

reini-1 opened this issue Aug 9, 2023 · 4 comments
Assignees
Labels

Comments

@reini-1
Copy link

reini-1 commented Aug 9, 2023

I use editorconfig-vim installed with Plug and get some errors with the plugin:

$ echo q | /usr/bin/vim -u ~/.vimrc -U NONE -i NONE -V1 -nNes
not found in 'runtimepath': "ftdetect/*.vim"
not found in 'packpath': "pack/*/start/matchit"
not found in 'packpath': "pack/*/start/*"
not found in 'packpath': "pack/*/start/*"
not found in 'runtimepath': "plugin/**/*.vim"
Error detected while processing VimEnter Autocommands for "*"..function <SNR>26_UseConfigFiles:
line    6:
E495: No autocommand file name to substitute for "<afile>"
Entering Ex mode.  Type "visual" to go to Normal mode.
:q

I think this is in the code somewhere here: https://github.com/editorconfig/editorconfig-vim/blob/master/plugin/editorconfig.vim#L214 and happens if vim is opened without a file to edit given.

When giving a file this error is gone but then there is another:

echo q | /usr/bin/vim -u ~/.vimrc -U NONE -i NONE -V1 -nNes test.txt
not found in 'runtimepath': "ftdetect/*.vim"
not found in 'packpath': "pack/*/start/matchit"
not found in 'packpath': "pack/*/start/*"
not found in 'packpath': "pack/*/start/*"
not found in 'runtimepath': "plugin/**/*.vim"
"test.txt" [New]
not found in 'runtimepath': "indent/text.vim"
W22: Text found after :endfunction: !
Entering Ex mode.  Type "visual" to go to Normal mode.
:q

I think this comes from https://github.com/editorconfig/editorconfig-vim/blob/master/autoload/editorconfig_core/ini.vim#L193
When I remove the "!", the message is gone.

I come across this problems because I use topgrade-rs to update my system and the vim update failed so I tried to find out what the problem is.

Maybe you can fix this.

Thanks in advance.
Reini

@reini-1
Copy link
Author

reini-1 commented Aug 9, 2023

This is on vim 9 on mac. On vim 8.2 on ubuntu 22.04 (multipass vm on the sam mac) there is no error.

vim version on mac:

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jun 23 2023 22:12:29)
macOS version - arm64
Included patches: 1-1544
Compiled by [email protected]
Normal version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
-arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
-balloon_eval_term -gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        -vartabs
+clipboard         -keymap            +printer           +vertsplit
+cmdline_compl     +lambda            -profile           +vim9script
+cmdline_hist      -langmap           -python            +viminfo
+cmdline_info      +libcall           -python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          -rightleft         +vreplace
+cscope            +localmap          -ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
-emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa

vim version on ubuntu:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Aug 01 2023 05:37:49)
Included patches: 1-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          -ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-aUXbZa/vim-8.2.3995=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lacl -lattr -lgpm -L/usr/lib/python3.10/config-3.10-aarch64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm

@bdarfler
Copy link

bdarfler commented Aug 9, 2023

Same issue. In the meantime, I've reverted to commit 7f4e4df.

bdarfler added a commit to bdarfler/dotfiles that referenced this issue Aug 9, 2023
@cxw42
Copy link
Member

cxw42 commented Aug 15, 2023

Thanks for reporting!

I agree the endfunction shouldn't have a bang. PRs welcome! I'll make the change when I can if no one beats me to it :) .

@cxw42 cxw42 added the Bug label Aug 15, 2023
@cxw42 cxw42 mentioned this issue Aug 15, 2023
@bruhtus
Copy link
Contributor

bruhtus commented Sep 16, 2023

The weird part is that, i could only reproduce this error when using -V1 flag when starting vim, like this (using the included package in vim):

vim -V1 +'packadd editorconfig'

We could solve the error:

Error detected while processing VimEnter Autocommands for "*"..function <SNR>26_UseConfigFiles:
line    6:
E495: No autocommand file name to substitute for "<afile>"

using <amatch> instead of <afile>. To test the difference we can use this autocmd:

augroup afile_amatch
  autocmd!
  autocmd VimEnter *
        \ echom 'afile fullpath file: ' . expand('<afile>:p') |
        \ echom 'afile fullpath directory: ' . expand('<afile>:p:h') |
        \ echom 'amatch fullpath file: ' . expand('<amatch>:p') |
        \ echom 'amatch fullpath directory: ' . expand('<amatch>:p:h')
augroup END

and then open vim without a file and use :mes to check the echo message.

The problem if we use <amatch> is that the l:buffer_name won't be empty and if we open the unnamed buffer, it will get rejected on this condition first:

    " Only process normal buffers (do not treat help files as '.txt' files)
    " When starting Vim with a directory, the buftype might not yet be set:
    " Therefore, also check if buffer_name is a directory.
    if index(['', 'acwrite'], &buftype) == -1 || isdirectory(l:buffer_name)
        return
    endif

because expand('<amatch>:p') return current working directory in unnamed buffer.

So this condition won't be run if we use <amatch> and open unnamed buffer:

    if empty(l:buffer_name)
        if g:EditorConfig_enable_for_new_buf
            let l:buffer_name = getcwd() . "/."
        else
            if g:EditorConfig_verbose
                echo 'Skipping EditorConfig for unnamed buffer'
            endif
            return
        endif
    endif

Btw, I'll make a PR to remove bang at endfunction after this :)

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

4 participants