Mercurial > vim
annotate runtime/indent/rmd.vim @ 12770:89889fea43e0
Added tag v8.0.1262 for changeset 083ae2cfcc5b13d3438d6d0489865aa3612d8c75
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 04 Nov 2017 21:00:06 +0100 |
parents | da01d5da2cfa |
children | 0ecb909e3249 |
rev | line source |
---|---|
6051 | 1 " Vim indent file |
2 " Language: Rmd | |
3 " Author: Jakson Alves de Aquino <jalvesaq@gmail.com> | |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
6840
diff
changeset
|
4 " Homepage: https://github.com/jalvesaq/R-Vim-runtime |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
6840
diff
changeset
|
5 " Last Change: Tue Apr 07, 2015 04:38PM |
6051 | 6 |
7 | |
8 " Only load this indent file when no other was loaded. | |
9 if exists("b:did_indent") | |
10 finish | |
11 endif | |
12 runtime indent/r.vim | |
13 let s:RIndent = function(substitute(&indentexpr, "()", "", "")) | |
14 let b:did_indent = 1 | |
15 | |
16 setlocal indentkeys=0{,0},:,!^F,o,O,e | |
17 setlocal indentexpr=GetRmdIndent() | |
18 | |
19 if exists("*GetRmdIndent") | |
20 finish | |
21 endif | |
22 | |
23 function GetMdIndent() | |
24 let pline = getline(v:lnum - 1) | |
25 let cline = getline(v:lnum) | |
26 if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+' | |
27 return indent(v:lnum) | |
28 elseif pline =~ '^\s*[-\+\*]\s' | |
29 return indent(v:lnum - 1) + 2 | |
30 elseif pline =~ '^\s*\d\+\.\s\+' | |
31 return indent(v:lnum - 1) + 3 | |
32 endif | |
33 return indent(prevnonblank(v:lnum - 1)) | |
34 endfunction | |
35 | |
36 function GetRmdIndent() | |
6840 | 37 if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$' |
6051 | 38 return 0 |
39 endif | |
6840 | 40 if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW") |
6051 | 41 return s:RIndent() |
42 else | |
43 return GetMdIndent() | |
44 endif | |
45 endfunction | |
46 | |
47 " vim: sw=2 |