annotate runtime/indent/rst.vim @ 10357:59d01e335858 v8.0.0073

commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 10 18:16:33 2016 +0100 patch 8.0.0073 Problem: More comparisons between firstwin and lastwin. Solution: Use ONE_WINDOW for consistency. (Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Thu, 10 Nov 2016 18:30:05 +0100
parents 3502a7f991fc
children 1218c5353e2b
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
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
2 " Language: reStructuredText Documentation Format
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
4 " Latest Revision: 2011-08-03
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 setlocal indentexpr=GetRSTIndent()
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
12 setlocal indentkeys=!^F,o,O
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
13 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 if exists("*GetRSTIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
19 let s:itemization_pattern = '^\s*[-*+]\s'
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
20 let s:enumeration_pattern = '^\s*\%(\d\+\|#\)\.\s\+'
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
21
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 function GetRSTIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
31 if line =~ s:itemization_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
32 let ind += 2
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
33 elseif line =~ s:enumeration_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
34 let ind += matchend(line, s:enumeration_pattern)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 let line = getline(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
39 " Indent :FIELD: lines. Don’t match if there is no text after the field or
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
40 " if the text ends with a sent-ender.
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
41 if line =~ '^:.\+:\s\{-1,\}\S.\+[^.!?:]$'
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
42 return matchend(line, '^:.\{-1,}:\s\+')
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
43 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
44
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if line =~ '^\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 execute lnum
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
47 call search('^\s*\%([-*+]\s\|\%(\d\+\|#\)\.\s\|\.\.\|$\)', 'bW')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let line = getline('.')
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
49 if line =~ s:itemization_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
50 let ind -= 2
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
51 elseif line =~ s:enumeration_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
52 let ind -= matchend(line, s:enumeration_pattern)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 elseif line =~ '^\s*\.\.'
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
54 let ind -= 3
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 endfunction