Mercurial > vim
annotate runtime/ftplugin/eruby.vim @ 19814:e7bbf6cadc9e v8.2.0464
patch 8.2.0464: typos and other small problems
Commit: https://github.com/vim/vim/commit/2d9d409ad4fab1ae7ceaecc0ef0e9b511d868374
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 27 20:52:45 2020 +0100
patch 8.2.0464: typos and other small problems
Problem: Typos and other small problems.
Solution: Fix the typos. Add missing file to distribution.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 27 Mar 2020 21:00:06 +0100 |
parents | f0f06837a699 |
children | 43593a5d873f |
rev | line source |
---|---|
529 | 1 " Vim filetype plugin |
831 | 2 " Language: eRuby |
2225 | 3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> |
4869 | 4 " URL: https://github.com/vim-ruby/vim-ruby |
831 | 5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
15512 | 6 " Last Change: 2019 Jan 06 |
529 | 7 |
8 " Only do this when not done yet for this buffer | |
1205 | 9 if exists("b:did_ftplugin") |
529 | 10 finish |
11 endif | |
12 | |
13 let s:save_cpo = &cpo | |
14 set cpo-=C | |
15 | |
16 " Define some defaults in case the included ftplugins don't set them. | |
17 let s:undo_ftplugin = "" | |
1205 | 18 let s:browsefilter = "All Files (*.*)\t*.*\n" |
529 | 19 let s:match_words = "" |
20 | |
1205 | 21 if !exists("g:eruby_default_subtype") |
22 let g:eruby_default_subtype = "html" | |
23 endif | |
24 | |
4869 | 25 if &filetype =~ '^eruby\.' |
26 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') | |
27 elseif !exists("b:eruby_subtype") | |
1205 | 28 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") |
29 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') | |
30 if b:eruby_subtype == '' | |
15512 | 31 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$') |
1205 | 32 endif |
33 if b:eruby_subtype == 'rhtml' | |
34 let b:eruby_subtype = 'html' | |
35 elseif b:eruby_subtype == 'rb' | |
36 let b:eruby_subtype = 'ruby' | |
37 elseif b:eruby_subtype == 'yml' | |
38 let b:eruby_subtype = 'yaml' | |
39 elseif b:eruby_subtype == 'js' | |
40 let b:eruby_subtype = 'javascript' | |
41 elseif b:eruby_subtype == 'txt' | |
42 " Conventional; not a real file type | |
43 let b:eruby_subtype = 'text' | |
44 elseif b:eruby_subtype == '' | |
45 let b:eruby_subtype = g:eruby_default_subtype | |
46 endif | |
47 endif | |
48 | |
15512 | 49 if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby' |
1205 | 50 exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" |
51 else | |
52 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim | |
53 endif | |
54 unlet! b:did_ftplugin | |
529 | 55 |
56 " Override our defaults if these were set by an included ftplugin. | |
57 if exists("b:undo_ftplugin") | |
1205 | 58 let s:undo_ftplugin = b:undo_ftplugin |
59 unlet b:undo_ftplugin | |
529 | 60 endif |
61 if exists("b:browsefilter") | |
1205 | 62 let s:browsefilter = b:browsefilter |
63 unlet b:browsefilter | |
529 | 64 endif |
65 if exists("b:match_words") | |
1205 | 66 let s:match_words = b:match_words |
67 unlet b:match_words | |
529 | 68 endif |
69 | |
15512 | 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 | |
529 | 85 runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim |
86 let b:did_ftplugin = 1 | |
87 | |
88 " Combine the new set of values with those previously included. | |
89 if exists("b:undo_ftplugin") | |
1205 | 90 let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin |
529 | 91 endif |
92 if exists ("b:browsefilter") | |
1205 | 93 let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter |
529 | 94 endif |
95 if exists("b:match_words") | |
1205 | 96 let s:match_words = b:match_words . ',' . s:match_words |
529 | 97 endif |
98 | |
15512 | 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 | |
107 | |
529 | 108 " Change the browse dialog on Win32 to show mainly eRuby-related files |
109 if has("gui_win32") | |
1205 | 110 let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter |
529 | 111 endif |
112 | |
113 " Load the combined list of match_words for matchit.vim | |
114 if exists("loaded_matchit") | |
1205 | 115 let b:match_words = s:match_words |
529 | 116 endif |
117 | |
118 " TODO: comments= | |
119 setlocal commentstring=<%#%s%> | |
120 | |
121 let b:undo_ftplugin = "setl cms< " | |
122 \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin | |
123 | |
124 let &cpo = s:save_cpo | |
3410
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
2225
diff
changeset
|
125 unlet s:save_cpo |
529 | 126 |
15512 | 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 | |
1620 | 132 " vim: nowrap sw=2 sts=2 ts=8: |