annotate runtime/indent/dylan.vim @ 32208:73c5881c1793 v9.0.1435

patch 9.0.1435: scrolling too many lines when 'wrap' and 'diff' are set Commit: https://github.com/vim/vim/commit/38d867f041349e1400c2cce9cac06f59ae6ccbb1 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 1 19:54:40 2023 +0100 patch 9.0.1435: scrolling too many lines when 'wrap' and 'diff' are set Problem: Scrolling too many lines when 'wrap' and 'diff' are set. Solution: Only scroll by screenlines for 'diff' when 'wrap' is not set. (closes #12211)
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Apr 2023 21:00:04 +0200
parents 6dd88e45d47d
children
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
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
6 " Last Change: 2022 Apr 06
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()
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
18
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
19 let b:undo_indent = "setl inde< indk<"
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
20
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if exists("*DylanGetIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 function DylanGetIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 " Get the line to be indented
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let cline = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Don't reindent comments on first column
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 if cline =~ '^/\[/\*]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 "Find the previous non-blank line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 "Use zero indent at the top of the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 let prevline=getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 let chg = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " If previous line was a comment, use its indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 if prevline =~ '^\s*//'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " If previous line was a 'define', indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 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
52 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " local methods indent the shift-width, plus 6 for the 'local'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 elseif prevline =~? '^\s*local'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
55 let chg = shiftwidth() + 6
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " If previous line was a let with no closing semicolon, indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 elseif prevline =~? '^\s*let.*[^;]\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
58 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " If previous line opened a parenthesis, and did not close it, indent
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 return = match( prevline, '(.*\((.*)\|[^)]\)*.*$') + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 "elseif prevline =~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 elseif prevline =~ '^[^(]*)\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " This line closes a parenthesis. Find opening
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let curr_line = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 while curr_line >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 let str = getline(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 if str !~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 let curr_line = prevnonblank(curr_line - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 if curr_line < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let ind = indent(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " Although we found the closing parenthesis, make sure this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 " line doesn't start with an indentable command:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let curr_str = getline(curr_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 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
82 let chg = shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 " If a line starts with end, un-indent (even if we just indented!)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 if cline =~? '^\s*\(cleanup\|end\|else\|elseif\|exception\|finally\|otherwise\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
88 let chg = chg - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 return ind + chg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 " vim:sw=2 tw=130