blob: d088f98224fc00763343306ec17d73907c60504c [file] [log] [blame]
Bram Moolenaardb6ea062014-07-10 22:01:47 +02001" Vim filetype plugin file
dkearnse93afc22024-03-03 05:27:47 +11002" Language: reStructuredText documentation format with R code
3" Maintainer: This runtime file is looking for a new maintainer.
4" Former Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com>
5" Former Repository: https://github.com/jalvesaq/R-Vim-runtime
6" Last Change: 2024 Feb 28 by Vim Project
Bram Moolenaardb6ea062014-07-10 22:01:47 +02007" Original work by Alex Zvoleff
8
9" Only do this when not yet done for this buffer
10if exists("b:did_ftplugin")
11 finish
12endif
13
14" Don't load another plugin for this buffer
15let b:did_ftplugin = 1
16
17let s:cpo_save = &cpo
18set cpo&vim
19
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020020setlocal comments=fb:*,fb:-,fb:+,n:>
21setlocal commentstring=#\ %s
Bram Moolenaardb6ea062014-07-10 22:01:47 +020022setlocal formatoptions+=tcqln
23setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+
24setlocal iskeyword=@,48-57,_,.
25
Bram Moolenaar71badf92023-04-22 22:40:14 +010026function FormatRrst()
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020027 if search('^\.\. {r', "bncW") > search('^\.\. \.\.$', "bncW")
28 setlocal comments=:#',:###,:##,:#
29 else
30 setlocal comments=fb:*,fb:-,fb:+,n:>
31 endif
32 return 1
33endfunction
34
35" If you do not want 'comments' dynamically defined, put in your vimrc:
36" let g:rrst_dynamic_comments = 0
37if !exists("g:rrst_dynamic_comments") || (exists("g:rrst_dynamic_comments") && g:rrst_dynamic_comments == 1)
38 setlocal formatexpr=FormatRrst()
39endif
40
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020041if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
dkearnse93afc22024-03-03 05:27:47 +110042 let b:browsefilter = "R Source Files (*.R, *.Rnw, *.Rd, *.Rmd, *.Rrst, *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n"
Doug Kearns93197fd2024-01-14 20:59:02 +010043 if has("win32")
44 let b:browsefilter .= "All Files (*.*)\t*\n"
45 else
46 let b:browsefilter .= "All Files (*)\t*\n"
47 endif
Bram Moolenaardb6ea062014-07-10 22:01:47 +020048endif
49
50if exists('b:undo_ftplugin')
51 let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
52else
53 let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
54endif
55
56let &cpo = s:cpo_save
57unlet s:cpo_save
58
59" vim: sw=2