annotate runtime/indent/rst.vim @ 10200:b85c507b50f3 v8.0.0001

commit https://github.com/vim/vim/commit/6401024869dcd722ee1b98b4ba58e6caa215201b Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 12 16:23:34 2016 +0200 patch 8.0.0001 Problem: Intro screen still mentions version7. (Paul) Solution: Change it to version8.
author Christian Brabandt <cb@256bit.org>
date Mon, 12 Sep 2016 16:30:08 +0200
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