Emacs major mode for editing Jsonnet files.
Clone or download
seh and mgyucht Accommodate library search directories during Jsonnet evaluation (#5)
* Accommodate library search directories in eval

Introduce the "jsonnet-lib-dirs" customizable variable to allow
specifying the sequence of library directories in which Jsonnet should
search for included files during evaluation, as one supplies to the
"jsonnet" command's "-J" or "--jpath" command-line flags.

* Honor a buffer-local value for library search path

* Reduce allocation in command argument construction

* Rename new library search directories variable
Latest commit 0d68681 Aug 22, 2018


License: GPL v3


Provides Emacs font-lock, indentation, and some useful functions for the Jsonnet templating language.

Table of Contents


The jsonnet-eval method depends on the jsonnet binary, which should be available on your exec-path. Install this on OSX with Homebrew by running brew install jsonnet.



The indentation rules are a set of rules which I put together based on my experience with Jsonnet. You can see them by looking at the implementation of jsonnet-calculate-indent.


Closely related to indentation is formatting. By running jsonnet-reformat-buffer (bound to C-c C-r), the jsonnet fmt utility will reformat your buffer and make it pretty.


To get a snapshot of what your Jsonnet file will render to, run jsonnet-eval (bound to C-c C-e). This will popup another window and show the result of running jsonnet-command on the current buffer.


jsonnet-mode also provides some methods to make navigation easier. In particular, jsonnet-jump (bound to C-c C-f) allows you to jump to the definition of a given identifier.


There are three customizable parameters that you may configure in this mode:

  • jsonnet-command allows you to indicate which Jsonnet binary should be used to render a JSON document.
  • jsonnet-library-search-directories specifies the sequence of Jsonnet library search directories use during evaluation.
    Relative paths in this sequence must resolve from the directory of the buffer being evaluated.
  • jsonnet-enable-debug-print will cause methods in jsonnet-mode to write messages to the status bar if enabled.