blob: 26c1ab4e3f414fd3a70f598372fd3de319f90e5c [file] [log] [blame]
Bram Moolenaardb6ea062014-07-10 22:01:47 +02001" Vim filetype plugin file
2" Language: Rnoweb
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 Moolenaar71badf92023-04-22 22:40:14 +01005" Last Change: Mon Feb 27, 2023 07:16PM
Bram Moolenaardb6ea062014-07-10 22:01:47 +02006
7" Only do this when not yet done for this buffer
8if exists("b:did_ftplugin")
9 finish
10endif
11
12let s:cpo_save = &cpo
13set cpo&vim
14
15runtime! ftplugin/tex.vim
16
17" Don't load another plugin for this buffer
18let b:did_ftplugin = 1
19
20" Enables Vim-Latex-Suite, LaTeX-Box if installed
21runtime ftplugin/tex_*.vim
22
23setlocal iskeyword=@,48-57,_,.
24setlocal suffixesadd=.bib,.tex
25setlocal comments=b:%,b:#,b:##,b:###,b:#'
26
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020027if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaardd60c362023-02-27 15:49:53 +000028 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 +020029 \ "All Files (*.*)\t*.*\n"
30endif
31
Bram Moolenaar71badf92023-04-22 22:40:14 +010032function SetRnwCommentStr()
Bram Moolenaardd60c362023-02-27 15:49:53 +000033 if (search("^\s*<<.*>>=", "bncW") > search("^@", "bncW"))
34 set commentstring=#\ %s
35 else
36 set commentstring=%\ %s
37 endif
38endfunction
39
40" If you do not want both 'comments' and 'commentstring' dynamically defined,
41" put in your vimrc: let g:rnw_dynamic_comments = 0
42if !exists("g:rnw_dynamic_comments") || (exists("g:rnw_dynamic_comments") && g:rnw_dynamic_comments == 1)
43 augroup RnwCStr
44 autocmd!
45 autocmd CursorMoved <buffer> call SetRnwCommentStr()
46 augroup END
47endif
48
Bram Moolenaardb6ea062014-07-10 22:01:47 +020049if exists('b:undo_ftplugin')
Bram Moolenaar71badf92023-04-22 22:40:14 +010050 let b:undo_ftplugin .= " | setl isk< sua< com< cms< | unlet! b:browsefilter"
Bram Moolenaardb6ea062014-07-10 22:01:47 +020051else
Bram Moolenaar71badf92023-04-22 22:40:14 +010052 let b:undo_ftplugin = "setl isk< sua< com< cms< | unlet! b:browsefilter"
Bram Moolenaardb6ea062014-07-10 22:01:47 +020053endif
54
55let &cpo = s:cpo_save
56unlet s:cpo_save
57
58" vim: sw=2