annotate runtime/syntax/jsonc.vim @ 34378:4d02bc6ddd97

runtime(doc): Add a place holder section for version 9.2 (#14060) Commit: https://github.com/vim/vim/commit/15935e7f54f0e00782a55ebc39a68e4cd94c2571 Author: Yegappan Lakshmanan <4298407+yegappan@users.noreply.github.com> Date: Tue Feb 20 10:48:22 2024 -0800 runtime(doc): Add a place holder section for version 9.2 (https://github.com/vim/vim/issues/14060) Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 20 Feb 2024 20:00:08 +0100
parents 84c7dc0fdcd2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Vim syntax file
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " Language: JSONC (JSON with Comments)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 " Original Author: Izhak Jakov <izhak724@gmail.com>
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 " Acknowledgement: Based off of vim-jsonc maintained by Kevin Locke <kevin@kevinlocke.name>
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " https://github.com/kevinoid/vim-jsonc
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 " License: MIT
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 " Last Change: 2021-07-01
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 " Ensure syntax is loaded once, unless nested inside another (main) syntax
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 " For description of main_syntax, see https://stackoverflow.com/q/16164549
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 if !exists('g:main_syntax')
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 if exists('b:current_syntax') && b:current_syntax ==# 'jsonc'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 finish
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 let g:main_syntax = 'jsonc'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 " Based on vim-json syntax
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 runtime! syntax/json.vim
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 " Remove syntax group for comments treated as errors
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 if !exists("g:vim_json_warnings") || g:vim_json_warnings
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 syn clear jsonCommentError
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze\(\_s*\/\/.*\_s*\)*[}\]]/ contains=jsonString
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze\_s*\/\*\_.*\*\/\_s*[}\]]/ contains=jsonString
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 syn match jsonTrailingCommaError /\(,\)\+\ze\(\_s*\/\/.*\_s*\)*[}\]]/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 syn match jsonTrailingCommaError /\(,\)\+\ze\_s*\/\*\_.*\*\/\_s*[}\]]/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 " Define syntax matching comments and their contents
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 syn keyword jsonCommentTodo FIXME NOTE TBD TODO XXX
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 syn region jsonLineComment start=+\/\/+ end=+$+ contains=@Spell,jsonCommentTodo keepend
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 syn region jsonComment start='/\*' end='\*/' contains=@Spell,jsonCommentTodo fold
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 " Link comment syntax comment to highlighting
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 hi! def link jsonLineComment Comment
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 hi! def link jsonComment Comment
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 " Set/Unset syntax to avoid duplicate inclusion and correctly handle nesting
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 let b:current_syntax = 'jsonc'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 if g:main_syntax ==# 'jsonc'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 unlet g:main_syntax
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 endif