xref: /vim-8.2.3635/runtime/ftplugin/rrst.vim (revision 11e3c5ba)
1" Vim filetype plugin file
2" Language: reStructuredText documentation format with R code
3" Maintainer: Jakson Alves de Aquino <[email protected]>
4" Homepage: https://github.com/jalvesaq/R-Vim-runtime
5" Last Change:	Sat Aug 15, 2020  12:02PM
6" 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
19setlocal comments=fb:*,fb:-,fb:+,n:>
20setlocal commentstring=#\ %s
21setlocal formatoptions+=tcqln
22setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+
23setlocal iskeyword=@,48-57,_,.
24
25function! 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
40if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
41  let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" .
42        \ "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
55