forked from aniani/vim
patch 9.0.1601: filetype detection fails for *.conf file without comments
Problem: Filetype detection fails for *.conf file without comments.
(Dmitrii Tcyganok)
Solution: Use "conf" filetype as a fallback for an empty .conf file.
(closes #12487, closes #12483)
This commit is contained in:
@@ -2811,8 +2811,10 @@ augroup END
|
||||
" Generic configuration file. Use FALLBACK, it's just guessing!
|
||||
au filetypedetect BufNewFile,BufRead,StdinReadPost *
|
||||
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
|
||||
\ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
|
||||
\ || getline(4) =~ '^#' || getline(5) =~ '^#') |
|
||||
\ && (expand("<amatch>") =~# '\.conf$'
|
||||
\ || getline(1) =~ '^#' || getline(2) =~ '^#'
|
||||
\ || getline(3) =~ '^#' || getline(4) =~ '^#'
|
||||
\ || getline(5) =~ '^#') |
|
||||
\ setf FALLBACK conf |
|
||||
\ endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user