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

Overview

tree-sitter-hcl

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

Status

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.

Screenshot

The screenshot shows a Terraform example syntax highlighted.

Screenshot

You might also like...
tree-sitter parser and syntax highlighter for the Dwarf Fortress raw language
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

This is like Inverting Binary Tree, but instead of a Binary Tree it's a File Tree.
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

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

Build a tree-sitter dynamic module

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

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

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

Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java. Implementation of K-D tree in C++ programming language.
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

Given two arrays X and Y of positive integers, find the number of pairs such that x^y y^x (raised to power of) where x is an element from X and y is an element from Y.

Number-of-pairs Given two arrays X and Y of positive integers, find the number of pairs such that x^y y^x (raised to power of) where x is an element

Comments
  • 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 buildd@lcy01-amd64-011
    
    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

    Collaboration

    Hey,

    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)?

    Thanks!

    opened by WhyNotHugo 0
Owner
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 22 Sep 10, 2022
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 48 Dec 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 24 Dec 3, 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 43 Nov 2, 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 161 Jan 7, 2023
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 28 Nov 30, 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 5 Dec 9, 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 6 Nov 22, 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 6 Dec 27, 2022