annotate runtime/indent/perl6.vim @ 21753:9ef7ae8ab51c v8.2.1426

patch 8.2.1426: Vim9: cannot call autoload function in :def function Commit: https://github.com/vim/vim/commit/a177344dc0c337e5b272c1c59d13964a8318bcfa Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 12 15:21:22 2020 +0200 patch 8.2.1426: Vim9: cannot call autoload function in :def function Problem: Vim9: cannot call autoload function in :def function. Solution: Load the autoload script. (closes https://github.com/vim/vim/issues/6690)
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Aug 2020 15:30:04 +0200
parents bd021eb62e73
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
1 " Vim indent file
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
2 " Language: Perl 6
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
3 " Maintainer: vim-perl <vim-perl@googlegroups.com>
20115
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
4 " Homepage: https://github.com/vim-perl/vim-perl
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
5 " Bugs/requests: https://github.com/vim-perl/vim-perl/issues
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
6 " Last Change: 2020 Apr 15
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
7 " Contributors: Andy Lester <andy@petdance.com>
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
8 " Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
9 "
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
10 " Adapted from indent/perl.vim by Rafael Garcia-Suarez <rgarciasuarez@free.fr>
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
11
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
12 " Suggestions and improvements by :
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
13 " Aaron J. Sherman (use syntax for hints)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
14 " Artem Chuprina (play nice with folding)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
15 " TODO:
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
16 " This file still relies on stuff from the Perl 5 syntax file, which Perl 6
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
17 " does not use.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
18 "
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
19 " Things that are not or not properly indented (yet) :
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
20 " - Continued statements
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
21 " print "foo",
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
22 " "bar";
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
23 " print "foo"
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
24 " if bar();
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
25 " - Multiline regular expressions (m//x)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
26 " (The following probably needs modifying the perl syntax file)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
27 " - qw() lists
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
28 " - Heredocs with terminators that don't match \I\i*
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
29
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
30 " Only load this indent file when no other was loaded.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
31 if exists("b:did_indent")
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
32 finish
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
33 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
34 let b:did_indent = 1
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
35
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
36 " Is syntax highlighting active ?
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
37 let b:indent_use_syntax = has("syntax")
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
38
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
39 setlocal indentexpr=GetPerl6Indent()
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
40
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
41 " we reset it first because the Perl 5 indent file might have been loaded due
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
42 " to a .pl/pm file extension, and indent files don't clean up afterwards
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
43 setlocal indentkeys&
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
44
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
45 setlocal indentkeys+=0=,0),0],0>,0»,0=or,0=and
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
46 if !b:indent_use_syntax
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
47 setlocal indentkeys+=0=EO
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
48 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
49
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
50 let s:cpo_save = &cpo
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
51 set cpo-=C
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
52
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
53 function! GetPerl6Indent()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
54
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
55 " Get the line to be indented
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
56 let cline = getline(v:lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
57
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
58 " Indent POD markers to column 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
59 if cline =~ '^\s*=\L\@!'
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
60 return 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
61 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
62
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
63 " Don't reindent coments on first column
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
64 if cline =~ '^#'
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
65 return 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
66 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
67
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
68 " Get current syntax item at the line's first char
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
69 let csynid = ''
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
70 if b:indent_use_syntax
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
71 let csynid = synIDattr(synID(v:lnum,1,0),"name")
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
72 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
73
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
74 " Don't reindent POD and heredocs
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
75 if csynid =~ "^p6Pod"
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
76 return indent(v:lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
77 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
78
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
79
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
80 " Now get the indent of the previous perl line.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
81
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
82 " Find a non-blank line above the current line.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
83 let lnum = prevnonblank(v:lnum - 1)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
84 " Hit the start of the file, use zero indent.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
85 if lnum == 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
86 return 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
87 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
88 let line = getline(lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
89 let ind = indent(lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
90 " Skip heredocs, POD, and comments on 1st column
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
91 if b:indent_use_syntax
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
92 let skippin = 2
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
93 while skippin
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
94 let synid = synIDattr(synID(lnum,1,0),"name")
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
95 if (synid =~ "^p6Pod" || synid =~ "p6Comment")
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
96 let lnum = prevnonblank(lnum - 1)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
97 if lnum == 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
98 return 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
99 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
100 let line = getline(lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
101 let ind = indent(lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
102 let skippin = 1
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
103 else
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
104 let skippin = 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
105 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
106 endwhile
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
107 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
108
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
109 if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5277
diff changeset
110 let ind = ind + shiftwidth()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
111 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
112 if cline =~ '^\s*[)}\]»>]'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5277
diff changeset
113 let ind = ind - shiftwidth()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
114 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
115
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
116 " Indent lines that begin with 'or' or 'and'
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
117 if cline =~ '^\s*\(or\|and\)\>'
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
118 if line !~ '^\s*\(or\|and\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5277
diff changeset
119 let ind = ind + shiftwidth()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
120 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
121 elseif line =~ '^\s*\(or\|and\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5277
diff changeset
122 let ind = ind - shiftwidth()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
123 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
124
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
125 return ind
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
126
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
127 endfunction
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
128
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
129 let &cpo = s:cpo_save
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
130 unlet s:cpo_save
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
131
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
132 " vim:ts=8:sts=4:sw=4:expandtab:ft=vim