Mercurial > vim
annotate runtime/indent/lua.vim @ 19728:41a1ea967a97 v8.2.0420
patch 8.2.0420: Vim9: cannot interrupt a loop with CTRL-C
Commit: https://github.com/vim/vim/commit/f1ec378b014efb9897422c40369a6462163a512a
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 20 19:37:47 2020 +0100
patch 8.2.0420: Vim9: cannot interrupt a loop with CTRL-C
Problem: Vim9: cannot interrupt a loop with CTRL-C.
Solution: Check for CTRL-C once in a while. Doesn't fully work yet.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 20 Mar 2020 19:45:03 +0100 |
parents | 63b0b7b79b25 |
children | 0827d3d6d8c0 |
rev | line source |
---|---|
7 | 1 " Vim indent file |
2 " Language: Lua script | |
22 | 3 " Maintainer: Marcus Aurelius Farias <marcus.cf 'at' bol.com.br> |
4 " First Author: Max Ischenko <mfi 'at' ukr.net> | |
11518 | 5 " Last Change: 2017 Jun 13 |
323 | 6 |
7 " Only load this indent file when no other was loaded. | |
8 if exists("b:did_indent") | |
9 finish | |
10 endif | |
11 let b:did_indent = 1 | |
7 | 12 |
359 | 13 setlocal indentexpr=GetLuaIndent() |
14 | |
15 " To make Vim call GetLuaIndent() when it finds '\s*end' or '\s*until' | |
16 " on the current line ('else' is default and includes 'elseif'). | |
17 setlocal indentkeys+=0=end,0=until | |
18 | |
19 setlocal autoindent | |
20 | |
7 | 21 " Only define the function once. |
22 | 22 if exists("*GetLuaIndent") |
23 finish | |
24 endif | |
7 | 25 |
26 function! GetLuaIndent() | |
27 " Find a non-blank line above the current line. | |
1620 | 28 let prevlnum = prevnonblank(v:lnum - 1) |
7 | 29 |
30 " Hit the start of the file, use zero indent. | |
1620 | 31 if prevlnum == 0 |
7 | 32 return 0 |
33 endif | |
34 | |
359 | 35 " Add a 'shiftwidth' after lines that start a block: |
36 " 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{' | |
1620 | 37 let ind = indent(prevlnum) |
38 let prevline = getline(prevlnum) | |
39 let midx = match(prevline, '^\s*\%(if\>\|for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>\)') | |
40 if midx == -1 | |
41 let midx = match(prevline, '{\s*$') | |
42 if midx == -1 | |
43 let midx = match(prevline, '\<function\>\s*\%(\k\|[.:]\)\{-}\s*(') | |
44 endif | |
7 | 45 endif |
46 | |
1620 | 47 if midx != -1 |
48 " Add 'shiftwidth' if what we found previously is not in a comment and | |
49 " an "end" or "until" is not present on the same line. | |
50 if synIDattr(synID(prevlnum, midx + 1, 1), "name") != "luaComment" && prevline !~ '\<end\>\|\<until\>' | |
11518 | 51 let ind = ind + shiftwidth() |
1620 | 52 endif |
7 | 53 endif |
54 | |
7557
502ca0a62fd8
commit https://github.com/vim/vim/commit/acb4f221c715a333f4c49a2235a8006c6ac6e4d5
Christian Brabandt <cb@256bit.org>
parents:
6369
diff
changeset
|
55 " Subtract a 'shiftwidth' on end, else, elseif, until and '}' |
7 | 56 " This is the part that requires 'indentkeys'. |
7557
502ca0a62fd8
commit https://github.com/vim/vim/commit/acb4f221c715a333f4c49a2235a8006c6ac6e4d5
Christian Brabandt <cb@256bit.org>
parents:
6369
diff
changeset
|
57 let midx = match(getline(v:lnum), '^\s*\%(end\>\|else\>\|elseif\>\|until\>\|}\)') |
1620 | 58 if midx != -1 && synIDattr(synID(v:lnum, midx + 1, 1), "name") != "luaComment" |
11518 | 59 let ind = ind - shiftwidth() |
7 | 60 endif |
61 | |
62 return ind | |
63 endfunction |