summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-12-30 12:13:50 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2020-12-30 12:13:50 +0100
commit8af4f8e6c04b163d39de4327fca7f69cce78c0ab (patch)
tree23f7dff144bd3cfe95d298245b5017ebadd2c30c
parente5668602cc89f3298a1ab936b082e82519aa6a50 (diff)
downloadvim-polyglot-8af4f8e6c04b163d39de4327fca7f69cce78c0ab.tar.gz
vim-polyglot-8af4f8e6c04b163d39de4327fca7f69cce78c0ab.zip
Add jsonc, closes #635
-rw-r--r--README.md3
-rw-r--r--autoload/polyglot/sleuth.vim1
-rw-r--r--ftdetect/polyglot.vim4
-rw-r--r--indent/jsonc.vim5
-rw-r--r--packages.yaml8
-rw-r--r--syntax/jsonc.vim61
-rw-r--r--tests/filetypes.vim1
7 files changed, 82 insertions, 1 deletions
diff --git a/README.md b/README.md
index e88ed3dc..c6f537b4 100644
--- a/README.md
+++ b/README.md
@@ -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)
diff --git a/autoload/polyglot/sleuth.vim b/autoload/polyglot/sleuth.vim
index 155ae0b5..2fb3b827 100644
--- a/autoload/polyglot/sleuth.vim
+++ b/autoload/polyglot/sleuth.vim
@@ -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',
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim
index 29a4a2c7..85c933e3 100644
--- a/ftdetect/polyglot.vim
+++ b/ftdetect/polyglot.vim
@@ -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
diff --git a/indent/jsonc.vim b/indent/jsonc.vim
new file mode 100644
index 00000000..baffdae8
--- /dev/null
+++ b/indent/jsonc.vim
@@ -0,0 +1,5 @@
+if has_key(g:polyglot_is_disabled, 'jsonc')
+ finish
+endif
+
+runtime! indent/json.vim
diff --git a/packages.yaml b/packages.yaml
index dc127f28..a1bf7d40 100644
--- a/packages.yaml
+++ b/packages.yaml
@@ -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/)'
diff --git a/syntax/jsonc.vim b/syntax/jsonc.vim
new file mode 100644
index 00000000..49c14bcc
--- /dev/null
+++ b/syntax/jsonc.vim
@@ -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
diff --git a/tests/filetypes.vim b/tests/filetypes.vim
index 08d4cb93..3b71ac76 100644
--- a/tests/filetypes.vim
+++ b/tests/filetypes.vim
@@ -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