summaryrefslogtreecommitdiffstats
path: root/autoload/rust/delimitmate.vim
blob: e99cc87df248e7ad5f470e8a338b706015437a40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
  
let s:delimitMate_extra_excluded_regions = ',rustLifetimeCandidate,rustGenericLifetimeCandidate'

" For this buffer, when delimitMate issues the `User delimitMate_map`
" event in the autocommand system, add the above-defined extra excluded
" regions to delimitMate's state, if they have not already been added.
function! rust#delimitmate#onMap() abort
    if &filetype !=# 'rust'
        return
    endif

    if get(b:, "delimitMate_quotes")
        let b:rust_prev_delimitMate_quotes = b:delimitMate_quotes
    endif
    let b:delimitMate_quotes = "\" `"

    if match(delimitMate#Get("excluded_regions"),
                \ s:delimitMate_extra_excluded_regions) == -1
        call delimitMate#Set("excluded_regions",
                    \delimitMate#Get("excluded_regions").s:delimitMate_extra_excluded_regions)
    endif
endfunction

" For this buffer, when delimitMate issues the `User delimitMate_unmap`
" event in the autocommand system, delete the above-defined extra excluded
" regions from delimitMate's state (the deletion being idempotent and
" having no effect if the extra excluded regions are not present in the
" targeted part of delimitMate's state).
function! rust#delimitmate#onUnmap() abort
    if &filetype !=# 'rust'
        return
    endif

    if get(b:, "rust_prev_delimitMate_quotes")
        let b:delimitMate_quotes = b:rust_prev_delimitMate_quotes
    endif

    call delimitMate#Set("excluded_regions", substitute(
               \ delimitMate#Get("excluded_regions"),
               \ '\C\V' . s:delimitMate_extra_excluded_regions,
               \ '', 'g'))
endfunction

" vim: set et sw=4 sts=4 ts=8:


endif