annotate runtime/indent/prolog.vim @ 27150:2d0ea3f9ffe1 v8.2.4104

patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems Commit: https://github.com/vim/vim/commit/bfac409d0b24d212a6d846edb651c49dac03745f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 16 11:12:12 2022 +0000 patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems Problem: Vim9: lower casing the autoload prefix causes problems. Solution: Always store the prefix with case preserved.
author Bram Moolenaar <Bram@vim.org>
date Sun, 16 Jan 2022 12:15:04 +0100
parents 9c221ad9634a
children 6dd88e45d47d
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:
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14864
diff changeset
2 " Language: Prolog
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14864
diff changeset
3 " Maintainer: Gergely Kontra <kgergely@mcl.hu> (Invalid email address)
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14864
diff changeset
4 " Doug Kearns <dougkearns@gmail.com>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14864
diff changeset
5 " Revised on: 2002.02.18. 23:34:05
14864
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
6 " Last change by: Takuya Fujiwara, 2018 Sep 23
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " TODO:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " checking with respect to syntax highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " ignoring multiline comments
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " detecting multiline strings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 setlocal indentexpr=GetPrologIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 setlocal indentkeys-=:,0#
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 setlocal indentkeys+=0%,-,0;,>,0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 "if exists("*GetPrologIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 " finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 "endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 function! GetPrologIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let pnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " Hit the start of the file, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if pnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let line = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 let pline = getline(pnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let ind = indent(pnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 " Previous line was comment -> use previous line's indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 if pline =~ '^\s*%'
14864
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
42 return ind
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
43 endif
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
44 " Previous line was the start of block comment -> +1 after '/*' comment
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
45 if pline =~ '^\s*/\*'
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
46 return ind + 1
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
47 endif
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
48 " Previous line was the end of block comment -> -1 after '*/' comment
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
49 if pline =~ '^\s*\*/'
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
50 return ind - 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " Check for clause head on previous line
14864
40ef13331e02 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
53 if pline =~ '\%(:-\|-->\)\s*\(%.*\)\?$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
54 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " Check for end of clause on previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 elseif pline =~ '\.\s*\(%.*\)\?$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
57 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " Check for opening conditional on previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 if pline =~ '^\s*\([(;]\|->\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
61 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Check for closing an unclosed paren, or middle ; or ->
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 if line =~ '^\s*\([);]\|->\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
65 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 endfunction