blob: 4af589b4f6a1ccf6a261aacf4bb7d5acfe2abd0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
const std = @import("std");
const Config = @import("../config/Config.zig");
const Template = struct {
const header =
\\%YAML 1.2
\\---
\\# See http://www.sublimetext.com/docs/syntax.html
\\name: Ghostty Config
\\file_extensions:
\\ - ghostty
\\scope: source.ghostty
\\
\\contexts:
\\ main:
\\ # Comments
\\ - match: '^\s*#.*$'
\\ scope: comment.line.number-sign.ghostty
\\
\\ # Keywords
\\ - match: '\b(
;
const footer =
\\)\b'
\\ scope: keyword.other.ghostty
\\
;
};
/// Check if a field is internal (starts with underscore)
fn isInternal(name: []const u8) bool {
return name.len > 0 and name[0] == '_';
}
/// Generate keywords from Config fields
fn generateKeywords() []const u8 {
@setEvalBranchQuota(5000);
var keywords: []const u8 = "";
const config_fields = @typeInfo(Config).@"struct".fields;
for (config_fields) |field| {
if (isInternal(field.name)) continue;
if (keywords.len > 0) keywords = keywords ++ "|";
keywords = keywords ++ field.name;
}
return keywords;
}
/// Complete Sublime syntax file content
pub const syntax = Template.header ++ generateKeywords() ++ Template.footer;
|