diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2018-10-08 19:00:59 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2018-10-08 19:00:59 +0200 |
commit | fd74d8b2b170b540680a9bbf6c64990f8ebafd08 (patch) | |
tree | b1fdef6203a78a21053d1b8e0666ab7a38c36df2 /autoload/rust/delimitmate.vim | |
parent | 055f7710b65dfa2df52fc0b5be2486ae36ac5751 (diff) | |
download | vim-polyglot-3.3.3.tar.gz vim-polyglot-3.3.3.zip |
Updatev3.3.3
Diffstat (limited to 'autoload/rust/delimitmate.vim')
-rw-r--r-- | autoload/rust/delimitmate.vim | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/autoload/rust/delimitmate.vim b/autoload/rust/delimitmate.vim new file mode 100644 index 00000000..e99cc87d --- /dev/null +++ b/autoload/rust/delimitmate.vim @@ -0,0 +1,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 |