Mercurial > vim
annotate runtime/indent/rmd.vim @ 15446:8ac454818352 v8.1.0731
patch 8.1.0731: JS encoding does not handle negative infinity
commit https://github.com/vim/vim/commit/5f6b379ff3e34297d171635933f907ec80ed4f05
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 12 14:24:27 2019 +0100
patch 8.1.0731: JS encoding does not handle negative infinity
Problem: JS encoding does not handle negative infinity.
Solution: Add support for negative infinity for JS encoding. (Dominique
Pelle, closes #3792)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Jan 2019 14:30:06 +0100 |
parents | 0ecb909e3249 |
children | 1eaf34420bb3 |
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 |
14637 | 5 " Last Change: Sun Aug 19, 2018 09:14PM |
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 | |
14637 | 23 let s:cpo_save = &cpo |
24 set cpo&vim | |
25 | |
26 function s:GetMdIndent() | |
6051 | 27 let pline = getline(v:lnum - 1) |
28 let cline = getline(v:lnum) | |
29 if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+' | |
30 return indent(v:lnum) | |
31 elseif pline =~ '^\s*[-\+\*]\s' | |
32 return indent(v:lnum - 1) + 2 | |
33 elseif pline =~ '^\s*\d\+\.\s\+' | |
34 return indent(v:lnum - 1) + 3 | |
35 endif | |
36 return indent(prevnonblank(v:lnum - 1)) | |
37 endfunction | |
38 | |
14637 | 39 function s:GetYamlIndent() |
40 let pline = getline(v:lnum - 1) | |
41 if pline =~ ':\s*$' | |
42 return indent(v:lnum) + &sw | |
43 elseif pline =~ '^\s*- ' | |
44 return indent(v:lnum) + 2 | |
45 endif | |
46 return indent(prevnonblank(v:lnum - 1)) | |
47 endfunction | |
48 | |
6051 | 49 function GetRmdIndent() |
6840 | 50 if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$' |
6051 | 51 return 0 |
52 endif | |
6840 | 53 if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW") |
6051 | 54 return s:RIndent() |
14637 | 55 elseif v:lnum > 1 && search('^---$', "bnW") == 1 && |
56 \ (search('^---$', "nW") > v:lnum || search('^...$', "nW") > v:lnum) | |
57 return s:GetYamlIndent() | |
6051 | 58 else |
14637 | 59 return s:GetMdIndent() |
6051 | 60 endif |
61 endfunction | |
62 | |
14637 | 63 let &cpo = s:cpo_save |
64 unlet s:cpo_save | |
65 | |
6051 | 66 " vim: sw=2 |