Mercurial > vim
annotate runtime/indent/raku.vim @ 24649:31a7fa6b2e93 v8.2.2863
patch 8.2.2863: removing a text property does not redraw optimally
Commit: https://github.com/vim/vim/commit/965c04486c9364ded99b49c86f4c41228503df1f
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 17 00:22:06 2021 +0200
patch 8.2.2863: removing a text property does not redraw optimally
Problem: Removing a text property does not redraw optimally.
Solution: Only redraw the lines that mithg actually have been changed.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 May 2021 00:30:04 +0200 |
parents | 5bda4653aced |
children | 5c220cf30f1f |
rev | line source |
---|---|
2152 | 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 | 4 " Homepage: https://github.com/vim-perl/vim-perl |
5 " Bugs/requests: https://github.com/vim-perl/vim-perl/issues | |
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 | 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 | 11 |
12 " Suggestions and improvements by : | |
13 " Aaron J. Sherman (use syntax for hints) | |
14 " Artem Chuprina (play nice with folding) | |
15 " TODO: | |
16 " This file still relies on stuff from the Perl 5 syntax file, which Perl 6 | |
17 " does not use. | |
18 " | |
19 " Things that are not or not properly indented (yet) : | |
20 " - Continued statements | |
21 " print "foo", | |
22 " "bar"; | |
23 " print "foo" | |
24 " if bar(); | |
25 " - Multiline regular expressions (m//x) | |
26 " (The following probably needs modifying the perl syntax file) | |
27 " - qw() lists | |
28 " - Heredocs with terminators that don't match \I\i* | |
29 | |
30 " Only load this indent file when no other was loaded. | |
31 if exists("b:did_indent") | |
32 finish | |
33 endif | |
34 let b:did_indent = 1 | |
35 | |
36 " Is syntax highlighting active ? | |
37 let b:indent_use_syntax = has("syntax") | |
38 | |
24520 | 39 setlocal indentexpr=GetRakuIndent() |
2152 | 40 |
41 " we reset it first because the Perl 5 indent file might have been loaded due | |
42 " to a .pl/pm file extension, and indent files don't clean up afterwards | |
43 setlocal indentkeys& | |
44 | |
45 setlocal indentkeys+=0=,0),0],0>,0»,0=or,0=and | |
46 if !b:indent_use_syntax | |
47 setlocal indentkeys+=0=EO | |
48 endif | |
49 | |
50 let s:cpo_save = &cpo | |
51 set cpo-=C | |
52 | |
24520 | 53 function! GetRakuIndent() |
2152 | 54 |
55 " Get the line to be indented | |
56 let cline = getline(v:lnum) | |
57 | |
58 " Indent POD markers to column 0 | |
59 if cline =~ '^\s*=\L\@!' | |
60 return 0 | |
61 endif | |
62 | |
63 " Get current syntax item at the line's first char | |
64 let csynid = '' | |
65 if b:indent_use_syntax | |
66 let csynid = synIDattr(synID(v:lnum,1,0),"name") | |
67 endif | |
68 | |
69 " Don't reindent POD and heredocs | |
24520 | 70 if csynid =~ "^rakuPod" |
2152 | 71 return indent(v:lnum) |
72 endif | |
73 | |
74 | |
75 " Now get the indent of the previous perl line. | |
76 | |
77 " Find a non-blank line above the current line. | |
78 let lnum = prevnonblank(v:lnum - 1) | |
79 " Hit the start of the file, use zero indent. | |
80 if lnum == 0 | |
81 return 0 | |
82 endif | |
83 let line = getline(lnum) | |
84 let ind = indent(lnum) | |
85 " Skip heredocs, POD, and comments on 1st column | |
86 if b:indent_use_syntax | |
87 let skippin = 2 | |
88 while skippin | |
89 let synid = synIDattr(synID(lnum,1,0),"name") | |
24520 | 90 if (synid =~ "^rakuPod" || synid =~ "rakuComment") |
2152 | 91 let lnum = prevnonblank(lnum - 1) |
92 if lnum == 0 | |
93 return 0 | |
94 endif | |
95 let line = getline(lnum) | |
96 let ind = indent(lnum) | |
97 let skippin = 1 | |
98 else | |
99 let skippin = 0 | |
100 endif | |
101 endwhile | |
102 endif | |
103 | |
104 if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$' | |
24520 | 105 let ind = ind + &sw |
2152 | 106 endif |
107 if cline =~ '^\s*[)}\]»>]' | |
24520 | 108 let ind = ind - &sw |
2152 | 109 endif |
110 | |
111 " Indent lines that begin with 'or' or 'and' | |
112 if cline =~ '^\s*\(or\|and\)\>' | |
113 if line !~ '^\s*\(or\|and\)\>' | |
24520 | 114 let ind = ind + &sw |
2152 | 115 endif |
116 elseif line =~ '^\s*\(or\|and\)\>' | |
24520 | 117 let ind = ind - &sw |
2152 | 118 endif |
119 | |
120 return ind | |
121 | |
122 endfunction | |
123 | |
124 let &cpo = s:cpo_save | |
125 unlet s:cpo_save | |
126 | |
127 " vim:ts=8:sts=4:sw=4:expandtab:ft=vim |