annotate runtime/syntax/jsonc.vim @ 26773:80e134cbee4b v8.2.3915

patch 8.2.3915: illegal memory access when completing with invalid bytes Commit: https://github.com/vim/vim/commit/4b28ba3245df8274303c79429972f9dc9438e4aa Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 27 19:28:37 2021 +0000 patch 8.2.3915: illegal memory access when completing with invalid bytes Problem: illegal memory access when completing with invalid bytes. Solution: Avoid going over the end of the completion text.
author Bram Moolenaar <Bram@vim.org>
date Mon, 27 Dec 2021 20:30:03 +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