annotate vendor/vim-syntax/eruby.vim @ 633:f382ac2f585e

Update default indent for tsx
author nanaya <me@nanaya.pro>
date Tue, 17 Dec 2019 20:10:29 +0900
parents 0f0bdbd8d37d
children 6cdd7d26260d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
1 " Vim syntax file
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
2 " Language: eRuby
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
4 " URL: https://github.com/vim-ruby/vim-ruby
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
6 " Last Change: 2018 Jul 04
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
7
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
8 if &syntax !~# '\<eruby\>' || get(b:, 'current_syntax') =~# '\<eruby\>'
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
9 finish
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
10 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
11
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
12 if !exists("main_syntax")
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
13 let main_syntax = 'eruby'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
14 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
15
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
16 if !exists("g:eruby_default_subtype")
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
17 let g:eruby_default_subtype = "html"
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
18 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
19
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
20 if &filetype =~ '^eruby\.'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
21 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+')
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
22 elseif &filetype =~ '^.*\.eruby\>'
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
23 let b:eruby_subtype = matchstr(&filetype,'^.\{-\}\ze\.eruby\>')
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
24 elseif !exists("b:eruby_subtype") && main_syntax == 'eruby'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
25 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
26 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
27 if b:eruby_subtype == ''
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
28 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
29 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
30 if b:eruby_subtype == 'rhtml'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
31 let b:eruby_subtype = 'html'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
32 elseif b:eruby_subtype == 'rb'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
33 let b:eruby_subtype = 'ruby'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
34 elseif b:eruby_subtype == 'yml'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
35 let b:eruby_subtype = 'yaml'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
36 elseif b:eruby_subtype == 'js'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
37 let b:eruby_subtype = 'javascript'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
38 elseif b:eruby_subtype == 'txt'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
39 " Conventional; not a real file type
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
40 let b:eruby_subtype = 'text'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
41 elseif b:eruby_subtype == ''
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
42 let b:eruby_subtype = g:eruby_default_subtype
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
43 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
44 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
45
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
46 if !exists("b:eruby_nest_level")
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
47 if &syntax =~# '\<eruby\.eruby\>'
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
48 let b:eruby_nest_level = strlen(substitute(substitute(&filetype,'\C\<eruby\>','@','g'),'[^@]','','g'))
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
49 else
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
50 let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
51 endif
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
52 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
53 if !b:eruby_nest_level
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
54 let b:eruby_nest_level = 1
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
55 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
56
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
57 if get(b:, 'eruby_subtype', '') !~# '^\%(eruby\)\=$' && &syntax =~# '^eruby\>'
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
58 exe "runtime! syntax/".b:eruby_subtype.".vim"
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
59 endif
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
60 unlet! b:current_syntax
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
61 syn include @rubyTop syntax/ruby.vim
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
62
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
63 syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
64
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
65 exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend oneline'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
66 exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
67 exe 'syn region erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=\{1,4}" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
68 exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}-\=#" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=rubyTodo,@Spell containedin=ALLBUT,@erubyRegions keepend'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
69
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
70 " Define the default highlighting.
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
71
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
72 hi def link erubyDelimiter PreProc
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
73 hi def link erubyComment Comment
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
74
623
0f0bdbd8d37d Update syntax files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
75 let b:current_syntax = matchstr(&syntax, '^.*\<eruby\>')
508
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
76
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
77 if main_syntax == 'eruby'
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
78 unlet main_syntax
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
79 endif
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
80
bbcffc594d1e Vendor what should be vendored and add some more.
edogawaconan <me@myconan.net>
parents:
diff changeset
81 " vim: nowrap sw=2 sts=2 ts=8: