tminor / jsonnet-mode Goto Github PK
View Code? Open in Web Editor NEWEmacs major mode for editing Jsonnet files.
License: GNU General Public License v3.0
Emacs major mode for editing Jsonnet files.
License: GNU General Public License v3.0
When running jsonnet-reformat-buffer
if there's an error the whole buffer is replaced by the output of the fmt
command. In that case an undo will give you back the buffer content but it would be better if checking first if there's an error and in that case log to the *jsonnet*
buffer, if not reformat in place.
Is there an easy way to get the indentation strategy to be consistent with jsonnet fmt?
For example jsonnet fmt gives:
function()
"bar"
but the jsonnet-mode indentation wants to do:
function()
"bar"
Some examples:
{
// This gets highlighted as a multiline string, but it should not be:
foo1: |
bar
|;
// This too:
foo2: | bar |;
// This too:
foo3: = |||||
bar
|||||;
// This one gets interrupted at the | in the middle, and the rest of
// the file gets highlighted as a string until another | shows up:
foo4: |||
bar | this text should still be inside the triple-pipe string
|||;
// this line should be a comment but it's highlighted as a string?
// if I add a single | it ends the incorrect string match
// now it's back to normal and this is a comment again
}
here's what that looks like in a screenshot:
Consider the following snippet
local data_base_path = 'path/to/data/';
{
"data_pattern": data_base_path + "*.tsv"
"key1": "value1",
"key2": "value2",
}
Indenting the region messes up all lines after the line containing the asterisk.
/*
inside a string is treated as though it begins a multiline comment for indentation purposes.
Example:
{
foo = "/dir/*",
bar = "should not be indented",
baz = "*/ <--- this will end the extra indentation",
quz = "back to where it should be",
}
I am trying to use this mode for qbec files, which contains custom external variable:
local env = std.extVar('qbec.io/env');
And I got the error in *Messages*
:
undefined external variable: qbec.io/env
I tried to customize jsonnet command with this:
(jsonnet-command "jsonnet --ext-str qbec.io/env=testenv")
But it didn't help.
Could you please help me to understand what exactly is wrong here?
UPD: apparently that error comes from flycheck, not from jsonnet-mode
, but:
When I call jsonnet-eval-function
it returns:
apply: Searching for program: No such file or directory, jsonnet --ext-str qbec.io/env=testenv
After installing a library using jsonnet-bundler
, I have tried:
vendor
vendor
vendor
vendor
None of the four worked, I still get an error on the import
line saying couldn't open import ...
.
If I run jsonnet path/to/my.jsonnet -J path/to/vendor
, that succeeds.
When I am trying to install latest version I have errors in compule log.
jsonnet-mode version: 20200930.1418
emacs versiion: GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2020-08-12
Code to install:
(use-package jsonnet-mode
:ensure t)
Messages:
In jsonnet-smie-rules:
jsonnet-mode.el:178:33:Warning: value returned from (member x4 '("]" "}" ")"))
is unused
jsonnet-mode.el:178:33:Warning: value returned from (member x4 '("]" "}" ")"))
is unused
In jsonnet-eval-buffer:
jsonnet-mode.el:629:4:Warning: `(directories (cons (file-name-directory
file-to-eval) search-dirs))' is a malformed function
jsonnet-mode.el:638:36:Warning: reference to free variable `directories'
In end of data:
jsonnet-mode.el:775:1:Warning: the following functions are not known to be
defined: some, lexical-let
When I press C-c C-r
my buffers appears reformatted but the mode adds some odd newlines at the end of file.
If I will apply reformat multiple times it will add up to 4 newlines and only after that message No format change necessary.
will appear.
UPD: apparently it works only if file ends with comment line like this:
I tried to run jsonnet-reformat-buffer
and got empty buffer after that because of error:
jsonnet-reformat-buffer: Searching for program: No such file or directory, jsonnet
I think we need to check jsonnet
command is available before replacing the buffer content.
I have problems with highlighting when I am trying to open file https://github.com/google/jsonnet/blob/master/doc/_stdlib_gen/stdlib-content.jsonnet
Here is the stuff:
7c9961b adds a test illustrating what the subject refers to.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.