Skip to content

tminor/jsonnet-mode

Repository files navigation

License: GPL v3 CI Coverage Status

jsonnet-mode

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

Table of Contents

Dependencies

The jsonnet-eval-buffer method depends on the jsonnet binary, which should be available on your exec-path. For installation details, see here for go-jsonnet and here for the C++ implementation.

Features

Indentation

Indentation is provided by a function implemented with SMIE. To use the old indentation function (not recommended), set jsonnet-use-smie to nil.

Formatting

jsonnet-reformat-buffer (bound to C-c C-r by default) uses the jsonnetfmt utility to reformat your buffer. jsonnet-mode's indentation function should match its output in most cases.

Rendering

jsonnet-eval-buffer runs jsonnet to evaluate and render a jsonnet-mode buffer. It's bound to C-c C-c by default. If any errors are encountered, they should be conveniently displayed in compilation-mode.

It will create a buffer called *jsonnet output*. Default display behaviour of these buffers can be customized using display-buffer-alist (see The Zen of Buffer Display for examples of how to do this).

Navigation

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.

Configuration

There are several 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-command-options can be specified if additional options should be sent with jsonnet-command.
  • 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.
  • jsonnet-use-smie enables SMIE-provided indentation.
  • jsonnet-indent-level changes the number of spaces used to indent Jsonnet code.

Buffer display

The potential buffers that the mode creates are:

  • *jsonnet output*

If you require special customization of their display, you can either use display-buffer-alist as described above or investigate the options provided in your distribution of GNU Emacs.

About

Emacs major mode for editing Jsonnet files.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published