Skip to content

Commit 657b1e5

Browse files
committed
Add support for def $name and def @name
def @name is used by jaq for cusome @Format def @name is extension for jq-lsp to allow adding own global variables in .jq-lsp.jq Add hover documenation and completion for @Format Swap hover_{def,builtins}.json as they were wrong Fixes #24
1 parent 10b38ac commit 657b1e5

File tree

19 files changed

+741
-451
lines changed

19 files changed

+741
-451
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ It can currently do:
1818
- Function symbols per document.
1919
- Read additional builtins from `.jq-lsp.jq`.
2020

21+
## Own builtins and global variables using `.jq-lsp.jq`
22+
23+
jq-lsp will automcatically include `.jq-lsp.jq` in the smae directory as the file being edited.
24+
25+
Example `.jq-lsp.jq` file adding builtin `new_builtin` and global variable `$new_variable`:
26+
```jq
27+
# body will be ignored
28+
def new_builtin: empty;
29+
def $new_variable: empty;
30+
```
31+
2132
## Install
2233

2334
```sh
@@ -54,8 +65,8 @@ and is licensed under https://github.com/stedolan/jq/blob/master/COPYING
5465
- Server loop and https://github.com/itchyny/gojq/issues/86
5566
- Warn about unused functions and bindings
5667
- Better at handling broken syntax while typing
57-
- `$<cursor>` auto complete, add temp name?
58-
- `a | n<cursor> f`, add temp name?
68+
- `$<cursor>`/`@<cursor>` auto complete, add temp name?
69+
- `a | n<cursor> f`, add temp name/try fix syntax?
5970
- Transitive include behavior (jq/gojq behaves differently?)
6071
- Source formatting
6172
- Requires whitespace/comment support in lexer/parser

gojqparser/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
This is a modified version of gojq's parser https://github.com/itchyny/gojq which adds token positions and query marshal/unmarshal support.
1+
This is a modified version of gojq's parser https://github.com/itchyny/gojq which adds
2+
- token position
3+
- query marshal/unmarshal
4+
- `def @name` support, used by jaq for custom @formats
5+
- `def $name` support, used by jq-lsp to define own globals in .jq-lsp.jq

0 commit comments

Comments
 (0)