patch 9.1.0953: filetype: APKBUILD files not correctly detected
Problem: filetype: APKBUILD files not correctly detected
Solution: detect 'APKBUILD' files as apkbuild filetype,
include a apkbuild syntax script (which basically
just sources the sh.vim syntax file)
(Hugo Osvaldo Barrera)
Vim plugins (e.g.: ALE, nvim-lspconfig, etc) rely on filetype to
determine which integrations/helpers are applicable. They expect
filetype=apkbuild for APKBUILD files.
On the other hand, plugins also enable bash-specific linters and
functionality when filetype=bash, but APKBUILD files are POSIX sh, not
bash, so these often provide bogus results.
Change the filetype for APKBUILD to a 'apkbuild', so that tools and
ftplugin can properly target these files. This filetype will use the
existing `sh` syntax rules, since these are applicable for them.
Signed-off-by: Hugo Osvaldo Barrera' via vim_dev <vim_dev@googlegroups.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
92195ae72f
commit
7cb24917a1
@ -2273,12 +2273,13 @@ au BufNewFile,BufRead *.decl,*.dcl,*.dec
|
||||
au BufNewFile,BufRead catalog setf catalog
|
||||
|
||||
" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
|
||||
" Gentoo ebuilds, Arch Linux PKGBUILDs and Alpine Linux APKBUILDs are actually
|
||||
" bash scripts.
|
||||
" Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts.
|
||||
" NOTE: Patterns ending in a star are further down, these have lower priority.
|
||||
au BufNewFile,BufRead .bashrc,bashrc,bash.bashrc,.bash[_-]profile,.bash[_-]logout,.bash[_-]aliases,.bash[_-]history,bash-fc[-.],*.ebuild,*.bash,*.eclass,PKGBUILD,APKBUILD,*.bats,*.cygport call dist#ft#SetFileTypeSH("bash")
|
||||
au BufNewFile,BufRead .bashrc,bashrc,bash.bashrc,.bash[_-]profile,.bash[_-]logout,.bash[_-]aliases,.bash[_-]history,bash-fc[-.],*.ebuild,*.bash,*.eclass,PKGBUILD,*.bats,*.cygport call dist#ft#SetFileTypeSH("bash")
|
||||
au BufNewFile,BufRead .kshrc,*.ksh call dist#ft#SetFileTypeSH("ksh")
|
||||
au BufNewFile,BufRead */etc/profile,.profile,*.sh,*.env{rc,} call dist#ft#SetFileTypeSH(getline(1))
|
||||
" Alpine Linux APKBUILDs are actually POSIX sh scripts with special treatment.
|
||||
au BufNewFile,BufRead APKBUILD setf apkbuild
|
||||
|
||||
" Shell script (Arch Linux) or PHP file (Drupal)
|
||||
au BufNewFile,BufRead *.install
|
||||
|
||||
17
runtime/syntax/apkbuild.vim
Normal file
17
runtime/syntax/apkbuild.vim
Normal file
@ -0,0 +1,17 @@
|
||||
" Vim syntax file
|
||||
" Language: apkbuild
|
||||
" Maintainer: The Vim Project <https://github.com/vim/vim>
|
||||
" Last Change: 2024 Dec 22
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" The actual syntax is in sh.vim and controlled by buffer-local variables.
|
||||
unlet! b:is_bash b:is_kornshell
|
||||
let b:is_sh = 1
|
||||
|
||||
runtime! syntax/sh.vim
|
||||
|
||||
let b:current_syntax = 'apkbuild'
|
||||
Reference in New Issue
Block a user