blob: 33bc103d1892a6a84fc8e4d3d15b54a7c7e8df73 [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 Moolenaardd60c362023-02-27 15:49:53 +00005" Last Change: Feb 25, 2023
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
Bram Moolenaardd60c362023-02-27 15:49:53 +000032let b:undo_indent = "setl inde< indk<"
33
Bram Moolenaardb6ea062014-07-10 22:01:47 +020034if exists("*GetRnowebIndent")
35 finish
36endif
37
38function GetRnowebIndent()
Bram Moolenaar541f92d2015-06-19 13:27:23 +020039 let curline = getline(".")
40 if curline =~ '^<<.*>>=$' || curline =~ '^\s*@$'
Bram Moolenaardb6ea062014-07-10 22:01:47 +020041 return 0
42 endif
43 if search("^<<", "bncW") > search("^@", "bncW")
44 return s:RIndent()
45 endif
46 return s:TeXIndent()
47endfunction
48
49" vim: sw=2