Skip to content

Commit

Permalink
Fix VDF syntax highlighting
Browse files Browse the repository at this point in the history
Remove invalid negated set
Allow 0 whitespace between key and value
Terminate value by first double quote not preceded by '\'
Add test file

Fixes #13
  • Loading branch information
cooolbros committed Feb 24, 2025
1 parent 42d67d5 commit a878baa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/syntaxes/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const preprocessors = {

const map = new Map()

for (const name of readdirSync(SRC)) {
for (const name of readdirSync(SRC).filter((value) => posix.extname(value) == ".yaml")) {
let text = readFileSync(`${SRC}/${name}`, "utf-8")

const preprocessor = preprocessors[name.split(".")[0]]
Expand Down
29 changes: 29 additions & 0 deletions packages/syntaxes/src/vdf.test.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// https://github.com/cooolbros/vscode-vdf/issues/13
"CaratLabel" // Just ">>" to indicate that you are editing loadouts
{
"key" "value"
"key" "value" // comment
key value
"" ""
""""
"" "value\value\"value"
}

"lang"
{
"Language" "English"

"Tokens" [$WIN32]
{
"TF_LessThan" "<" [$WIN32]
"TF_GreaterThan" ">"
"game_player_left_game" "%s1 left the \" game (%s2)" // Just ">>" to indicate that you are editing loadouts
"Scoreboard_ChangeOnRoundEnd" "(Map change on round end...) Server map time left: 00:00" // comment
}
}

UnlitGeneric
{
"$detail" "hud\death_panel_mask"
$outline 1
}
4 changes: 2 additions & 2 deletions packages/syntaxes/src/vdf.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ patterns:
name: comment
- match: '\[.*\]'
name: constant.character
- match: '("[^(?<!\\)"]*"|\b\S+\b)\s+("[^(?<!\\)"]*"|\b\S+\b)'
- match: '("[^"]*"|\b\S+\b)\s*(".*?(?<!\\)"|\b\S+\b)'
name: variable
captures:
'1':
Expand All @@ -24,7 +24,7 @@ patterns:
patterns:
- match: '\\["\\/bfnrt]'
name: constant.character.escape
- match: '("[^(?<!\\)"]*"|\b\S+\b)'
- match: '("[^"]*"|\b\S+\b)'
name: variable
repository: {}
scopeName: source.vdf

0 comments on commit a878baa

Please sign in to comment.