diff options
author | Christian Clason <c.clason@uni-graz.at> | 2024-12-22 15:15:57 +0100 |
---|---|---|
committer | Christian Clason <ch.clason+github@icloud.com> | 2024-12-22 18:05:07 +0100 |
commit | 665a0e85c4788cb2847e270c333c0aee306f07ad (patch) | |
tree | 3930e7bf81a2d321bd2c57099e3e71bbaa578ce9 | |
parent | d1e00a5f6dce9cf1fa80f613d4d27019966e5a79 (diff) | |
download | rneovim-665a0e85c4788cb2847e270c333c0aee306f07ad.tar.gz rneovim-665a0e85c4788cb2847e270c333c0aee306f07ad.tar.bz2 rneovim-665a0e85c4788cb2847e270c333c0aee306f07ad.zip |
vim-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.
https://github.com/vim/vim/commit/7cb24917a112ba473cb351bdcdc48b8adbd46793
Co-authored-by: Hugo Osvaldo Barrera' via vim_dev <vim_dev@googlegroups.com>
-rw-r--r-- | runtime/lua/vim/filetype.lua | 2 | ||||
-rw-r--r-- | runtime/syntax/apkbuild.vim | 17 | ||||
-rw-r--r-- | test/old/testdir/test_filetype.vim | 3 |
3 files changed, 20 insertions, 2 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 31de25a714..6fa1684704 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1439,6 +1439,7 @@ local filename = { ['/etc/asound.conf'] = 'alsaconf', ['build.xml'] = 'ant', ['.htaccess'] = 'apache', + APKBUILD = 'apkbuild', ['apt.conf'] = 'aptconf', ['/.aptitude/config'] = 'aptconf', ['=tagging-method'] = 'arch', @@ -1798,7 +1799,6 @@ local filename = { ['.kshrc'] = detect.ksh, ['.profile'] = detect.sh, ['/etc/profile'] = detect.sh, - APKBUILD = detect.bash, PKGBUILD = detect.bash, ['.tcshrc'] = detect.tcsh, ['tcsh.login'] = detect.tcsh, diff --git a/runtime/syntax/apkbuild.vim b/runtime/syntax/apkbuild.vim new file mode 100644 index 0000000000..f969ff0e2e --- /dev/null +++ b/runtime/syntax/apkbuild.vim @@ -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' diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 7b7e3bdbfb..eb4d14c800 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -108,6 +108,7 @@ func s:GetFilenameChecks() abort \ '/etc/httpd/sites-some/file', '/etc/httpd/conf.file/conf'], \ 'apachestyle': ['/etc/proftpd/file.config,/etc/proftpd/conf.file/file', '/etc/proftpd/conf.file/file', '/etc/proftpd/file.conf', '/etc/proftpd/file.conf-file', \ 'any/etc/proftpd/conf.file/file', 'any/etc/proftpd/file.conf', 'any/etc/proftpd/file.conf-file', 'proftpd.conf', 'proftpd.conf-file'], + \ 'apkbuild': ['APKBUILD'], \ 'applescript': ['file.scpt'], \ 'aptconf': ['apt.conf', '/.aptitude/config', 'any/.aptitude/config'], \ 'arch': ['.arch-inventory', '=tagging-method'], @@ -680,7 +681,7 @@ func s:GetFilenameChecks() abort \ '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', + \ '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', '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', 'file.mdd', 'file.cygport', '.env', '.envrc', 'devscripts.conf', \ '.devscripts', 'file.lo', 'file.la', 'file.lai'], |