vim-patch:8.2.1055: no filetype set for pacman config files

Problem:    No filetype set for pacman config files.
Solution:   Recognize pacman.conf and *.hook. (Guido Cella, closes vim/vim#6335)
73b4465ba7
This commit is contained in:
Jan Edmund Lazo 2020-06-25 20:49:48 -04:00
parent bd5f0e9695
commit 43a2e5fe4b
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 31 additions and 2 deletions

View File

@ -1130,8 +1130,17 @@ au BufNewFile,BufRead *.ora setf ora
" Packet filter conf
au BufNewFile,BufRead pf.conf setf pf
" Pacman Config (close enough to dosini)
au BufNewFile,BufRead */etc/pacman.conf setf dosini
" Pacman hooks
au BufNewFile,BufRead *.hook
\ if getline(1) == '[Trigger]' |
\ setf dosini |
\ endif
" Pam conf
au BufNewFile,BufRead */etc/pam.conf setf pamconf
au BufNewFile,BufRead */etc/pam.conf setf pamconf
" Pam environment
au BufNewFile,BufRead pam_env.conf,.pam_environment setf pamenv

View File

@ -139,7 +139,7 @@ let s:filename_checks = {
\ 'dnsmasq': ['/etc/dnsmasq.conf'],
\ 'dockerfile': ['Dockerfile', 'file.Dockerfile'],
\ 'dosbatch': ['file.bat', 'file.sys'],
\ 'dosini': ['.editorconfig', '/etc/yum.conf', 'file.ini'],
\ 'dosini': ['.editorconfig', '/etc/pacman.conf', '/etc/yum.conf', 'file.ini'],
\ 'dot': ['file.dot', 'file.gv'],
\ 'dracula': ['file.drac', 'file.drc', 'filelvs', 'filelpe'],
\ 'dsl': ['file.dsl'],
@ -639,3 +639,23 @@ func Test_setfiletype_completion()
call feedkeys(":setfiletype java\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"setfiletype java javacc javascript javascriptreact', @:)
endfunc
func Test_hook_file()
filetype on
call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook')
split Xfile.hook
call assert_equal('dosini', &filetype)
bwipe!
call writefile(['not pacman'], 'Xfile.hook')
split Xfile.hook
call assert_notequal('dosini', &filetype)
bwipe!
call delete('Xfile.hook')
filetype off
endfunc
" vim: shiftwidth=2 sts=2 expandtab