diff options
Diffstat (limited to 'autoload/rust')
-rw-r--r-- | autoload/rust/debugging.vim | 1 | ||||
-rw-r--r-- | autoload/rust/delimitmate.vim | 48 |
2 files changed, 49 insertions, 0 deletions
diff --git a/autoload/rust/debugging.vim b/autoload/rust/debugging.vim index 352556d7..ff88e00c 100644 --- a/autoload/rust/debugging.vim +++ b/autoload/rust/debugging.vim @@ -18,6 +18,7 @@ let s:global_variable_list = [ \ 'rust_last_rustc_args', \ 'rust_original_delimitMate_excluded_regions', \ 'rust_playpen_url', + \ 'rust_prev_delimitMate_quotes', \ 'rust_recent_nearest_cargo_tol', \ 'rust_recent_root_cargo_toml', \ 'rust_recommended_style', 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 |