From 9f2edb2f8186b6941d896b4c5ef61deb9f640ae2 Mon Sep 17 00:00:00 2001 From: Midgard Date: Fri, 24 Jan 2020 01:17:30 +0100 Subject: [PATCH] Add initial HLDS highlighting for Vim --- etc/vim/ftdetect.vim | 1 + etc/vim/ftplugin.vim | 1 + etc/vim/syntax.vim | 51 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 etc/vim/ftdetect.vim create mode 100644 etc/vim/ftplugin.vim create mode 100644 etc/vim/syntax.vim diff --git a/etc/vim/ftdetect.vim b/etc/vim/ftdetect.vim new file mode 100644 index 0000000..74b7d82 --- /dev/null +++ b/etc/vim/ftdetect.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.hlds set filetype=hlds diff --git a/etc/vim/ftplugin.vim b/etc/vim/ftplugin.vim new file mode 100644 index 0000000..bbd8967 --- /dev/null +++ b/etc/vim/ftplugin.vim @@ -0,0 +1 @@ +setlocal noexpandtab diff --git a/etc/vim/syntax.vim b/etc/vim/syntax.vim new file mode 100644 index 0000000..4bb78c0 --- /dev/null +++ b/etc/vim/syntax.vim @@ -0,0 +1,51 @@ +" Vim syntax file +" Language: HLDS +" Maintainer: Zeus WPI + +" quit when a syntax file was already loaded. +if exists("b:current_syntax") + finish +endif + +" We need nocompatible mode in order to continue lines with backslashes. +" Original setting will be restored. +let s:cpo_save = &cpo +set cpo&vim + +syn match hldsLocationAttribute "^\t[a-z0-9_-]\+ " display contained nextgroup=hldsLocationAttributeValue +syn match hldsLocationAttributeValue "[^\n]\+$" display contained + +syn region hldsLocationHeader matchgroup=hldsLocationHeaderDelim + \ start="^====*$" end="^====*$" + \ contains=hldsLocationAttribute + +syn keyword hldsBlockType base nextgroup=hldsBlockIdAftrKywrd skipwhite +syn keyword hldsChoiceType single_choice multi_choice nextgroup=hldsBlockIdAftrKywrd skipwhite + +syn match hldsBlockId "^[a-z0-9_-]\+: " +syn match hldsBlockIdAftrKywrd "[a-z0-9_-]\+: " contained + +syn match hldsTag " {[a-z0-9_-]\+}" +syn match hldsPrice "€ *[0-9]\+\(\.[0-9]\+\|\)" + +" trailing whitespace +syn match hldsSpaceError display excludenl "\s\+$" +" spaces instead of tabs +syn match hldsSpaceError display "^\t* " + +" The default highlight links. Can be overridden later. +hi def link hldsLocationHeader Function +hi def link hldsLocationHeaderDelim hldsLocationHeader +hi def link hldsLocationAttribute hldsLocationHeader +hi def link hldsChoiceType Statement +hi def link hldsBlockType Statement +hi def link hldsBlockId Include +hi def link hldsBlockIdAftrKywrd hldsBlockId +hi def link hldsPrice Number +hi def link hldsTag String +hi def link hldsSpaceError Error + +let b:current_syntax = "hlds" + +let &cpo = s:cpo_save +unlet s:cpo_save