Skip to content

Commit dab171f

Browse files
authored
Merge pull request #64 from SublimeText/bugfix/underscore-identifiers
Support identifiers starting with an underscore character
2 parents f2d8046 + 46c108a commit dab171f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3232
### Fixed
3333

3434
- Improved matching of identifiers by adding a scope and properly recognizing hyphens.
35+
- Support identifiers starting with an underscore character (#43).
3536

3637
---
3738

Terraform.sublime-syntax

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ file_extensions:
2828
scope: source.terraform
2929

3030
variables:
31-
# Identifiers: (UTF-8) (ID_Continue | '-')*;
31+
# Identifiers: ID_Start (ID_Continue | '-')*;
3232
#
33-
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#identifiers
34-
identifier: (?:\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\b)
33+
# There is an undocumented exception
34+
# that an underscore character is also accepted
35+
# as an id start character.
36+
#
37+
# https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#identifiers
38+
# http://unicode.org/reports/tr31/#Table_Lexical_Classes_for_Identifiers
39+
ID_Start: '[\p{ID_Start}_]'
40+
ID_Continue: '[\p{ID_Continue}-]'
41+
identifier: (?:{{ID_Start}}{{ID_Continue}}*)
3542

3643
# Exponent: "e" or "E" followed by an optional sign
3744
#

syntax_test_terraform.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@
274274
identifier-with-hyphens
275275
# ^^^^^^^^^^^^^^^^^^^^^^^ variable.other.readwrite.terraform
276276

277+
__EOF__
278+
# ^^^^^^^ variable.other.readwrite.terraform
279+
277280
identifier.
278281
// comment
279282
# <- comment
@@ -3128,6 +3131,12 @@
31283131
END
31293132
# ^^^^ keyword.control.heredoc.terraform
31303133

3134+
<<__EOF__
3135+
# ^^ keyword.operator.heredoc.terraform
3136+
# ^^^^^^^ keyword.control.heredoc.terraform
3137+
aaa
3138+
__EOF__
3139+
# ^^^^^^^^ keyword.control.heredoc.terraform
31313140
/////////////////////////////////////////////////////////////////////
31323141
// IMPORTS
31333142
/////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)