annotate runtime/indent/dylan.vim @ 25386:9c749ad22565 v8.2.3230

patch 8.2.3230: Vim9: type error when function return type is not known yet Commit: https://github.com/vim/vim/commit/f723701de0636ad8b4aad6179b322f72b04354b9 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 27 22:21:44 2021 +0200 patch 8.2.3230: Vim9: type error when function return type is not known yet Problem: Vim9: type error when function return type is not known yet. Solution: When return type is unknown, use "any". (closes https://github.com/vim/vim/issues/8644)
author Bram Moolenaar <Bram@vim.org>
date Tue, 27 Jul 2021 22:30:03 +0200
parents 63b0b7b79b25
children 9c221ad9634a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Dylan
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Version: 0.01
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
4 " Last Change: 2017 Jun 13
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Maintainer: Brent A. Fulgham <bfulgham@debian.org>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 setlocal indentkeys+==~begin,=~block,=~case,=~cleanup,=~define,=~end,=~else,=~elseif,=~exception,=~for,=~finally,=~if,=~otherwise,=~select,=~unless,=~while
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " Define the appropriate indent function but only once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 setlocal indentexpr=DylanGetIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 if exists("*DylanGetIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 function DylanGetIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 " Get the line to be indented
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 let cline = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " Don't reindent comments on first column
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 if cline =~ '^/\[/\*]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 "Find the previous non-blank line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 "Use zero indent at the top of the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 let prevline=getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let chg = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 " If previous line was a comment, use its indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 if prevline =~ '^\s*//'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " If previous line was a 'define', indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if prevline =~? '\(^\s*\(begin\|block\|case\|define\|else\|elseif\|for\|finally\|if\|select\|unless\|while\)\|\s*\S*\s*=>$\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
48 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " local methods indent the shift-width, plus 6 for the 'local'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 elseif prevline =~? '^\s*local'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
51 let chg = shiftwidth() + 6
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " If previous line was a let with no closing semicolon, indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 elseif prevline =~? '^\s*let.*[^;]\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
54 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " If previous line opened a parenthesis, and did not close it, indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 elseif prevline =~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 return = match( prevline, '(.*\((.*)\|[^)]\)*.*$') + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 "elseif prevline =~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 elseif prevline =~ '^[^(]*)\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " This line closes a parenthesis. Find opening
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 let curr_line = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 while curr_line >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 let str = getline(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 if str !~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let curr_line = prevnonblank(curr_line - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 if curr_line < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 let ind = indent(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " Although we found the closing parenthesis, make sure this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " line doesn't start with an indentable command:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 let curr_str = getline(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if curr_str =~? '^\s*\(begin\|block\|case\|define\|else\|elseif\|for\|finally\|if\|select\|unless\|while\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
78 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 " If a line starts with end, un-indent (even if we just indented!)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 if cline =~? '^\s*\(cleanup\|end\|else\|elseif\|exception\|finally\|otherwise\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
84 let chg = chg - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 return ind + chg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 " vim:sw=2 tw=130