blob: 19c67c4cc2cffabce308bf0c838d9eb4b14457f8 [file] [log] [blame]
Bram Moolenaardb6ea062014-07-10 22:01:47 +02001" Vim filetype plugin file
2" Language: reStructuredText documentation format with R code
3" Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com>
Bram Moolenaar77cdfd12016-03-12 12:57:59 +01004" Homepage: https://github.com/jalvesaq/R-Vim-runtime
Bram Moolenaardd60c362023-02-27 15:49:53 +00005" Last Change: Sun Apr 24, 2022 09:13AM
Bram Moolenaardb6ea062014-07-10 22:01:47 +02006" Original work by Alex Zvoleff
7
8" Only do this when not yet done for this buffer
9if exists("b:did_ftplugin")
10 finish
11endif
12
13" Don't load another plugin for this buffer
14let b:did_ftplugin = 1
15
16let s:cpo_save = &cpo
17set cpo&vim
18
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020019setlocal comments=fb:*,fb:-,fb:+,n:>
20setlocal commentstring=#\ %s
Bram Moolenaardb6ea062014-07-10 22:01:47 +020021setlocal formatoptions+=tcqln
22setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+
23setlocal iskeyword=@,48-57,_,.
24
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020025function! FormatRrst()
26 if search('^\.\. {r', "bncW") > search('^\.\. \.\.$', "bncW")
27 setlocal comments=:#',:###,:##,:#
28 else
29 setlocal comments=fb:*,fb:-,fb:+,n:>
30 endif
31 return 1
32endfunction
33
34" If you do not want 'comments' dynamically defined, put in your vimrc:
35" let g:rrst_dynamic_comments = 0
36if !exists("g:rrst_dynamic_comments") || (exists("g:rrst_dynamic_comments") && g:rrst_dynamic_comments == 1)
37 setlocal formatexpr=FormatRrst()
38endif
39
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020040if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaardd60c362023-02-27 15:49:53 +000041 let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n" .
Bram Moolenaardb6ea062014-07-10 22:01:47 +020042 \ "All Files (*.*)\t*.*\n"
43endif
44
45if exists('b:undo_ftplugin')
46 let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
47else
48 let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
49endif
50
51let &cpo = s:cpo_save
52unlet s:cpo_save
53
54" vim: sw=2