annotate runtime/indent/dylan.vim @ 28371:c3a7be75ef16 v8.2.4711

patch 8.2.4711: when 'insermode' is set :edit from <Cmd> mapping misbehaves Commit: https://github.com/vim/vim/commit/3a56b6d405fc0f1ca928b77382f97d0c552bea64 Author: zeertzjq <zeertzjq@outlook.com> Date: Fri Apr 8 11:56:14 2022 +0100 patch 8.2.4711: when 'insermode' is set :edit from <Cmd> mapping misbehaves Problem: When 'insermode' is set :edit from <Cmd> mapping misbehaves. Solution: Don't set "need_start_insertmode" when already in Insert mode. (closes #10116)
author Bram Moolenaar <Bram@vim.org>
date Fri, 08 Apr 2022 13:00:04 +0200
parents 9c221ad9634a
children 6dd88e45d47d
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
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
3 " Maintainer: Brent A. Fulgham <bfulgham@debian.org> (Invalid email address)
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
4 " Doug Kearns <dougkearns@gmail.com>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Version: 0.01
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
6 " Last Change: 2017 Jun 13
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 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
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " Define the appropriate indent function but only once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 setlocal indentexpr=DylanGetIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("*DylanGetIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 function DylanGetIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " Get the line to be indented
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let cline = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 " Don't reindent comments on first column
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 if cline =~ '^/\[/\*]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 "Find the previous non-blank line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 "Use zero indent at the top of the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let prevline=getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let chg = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " If previous line was a comment, use its indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if prevline =~ '^\s*//'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 " If previous line was a 'define', indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 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
49 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " local methods indent the shift-width, plus 6 for the 'local'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 elseif prevline =~? '^\s*local'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
52 let chg = shiftwidth() + 6
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " If previous line was a let with no closing semicolon, indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 elseif prevline =~? '^\s*let.*[^;]\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
55 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " If previous line opened a parenthesis, and did not close it, indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 elseif prevline =~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 return = match( prevline, '(.*\((.*)\|[^)]\)*.*$') + 1
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 elseif prevline =~ '^[^(]*)\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " This line closes a parenthesis. Find opening
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let curr_line = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 while curr_line >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let str = getline(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 if str !~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let curr_line = prevnonblank(curr_line - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 if curr_line < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 let ind = indent(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " Although we found the closing parenthesis, make sure this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " line doesn't start with an indentable command:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let curr_str = getline(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 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
79 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 " If a line starts with end, un-indent (even if we just indented!)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 if cline =~? '^\s*\(cleanup\|end\|else\|elseif\|exception\|finally\|otherwise\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
85 let chg = chg - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 return ind + chg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 " vim:sw=2 tw=130