summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2015-07-18 22:54:07 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2015-07-18 22:54:07 +0200
commit9ab9275f66562de7d87df31ac8f2786981d770fd (patch)
tree81d0b5d52af0c98954f6fe340965f92fbe3916bf
parent1c80c4bb08ae250d2eb19aabe0f31c1b2bdf5097 (diff)
downloadvim-polyglot-9ab9275f66562de7d87df31ac8f2786981d770fd.tar.gz
vim-polyglot-9ab9275f66562de7d87df31ac8f2786981d770fd.zip
Add cjsx support
Diffstat (limited to '')
-rw-r--r--README.md1
-rw-r--r--after/ftplugin/coffee.vim5
-rw-r--r--after/jsx-config.vim66
-rw-r--r--after/syntax/coffee.vim27
-rwxr-xr-xbuild1
-rw-r--r--ftdetect/polyglot.vim4
6 files changed, 104 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9b1e7b6d..0e9e9d95 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [c/c++](https://github.com/vim-jp/cpp-vim) (syntax)
- [clojure](https://github.com/guns/vim-clojure-static) (syntax, indent, autoload, ftplugin, ftdetect)
- [coffee-script](https://github.com/kchmck/vim-coffee-script) (syntax, indent, compiler, autoload, ftplugin, ftdetect)
+- [cjsx](https://github.com/mtscout6/vim-cjsx) (ftdetect, syntax, ftplugin)
- [css](https://github.com/JulesWang/css.vim) (syntax)
- [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin, ftdetect)
- [dockerfile](https://github.com/honza/dockerfile.vim) (syntax, ftdetect)
diff --git a/after/ftplugin/coffee.vim b/after/ftplugin/coffee.vim
new file mode 100644
index 00000000..104948d1
--- /dev/null
+++ b/after/ftplugin/coffee.vim
@@ -0,0 +1,5 @@
+if exists("loaded_matchit")
+ let b:match_ignorecase = 0
+ let b:match_words = '(:),\[:\],{:},<:>,' .
+ \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
+endif
diff --git a/after/jsx-config.vim b/after/jsx-config.vim
index 5270a518..d617bb40 100644
--- a/after/jsx-config.vim
+++ b/after/jsx-config.vim
@@ -64,3 +64,69 @@ if !g:jsx_pragma_required | finish | endif
" anything else in the file (except whitespace).
let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw')
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Vimscript file
+"
+" Set up a bunch of configuration variables.
+"
+" Also check (if desired) whether or not the @jsx pragma is correctly included
+" in '%'. Set the result in b:jsx_pragma_found.
+"
+" Language: JSX (JavaScript)
+" Maintainer: Max Wang <mxawng@gmail.com>
+"
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+" Only check once.
+if exists('b:jsx_pragma_found')
+ finish
+endif
+
+" Whether the .jsx extension is required to enable JSX syntax/indent.
+if !exists('g:jsx_ext_required')
+ let g:jsx_ext_required = 1
+endif
+
+" Whether the @jsx pragma is required to enable JSX syntax/indent.
+if !exists('g:jsx_pragma_required')
+ let g:jsx_pragma_required = 0
+endif
+if !g:jsx_pragma_required | finish | endif
+
+" Look for the @jsx pragma. It must be included in a docblock comment before
+" anything else in the file (except whitespace).
+let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
+let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw')
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Vimscript file
+"
+" Set up a bunch of configuration variables.
+"
+" Also check (if desired) whether or not the @jsx pragma is correctly included
+" in '%'. Set the result in b:jsx_pragma_found.
+"
+" Language: JSX (JavaScript)
+" Maintainer: Max Wang <mxawng@gmail.com>
+"
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+" Only check once.
+if exists('b:jsx_pragma_found')
+ finish
+endif
+
+" Whether the .jsx extension is required to enable JSX syntax/indent.
+if !exists('g:jsx_ext_required')
+ let g:jsx_ext_required = 1
+endif
+
+" Whether the @jsx pragma is required to enable JSX syntax/indent.
+if !exists('g:jsx_pragma_required')
+ let g:jsx_pragma_required = 0
+endif
+if !g:jsx_pragma_required | finish | endif
+
+" Look for the @jsx pragma. It must be included in a docblock comment before
+" anything else in the file (except whitespace).
+let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
+let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw')
diff --git a/after/syntax/coffee.vim b/after/syntax/coffee.vim
new file mode 100644
index 00000000..64e0dc4f
--- /dev/null
+++ b/after/syntax/coffee.vim
@@ -0,0 +1,27 @@
+if exists('b:current_syntax')
+ let s:current_syntax=b:current_syntax
+ unlet b:current_syntax
+endif
+
+if exists('s:current_syntax')
+ let b:current_syntax=s:current_syntax
+endif
+
+syn match cjsxEntity contained "&[^; \t]*;" contains=cjsxEntityPunct
+syn match cjsxEntityPunct contained "[&.;]"
+
+syn match cjsxAttribProperty /[A-Za-z_][A-Za-z0-9_-]*/ contained
+syn region cjsxAttrib start=/\s[A-Za-z_][A-Za-z0-9_-]/hs=s+1 end=/=/ end=/\s[A-Za-z_]/me=e-2 end=+[/>]+me=e-1 contained contains=cjsxAttribProperty
+
+syn region cjsxBody start=+[^/]>+ms=s+2 start=/>/ms=s+1 end=+<\/+me=e-2 contained contains=cjsxElement,coffeeCurlies,cjsxEntity
+
+syn region cjsxElement start=/<@\=[A-Za-z_][A-Za-z0-9-_\.]*/ end=/\/>/ end=/<\/@\=[A-Za-z_][A-Za-z0-9-_\.]*>/ contains=cjsxOpenTag,cjsxBody,coffeeCurlies,coffeeString,cjsxAttrib,coffeeNumber,coffeeFloat
+
+syn cluster coffeeAll add=cjsxElement
+
+" The default highlighting.
+hi def link cjsxElement Function
+hi def link cjsxTagName Function
+hi def link cjsxEntity Statement
+hi def link cjsxEntityPunct Type
+hi def link cjsxAttribProperty Type
diff --git a/build b/build
index 065af518..120a3ddd 100755
--- a/build
+++ b/build
@@ -100,6 +100,7 @@ PACKS="
c/c++:vim-jp/cpp-vim
clojure:guns/vim-clojure-static
coffee-script:kchmck/vim-coffee-script
+ cjsx:mtscout6/vim-cjsx
css:JulesWang/css.vim
cucumber:tpope/vim-cucumber
dockerfile:honza/dockerfile.vim
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim
index 932dc349..5ecde6fc 100644
--- a/ftdetect/polyglot.vim
+++ b/ftdetect/polyglot.vim
@@ -1,5 +1,9 @@
au BufRead,BufNewFile *.ino,*.pde set filetype=arduino
au BufNewFile,BufRead *.blade.php set filetype=blade
+augroup CJSX
+ au!
+ autocmd BufNewFile,BufRead *.csx,*.cjsx set filetype=coffee
+augroup END
autocmd BufNewFile,BufRead *.clj,*.cljs,*.edn,*.cljx,*.cljc setlocal filetype=clojure
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
autocmd BufNewFile,BufRead *Cakefile set filetype=coffee