annotate runtime/indent/yacc.vim @ 36514:4a4e3aaabc52 draft default tip

runtime(vim): Fix indent after :silent! function Commit: https://github.com/vim/vim/commit/7724d621f21ff6599ba49f11401ddb45ff321099 Author: Doug Kearns <dougkearns@gmail.com> Date: Sun Nov 10 20:36:28 2024 +0100 runtime(vim): Fix indent after :silent! function See https://github.com/vim/vim/commit/35699f17497dcdcfdd747fedaef28f208ac6eb5f#commitcomment-148816912 closes: #16009 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Nov 2024 20:45:04 +0100
parents 4d76b3e07c07
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
28620
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
2 " Language: YACC input file
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
5 " Last Change: 2022 April 25
7
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
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 indentexpr=GetYaccIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 setlocal indentkeys=!^F,o,O
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
16 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
28620
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
18 let b:undo_indent = "setl inde< indk< si<"
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
19
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if exists("*GetYaccIndent")
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 GetYaccIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 if v:lnum == 1
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 let ind = indent(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let line = getline(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if line == ''
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 elseif line =~ '^\w\+\s*:'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let ind = ind + matchend(line, '^\w\+\s*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 elseif line =~ '^\s*;'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let ind = indent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 endfunction