Mercurial > vim
annotate runtime/ftplugin/rmd.vim @ 34375:02bd0fe77c68
runtime(misc): announce adoption of various runtime files
Commit: https://github.com/vim/vim/commit/f9ca139e3aa12dd03177ebba5eedcee4f0836f27
Author: Christian Brabandt <cb@256bit.org>
Date: Mon Feb 19 20:37:11 2024 +0100
runtime(misc): announce adoption of various runtime files
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 19 Feb 2024 21:00:10 +0100 |
parents | 8ae680be2a51 |
children | 95da9260ac66 |
rev | line source |
---|---|
6051 | 1 " Vim filetype plugin file |
9975
03fa8a51e9dc
commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents:
8497
diff
changeset
|
2 " Language: R Markdown file |
6051 | 3 " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
6051
diff
changeset
|
4 " Homepage: https://github.com/jalvesaq/R-Vim-runtime |
34375
02bd0fe77c68
runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents:
34134
diff
changeset
|
5 " Last Change: 2023 May 29 06:31AM |
34134
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33368
diff
changeset
|
6 " 2024 Jan 14 by Vim Project (browsefilter) |
9975
03fa8a51e9dc
commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents:
8497
diff
changeset
|
7 " Original work by Alex Zvoleff (adjusted from R help for rmd by Michel Kuhlmann) |
6051 | 8 |
9 " Only do this when not yet done for this buffer | |
10 if exists("b:did_ftplugin") | |
11 finish | |
12 endif | |
13 | |
14637 | 14 if exists('g:rmd_include_html') && g:rmd_include_html |
15 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim | |
9975
03fa8a51e9dc
commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents:
8497
diff
changeset
|
16 endif |
03fa8a51e9dc
commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents:
8497
diff
changeset
|
17 |
14637 | 18 setlocal comments=fb:*,fb:-,fb:+,n:> |
19 setlocal commentstring=#\ %s | |
6051 | 20 setlocal formatoptions+=tcqln |
21 setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+ | |
22 setlocal iskeyword=@,48-57,_,. | |
23 | |
24 let s:cpo_save = &cpo | |
25 set cpo&vim | |
26 | |
32294 | 27 function FormatRmd() |
14637 | 28 if search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW") |
29 setlocal comments=:#',:###,:##,:# | |
30 else | |
31 setlocal comments=fb:*,fb:-,fb:+,n:> | |
32 endif | |
33 return 1 | |
34 endfunction | |
35 | |
33368
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
36 let s:last_line = 0 |
32294 | 37 function SetRmdCommentStr() |
33368
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
38 if line('.') == s:last_line |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
39 return |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
40 endif |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
41 let s:last_line = line('.') |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
42 |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
43 if (search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")) || ((search('^---$', 'Wn') || search('^\.\.\.$', 'Wn')) && search('^---$', 'bnW')) |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
44 set commentstring=#\ %s |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
45 else |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
46 set commentstring=<!--\ %s\ --> |
033f22d4a52a
runtime(rmd) Update ftplugin and syntax files (#13193)
Christian Brabandt <cb@256bit.org>
parents:
32294
diff
changeset
|
47 endif |
32061 | 48 endfunction |
49 | |
50 " If you do not want both 'comments' and 'commentstring' dynamically defined, | |
51 " put in your vimrc: let g:rmd_dynamic_comments = 0 | |
14637 | 52 if !exists("g:rmd_dynamic_comments") || (exists("g:rmd_dynamic_comments") && g:rmd_dynamic_comments == 1) |
53 setlocal formatexpr=FormatRmd() | |
32061 | 54 augroup RmdCStr |
55 autocmd! | |
56 autocmd CursorMoved <buffer> call SetRmdCommentStr() | |
57 augroup END | |
14637 | 58 endif |
59 | |
6051 | 60 " Enables pandoc if it is installed |
61 unlet! b:did_ftplugin | |
62 runtime ftplugin/pandoc.vim | |
63 | |
64 " Don't load another plugin for this buffer | |
65 let b:did_ftplugin = 1 | |
66 | |
24520 | 67 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
34134
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33368
diff
changeset
|
68 let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33368
diff
changeset
|
69 if has("win32") |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33368
diff
changeset
|
70 let b:browsefilter .= "All Files (*.*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33368
diff
changeset
|
71 else |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33368
diff
changeset
|
72 let b:browsefilter .= "All Files (*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33368
diff
changeset
|
73 endif |
6051 | 74 endif |
75 | |
76 if exists('b:undo_ftplugin') | |
77 let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter" | |
78 else | |
79 let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter" | |
80 endif | |
81 | |
82 let &cpo = s:cpo_save | |
83 unlet s:cpo_save | |
84 | |
85 " vim: sw=2 |