Tuesday, May 23, 2017

Re: Bug in ftdetect?

The fast version is a filetype.vim script in my ~/. vim. If there is a cost to these settings, why does it show up with ftdetect but not a local filetype.vim?

Also most machines are not on vim 8, and thus still think .md is modula 2.

--
Sent from a telephone. Pardon my brevity.

On May 23, 2017 1:52 AM, "Bram Moolenaar" <Bram@moolenaar.net> wrote:

Frew Schmidt wrote:

> I recently discovered that using ftdetect is absurdly slower than filetype.vim.  To reproduce, try this:
>
>      mkdir -p ~/.vim/ftdetect
>      echo 'autocmd BufNew,BufNewFile,BufRead *.md :set filetype=markdown' >  ~/.vim/ftdetect/markdown.vim
>      mkdir testing
>      cd testing
>      touch {1..500}.md
>      vim
>      :args *

What do you compare this with?  Filetype detection already has this rule
for markdown, thus the extra markdown.vim file isn't needed.

Perhaps you can get some more information by setting 'verbose' to a
non-zero number, e.g. ten.

From your logs it looks like one run detects the filetype only for the
one file that is loaded, while the other does it for every file in the
argiument list.  Looks like something causes loading of every file.

> Here's vim --version:
>
>      VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 17 2017 12:13:35)
>      Included patches: 1-95
>      Modified by pkg-vim-maintainers@lists.alioth.debian.org
>      Compiled by pkg-vim-maintainers@lists.alioth.debian.org
>      Huge version with GTK3 GUI.  Features included (+) or not (-):
>      +acl             +file_in_path    +mouse_sgr       +tag_old_static
>      +arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
>      +autocmd         +float           +mouse_urxvt     +tcl
>      +balloon_eval    +folding         +mouse_xterm     +termguicolors
>      +browse          -footer          +multi_byte      +terminfo
>      ++builtin_terms  +fork()          +multi_lang      +termresponse
>      +byte_offset     +gettext         -mzscheme        +textobjects
>      +channel         -hangul_input    +netbeans_intg   +timers
>      +cindent         +iconv           +num64           +title
>      +clientserver    +insert_expand   +packages        +toolbar
>      +clipboard       +job             +path_extra      +user_commands
>      +cmdline_compl   +jumplist        +perl            +vertsplit
>      +cmdline_hist    +keymap          +persistent_undo +virtualedit
>      +cmdline_info    +lambda          +postscript      +visual
>      +comments        +langmap         +printer         +visualextra
>      +conceal         +libcall         +profile         +viminfo
>      +cryptv          +linebreak       -python          +vreplace
>      +cscope          +lispindent      +python3         +wildignore
>      +cursorbind      +listcmds        +quickfix        +wildmenu
>      +cursorshape     +localmap        +reltime         +windows
>      +dialog_con_gui  +lua             +rightleft       +writebackup
>      +diff            +menu            +ruby            +X11
>      +digraphs        +mksession       +scrollbind      -xfontset
>      +dnd             +modify_fname    +signs           +xim
>      -ebcdic          +mouse           +smartindent     +xpm
>      +emacs_tags      +mouseshape      +startuptime     +xsmp_interact
>      +eval            +mouse_dec       +statusline      +xterm_clipboard
>      +ex_extra        +mouse_gpm       -sun_workshop    -xterm_save
>      +extra_search    -mouse_jsbterm   +syntax
>      +farsi           +mouse_netterm   +tag_binary
>         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"
>             defaults file: "$VIMRUNTIME/defaults.vim"
>          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-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircore -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-8krYYf/vim-8.0.0095=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
>      Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -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-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.24/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm
>
> The docs *do* say that if you are detecting files based purely on names you should instead use an autload group in a filetype.vim file, but it's pretty far down in the docs and a *lot* of people seem to have made this mistake: https://github.com/search?p=4&q=%22set+ft%3Dmarkdown%22+language%3Avim&type=Code&utf8=%E2%9C%93
>
> I would like to know why this is slower, but more, if filetype.vim needs to be used for filename based filetype detection, and functions need to be defined in scripts.vim for content detection, what good is ftdetect anyway?

Each sourced file has overhead, the more files you add that are sourced
when opening a file the slower Vim gets.

The ftdetect files are good when you want to just drop a file in a
directory.  Installing a package is simpler that way.  Otherwise
installing a package for a file type would require editing
the filetype.vim script.

--
SOLDIER: What?  Ridden on a horse?
ARTHUR:  Yes!
SOLDIER: You're using coconuts!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: