mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Add jsonc, closes #635
This commit is contained in:
@@ -7,7 +7,7 @@ A collection of language packs for Vim.
|
||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||
|
||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->600<!--/Package Count--> packages it consists of.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->601<!--/Package Count--> packages it consists of.
|
||||
- It is also more secure (scripts loaded for every filetype are generated by vim-polyglot)
|
||||
- Best syntax and indentation support (no other features). Hand-selected language packs.
|
||||
- Automatically detects indentation (includes performance-optimized version of [vim-sleuth](https://github.com/tpope/vim-sleuth), can be disabled)
|
||||
@@ -111,6 +111,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr
|
||||
- [jq](https://github.com/vito-c/jq.vim) (JSONiq syntax highlighting for jq files)
|
||||
- [json5](https://github.com/GutenYe/json5.vim) (JSON5 syntax highlighting for json5 files)
|
||||
- [json](https://github.com/elzr/vim-json) (JSON syntax highlighting for json, avsc, geojson, gltf, har and 13 more files)
|
||||
- [jsonc](https://github.com/neoclide/jsonc.vim) (Syntax highlighting for cjson and jsonc files)
|
||||
- [jsonnet](https://github.com/google/vim-jsonnet) (Jsonnet syntax highlighting for jsonnet and libsonnet files)
|
||||
- [jst](https://github.com/briancollins/vim-jst) (EJS syntax highlighting for ejs, ect and jst files)
|
||||
- [jsx](https://github.com/MaxMEllon/vim-jsx-pretty) (JSX syntax highlighting for jsx files)
|
||||
|
||||
@@ -263,6 +263,7 @@ let s:globs = {
|
||||
\ 'jq': '*.jq,.jqrc,.jqrc*',
|
||||
\ 'json': '*.json,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.JSON-tmLanguage,*.jsonl,*.mcmeta,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,*.jsonp,*.template,.arcconfig,.htmlhintrc,.tern-config,.tern-project,.watchmanconfig,composer.lock,mcmod.info,Pipfile.lock',
|
||||
\ 'json5': '*.json5',
|
||||
\ 'jsonc': '*.cjson,*.jsonc,coc-settings.json,.eslintrc.json,.babelrc,.jshintrc,.jslintrc,.mocharc.json,coffeelint.json,tsconfig.json,jsconfig.json',
|
||||
\ 'jsonnet': '*.jsonnet,*.libsonnet',
|
||||
\ 'jsp': '*.jsp',
|
||||
\ 'jst': '*.ejs,*.ect,*.jst',
|
||||
|
||||
@@ -142,6 +142,10 @@ set cpo&vim
|
||||
|
||||
" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE
|
||||
|
||||
if !has_key(g:polyglot_is_disabled, 'jsonc')
|
||||
au BufNewFile,BufRead *.cjson,*.jsonc,{.,}babelrc,{.,}eslintrc.json,{.,}jshintrc,{.,}jslintrc,{.,}mocharc.json,coc-settings.json,coffeelint.json,jsconfig.json,tsconfig.json setf jsonc
|
||||
endif
|
||||
|
||||
if !has_key(g:polyglot_is_disabled, 'mint')
|
||||
au BufNewFile,BufRead *.mint setf mint
|
||||
endif
|
||||
|
||||
5
indent/jsonc.vim
Normal file
5
indent/jsonc.vim
Normal file
@@ -0,0 +1,5 @@
|
||||
if has_key(g:polyglot_is_disabled, 'jsonc')
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime! indent/json.vim
|
||||
@@ -5554,3 +5554,11 @@ filetypes:
|
||||
patterns:
|
||||
- pattern: '*.mint'
|
||||
description: Mint (https://www.mint-lang.com/)
|
||||
---
|
||||
name: jsonc
|
||||
remote: neoclide/jsonc.vim
|
||||
filetypes:
|
||||
- name: jsonc
|
||||
patterns:
|
||||
- pattern: '*.cjson,coc-settings.json,*.jsonc,.eslintrc.json,.babelrc,.jshintrc,.jslintrc,.mocharc.json,coffeelint.json,tsconfig.json,jsconfig.json'
|
||||
description: 'JSON with comments (https://komkom.github.io/)'
|
||||
|
||||
61
syntax/jsonc.vim
Normal file
61
syntax/jsonc.vim
Normal file
@@ -0,0 +1,61 @@
|
||||
if has_key(g:polyglot_is_disabled, 'jsonc')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Syntax setup {{{1
|
||||
if exists('b:current_syntax') && b:current_syntax == 'jsonc'
|
||||
finish
|
||||
endif
|
||||
|
||||
" Syntax: Strings {{{1
|
||||
syn region jsoncString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=jsoncEscape
|
||||
syn region jsoncString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=jsoncEscape
|
||||
|
||||
" Syntax: JSON Keywords {{{1
|
||||
" Separated into a match and region because a region by itself is always greedy
|
||||
syn match jsoncKeywordMatch /"\([^"]\|\\\"\)\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword
|
||||
|
||||
" Syntax: Escape sequences
|
||||
syn match jsoncEscape "\\["\\/bfnrt]" contained
|
||||
syn match jsoncEscape "\\u\x\{4}" contained
|
||||
|
||||
" Syntax: Numbers {{{1
|
||||
syn match jsoncNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>"
|
||||
syn keyword jsoncNumber Infinity -Infinity
|
||||
|
||||
" Syntax: An integer part of 0 followed by other digits is not allowed.
|
||||
syn match jsoncNumError "-\=\<0\d\.\d*\>"
|
||||
|
||||
" Syntax: Boolean {{{1
|
||||
syn keyword jsoncBoolean true false
|
||||
|
||||
" Syntax: Null {{{1
|
||||
syn keyword jsoncNull null
|
||||
|
||||
" Syntax: Braces {{{1
|
||||
syn match jsoncBraces "[{}\[\]]"
|
||||
syn match jsoncObjAssign /@\?\%(\I\|\$\)\%(\i\|\$\)*\s*\ze::\@!/
|
||||
|
||||
" Syntax: Comment {{{1
|
||||
syn region jsoncLineComment start=+\/\/+ end=+$+ keepend
|
||||
syn region jsoncLineComment start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend fold
|
||||
syn region jsoncComment start="/\*" end="\*/" fold
|
||||
|
||||
" Define the default highlighting. {{{1
|
||||
hi def link jsoncString String
|
||||
hi def link jsoncObjAssign Identifier
|
||||
hi def link jsoncEscape Special
|
||||
hi def link jsoncNumber Number
|
||||
hi def link jsoncBraces Operator
|
||||
hi def link jsoncNull Function
|
||||
hi def link jsoncBoolean Boolean
|
||||
hi def link jsoncLineComment Comment
|
||||
hi def link jsoncComment Comment
|
||||
hi def link jsoncNumError Error
|
||||
hi def link jsoncKeywordMatch Label
|
||||
|
||||
if !exists('b:current_syntax')
|
||||
let b:current_syntax = 'jsonc'
|
||||
endif
|
||||
|
||||
" vim: fdm=marker
|
||||
@@ -645,6 +645,7 @@ call TestFiletype('xpm')
|
||||
call TestFiletype('xpm2')
|
||||
call TestFiletype('context')
|
||||
call TestFiletype('mint')
|
||||
call TestFiletype('jsonc')
|
||||
|
||||
" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user