xref: /vim-8.2.3635/runtime/ftplugin/rst.vim (revision d1caa941)
1" reStructuredText filetype plugin file
2" Language: reStructuredText documentation format
3" Maintainer: Marshall Ward <[email protected]>
4" Original Maintainer: Nikolai Weibull <[email protected]>
5" Website: https://github.com/marshallward/vim-restructuredtext
6" Latest Revision: 2020-03-31
7
8if exists("b:did_ftplugin")
9    finish
10endif
11let b:did_ftplugin = 1
12
13let s:cpo_save = &cpo
14set cpo&vim
15
16"Disable folding
17if !exists('g:rst_fold_enabled')
18  let g:rst_fold_enabled = 0
19endif
20
21let b:undo_ftplugin = "setl com< cms< et< fo<"
22
23setlocal comments=fb:.. commentstring=..\ %s expandtab
24setlocal formatoptions+=tcroql
25
26" reStructuredText standard recommends that tabs be expanded to 8 spaces
27" The choice of 3-space indentation is to provide slightly better support for
28" directives (..) and ordered lists (1.), although it can cause problems for
29" many other cases.
30"
31" More sophisticated indentation rules should be revisted in the future.
32
33if exists("g:rst_style") && g:rst_style != 0
34    setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8
35endif
36
37if g:rst_fold_enabled != 0 && has('patch-7.3.867')  " Introduced the TextChanged event.
38  setlocal foldmethod=expr
39  setlocal foldexpr=RstFold#GetRstFold()
40  setlocal foldtext=RstFold#GetRstFoldText()
41  augroup RstFold
42    autocmd TextChanged,InsertLeave <buffer> unlet! b:RstFoldCache
43  augroup END
44endif
45
46let &cpo = s:cpo_save
47unlet s:cpo_save
48