Skip to content

Instantly share code, notes, and snippets.

@guitarmanvt
Created June 26, 2019 14:47
Show Gist options
  • Save guitarmanvt/fae4a20f020c05d014f9632bad644f96 to your computer and use it in GitHub Desktop.
Save guitarmanvt/fae4a20f020c05d014f9632bad644f96 to your computer and use it in GitHub Desktop.
Hashicorp Terraform Language Specification for GtkSourceView 4 (gedit and xed) . Generated by https://github.com/guitarmanvt/cson2lang
<?xml version="1.0" encoding="UTF-8"?>
<!--
Syntax highlighting for the HashiCorp Configuration Language language
-->
<language id="hcl" name="HashiCorp Configuration Language" section="Sources" version="2.0">
<metadata>
<property name="globs">*.hcl;*.nomad;*.tf</property>
<property name="line-comment-start">//</property>
<property name="block-comment-start">/*</property>
<property name="block-comment-end">*/</property>
</metadata>
<styles>
<style id="comment" name="Comment" map-to="def:comment"/>
<style id="number" name="Number" map-to="def:number"/>
<style id="constant" name="Constant" map-to="def:constant"/>
<style id="keyword" name="Keyword" map-to="def:keyword"/>
<style id="string" name="String" map-to="def:string"/>
<style id="comment" name="Comment" map-to="def:comment"/>
</styles>
<definitions>
<context id="hcl">
<include>
<context id="comment_type_0" style-ref="comment">
<start>//</start>
<end>$</end>
</context>
<context id="comment_type_1" style-ref="comment">
<start>#</start>
<end>$</end>
</context>
<context id="comment_type_2" style-ref="comment">
<start>/\*</start>
<end>\*/</end>
</context>
<context id="number" style-ref="number">
<match extended="true">-?(?=[1-9]|0(?!\d))\d+(\.\d+)?([eE][+-]?\d+)?</match>
</context>
<context id="constant" style-ref="constant">
<match extended="true">\b(?:true|false|null)\b</match>
</context>
<context id="keyword" style-ref="keyword">
<match extended="true">\b(?:[\w\d_-]+)\b</match>
</context>
<context id="string" style-ref="string">
<start>"</start>
<end>"</end>
</context>
<context id="comment" style-ref="comment">
<start>(^[ \t]+)?(?=(#|//))</start>
<end>(?!\G)</end>
</context>
</include>
</context>
</definitions>
</language>
@guitarmanvt
Copy link
Author

This has one annoying bug: # and // single-line comments only really work right at the start of the line. I've tried to figure out the right syntax to make it work, but I'm beginning to wonder if language-spec can handle two different types of line comments.

@jebw
Copy link

jebw commented Feb 27, 2021

Any objections if I submit this to gtksourceview?

@guitarmanvt
Copy link
Author

@jebw Feel free. (Sorry for the tardy response.)

@giuspen
Copy link

giuspen commented Mar 17, 2022

@guitarmanvt thanks for your work I have included it in my app cherrytree I hope you don't mind!
I should have fixed the issue of the single line comment in giuspen/cherrytree@fdc0457

@guitarmanvt
Copy link
Author

@giuspen Thanks! I just saw this. Made my day. 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment