blob: 73966868b876f56baac8ef3444c784784e21c35b [file] [log] [blame]
Bram Moolenaardb6ea062014-07-10 22:01:47 +02001" Vim indent file
2" Language: Rnoweb
3" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
Bram Moolenaar77cdfd12016-03-12 12:57:59 +01004" Homepage: https://github.com/jalvesaq/R-Vim-runtime
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +02005" Last Change: Fri Apr 15, 2016 10:58PM
Bram Moolenaardb6ea062014-07-10 22:01:47 +02006
7
8" Only load this indent file when no other was loaded.
9if exists("b:did_indent")
10 finish
11endif
12runtime indent/tex.vim
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +020013
14function! s:NoTeXIndent()
15 return indent(line("."))
16endfunction
17
18if &indentexpr == "" || &indentexpr == "GetRnowebIndent()"
19 let s:TeXIndent = function("s:NoTeXIndent")
20else
21 let s:TeXIndent = function(substitute(&indentexpr, "()", "", ""))
22endif
23
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020024unlet! b:did_indent
Bram Moolenaardb6ea062014-07-10 22:01:47 +020025runtime indent/r.vim
26let s:RIndent = function(substitute(&indentexpr, "()", "", ""))
27let b:did_indent = 1
28
29setlocal indentkeys=0{,0},!^F,o,O,e,},=\bibitem,=\item
30setlocal indentexpr=GetRnowebIndent()
31
32if exists("*GetRnowebIndent")
33 finish
34endif
35
36function GetRnowebIndent()
Bram Moolenaar541f92d2015-06-19 13:27:23 +020037 let curline = getline(".")
38 if curline =~ '^<<.*>>=$' || curline =~ '^\s*@$'
Bram Moolenaardb6ea062014-07-10 22:01:47 +020039 return 0
40 endif
41 if search("^<<", "bncW") > search("^@", "bncW")
42 return s:RIndent()
43 endif
44 return s:TeXIndent()
45endfunction
46
47" vim: sw=2