annotate runtime/indent/chaiscript.vim @ 29607:33d7c1fa2dac v9.0.0144

patch 9.0.0144: text property cannot override 'cursorline' highlight Commit: https://github.com/vim/vim/commit/f4ba8bc47eb3c6b5899ef31d083b9b8f0d4ca456 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 5 17:05:04 2022 +0100 patch 9.0.0144: text property cannot override 'cursorline' highlight Problem: Text property cannot override 'cursorline' highlight. Solution: Add the "override" flag to prop_type_add(). (closes https://github.com/vim/vim/issues/5533, closes #8225).
author Bram Moolenaar <Bram@vim.org>
date Fri, 05 Aug 2022 18:15:08 +0200
parents 6dd88e45d47d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
1 " Vim indent file
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
2 " Language: ChaiScript
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
3 " Maintainer: Jason Turner <lefticus 'at' gmail com>
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
4 " Last Change: 2022 Apr 06
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
5
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
6 " Only load this indent file when no other was loaded.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
7 if exists("b:did_indent")
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
8 finish
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
9 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
10 let b:did_indent = 1
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
11
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
12 setlocal indentexpr=GetChaiScriptIndent()
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
13 setlocal autoindent
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
14
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
15 let b:undo_indent = "setl ai< inde<"
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
16
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
17 " Only define the function once.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
18 if exists("*GetChaiScriptIndent")
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
19 finish
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
20 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
21
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
22 function! GetChaiScriptIndent()
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
23 " Find a non-blank line above the current line.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
24 let lnum = prevnonblank(v:lnum - 1)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
25
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
26 " Hit the start of the file, use zero indent.
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
27 if lnum == 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
28 return 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
29 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
30
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
31 " Add a 'shiftwidth' after lines that start a block:
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
32 " lines containing a {
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
33 let ind = indent(lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
34 let flag = 0
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
35 let prevline = getline(lnum)
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
36 if prevline =~ '^.*{.*'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2152
diff changeset
37 let ind = ind + shiftwidth()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
38 let flag = 1
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
39 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
40
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
41 " Subtract a 'shiftwidth' after lines containing a { followed by a }
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
42 " to keep it balanced
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
43 if flag == 1 && prevline =~ '.*{.*}.*'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2152
diff changeset
44 let ind = ind - shiftwidth()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
45 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
46
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
47 " Subtract a 'shiftwidth' on lines ending with }
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
48 if getline(v:lnum) =~ '^\s*\%(}\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2152
diff changeset
49 let ind = ind - shiftwidth()
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
50 endif
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
51
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
52 return ind
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
53 endfunction