├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── grammars └── hcl.cson ├── package.json ├── settings └── language-hcl.cson └── snippets └── language-hcl.cson /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.1 2 | * Fixed comment patterns 3 | 4 | ## 0.1.0 - First Release 5 | * Every feature added 6 | * Every bug fixed 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HashiCorp Configuration Language package 2 | 3 | A grammar for the HashiCorp Configuration Language. 4 | -------------------------------------------------------------------------------- /grammars/hcl.cson: -------------------------------------------------------------------------------- 1 | # If this is your first time writing a language grammar, check out: 2 | # - http://manual.macromates.com/en/language_grammars 3 | 4 | 'scopeName': 'source.hcl' 5 | 'name': 'HashiCorp Configuration Language' 6 | 'fileTypes': [ 7 | 'hcl', 8 | 'nomad', 9 | 'tf' 10 | ] 11 | 'patterns': [ 12 | { 13 | 'include': '#value' 14 | } 15 | ] 16 | 17 | 'repository': 18 | 'constant': 19 | 'match': '\\b(?:true|false|null)\\b' 20 | 'name': 'constant.language.hcl' 21 | 22 | 'number': 23 | 'comment': 'handles integer and decimal numbers' 24 | 'match': '-?(?=[1-9]|0(?!\\d))\\d+(\\.\\d+)?([eE][+-]?\\d+)?' 25 | 'name': 'constant.numeric.hcl' 26 | 27 | 'kwString': 28 | 'match': '\\b(?:[\\w\\d_-]+)\\b' 29 | 'name': 'entity.name.key.hcl' 30 | 31 | 'string': 32 | 'begin': '"' 33 | 'beginCaptures': 34 | '0': 35 | 'name': 'punctuation.definition.string.begin.hcl' 36 | 'end': '"' 37 | 'endCaptures': 38 | '0': 39 | 'name': 'punctuation.definition.string.end.hcl' 40 | 'name': 'string.quoted.double.hcl' 41 | 'patterns': [ 42 | { 43 | 'match': '(?x: # turn on extended mode\n \\\\ # a literal backslash\n (?: # ...followed by...\n ["\\\\/bfnrt] # one of these characters\n | # ...or...\n u # a u\n [0-9a-fA-F]{4} # and four hex digits\n )\n )' 44 | 'name': 'constant.character.escape.hcl' 45 | } 46 | { 47 | 'match': '\\\\.' 48 | 'name': 'invalid.illegal.unrecognized-string-escape.hcl' 49 | } 50 | { 'include': '#interpolation' } 51 | ] 52 | 53 | 'array': 54 | 'begin': '\\[' 55 | 'beginCaptures': 56 | '0': 57 | 'name': 'punctuation.definition.array.begin.hcl' 58 | 'end': '\\]' 59 | 'endCaptures': 60 | '0': 61 | 'name': 'punctuation.definition.array.end.hcl' 62 | 'name': 'meta.structure.array.hcl' 63 | 'patterns': [ 64 | { 65 | 'include': '#value' 66 | } 67 | { 68 | 'match': ',' 69 | 'name': 'punctuation.separator.array.hcl' 70 | } 71 | { 72 | 'match': '[^\\s\\]]' 73 | 'name': 'invalid.illegal.expected-array-separator.hcl' 74 | } 75 | ] 76 | 77 | 'object': 78 | 'begin': '\\{' 79 | 'beginCaptures': 80 | '0': 81 | 'name': 'punctuation.definition.dictionary.begin.hcl' 82 | 'comment': 'a HCL object' 83 | 'end': '\\}' 84 | 'endCaptures': 85 | '0': 86 | 'name': 'punctuation.definition.dictionary.end.hcl' 87 | 'name': 'meta.structure.dictionary.hcl' 88 | 'patterns': [ 89 | { 90 | 'comment': 'the HCL object value' 91 | 'include': '#comment' 92 | } 93 | { 94 | 'comment': 'the HCL object key' 95 | 'include': '#string' 96 | } 97 | { 98 | 'comment': 'the HCL object key' 99 | 'include': '#kwString' 100 | } 101 | { 102 | 'begin': '=' 103 | 'beginCaptures': 104 | '0': 105 | 'name': 'punctuation.separator.dictionary.key-value.hcl' 106 | 'end': '(,)|(?=\\})' 107 | 'endCaptures': 108 | '1': 109 | 'name': 'punctuation.separator.dictionary.pair.hcl' 110 | 'name': 'meta.structure.dictionary.value.hcl' 111 | 'patterns': [ 112 | { 113 | 'comment': 'the HCL object value' 114 | 'include': '#value' 115 | } 116 | ] 117 | } 118 | { 119 | 'match': '[^\\s\\}]' 120 | 'name': 'invalid.illegal.expected-dictionary-separator.hcl' 121 | } 122 | ] 123 | 124 | 'comment': 125 | 'begin': '(^[ \\t]+)?(?=(#|//))' 126 | 'beginCaptures': 127 | '1': 128 | 'name': 'punctuation.whitespace.comment.leading.hcl' 129 | 'end': '(?!\\G)' 130 | 'patterns': [ 131 | { 132 | 'begin': '//' 133 | 'beginCaptures': 134 | '0': 135 | 'name': 'punctuation.definition.comment.hcl' 136 | 'end': '\\n' 137 | 'name': 'comment.line.double-slash.hcl' 138 | } 139 | { 140 | 'begin': '#' 141 | 'beginCaptures': 142 | '0': 143 | 'name': 'punctuation.definition.comment.hcl' 144 | 'end': '\\n' 145 | 'name': 'comment.line.pound.hcl' 146 | } 147 | ] 148 | 149 | 'heredoc': 150 | 'begin': '(?>\\=\\s*<<(\\w+))' 151 | 'beginCaptures': 152 | '0': 153 | 'name': 'punctuation.definition.string.begin.hcl' 154 | 'end': '^\\1$' 155 | 'endCaptures': 156 | '0': 157 | 'name': 'punctuation.definition.string.end.hcl' 158 | 'name': 'string.unquoted.heredoc.hcl' 159 | 'patterns': [ 160 | { 'include': '#interpolation' } 161 | ] 162 | 163 | 'interpolation': 164 | 'begin': '\\$\\{' 165 | 'beginCaptures': 166 | '0': 167 | 'name': 'punctuation.section.embedded.hcl' 168 | 'end': '\\}' 169 | 'endCaptures': 170 | '0': 171 | 'name': 'punctuation.section.embedded.hcl' 172 | 'name': 'source.hcl.embedded.source' 173 | 'patterns': [ 174 | { 175 | 'begin': '\\{' 176 | 'beginCaptures': 177 | '0': 178 | 'name': 'meta.brace.curly.hcl' 179 | 'end': '\\}' 180 | 'endCaptures': 181 | '0': 182 | 'name': 'meta.brace.curly.hcl' 183 | 'patterns': [ 184 | { 185 | 'include': '$self' 186 | } 187 | ] 188 | } 189 | { 190 | 'include': '$self' 191 | } 192 | ] 193 | 194 | 'value': 195 | 'comment': 'the \'value\' diagram at http://json.org' 196 | 'patterns': [ 197 | { 198 | 'include': '#constant' 199 | } 200 | { 201 | 'include': '#number' 202 | } 203 | { 204 | 'include': '#kwString' 205 | } 206 | { 207 | 'include': '#heredoc' 208 | } 209 | { 210 | 'include': '#string' 211 | } 212 | { 213 | 'include': '#array' 214 | } 215 | { 216 | 'include': '#object' 217 | } 218 | { 219 | 'include': '#comment' 220 | } 221 | ] 222 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-hcl", 3 | "version": "0.4.0", 4 | "description": "Syntax support for the HashiCorp Configuration Language", 5 | "keywords": [ 6 | "language", 7 | "grammar" 8 | ], 9 | "repository": "https://github.com/fd/language-hcl", 10 | "license": "MIT", 11 | "engines": { 12 | "atom": ">=0.174.0 <2.0.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /settings/language-hcl.cson: -------------------------------------------------------------------------------- 1 | # If you want some examples of settings, check out: 2 | # https://github.com/atom/language-gfm/blob/master/settings/gfm.cson 3 | 4 | '.source.hcl': 5 | 'editor': 6 | 'commentStart': '// ' 7 | -------------------------------------------------------------------------------- /snippets/language-hcl.cson: -------------------------------------------------------------------------------- 1 | # If you want some example snippets, check out: 2 | # https://github.com/atom/language-gfm/blob/master/snippets/gfm.cson 3 | 4 | # '.source.hcl': 5 | # 'Method documentation': 6 | # 'prefix': 'doc' 7 | # 'body': '@@ ${1:method} - ${2:description}' 8 | --------------------------------------------------------------------------------