A tree-sitter grammar for HCL (HashiCorp Configuration Language), used by projects such as Terraform.



tree-sitter grammar for HCL (HashiCorp Configuration Language) files. HCL is the configuration format used by projects such as Terraform, Vault, Waypoint, Nomad, etc.


Important: This is not an officially supported HashiCorp project. I am one of the founders of HashiCorp, but I built this in my personal free time and there are no dedicated resources (people or otherwise) from the company on this project.

The grammar parses most HCL files I've thrown at it. It doesn't handle interpolations yet (in strings or heredocs) and instead treats the full string as just a string. This is the biggest feature missing at the moment. Regardless, I am using this day to day for general HCL highlighting.


The screenshot shows a Terraform example syntax highlighted.


  • Not getting parser to work

    Not getting parser to work

    I saw your tweet and tried to implement this Tree Sitter module, but somehow it doesn't parse the HCL files. Tried with Terraform .tf and Nomad .nomad, but no luck.

    NVIM v0.5.0-dev
    Build type: RelWithDebInfo
    LuaJIT 2.1.0-beta3
    Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-eimZbm/neovim-0.5.0+ubuntu2+git202106210023-b585f723b-d569569c9=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unus
    ed-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_F
    ROM -DMIN_LOG_LEVEL=3 -I/build/neovim-eimZbm/neovim-0.5.0+ubuntu2+git202106210023-b585f723b-d569569c9/build/config -I/build/neovim-eimZbm/neovim-0.5.0+ubuntu2+git202106210023-b585f723b-d569569c9/src -I/build/neovim-eimZbm/neovim-0.5.0+ubuntu2+git202106210023-b585f723b-d5695
    69c9/.deps/usr/include -I/usr/include -I/build/neovim-eimZbm/neovim-0.5.0+ubuntu2+git202106210023-b585f723b-d569569c9/build/src/nvim/auto -I/build/neovim-eimZbm/neovim-0.5.0+ubuntu2+git202106210023-b585f723b-d569569c9/build/include
    Compiled by [email protected]
    Features: +acl +iconv +tui
    See ":help feature-compile"
       system vimrc file: "$VIM/sysinit.vim"
      fall-back for $VIM: "/usr/share/nvim"
    Run :checkhealth for more info
    hcl             [✓] installed
    >> default       highlight  incremental_selection  indent
    hcl              ✗          ✗                      ✗ 
    toml             ✓          ✗                      ✗

    Here is my TSConfigInfo:

      ensure_installed = {},
      ignore_install = {},
      modules = {
        highlight = {
          additional_vim_regex_highlighting = false,
          custom_captures = {},
          disable = { "markdown" },
          enable = true,
          loaded = true,
          module_path = "nvim-treesitter.highlight"
        incremental_selection = {
          disable = {},
          enable = false,
          keymaps = {
            init_selection = "gnn",
            node_decremental = "grm",
            node_incremental = "grn",
            scope_incremental = "grc"
          module_path = "nvim-treesitter.incremental_selection"
        indent = {
          disable = {},
          enable = false,
          module_path = "nvim-treesitter.indent"
      update_strategy = "lockfile"
    opened by rgruyters 7
  • Collaboration



    about 3 weeks ago i started to write a tree-sitter grammar for hcl too: https://github.com/MichaHoffmann/tree-sitter-hcl

    it works reasonably well and handles templates ( somewhat ). would you like to collaborate here ? If so i would try to help out here and deprecate mine.

    i hope its not bad form to advertise here, but i could not reach you otherwise.

    opened by MichaHoffmann 2
  • Create a tag

    Create a tag

    Hi! I'm trying to integrate this into nvim via nvim-treesitter.

    However, due to the way it works right now, a specific tag must be pinned, that specific version is downloaded.

    Can you provide a single tag with the current version (even if just v0.1.0)?


    opened by WhyNotHugo 0
Mitchell Hashimoto
Mitchell Hashimoto
SQL grammar for tree sitter

tree-sitter-sql I want to do something fun at work since we have stuff like this in Go: const hoverDocumentQuery = ` -- source: enterprise/internal/co

TJ DeVries 20 Nov 16, 2021
Tree sitter grammar for Svelte

Tree-sitter-svelte Tree-sitter grammar for svelte Install npm i tree-sitter-svelte tree-sitter Usage To get started with exploring the grammar in a w

Himujjal Upadhyaya 41 Aug 2, 2022
A tree-sitter grammar for go.mod files

tree-sitter-go-mod tree-sitter grammar for go.mod files. Status The grammar is fairly small, and has been working well for highlighting for me. I expe

Camden Cheek 21 Jul 10, 2022
A tree-sitter grammar for protocol buffer files (proto3).

tree-sitter-proto tree-sitter grammar for protocol buffer files (proto3 only). Status The grammar should be complete. I'm still working on the highlig

Mitchell Hashimoto 41 Jul 19, 2022
Org grammar for tree-sitter

tree-sitter-org Unstable: This build will change. Org grammar for tree-sitter. It is not meant to implement emacs' orgmode parser, but to implement a

Emilia Simmons 140 Jul 11, 2022
Golang template grammar for tree-sitter

tree-sitter-go-template Golang templates grammar for tree-sitter. NeoVim integration using nvim-treesitter Add gotmpl parser following nvim-treesitter

Nikita Galaiko 23 Jul 27, 2022
Surface grammar for Tree-sitter

Tree-sitter Surface Tree-sitter grammar and parser for Surface, the server-side rendering component library for Phoenix. Supports the Surface 0.5+ tem

Clay 13 Jul 12, 2022
A tree-sitter grammar for `git diff` output

tree-sitter-git-diff A tree-sitter grammar for git diffs. Status Working, but needs more testing. Examples Highlighting a .diff file: Injecting this g

Michael Davis 1 Mar 2, 2022
Promela grammar for tree-sitter

tree-sitter-promela Promela grammar for tree-sitter. Motivation Promela is a language used for specifying models, especially in distributed systems co

Ben Siraphob 5 Mar 13, 2022
Scheme grammar for tree-sitter

tree-sitter-scheme Scheme grammar for tree-sitter. Status tree-sitter-scheme should work on a superset of Scheme. The standards are expected to suppor

null 4 Jul 24, 2022
tree-sitter parser and syntax highlighter for the Dwarf Fortress raw language

tree-sitter-dfraw A simple language parser and highlighter made with tree-sitter tokyonight nightfly Using with nvim-treesitter Please refer to the ad

null 2 Apr 1, 2022
This is like Inverting Binary Tree, but instead of a Binary Tree it's a File Tree.

Invert File Tree in C++ This is like Inverting Binary Tree, but instead of the Binary Tree it's a File Tree. This is intended as a simple exercise to

Tsoding 11 Jun 18, 2021
An intrusive C++17 implementation of a Red-Black-Tree, a Weight Balanced Tree, a Dynamic Segment Tree and much more!

This is Ygg (short for Yggdrasil), a C++17 implementation of several intrusive data structures: several balanced binary search trees: a red-black Tree

Lukas Barth 93 May 29, 2022
Build a tree-sitter dynamic module

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I should clarify that this module is NOT a standalone tree-sitter module. It is supo

Yuan Fu 4 May 22, 2022
HEEx grammer for Tree-sitter

Tree-sitter HEEx Tree-sitter grammar and parser for HEEx, the HTML-aware and component-friendly extension of EEx for Phoenix. For Surface support, see

Connor Lay (Clay) 27 Jul 16, 2022
Languages for the Tree-sitter parser generator wrapped in Swift packages

TreeSitterLanguages Languages for the Tree-sitter parser generator wrapped in Swift packages. Motivation There are two reasons this package exists: As

Simon Støvring 15 Aug 2, 2022
Implementation of K-D tree in C++ programming language.

KD_Trees Implementation of K-D tree in C++ programming language Demonstration Image What's in this repository anyway? This is a C++(PL) implementation

Shreyash 4 Dec 17, 2021
Simple and fast configuration file library (written in C99)

Features Configuration file reading Supported operating systems Ubuntu MacOS Windows Build requirements C99 compiler CMake 3.10+ Cloning git clone htt

Nikita Fediuchin 3 May 26, 2022