annotate runtime/indent/prolog.vim @ 14774:5e5f2d824189 v8.1.0399

patch 8.1.0399: 'hlsearch' highlight remains in other window commit https://github.com/vim/vim/commit/65985ac998713dfe0f0ff1dd49c5e3e8f17f4870 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 16 17:08:04 2018 +0200 patch 8.1.0399: 'hlsearch' highlight remains in other window Problem: 'hlsearch' highlight remains in other window after cancelling command. Solution: Redraw all windows. Also remove unnecessary delays. (closes #3437)
author Christian Brabandt <cb@256bit.org>
date Sun, 16 Sep 2018 17:15:05 +0200
parents 63b0b7b79b25
children 40ef13331e02
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: set sw=4 sts=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Maintainer : Gergely Kontra <kgergely@mcl.hu>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Revised on : 2002.02.18. 23:34:05
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Language : Prolog
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " TODO:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " checking with respect to syntax highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " ignoring multiline comments
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " detecting multiline strings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 setlocal indentexpr=GetPrologIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 setlocal indentkeys-=:,0#
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 setlocal indentkeys+=0%,-,0;,>,0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 "if exists("*GetPrologIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 "endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 function! GetPrologIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 let pnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " Hit the start of the file, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 if pnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let line = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 let pline = getline(pnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 let ind = indent(pnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " Previous line was comment -> use previous line's indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 if pline =~ '^\s*%'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 retu ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " Check for clause head on previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if pline =~ ':-\s*\(%.*\)\?$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
44 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " Check for end of clause on previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 elseif pline =~ '\.\s*\(%.*\)\?$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
47 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " Check for opening conditional on previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 if pline =~ '^\s*\([(;]\|->\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
51 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " Check for closing an unclosed paren, or middle ; or ->
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 if line =~ '^\s*\([);]\|->\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
55 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 endfunction