From 8f0d87271de5f99bac7078ebcd123c66a4e31dbb Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Fri, 22 Jan 2016 09:28:22 +0900 Subject: [PATCH] Add requirement of json syntax Ubuntu vim package does not have json syntax. --- Makefile | 8 ++++++-- README.md | 2 ++ syntax/markdown.vim | 10 +++++++--- test/run-tests.sh | 2 +- test/vimrc | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a50adc0..231c0af 100644 --- a/Makefile +++ b/Makefile @@ -18,13 +18,14 @@ install: mkdir -pv ${REGISTRY} cp -v registry/markdown.yaml ${REGISTRY}/markdown.yaml -test: build/tabular build/vim-toml build/vader.vim +test: build/tabular build/vim-toml build/vim-json build/vader.vim test/run-tests.sh .PHONY: test -update: build/tabular build/vim-toml build/vader.vim +update: build/tabular build/vim-toml build/vim-json build/vader.vim cd build/tabular && git pull cd build/vim-toml && git pull + cd build/vim-json && git pull cd build/vader.vim && git pull .PHONY: update @@ -34,6 +35,9 @@ build/tabular: | build build/vim-toml: | build git clone https://github.com/cespare/vim-toml build/vim-toml +build/vim-json: | build + git clone https://github.com/elzr/vim-json build/vim-json + build/vader.vim: | build git clone https://github.com/junegunn/vader.vim build/vader.vim diff --git a/README.md b/README.md index 60c58ec..6780572 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,8 @@ let g:vim_markdown_toml_frontmatter = 1 Highlight JSON front matter as used by [Hugo](https://gohugo.io/content/front-matter/). +JSON syntax highlight requires [vim-json](https://github.com/elzr/vim-json). + ```vim let g:vim_markdown_json_frontmatter = 1 ``` diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 05cf751..186216e 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -124,9 +124,13 @@ if get(g:, 'vim_markdown_toml_frontmatter', 0) endif if get(g:, 'vim_markdown_json_frontmatter', 0) - syn include @jsonTop syntax/json.vim - syn region Comment matchgroup=mkdDelimiter start="\%^{$" end="^}$" contains=@jsonTop - unlet! b:current_syntax + try + syn include @jsonTop syntax/json.vim + syn region Comment matchgroup=mkdDelimiter start="\%^{$" end="^}$" contains=@jsonTop + unlet! b:current_syntax + catch /E484/ + syn region Comment matchgroup=mkdDelimiter start="\%^{$" end="^}$" + endtry endif if get(g:, 'vim_markdown_math', 0) diff --git a/test/run-tests.sh b/test/run-tests.sh index ba00fc0..5c9db06 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -5,7 +5,7 @@ set -e cd "$( dirname "${BASH_SOURCE[0]}" )" -for dep in ../build/tabular ../build/vim-toml ../build/vader.vim; do +for dep in ../build/tabular ../build/vim-toml ../build/vim-json ../build/vader.vim; do if [[ ! -d $dep ]]; then echo "Missing dependency: $dep" echo "You may just want to use 'make test'." diff --git a/test/vimrc b/test/vimrc index 015febf..463cbd8 100644 --- a/test/vimrc +++ b/test/vimrc @@ -2,6 +2,7 @@ set nocompatible set rtp+=../ set rtp+=../build/tabular/ set rtp+=../build/vim-toml/ +set rtp+=../build/vim-json/ set rtp+=../build/vader.vim/ let $LANG='en_US' filetype on -- 2.39.5