aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_openscad.lua
blob: 078ec0380ff9de2b486b940a2bbb03b3751df942 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
-- mod-version:3
local syntax = require "core.syntax"

syntax.add {
  name = "OpenSCAD",
  files = {"%.scad$"},
  comment = "//",
  block_comment = { "/*", "*/" },
  patterns = {
    { pattern = "//.*",                          type = "comment"  }, -- Single-line comment
    { pattern = { "/%*", "%*/" },                type = "comment"  }, -- Multi-line comment
    { pattern = { '"', '"', '\\' },              type = "string"   }, -- String, double quotes
    { pattern = { "'", "'", '\\' },              type = "string"   }, -- String, apices
    { pattern = "-?0x%x+",                       type = "number"   }, -- ?
    { pattern = "-?%d+[%d%.eE]*[a-zA-Z]?",       type = "number"   }, -- ?
    { pattern = "-?%.?%d+",                      type = "number"   }, -- ?
    { pattern = "[%+%-=/%*%^%%<>!~|&%?%:]",      type = "operator" }, -- Operators
    { pattern = "[%a_][%w_]*%f[(]",              type = "function" }, -- Functions
    { regex   = "\\$[a-zA-Z]+",                  type = "keyword"  }, -- Special variables
    { pattern = "[%a_][%w_]*",                   type = "symbol"   },
  },
  symbols = {
    -- ?
    ["var"]               = "keyword",
    ["module"]            = "keyword",
    ["function"]          = "keyword",
    ["include"]           = "keyword",
    ["use"]               = "keyword",
    -- Constants
    ["undef"]             = "keyword2",
    ["PI"]                = "keyword2",
    -- 2D
    ["circle"]            = "keyword",
    ["square"]            = "keyword",
    ["polygon"]           = "keyword",
    ["text"]              = "keyword",
    ["import"]            = "keyword",
    ["projection"]        = "keyword",
    -- 3D
    ["sphere"]            = "keyword",
    ["cube"]              = "keyword",
    ["cylinder"]          = "keyword",
    ["polyhedron"]        = "keyword",
    ["surface"]           = "keyword",
    -- Transformations
    ["linear_extrude"]    = "keyword",
    ["rotate_extrude"]    = "keyword",
    ["translate"]         = "keyword",
    ["rotate"]            = "keyword",
    ["scale"]             = "keyword",
    ["resize"]            = "keyword",
    ["mirror"]            = "keyword",
    ["multmatrix"]        = "keyword",
    ["color"]             = "keyword",
    ["offset"]            = "keyword",
    ["hull"]              = "keyword",
    ["minkowski"]         = "keyword",
    -- Boolean Operations
    ["union"]             = "keyword",
    ["difference"]        = "keyword",
    ["intersection"]      = "keyword",
    -- Flow Control
    ["for"]               = "keyword",
    ["each"]              = "keyword",
    -- Type Test Functions
    ["is_undef"]          = "function",
    ["is_bool"]           = "function",
    ["is_num"]            = "function",
    ["is_string"]         = "function",
    ["is_list"]           = "function",
    ["is_function"]       = "function",
    -- Other
    ["echo"]              = "keyword",
    ["render"]            = "keyword",
    ["children"]          = "keyword",
    ["assert"]            = "keyword",
    -- Functions
    ["concat"]            = "function",
    ["lookup"]            = "function",
    ["str"]               = "function",
    ["chr"]               = "function",
    ["ord"]               = "function",
    ["search"]            = "function",
    ["version"]           = "function",
    ["version_num"]       = "function",
    ["parent_module"]     = "function",    
    -- Math Functions
    ["abs"]               = "keyword",
    ["sign"]              = "keyword",
    ["sin"]               = "keyword",
    ["cos"]               = "keyword",
    ["tan"]               = "keyword",
    ["acos"]              = "keyword",
    ["asin"]              = "keyword",
    ["atan"]              = "keyword",
    ["atan2"]             = "keyword",
    ["floor"]             = "keyword",
    ["round"]             = "keyword",
    ["ceil"]              = "keyword",
    ["ln"]                = "keyword",
    ["len"]               = "keyword",
    ["let"]               = "keyword",
    ["log"]               = "keyword",
    ["pow"]               = "keyword",
    ["sqrt"]              = "keyword",
    ["exp"]               = "keyword",
    ["rands"]             = "keyword",
    ["min"]               = "keyword",
    ["max"]               = "keyword",
    ["norm"]              = "keyword",
    ["cross"]             = "keyword",
    -- Literals
    ["true"]              = "literal",
    ["false"]             = "literal",
  }
}