summaryrefslogtreecommitdiff
path: root/syntax/preseed.vim
diff options
context:
space:
mode:
authorcos <cos>2023-10-14 11:46:26 +0200
committercos <cos>2023-10-14 11:48:47 +0200
commit881d14ef241063c934a5ef28ce0413a8f84308e4 (patch)
tree42d3227cec8aff7600c63c885f1177f03e9255e4 /syntax/preseed.vim
parent3db59dd0a0f7c40ae866df608e9ea133c52f94e4 (diff)
downloadvim-preseed-881d14ef241063c934a5ef28ce0413a8f84308e4.zip
Move plugin from ftplugin/ to syntax/ folder
Thanks to bauen1 on #debian-boot for pointing out that the original location does not always work. Specifically loading with vim-plug was problematic. The syntax/ folder seems like a more appropriate place anyways. Investigating the cause a bit more; It appears that even though it is claimed at https://github.com/junegunn/vim-plug that `call plug#end()` should do `syntax enable` and `filetype plugin indent`, adding that exact `syntax enable` at the top of .vimrc makes loading from ftplugin/ work with vim-plug. Loading from syntax/ works with vim-plug also without the seemingly, but actually not, superfluous duplication of `syntax enable`.
Diffstat (limited to 'syntax/preseed.vim')
-rw-r--r--syntax/preseed.vim107
1 files changed, 107 insertions, 0 deletions
diff --git a/syntax/preseed.vim b/syntax/preseed.vim
new file mode 100644
index 0000000..7b4e1ed
--- /dev/null
+++ b/syntax/preseed.vim
@@ -0,0 +1,107 @@
+" Vim syntax file
+" Language: Debian preseed
+" Maintainer: cos <cos>, https://www.netizen.se/#contact
+" Last Change: 2023 Oct 13
+" Remark: https://wiki.debian.org/DebianInstaller/Preseed
+
+" quit when a syntax file was already loaded
+if exists('b:current_syntax')
+ finish
+endif
+
+
+" The syntax of each line in a preseed file follows:
+" <owner> <question name> <question type> <value>
+
+" Create clusters for two of these four parts of a preseed line.
+syntax cluster preseedSecond contains=preseedQuestion,preseedOwnerLC
+syntax cluster preseedThird contains=preseedBooleanType,
+ \ preseedStrLikeType,
+ \ preseedMultiSelType,
+ \ preseedNote,
+ \ preseedSelectType,
+ \ preseedQuestionLC
+
+
+" Define the highlighting. Doesn't map perfectly to the group's intents, but
+" arguably close enough?
+
+" First, <owner>
+hi! def link preseedOwner Label
+
+" Second, <question name>
+hi! def link preseedQuestion Identifier
+
+" Third, <question type>
+hi! def link preseedBooleanType Type
+hi! def link preseedMultiSelType Type
+hi! def link preseedNote Type
+hi! def link preseedSelectType Type
+hi! def link preseedStrLikeType Type
+
+" Fourth, <value>
+hi! def link preseedBooleanVal Special
+hi! def link preseedMultiSelVal Special
+hi! def link preseedStrLikeVal String
+hi! def link preseedVal String
+hi! def link preseedSelectVal Special
+hi! def link preseedMultiSelSep Operator
+hi! def link preseedComment Comment
+
+" Line Continuation
+hi! def link preseedOwnerLC Operator
+hi! def link preseedQuestionLC Operator
+hi! def link preseedBooleanLC Operator
+hi! def link preseedMultiSelLC Operator
+hi! def link preseedStrLikeLC Operator
+
+
+" Add the syntax matching rules.
+
+" First, <owner>
+sy match preseedOwner /^\s*[[:alnum:]_-]\+\(\s\|$\)/
+ \ nextgroup=@preseedSecond,preseedOwnerLC
+
+" Second, <question name>
+sy match preseedQuestion contained
+ \ "\s*\([[:alnum:]_-]\+/\)\+[[:alnum:]_-]\+\(\s\|$\)"
+ \ nextgroup=@preseedThird,preseedQuestionLC
+
+" Third, <question type>
+" (boolean, multiselect, note, password, select, string)
+sy match preseedBooleanType contained /\s*boolean\(\s\|$\)/
+ \ nextgroup=preseedBooleanVal,preseedBooleanLC
+sy match preseedMultiSelType contained /\s*multiselect\(\s\|$\)/
+ \ nextgroup=preseedMultiSelVal,preseedMultiSelLC
+sy match preseedNote contained /\s*note$/
+sy match preseedSelectType contained /\s*select\(\s\|$\)/
+ \ nextgroup=preseedSelectVal,preseedSelectLC
+sy match preseedStrLikeType contained /\s*\(password\|string\)\(\s\|$\)/
+ \ nextgroup=preseedStrLikeVal,preseedStrLikeLC
+
+
+" Fourth, <value>
+sy match preseedBooleanVal contained /\s*\(false\|true\)/
+sy match preseedMultiSelVal contained /.*/me=e
+ \ contains=preseedMultiSelSep
+sy match preseedMultiSelVal contained /.*\\/me=e-1
+ \ contains=preseedMultiSelSep nextgroup=preseedMultiSelLC
+sy match preseedMultiSelSep contained /,/
+sy match preseedSelectVal contained /.*/
+sy match preseedStrLikeVal contained /.*/me=e
+sy match preseedStrLikeVal contained /.*\\/me=e-1
+ \ nextgroup=preseedStrLikeLC
+
+
+" Line continuation needs to be down here override everything other syntax.
+sy match preseedBooleanLC contained /\s*\\$/
+ \ nextgroup=preseedBooleanVal,preseedBooleanLC skipnl
+sy match preseedMultiSelLC contained /\\$/ nextgroup=preseedMultiSelVal skipnl
+sy match preseedOwnerLC contained /\s*\\$/ nextgroup=@preseedSecond skipnl
+sy match preseedQuestionLC contained /\s*\\$/ nextgroup=@preseedThird skipnl
+sy match preseedSelectLC contained /\s*\\$/
+ \ nextgroup=preseedSelectVal,preseedSelectLC skipnl
+sy match preseedStrLikeLC contained /\\$/ nextgroup=preseedStrLikeVal skipnl
+
+" And comments must override everything else.
+sy match preseedComment /^\s*#.*/