Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 1 | " Vim indent file |
| 2 | " Language: Rnoweb |
| 3 | " Author: Jakson Alves de Aquino <jalvesaq@gmail.com> |
Bram Moolenaar | 77cdfd1 | 2016-03-12 12:57:59 +0100 | [diff] [blame] | 4 | " Homepage: https://github.com/jalvesaq/R-Vim-runtime |
Bram Moolenaar | e4a3bcf | 2016-08-26 19:52:37 +0200 | [diff] [blame] | 5 | " Last Change: Fri Apr 15, 2016 10:58PM |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 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/tex.vim |
Bram Moolenaar | e4a3bcf | 2016-08-26 19:52:37 +0200 | [diff] [blame] | 13 | |
| 14 | function! s:NoTeXIndent() |
| 15 | return indent(line(".")) |
| 16 | endfunction |
| 17 | |
| 18 | if &indentexpr == "" || &indentexpr == "GetRnowebIndent()" |
| 19 | let s:TeXIndent = function("s:NoTeXIndent") |
| 20 | else |
| 21 | let s:TeXIndent = function(substitute(&indentexpr, "()", "", "")) |
| 22 | endif |
| 23 | |
Bram Moolenaar | fc65cab | 2018-08-28 22:58:02 +0200 | [diff] [blame] | 24 | unlet! b:did_indent |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 25 | runtime indent/r.vim |
| 26 | let s:RIndent = function(substitute(&indentexpr, "()", "", "")) |
| 27 | let b:did_indent = 1 |
| 28 | |
| 29 | setlocal indentkeys=0{,0},!^F,o,O,e,},=\bibitem,=\item |
| 30 | setlocal indentexpr=GetRnowebIndent() |
| 31 | |
| 32 | if exists("*GetRnowebIndent") |
| 33 | finish |
| 34 | endif |
| 35 | |
| 36 | function GetRnowebIndent() |
Bram Moolenaar | 541f92d | 2015-06-19 13:27:23 +0200 | [diff] [blame] | 37 | let curline = getline(".") |
| 38 | if curline =~ '^<<.*>>=$' || curline =~ '^\s*@$' |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 39 | return 0 |
| 40 | endif |
| 41 | if search("^<<", "bncW") > search("^@", "bncW") |
| 42 | return s:RIndent() |
| 43 | endif |
| 44 | return s:TeXIndent() |
| 45 | endfunction |
| 46 | |
| 47 | " vim: sw=2 |