annotate runtime/indent/eruby.vim @ 27269:24da57a079ef v8.2.4163

patch 8.2.4163: no error for omitting function name after autoload prefix Commit: https://github.com/vim/vim/commit/2017d6f3b1d523204e5471e941cfa687b4da0058 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 20 19:38:46 2022 +0000 patch 8.2.4163: no error for omitting function name after autoload prefix Problem: No error for omitting function name after autoload prefix. Solution: Check for missing function name. (issue https://github.com/vim/vim/issues/9577)
author Bram Moolenaar <Bram@vim.org>
date Thu, 20 Jan 2022 20:45:04 +0100
parents f0f06837a699
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
1 " Vim indent file
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
2 " Language: eRuby
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
4 " URL: https://github.com/vim-ruby/vim-ruby
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 557
diff changeset
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
15512
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
6 " Last Change: 2019 Jan 06
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
7
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
8 if exists("b:did_indent")
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
9 finish
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
10 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
11
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
12 runtime! indent/ruby.vim
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
13 unlet! b:did_indent
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
14 setlocal indentexpr=
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
15
15512
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
16 if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=# 'eruby'
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
17 exe "runtime! indent/".b:eruby_subtype.".vim"
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
18 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
19 runtime! indent/html.vim
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
20 endif
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
21 unlet! b:did_indent
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
22
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
23 " Force HTML indent to not keep state.
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
24 let b:html_indent_usestate = 0
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
25
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
26 if &l:indentexpr == ''
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
27 if &l:cindent
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
28 let &l:indentexpr = 'cindent(v:lnum)'
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
29 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
30 let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
31 endif
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
32 endif
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
33 let b:eruby_subtype_indentexpr = &l:indentexpr
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
34
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
35 let b:did_indent = 1
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
36
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
37 setlocal indentexpr=GetErubyIndent()
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
38 setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
39
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
40 " Only define the function once.
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
41 if exists("*GetErubyIndent")
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
42 finish
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
43 endif
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 557
diff changeset
44
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
45 " this file uses line continuations
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
46 let s:cpo_sav = &cpo
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
47 set cpo&vim
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
48
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
49 function! GetErubyIndent(...)
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
50 " The value of a single shift-width
15512
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
51 if exists('*shiftwidth')
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
52 let sw = shiftwidth()
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
53 else
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
54 let sw = &sw
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
55 endif
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
56
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
57 if a:0 && a:1 == '.'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
58 let v:lnum = line('.')
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
59 elseif a:0 && a:1 =~ '^\d'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
60 let v:lnum = a:1
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
61 endif
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
62 let vcol = col('.')
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
63 call cursor(v:lnum,1)
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1200
diff changeset
64 let inruby = searchpair('<%','','%>','W')
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
65 call cursor(v:lnum,vcol)
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
66 if inruby && getline(v:lnum) !~ '^<%\|^\s*[-=]\=%>'
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
67 let ind = GetRubyIndent(v:lnum)
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
68 else
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
69 exe "let ind = ".b:eruby_subtype_indentexpr
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
70
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
71 " Workaround for Andy Wokula's HTML indent. This should be removed after
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
72 " some time, since the newest version is fixed in a different way.
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
73 if b:eruby_subtype_indentexpr =~# '^HtmlIndent('
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
74 \ && exists('b:indent')
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
75 \ && type(b:indent) == type({})
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
76 \ && has_key(b:indent, 'lnum')
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
77 " Force HTML indent to not keep state
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
78 let b:indent.lnum = -1
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
79 endif
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
80 endif
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
81 let lnum = prevnonblank(v:lnum-1)
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
82 let line = getline(lnum)
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 1121
diff changeset
83 let cline = getline(v:lnum)
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
84 if cline =~# '^\s*<%[-=]\=\s*\%(}\|end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%([-=]\=%>\|$\)'
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
85 let ind = ind - sw
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
86 endif
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
87 if line =~# '\S\s*<%[-=]\=\s*\%(}\|end\).\{-\}\s*\%([-=]\=%>\|$\)'
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
88 let ind = ind - sw
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
89 endif
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
90 if line =~# '\%({\|\<do\)\%(\s*|[^|]*|\)\=\s*[-=]\=%>'
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
91 let ind = ind + sw
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
92 elseif line =~# '<%[-=]\=\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>'
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
93 let ind = ind + sw
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
94 endif
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
95 if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>'
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
96 let ind = ind + sw
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
97 endif
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
98 if line !~# '^\s*<%' && line =~# '%>\s*$' && line !~# '^\s*end\>'
15512
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
99 \ && synID(v:lnum, match(cline, '\S') + 1, 1) != hlID('htmlEndTag')
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
100 let ind = ind - sw
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
101 endif
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2225
diff changeset
102 if cline =~# '^\s*[-=]\=%>\s*$'
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
103 let ind = ind - sw
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
104 endif
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
105 return ind
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
106 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents: 831
diff changeset
107
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
108 let &cpo = s:cpo_sav
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
109 unlet! s:cpo_sav
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4869
diff changeset
110
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1200
diff changeset
111 " vim:set sw=2 sts=2 ts=8 noet: