Mercurial > vim
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 |
rev | line source |
---|---|
6051 | 1 " Vim indent file |
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 | 8 |
9 | |
10 " Only load this indent file when no other was loaded. | |
11 if exists("b:did_indent") | |
12 finish | |
13 endif | |
14 runtime indent/r.vim | |
15 let s:RIndent = function(substitute(&indentexpr, "()", "", "")) | |
16 let b:did_indent = 1 | |
17 | |
24520 | 18 setlocal indentkeys=0{,0},<:>,!^F,o,O,e |
6051 | 19 setlocal indentexpr=GetRmdIndent() |
20 | |
32061 | 21 let b:undo_indent = "setl inde< indk<" |
22 | |
6051 | 23 if exists("*GetRmdIndent") |
24 finish | |
25 endif | |
26 | |
14637 | 27 let s:cpo_save = &cpo |
28 set cpo&vim | |
29 | |
24520 | 30 " Simple Python indentation algorithm |
31 function s:GetPyIndent() | |
32 let plnum = prevnonblank(v:lnum - 1) | |
33 let pline = getline(plnum) | |
34 let cline = getline(v:lnum) | |
35 if pline =~ '^s```\s*{\s*python ' | |
36 return 0 | |
37 elseif pline =~ ':$' | |
38 return indent(plnum) + &shiftwidth | |
39 elseif cline =~ 'else:$' | |
40 return indent(plnum) - &shiftwidth | |
41 endif | |
42 return indent(plnum) | |
43 endfunction | |
44 | |
14637 | 45 function s:GetMdIndent() |
6051 | 46 let pline = getline(v:lnum - 1) |
47 let cline = getline(v:lnum) | |
48 if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+' | |
49 return indent(v:lnum) | |
50 elseif pline =~ '^\s*[-\+\*]\s' | |
51 return indent(v:lnum - 1) + 2 | |
52 elseif pline =~ '^\s*\d\+\.\s\+' | |
53 return indent(v:lnum - 1) + 3 | |
32061 | 54 elseif pline =~ '^\[\^\S\+\]: ' |
55 return indent(v:lnum - 1) + shiftwidth() | |
6051 | 56 endif |
57 return indent(prevnonblank(v:lnum - 1)) | |
58 endfunction | |
59 | |
14637 | 60 function s:GetYamlIndent() |
24520 | 61 let plnum = prevnonblank(v:lnum - 1) |
62 let pline = getline(plnum) | |
14637 | 63 if pline =~ ':\s*$' |
24520 | 64 return indent(plnum) + shiftwidth() |
14637 | 65 elseif pline =~ '^\s*- ' |
66 return indent(v:lnum) + 2 | |
67 endif | |
24520 | 68 return indent(plnum) |
14637 | 69 endfunction |
70 | |
6051 | 71 function GetRmdIndent() |
6840 | 72 if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$' |
6051 | 73 return 0 |
74 endif | |
6840 | 75 if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW") |
6051 | 76 return s:RIndent() |
24520 | 77 elseif v:lnum > 1 && (search('^---$', "bnW") == 1 && |
78 \ (search('^---$', "nW") > v:lnum || search('^\.\.\.$', "nW") > v:lnum)) | |
14637 | 79 return s:GetYamlIndent() |
24520 | 80 elseif search('^[ \t]*```{python', "bncW") > search('^[ \t]*```$', "bncW") |
81 return s:GetPyIndent() | |
6051 | 82 else |
14637 | 83 return s:GetMdIndent() |
6051 | 84 endif |
85 endfunction | |
86 | |
14637 | 87 let &cpo = s:cpo_save |
88 unlet s:cpo_save | |
89 | |
6051 | 90 " vim: sw=2 |