From 51edb42ce97c5624b5e0c3da25cbf1247ba9960b Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Wed, 10 Jan 2018 16:34:46 +0100 Subject: [PATCH] add jsonl support This patch adds jsonl file type detection and disable trailing commas syntax error for object if filetype is equal to jsonl. --- ftdetect/json.vim | 1 + jsonl-test.jsonl | 4 ++++ syntax/json.vim | 10 ++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 jsonl-test.jsonl diff --git a/ftdetect/json.vim b/ftdetect/json.vim index 1b1fef8..2e45f02 100644 --- a/ftdetect/json.vim +++ b/ftdetect/json.vim @@ -1,4 +1,5 @@ autocmd BufNewFile,BufRead *.json setlocal filetype=json +autocmd BufNewFile,BufRead *.jsonl setlocal filetype=json autocmd BufNewFile,BufRead *.jsonp setlocal filetype=json autocmd BufNewFile,BufRead *.geojson setlocal filetype=json autocmd BufNewFile,BufRead *.template setlocal filetype=json diff --git a/jsonl-test.jsonl b/jsonl-test.jsonl new file mode 100644 index 0000000..9720dd6 --- /dev/null +++ b/jsonl-test.jsonl @@ -0,0 +1,4 @@ +{"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} +{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]} +{"name": "May", "wins": []} +{"name": "Deloise", "wins": [["three of a kind", "5♣"]]} diff --git a/syntax/json.vim b/syntax/json.vim index 209d4c3..8d35609 100644 --- a/syntax/json.vim +++ b/syntax/json.vim @@ -71,10 +71,12 @@ if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1) syn match jsonTrailingCommaError ",\_s*[}\]]" " Syntax: Watch out for missing commas between elements - syn match jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/ - syn match jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values - syn match jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array - syn match jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value + syn match jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/ + syn match jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values + if (expand('%:e') !=? 'jsonl') + syn match jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array + endif + syn match jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value endif " ********************************************** END OF ERROR WARNINGS