Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 1 | " Vim filetype plugin file |
dkearns | e93afc2 | 2024-03-03 05:27:47 +1100 | [diff] [blame] | 2 | " 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 |
John M Devin | a7229c8 | 2024-09-23 20:09:33 +0200 | [diff] [blame] | 6 | " Last Change: |
| 7 | " 2024 Feb 28 by Vim Project |
| 8 | " 2024 Sep 23 by Vim Project: properly restore fex option |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 9 | " Original work by Alex Zvoleff |
| 10 | |
| 11 | " Only do this when not yet done for this buffer |
| 12 | if exists("b:did_ftplugin") |
| 13 | finish |
| 14 | endif |
| 15 | |
| 16 | " Don't load another plugin for this buffer |
| 17 | let b:did_ftplugin = 1 |
| 18 | |
| 19 | let s:cpo_save = &cpo |
| 20 | set cpo&vim |
| 21 | |
Bram Moolenaar | fc65cab | 2018-08-28 22:58:02 +0200 | [diff] [blame] | 22 | setlocal comments=fb:*,fb:-,fb:+,n:> |
| 23 | setlocal commentstring=#\ %s |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 24 | setlocal formatoptions+=tcqln |
| 25 | setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+ |
| 26 | setlocal iskeyword=@,48-57,_,. |
| 27 | |
Bram Moolenaar | 71badf9 | 2023-04-22 22:40:14 +0100 | [diff] [blame] | 28 | function FormatRrst() |
Bram Moolenaar | fc65cab | 2018-08-28 22:58:02 +0200 | [diff] [blame] | 29 | if search('^\.\. {r', "bncW") > search('^\.\. \.\.$', "bncW") |
| 30 | setlocal comments=:#',:###,:##,:# |
| 31 | else |
| 32 | setlocal comments=fb:*,fb:-,fb:+,n:> |
| 33 | endif |
| 34 | return 1 |
| 35 | endfunction |
| 36 | |
| 37 | " If you do not want 'comments' dynamically defined, put in your vimrc: |
| 38 | " let g:rrst_dynamic_comments = 0 |
| 39 | if !exists("g:rrst_dynamic_comments") || (exists("g:rrst_dynamic_comments") && g:rrst_dynamic_comments == 1) |
| 40 | setlocal formatexpr=FormatRrst() |
| 41 | endif |
| 42 | |
Bram Moolenaar | 11e3c5b | 2021-04-21 18:09:37 +0200 | [diff] [blame] | 43 | if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
dkearns | e93afc2 | 2024-03-03 05:27:47 +1100 | [diff] [blame] | 44 | let b:browsefilter = "R Source Files (*.R, *.Rnw, *.Rd, *.Rmd, *.Rrst, *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n" |
Doug Kearns | 93197fd | 2024-01-14 20:59:02 +0100 | [diff] [blame] | 45 | if has("win32") |
| 46 | let b:browsefilter .= "All Files (*.*)\t*\n" |
| 47 | else |
| 48 | let b:browsefilter .= "All Files (*)\t*\n" |
| 49 | endif |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 50 | endif |
| 51 | |
| 52 | if exists('b:undo_ftplugin') |
John M Devin | a7229c8 | 2024-09-23 20:09:33 +0200 | [diff] [blame] | 53 | let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< fex< | unlet! b:browsefilter" |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 54 | else |
John M Devin | a7229c8 | 2024-09-23 20:09:33 +0200 | [diff] [blame] | 55 | let b:undo_ftplugin = "setl cms< com< fo< flp< isk< fex< | unlet! b:browsefilter" |
Bram Moolenaar | db6ea06 | 2014-07-10 22:01:47 +0200 | [diff] [blame] | 56 | endif |
| 57 | |
| 58 | let &cpo = s:cpo_save |
| 59 | unlet s:cpo_save |
| 60 | |
| 61 | " vim: sw=2 |