Skip to content

Commit

Permalink
patch 9.1.0316: filetype: some sh and confini files not recognized
Browse files Browse the repository at this point in the history
Problem:  filetype: some sh and confini files not recognized
Solution: Detect neofetch, '.xprofile', XDG-User-Dirs files,
          paru and makepkg config files
          (Wu, Zhenyu)

See:
- https://github.com/dylanaraps/neofetch/wiki/Customizing-Info#config-file-location
- https://www.freedesktop.org/wiki/Software/xdg-user-dirs/

closes: #14505

Signed-off-by: Wu, Zhenyu <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
  • Loading branch information
Freed-Wu authored and chrisbra committed Apr 13, 2024
1 parent 0881329 commit 5a9f7e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
15 changes: 14 additions & 1 deletion runtime/filetype.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,9 @@ au BufNewFile,BufRead Neomuttrc setf neomuttrc
" Netrc
au BufNewFile,BufRead .netrc setf netrc

" Neofetch
au BufNewFile,BufRead */neofetch/config.conf setf sh

" Nginx
au BufNewFile,BufRead *.nginx,nginx*.conf,*nginx.conf,*/etc/nginx/*,*/usr/local/nginx/conf/*,*/nginx/*.conf setf nginx

Expand Down Expand Up @@ -1604,16 +1607,20 @@ au BufNewFile,BufRead *.org,*.org_archive setf org
au BufNewFile,BufRead pf.conf setf pf

" ini style config files, using # comments
au BufNewFile,BufRead */etc/pacman.conf,mpv.conf setf confini
au BufNewFile,BufRead pacman.conf,mpv.conf setf confini
au BufNewFile,BufRead */.aws/config,*/.aws/credentials setf confini
au BufNewFile,BufRead *.nmconnection setf confini
au BufNewFile,BufRead paru.conf setf confini

" Pacman hooks
au BufNewFile,BufRead *.hook
\ if getline(1) == '[Trigger]' |
\ setf confini |
\ endif

" Pacman makepkg
au BufNewFile,BufRead {.,}makepkg.conf setf sh

" Pacman log
au BufNewFile,BufRead pacman.log setf pacmanlog

Expand Down Expand Up @@ -2640,12 +2647,18 @@ au BufNewFile,BufRead *.web
" Windows Scripting Host and Windows Script Component
au BufNewFile,BufRead *.ws[fc] setf wsh

" Xdg-user-dirs
au BufNewFile,BufRead user-dirs.dirs,user-dirs.defaults setf sh

" XHTML
au BufNewFile,BufRead *.xhtml,*.xht setf xhtml

" X11vnc
au BufNewFile,BufRead .x11vncrc setf conf

" Xprofile
au BufNewFile,BufRead .xprofile setf sh

" X Pixmap (dynamically sets colors, this used to trigger on BufEnter to make
" it work better, but that breaks setting 'filetype' manually)
au BufNewFile,BufRead *.xpm
Expand Down
7 changes: 5 additions & 2 deletions src/testdir/test_filetype.vim
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def s:GetFilenameChecks(): dict<list<string>>
conaryrecipe: ['file.recipe'],
conf: ['auto.master', 'file.conf', 'texdoc.cnf', '.x11vncrc', '.chktexrc', '.ripgreprc', 'ripgreprc', 'file.ctags'],
config: ['configure.in', 'configure.ac', '/etc/hostname.file', 'any/etc/hostname.file'],
confini: ['/etc/pacman.conf', 'any/etc/pacman.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'],
confini: ['pacman.conf', 'paru.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'],
context: ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'],
cook: ['file.cook'],
corn: ['file.corn'],
Expand Down Expand Up @@ -634,7 +634,10 @@ def s:GetFilenameChecks(): dict<list<string>>
services: ['/etc/services', 'any/etc/services'],
setserial: ['/etc/serial.conf', 'any/etc/serial.conf'],
sexplib: ['file.sexp'],
sh: ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '.bash_history', '.bash-history', '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh', '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats', '.ash_history'],
sh: ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '.bash_history', '.bash-history',
'/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh',
'/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats', '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile',
'user-dirs.defaults', 'user-dirs.dirs', 'makepkg.conf', '.makepkg.conf'],
sieve: ['file.siv', 'file.sieve'],
sil: ['file.sil'],
simula: ['file.sim'],
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
316,
/**/
315,
/**/
Expand Down

0 comments on commit 5a9f7e6

Please sign in to comment.