mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #9749 from janlazo/vim-8.1.1017
This commit is contained in:
commit
a077f53914
26
runtime/autoload/dist/ft.vim
vendored
26
runtime/autoload/dist/ft.vim
vendored
@ -1,7 +1,7 @@
|
|||||||
" Vim functions for file type detection
|
" Vim functions for file type detection
|
||||||
"
|
"
|
||||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Last Change: 2017 Dec 05
|
" Last Change: 2019 Jan 18
|
||||||
|
|
||||||
" These functions are moved here from runtime/filetype.vim to make startup
|
" These functions are moved here from runtime/filetype.vim to make startup
|
||||||
" faster.
|
" faster.
|
||||||
@ -197,7 +197,7 @@ func dist#ft#FTe()
|
|||||||
exe 'setf ' . g:filetype_euphoria
|
exe 'setf ' . g:filetype_euphoria
|
||||||
else
|
else
|
||||||
let n = 1
|
let n = 1
|
||||||
while n < 100 && n < line("$")
|
while n < 100 && n <= line("$")
|
||||||
if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
|
if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
|
||||||
setf specman
|
setf specman
|
||||||
return
|
return
|
||||||
@ -211,7 +211,7 @@ endfunc
|
|||||||
" Distinguish between HTML, XHTML and Django
|
" Distinguish between HTML, XHTML and Django
|
||||||
func dist#ft#FThtml()
|
func dist#ft#FThtml()
|
||||||
let n = 1
|
let n = 1
|
||||||
while n < 10 && n < line("$")
|
while n < 10 && n <= line("$")
|
||||||
if getline(n) =~ '\<DTD\s\+XHTML\s'
|
if getline(n) =~ '\<DTD\s\+XHTML\s'
|
||||||
setf xhtml
|
setf xhtml
|
||||||
return
|
return
|
||||||
@ -222,13 +222,13 @@ func dist#ft#FThtml()
|
|||||||
endif
|
endif
|
||||||
let n = n + 1
|
let n = n + 1
|
||||||
endwhile
|
endwhile
|
||||||
setf html
|
setf FALLBACK html
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Distinguish between standard IDL and MS-IDL
|
" Distinguish between standard IDL and MS-IDL
|
||||||
func dist#ft#FTidl()
|
func dist#ft#FTidl()
|
||||||
let n = 1
|
let n = 1
|
||||||
while n < 50 && n < line("$")
|
while n < 50 && n <= line("$")
|
||||||
if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
|
if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
|
||||||
setf msidl
|
setf msidl
|
||||||
return
|
return
|
||||||
@ -484,6 +484,10 @@ endfunc
|
|||||||
|
|
||||||
" Called from filetype.vim and scripts.vim.
|
" Called from filetype.vim and scripts.vim.
|
||||||
func dist#ft#SetFileTypeSH(name)
|
func dist#ft#SetFileTypeSH(name)
|
||||||
|
if did_filetype()
|
||||||
|
" Filetype was already detected
|
||||||
|
return
|
||||||
|
endif
|
||||||
if expand("<amatch>") =~ g:ft_ignore_pat
|
if expand("<amatch>") =~ g:ft_ignore_pat
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -531,6 +535,10 @@ endfunc
|
|||||||
" as used for Tcl.
|
" as used for Tcl.
|
||||||
" Also called from scripts.vim, thus can't be local to this script.
|
" Also called from scripts.vim, thus can't be local to this script.
|
||||||
func dist#ft#SetFileTypeShell(name)
|
func dist#ft#SetFileTypeShell(name)
|
||||||
|
if did_filetype()
|
||||||
|
" Filetype was already detected
|
||||||
|
return
|
||||||
|
endif
|
||||||
if expand("<amatch>") =~ g:ft_ignore_pat
|
if expand("<amatch>") =~ g:ft_ignore_pat
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -551,6 +559,10 @@ func dist#ft#SetFileTypeShell(name)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func dist#ft#CSH()
|
func dist#ft#CSH()
|
||||||
|
if did_filetype()
|
||||||
|
" Filetype was already detected
|
||||||
|
return
|
||||||
|
endif
|
||||||
if exists("g:filetype_csh")
|
if exists("g:filetype_csh")
|
||||||
call dist#ft#SetFileTypeShell(g:filetype_csh)
|
call dist#ft#SetFileTypeShell(g:filetype_csh)
|
||||||
elseif &shell =~ "tcsh"
|
elseif &shell =~ "tcsh"
|
||||||
@ -687,7 +699,7 @@ endfunc
|
|||||||
|
|
||||||
func dist#ft#FTxml()
|
func dist#ft#FTxml()
|
||||||
let n = 1
|
let n = 1
|
||||||
while n < 100 && n < line("$")
|
while n < 100 && n <= line("$")
|
||||||
let line = getline(n)
|
let line = getline(n)
|
||||||
" DocBook 4 or DocBook 5.
|
" DocBook 4 or DocBook 5.
|
||||||
let is_docbook4 = line =~ '<!DOCTYPE.*DocBook'
|
let is_docbook4 = line =~ '<!DOCTYPE.*DocBook'
|
||||||
@ -713,7 +725,7 @@ endfunc
|
|||||||
|
|
||||||
func dist#ft#FTy()
|
func dist#ft#FTy()
|
||||||
let n = 1
|
let n = 1
|
||||||
while n < 100 && n < line("$")
|
while n < 100 && n <= line("$")
|
||||||
let line = getline(n)
|
let line = getline(n)
|
||||||
if line =~ '^\s*%'
|
if line =~ '^\s*%'
|
||||||
setf yacc
|
setf yacc
|
||||||
|
@ -1458,9 +1458,11 @@ au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog')
|
|||||||
|
|
||||||
" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
|
" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
|
||||||
" Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts
|
" Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts
|
||||||
au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,bash-fc[-.]*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call dist#ft#SetFileTypeSH("bash")
|
" NOTE: Patterns ending in a star are further down, these have lower priority.
|
||||||
au BufNewFile,BufRead .kshrc*,*.ksh call dist#ft#SetFileTypeSH("ksh")
|
au BufNewFile,BufRead .bashrc,bashrc,bash.bashrc,.bash[_-]profile,.bash[_-]logout,.bash[_-]aliases,bash-fc[-.],*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD call dist#ft#SetFileTypeSH("bash")
|
||||||
au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call dist#ft#SetFileTypeSH(getline(1))
|
au BufNewFile,BufRead .kshrc,*.ksh call dist#ft#SetFileTypeSH("ksh")
|
||||||
|
au BufNewFile,BufRead */etc/profile,.profile,*.sh,*.env call dist#ft#SetFileTypeSH(getline(1))
|
||||||
|
|
||||||
|
|
||||||
" Shell script (Arch Linux) or PHP file (Drupal)
|
" Shell script (Arch Linux) or PHP file (Drupal)
|
||||||
au BufNewFile,BufRead *.install
|
au BufNewFile,BufRead *.install
|
||||||
@ -1470,15 +1472,16 @@ au BufNewFile,BufRead *.install
|
|||||||
\ call dist#ft#SetFileTypeSH("bash") |
|
\ call dist#ft#SetFileTypeSH("bash") |
|
||||||
\ endif
|
\ endif
|
||||||
|
|
||||||
" tcsh scripts
|
" tcsh scripts (patterns ending in a star further below)
|
||||||
au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call dist#ft#SetFileTypeShell("tcsh")
|
au BufNewFile,BufRead .tcshrc,*.tcsh,tcsh.tcshrc,tcsh.login call dist#ft#SetFileTypeShell("tcsh")
|
||||||
|
|
||||||
" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
|
" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
|
||||||
au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call dist#ft#CSH()
|
" (patterns ending in a start further below)
|
||||||
|
au BufNewFile,BufRead .login,.cshrc,csh.cshrc,csh.login,csh.logout,*.csh,.alias call dist#ft#CSH()
|
||||||
|
|
||||||
" Z-Shell script
|
" Z-Shell script (patterns ending in a star further below)
|
||||||
au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks setf zsh
|
au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks setf zsh
|
||||||
au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh')
|
au BufNewFile,BufRead .zshrc,.zshenv,.zlogin,.zlogout,.zcompdump setf zsh
|
||||||
au BufNewFile,BufRead *.zsh setf zsh
|
au BufNewFile,BufRead *.zsh setf zsh
|
||||||
|
|
||||||
" Scheme
|
" Scheme
|
||||||
@ -2073,6 +2076,17 @@ au BufRead,BufNewFile *.rdf call dist#ft#Redif()
|
|||||||
" Remind
|
" Remind
|
||||||
au BufNewFile,BufRead .reminders* call s:StarSetf('remind')
|
au BufNewFile,BufRead .reminders* call s:StarSetf('remind')
|
||||||
|
|
||||||
|
" Shell scripts ending in a star
|
||||||
|
au BufNewFile,BufRead .bashrc*,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,bash-fc[-.]*,,PKGBUILD* call dist#ft#SetFileTypeSH("bash")
|
||||||
|
au BufNewFile,BufRead .kshrc* call dist#ft#SetFileTypeSH("ksh")
|
||||||
|
au BufNewFile,BufRead .profile* call dist#ft#SetFileTypeSH(getline(1))
|
||||||
|
|
||||||
|
" tcsh scripts ending in a star
|
||||||
|
au BufNewFile,BufRead .tcshrc* call dist#ft#SetFileTypeShell("tcsh")
|
||||||
|
|
||||||
|
" csh scripts ending in a star
|
||||||
|
au BufNewFile,BufRead .login*,.cshrc* call dist#ft#CSH()
|
||||||
|
|
||||||
" Vim script
|
" Vim script
|
||||||
au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')
|
au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')
|
||||||
|
|
||||||
@ -2100,7 +2114,8 @@ au BufNewFile,BufRead */etc/xinetd.d/* call s:StarSetf('xinetd')
|
|||||||
" yum conf (close enough to dosini)
|
" yum conf (close enough to dosini)
|
||||||
au BufNewFile,BufRead */etc/yum.repos.d/* call s:StarSetf('dosini')
|
au BufNewFile,BufRead */etc/yum.repos.d/* call s:StarSetf('dosini')
|
||||||
|
|
||||||
" Z-Shell script
|
" Z-Shell script ending in a star
|
||||||
|
au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh')
|
||||||
au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
|
au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user