Have a kind of json-editor-mode
Depends on #96, for easy impl of:
- context of cursor in doc
- text objects for object/field/key/value/list
Motivations:
-
Write
foo bar:in a new field like in an object, should expand to"foo bar":(with undo support?) -
Add/Delete-a-line can auto-add/remove the trailing
,at the end of previous json-item, if we're adding a line after the last item of an object or a list. -
text objects for: (lowercase uses char-wise selection, uppercase version is line-wise)
-
o : object,io : in object -
f : obj field / list item,if : in obj field / list item(if: not including the trailing,) (ORj : json itemandij : in json item? it's more generic) -
l : list,il : in list -
k : obj field key,ik : in obj field key(ik: inside quotes) -
v : obj field value,iv : in obj field value(iv: inside quotes) (FIXME: also valid when value is a list/object?)
OR: text objects like
o, f/i, l, k, vwith prefixij&oj(forinner json Xorouter json X) -
When I'm somewhere in a JSON, I want to know where I am (like a breadcrumb).
For example, show in a floating window just under(/above? or in vim's cmdline?) the current line:
Currently in: json.paths["/folders/{id}"].put.requestBody.content["application/json"].schema
EDIT: treesitter should help greatly for this!
There's a great tool that allows to grep json easily, called gron: https://github.com/tomnomnom/gron
which transforms:
[
{
"commit": {
"author": {
"date": "2016-07-02T10:51:21Z",
"email": "[email protected]",
"name": "Tom Hudson"
}
}
}
]
To:
json[0].commit.author = {};
json[0].commit.author.date = "2016-07-02T10:51:21Z";
json[0].commit.author.email = "[email protected]";
json[0].commit.author.name = "Tom Hudson";
Json schemas can give json validation, auto completion, etc... Big catalog of schemas at https://www.schemastore.org/
Available for neovim with https://github.com/b0o/schemastore.nvim (+ the json language server)