tminor / jsonnet-mode

Emacs major mode for editing Jsonnet files.
GNU General Public License v3.0
46 stars 17 forks source link

Prevent highlighting portions of variables that match built-in syntax. #30

Closed knoepfel closed 3 years ago

knoepfel commented 3 years ago

In the following Jsonnet snippet, the skip_if parameter contains an underscore, which is recognized as a word boundary in jsonnet-mode. In this case, the if component of the parameter is highlighted whereas the skip_ substring is not.

local gather_from(arr, field, skip_if="") =
  std.foldl(function(res, config) append(res, config[field], skip_if), arr, {});

{
  sources_from(arr): gather_from(arr, "sources", skip_if="source_channel"),
  publishers_from(arr): gather_from(arr, "publishers"),
  transforms_from(arr): gather_from(arr, "transforms"),
}

This PR adjusts the regular expressions according to the definition of a "symbol" instead of a "word", as defined here.

Types of changes

Checklist:

tminor commented 3 years ago

LGTM, thanks!