annotate runtime/indent/rmd.vim @ 9485:c16e207dc465 v7.4.2023

commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 10 20:27:32 2016 +0200 patch 7.4.2023 Problem: buflist_findname_stat() may find a dummy buffer. Solution: Set the BF_DUMMY flag after loading a dummy buffer. Start finding buffers from the end of the list.
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Jul 2016 20:30:06 +0200
parents da01d5da2cfa
children 0ecb909e3249
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: Rmd
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
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
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
5 " Last Change: Tue Apr 07, 2015 04:38PM
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 if exists("b:did_indent")
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 finish
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 runtime indent/r.vim
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 let s:RIndent = function(substitute(&indentexpr, "()", "", ""))
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 let b:did_indent = 1
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 setlocal indentkeys=0{,0},:,!^F,o,O,e
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 setlocal indentexpr=GetRmdIndent()
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 if exists("*GetRmdIndent")
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 finish
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 function GetMdIndent()
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 let pline = getline(v:lnum - 1)
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 let cline = getline(v:lnum)
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+'
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 return indent(v:lnum)
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 elseif pline =~ '^\s*[-\+\*]\s'
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 return indent(v:lnum - 1) + 2
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 elseif pline =~ '^\s*\d\+\.\s\+'
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 return indent(v:lnum - 1) + 3
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33 return indent(prevnonblank(v:lnum - 1))
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 endfunction
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 function GetRmdIndent()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
37 if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$'
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 return 0
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
40 if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW")
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 return s:RIndent()
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42 else
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43 return GetMdIndent()
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 endfunction
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 " vim: sw=2