Patch 8.0.1281
Problem:Loading file type detection slows down startup.
Solution: Move functions to an autoload script.
Files: runtime/filetype.vim, runtime/autoload/filetype.vim,
runtime/scripts.vim
*** ../vim-8.0.1280/runtime/filetype.vim2017-08-11 20:50:00.722908598
+0200
--- runtime/filetype.vim2017-11-09 20:35:00.182149228 +0100
***
*** 1,7
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar
! " Last Change:2017 Aug 11
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
--- 1,7
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar
! " Last Change:2017 Nov 09
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
***
*** 52,78
au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help
" Abaqus or Trasys
! au BufNewFile,BufRead *.inp call s:Check_inp()
!
! func! s:Check_inp()
! if getline(1) =~ '^\*'
! setf abaqus
! else
! let n = 1
! if line("$") > 500
! let nmax = 500
! else
! let nmax = line("$")
! endif
! while n <= nmax
! if getline(n) =~? "^header surface data"
! setf trasys
! break
! endif
! let n = n + 1
! endwhile
! endif
! endfunc
" A-A-P recipe
au BufNewFile,BufRead *.aap setf aap
--- 52,58
au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help
" Abaqus or Trasys
! au BufNewFile,BufRead *.inp call filetype#Check_inp()
" A-A-P recipe
au BufNewFile,BufRead *.aap setf aap
***
*** 174,217
" Assembly (all kinds)
" *.lst is not pure assembly, it has two extra columns (address, byte codes)
! au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm()
!
! " This function checks for the kind of assembly that is wanted by the user, or
! " can be detected from the first five lines of the file.
! func! s:FTasm()
! " make sure b:asmsyntax exists
! if !exists("b:asmsyntax")
! let b:asmsyntax = ""
! endif
!
! if b:asmsyntax == ""
! call s:FTasmsyntax()
! endif
!
! " if b:asmsyntax still isn't set, default to asmsyntax or GNU
! if b:asmsyntax == ""
! if exists("g:asmsyntax")
! let b:asmsyntax = g:asmsyntax
! else
! let b:asmsyntax = "asm"
! endif
! endif
!
! exe "setf " . fnameescape(b:asmsyntax)
! endfunc
!
! func! s:FTasmsyntax()
! " see if file contains any asmsyntax=foo overrides. If so, change
! " b:asmsyntax appropriately
! let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
! \" ".getline(5)." "
! let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
! if match != ''
! let b:asmsyntax = match
! elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~?
'\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
! let b:asmsyntax = "vmasm"
! endif
! endfunc
" Macro (VAX)
au BufNewFile,BufRead *.mar setf vmasm
--- 154,160
" Assembly (all kinds)
" *.lst is not pure assembly, it has two extra columns (address, byte codes)
! au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call filetype#FTasm()
" Macro (VAX)
au BufNewFile,BufRead *.mar setf vmasm
***
*** 241,257
au BufNewFile,BufRead *.mch,*.ref,*.imp setf b
" BASIC or Visual Basic
! au BufNewFile,BufRead *.bas call s:FTVB("basic")
!
! " Check if one of the first five lines contains "VB_Name". In that case it is
! " probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype.
! func! s:FTVB(alt)
! if getline(1).getline(2).getline(3).getline(4).getline(5) =~?
'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
! setf vb
! else
! exe "setf " . a:alt
! endif
! endfunc
" Visual Basic Script (close to Visual Basic) or Visual Basic .NET
au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb
--- 184,190
au BufNewFile,BufRead *.mch,*.ref,*.imp setf b
" BASIC or Visual Basic
! au BufNewFile,BufRead *.bas call filetype#FTVB("basic")
" Visual Basic Script (close to Visual Basic) or Visual Basic .NET
au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb
***
*** 269,282
\ if getline(1) =~ &