Article by editor Leo [email protected]
The Linux distro I contribute to, Alpine Linux, uses build recipes called
APKBUILDs. They are shell scripts but with context-aware variables that can
affect the final result of package. APKBUILDs are subject to policies that only
apply to Alpine Linux and its packaging system
Vim is a text editor used by many of our developers and users use for editing APKBUILDs. But while vim has a filetype for shellscripts, it is insufficient to provide syntax, plugins, indentation and other nice to have features that are specific to the context of an APKBUILD.
In light of that I took upon myself to write a complete implementation of
filetype for APKBUILDs.
The Whole Deal
APKBUILD.vim is a plugin for Vim and Neovim, that provides:
- Syntax Highlighting:
1.1. Different colors for variables that affect
Errorhighlighting for invalid values inside
abuildvariables, like non-existent arches in
arch. 1.4. Highlighting of
secfixes:blocks, version identifiers and recognized security identifiers (CVE, XSA, etc).
1.5. It is built on top of
sh.vim. That means all the syntax highlighting of
filetype=shis still in place.
2.1. Sets correct
textwidthof 80 columns.
noexpandtabas APKBUILD use tabs for indentation.
- ALE Integration:
3.1. Provides a script to run shellcheck with APKBUILD aware filtering and register it into ALE.
3.2. Adds support for the linters
secfixes-checkfrom atools and registers a handler for them.
Here are some comparisons of APKBUILDs with
Main block of variables used by
abuild, notice that the variables that are from
abuildhave a different color than the ones normally used by shell.
Comparison of secfixes, notice how the
secfixes:declaration, the versions and the security identifiers are all highlighted.
General comparison of