Mercurial > vim
comparison runtime/ftplugin/eruby.vim @ 15512:f0f06837a699
Update runtime files.
commit https://github.com/vim/vim/commit/d09091d4955c5f41de69928f2db85611ed54ed23
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 17 16:07:22 2019 +0100
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 17 Jan 2019 16:15:08 +0100 |
parents | 43efa4f5a8ea |
children | 43593a5d873f |
comparison
equal
deleted
inserted
replaced
15511:f41122780189 | 15512:f0f06837a699 |
---|---|
1 " Vim filetype plugin | 1 " Vim filetype plugin |
2 " Language: eRuby | 2 " Language: eRuby |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | 3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> |
4 " URL: https://github.com/vim-ruby/vim-ruby | 4 " URL: https://github.com/vim-ruby/vim-ruby |
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> | 5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
6 " Last Change: 2019 Jan 06 | |
6 | 7 |
7 " Only do this when not done yet for this buffer | 8 " Only do this when not done yet for this buffer |
8 if exists("b:did_ftplugin") | 9 if exists("b:did_ftplugin") |
9 finish | 10 finish |
10 endif | 11 endif |
25 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') | 26 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') |
26 elseif !exists("b:eruby_subtype") | 27 elseif !exists("b:eruby_subtype") |
27 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") | 28 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") |
28 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') | 29 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') |
29 if b:eruby_subtype == '' | 30 if b:eruby_subtype == '' |
30 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$') | 31 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$') |
31 endif | 32 endif |
32 if b:eruby_subtype == 'rhtml' | 33 if b:eruby_subtype == 'rhtml' |
33 let b:eruby_subtype = 'html' | 34 let b:eruby_subtype = 'html' |
34 elseif b:eruby_subtype == 'rb' | 35 elseif b:eruby_subtype == 'rb' |
35 let b:eruby_subtype = 'ruby' | 36 let b:eruby_subtype = 'ruby' |
43 elseif b:eruby_subtype == '' | 44 elseif b:eruby_subtype == '' |
44 let b:eruby_subtype = g:eruby_default_subtype | 45 let b:eruby_subtype = g:eruby_default_subtype |
45 endif | 46 endif |
46 endif | 47 endif |
47 | 48 |
48 if exists("b:eruby_subtype") && b:eruby_subtype != '' | 49 if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby' |
49 exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" | 50 exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" |
50 else | 51 else |
51 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim | 52 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim |
52 endif | 53 endif |
53 unlet! b:did_ftplugin | 54 unlet! b:did_ftplugin |
64 if exists("b:match_words") | 65 if exists("b:match_words") |
65 let s:match_words = b:match_words | 66 let s:match_words = b:match_words |
66 unlet b:match_words | 67 unlet b:match_words |
67 endif | 68 endif |
68 | 69 |
70 let s:cfilemap = v:version >= 704 ? maparg('<Plug><cfile>', 'c', 0, 1) : {} | |
71 if !get(s:cfilemap, 'buffer') || !s:cfilemap.expr || s:cfilemap.rhs =~# 'ErubyAtCursor()' | |
72 let s:cfilemap = {} | |
73 endif | |
74 if !has_key(s:cfilemap, 'rhs') | |
75 let s:cfilemap.rhs = "substitute(&l:inex =~# '\\<v:fname\\>' && len(expand('<cfile>')) ? eval(substitute(&l:inex, '\\<v:fname\\>', '\\=string(expand(\"<cfile>\"))', 'g')) : '', '^$', \"\\022\\006\",'')" | |
76 endif | |
77 let s:ctagmap = v:version >= 704 ? maparg('<Plug><ctag>', 'c', 0, 1) : {} | |
78 if !get(s:ctagmap, 'buffer') || !s:ctagmap.expr || s:ctagmap.rhs =~# 'ErubyAtCursor()' | |
79 let s:ctagmap = {} | |
80 endif | |
81 let s:include = &l:include | |
82 let s:path = &l:path | |
83 let s:suffixesadd = &l:suffixesadd | |
84 | |
69 runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim | 85 runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim |
70 let b:did_ftplugin = 1 | 86 let b:did_ftplugin = 1 |
71 | 87 |
72 " Combine the new set of values with those previously included. | 88 " Combine the new set of values with those previously included. |
73 if exists("b:undo_ftplugin") | 89 if exists("b:undo_ftplugin") |
77 let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter | 93 let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter |
78 endif | 94 endif |
79 if exists("b:match_words") | 95 if exists("b:match_words") |
80 let s:match_words = b:match_words . ',' . s:match_words | 96 let s:match_words = b:match_words . ',' . s:match_words |
81 endif | 97 endif |
98 | |
99 if len(s:include) | |
100 let &l:include = s:include | |
101 endif | |
102 let &l:path = s:path . (s:path =~# ',$\|^$' ? '' : ',') . &l:path | |
103 let &l:suffixesadd = s:suffixesadd . (s:suffixesadd =~# ',$\|^$' ? '' : ',') . &l:suffixesadd | |
104 exe 'cmap <buffer><script><expr> <Plug><cfile> ErubyAtCursor() ? ' . maparg('<Plug><cfile>', 'c') . ' : ' . s:cfilemap.rhs | |
105 exe 'cmap <buffer><script><expr> <Plug><ctag> ErubyAtCursor() ? ' . maparg('<Plug><ctag>', 'c') . ' : ' . get(s:ctagmap, 'rhs', '"\022\027"') | |
106 unlet s:cfilemap s:ctagmap s:include s:path s:suffixesadd | |
82 | 107 |
83 " Change the browse dialog on Win32 to show mainly eRuby-related files | 108 " Change the browse dialog on Win32 to show mainly eRuby-related files |
84 if has("gui_win32") | 109 if has("gui_win32") |
85 let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter | 110 let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter |
86 endif | 111 endif |
97 \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin | 122 \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin |
98 | 123 |
99 let &cpo = s:save_cpo | 124 let &cpo = s:save_cpo |
100 unlet s:save_cpo | 125 unlet s:save_cpo |
101 | 126 |
127 function! ErubyAtCursor() abort | |
128 let groups = map(['erubyBlock', 'erubyComment', 'erubyExpression', 'erubyOneLiner'], 'hlID(v:val)') | |
129 return !empty(filter(synstack(line('.'), col('.')), 'index(groups, v:val) >= 0')) | |
130 endfunction | |
131 | |
102 " vim: nowrap sw=2 sts=2 ts=8: | 132 " vim: nowrap sw=2 sts=2 ts=8: |