Mercurial > vim
diff runtime/indent/rmd.vim @ 14637:0ecb909e3249
Update runtime files.
commit https://github.com/vim/vim/commit/fc65cabb15d0236bce001ad78e12a40511caf941
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 28 22:58:02 2018 +0200
Update runtime files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 28 Aug 2018 23:00:08 +0200 |
parents | da01d5da2cfa |
children | 1eaf34420bb3 |
line wrap: on
line diff
--- a/runtime/indent/rmd.vim +++ b/runtime/indent/rmd.vim @@ -2,7 +2,7 @@ " Language: Rmd " Author: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Tue Apr 07, 2015 04:38PM +" Last Change: Sun Aug 19, 2018 09:14PM " Only load this indent file when no other was loaded. @@ -20,7 +20,10 @@ if exists("*GetRmdIndent") finish endif -function GetMdIndent() +let s:cpo_save = &cpo +set cpo&vim + +function s:GetMdIndent() let pline = getline(v:lnum - 1) let cline = getline(v:lnum) if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+' @@ -33,15 +36,31 @@ function GetMdIndent() return indent(prevnonblank(v:lnum - 1)) endfunction +function s:GetYamlIndent() + let pline = getline(v:lnum - 1) + if pline =~ ':\s*$' + return indent(v:lnum) + &sw + elseif pline =~ '^\s*- ' + return indent(v:lnum) + 2 + endif + return indent(prevnonblank(v:lnum - 1)) +endfunction + function GetRmdIndent() if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$' return 0 endif if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW") return s:RIndent() + elseif v:lnum > 1 && search('^---$', "bnW") == 1 && + \ (search('^---$', "nW") > v:lnum || search('^...$', "nW") > v:lnum) + return s:GetYamlIndent() else - return GetMdIndent() + return s:GetMdIndent() endif endfunction +let &cpo = s:cpo_save +unlet s:cpo_save + " vim: sw=2