annotate runtime/indent/rmd.vim @ 36544:a27d4c0319ac draft default tip

runtime(idris2): include filetype,indent+syntax plugins for (L)Idris2 + ipkg Commit: https://github.com/vim/vim/commit/5ca8f223f03dbd85f5e06c8e1d500c65f311eaf1 Author: Serhii Khoma <srghma@gmail.com> Date: Tue Nov 12 21:49:42 2024 +0100 runtime(idris2): include filetype,indent+syntax plugins for (L)Idris2 + ipkg closes: https://github.com/vim/vim/issues/15993 Co-authored-by: Christian Clason <ch.clason+github@icloud.com> Signed-off-by: Serhii Khoma <srghma@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Nov 2024 22:00:06 +0100
parents 02bd0fe77c68
children
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
34375
02bd0fe77c68 runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents: 32061
diff changeset
3 " Maintainer: This runtime file is looking for a new maintainer.
02bd0fe77c68 runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents: 32061
diff changeset
4 " Former Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com>
02bd0fe77c68 runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents: 32061
diff changeset
5 " Former Repository: https://github.com/jalvesaq/R-Vim-runtime
02bd0fe77c68 runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents: 32061
diff changeset
6 " Last Change: 2022 Nov 09 09:44PM
02bd0fe77c68 runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents: 32061
diff changeset
7 " 2024 Feb 19 by Vim Project (announce adoption)
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 " Only load this indent file when no other was loaded.
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 if exists("b:did_indent")
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 finish
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 runtime indent/r.vim
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 let s:RIndent = function(substitute(&indentexpr, "()", "", ""))
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 let b:did_indent = 1
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
18 setlocal indentkeys=0{,0},<:>,!^F,o,O,e
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 setlocal indentexpr=GetRmdIndent()
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20
32061
b2412874362f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24520
diff changeset
21 let b:undo_indent = "setl inde< indk<"
b2412874362f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24520
diff changeset
22
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 if exists("*GetRmdIndent")
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 finish
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
27 let s:cpo_save = &cpo
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
28 set cpo&vim
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
29
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
30 " Simple Python indentation algorithm
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
31 function s:GetPyIndent()
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
32 let plnum = prevnonblank(v:lnum - 1)
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
33 let pline = getline(plnum)
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
34 let cline = getline(v:lnum)
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
35 if pline =~ '^s```\s*{\s*python '
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
36 return 0
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
37 elseif pline =~ ':$'
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
38 return indent(plnum) + &shiftwidth
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
39 elseif cline =~ 'else:$'
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
40 return indent(plnum) - &shiftwidth
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
41 endif
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
42 return indent(plnum)
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
43 endfunction
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
44
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
45 function s:GetMdIndent()
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 let pline = getline(v:lnum - 1)
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 let cline = getline(v:lnum)
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 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
49 return indent(v:lnum)
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 elseif pline =~ '^\s*[-\+\*]\s'
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
51 return indent(v:lnum - 1) + 2
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 elseif pline =~ '^\s*\d\+\.\s\+'
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 return indent(v:lnum - 1) + 3
32061
b2412874362f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24520
diff changeset
54 elseif pline =~ '^\[\^\S\+\]: '
b2412874362f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24520
diff changeset
55 return indent(v:lnum - 1) + shiftwidth()
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 return indent(prevnonblank(v:lnum - 1))
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58 endfunction
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
60 function s:GetYamlIndent()
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
61 let plnum = prevnonblank(v:lnum - 1)
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
62 let pline = getline(plnum)
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
63 if pline =~ ':\s*$'
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
64 return indent(plnum) + shiftwidth()
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
65 elseif pline =~ '^\s*- '
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
66 return indent(v:lnum) + 2
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
67 endif
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
68 return indent(plnum)
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
69 endfunction
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
70
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
71 function GetRmdIndent()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
72 if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$'
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
73 return 0
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
75 if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW")
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
76 return s:RIndent()
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
77 elseif v:lnum > 1 && (search('^---$', "bnW") == 1 &&
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
78 \ (search('^---$', "nW") > v:lnum || search('^\.\.\.$', "nW") > v:lnum))
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
79 return s:GetYamlIndent()
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
80 elseif search('^[ \t]*```{python', "bncW") > search('^[ \t]*```$', "bncW")
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
81 return s:GetPyIndent()
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
82 else
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
83 return s:GetMdIndent()
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
84 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
85 endfunction
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
87 let &cpo = s:cpo_save
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
88 unlet s:cpo_save
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
89
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
90 " vim: sw=2