|
1 | 1 | " Vim syntax file
|
2 | 2 | " Language: Rust
|
3 | 3 | " Maintainer: Chris Morgan <[email protected]>
|
4 |
| -" Last Change: 2013 Jul 10 |
| 4 | +" Last Change: 2014 Feb 27 |
5 | 5 |
|
6 | 6 | if exists("b:did_ftplugin")
|
7 | 7 | finish
|
@@ -42,4 +42,55 @@ if exists("g:loaded_delimitMate")
|
42 | 42 | let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
|
43 | 43 | endif
|
44 | 44 |
|
45 |
| -let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< | if exists('b:rust_original_delimitMate_excluded_regions') | let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions | unlet b:rust_original_delimitMate_excluded_regions | elseif exists('b:delimitMate_excluded_regions') | unlet b:delimitMate_excluded_regions | endif" |
| 45 | +" Bind motion commands to support hanging indents |
| 46 | +nnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('n', 'Back')<CR> |
| 47 | +nnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('n', 'Forward')<CR> |
| 48 | +xnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('v', 'Back')<CR> |
| 49 | +xnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('v', 'Forward')<CR> |
| 50 | +onoremap <silent> <buffer> [[ :call <SID>Rust_Jump('o', 'Back')<CR> |
| 51 | +onoremap <silent> <buffer> ]] :call <SID>Rust_Jump('o', 'Forward')<CR> |
| 52 | +
|
| 53 | +let b:undo_ftplugin = " |
| 54 | + \setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< |
| 55 | + \|if exists('b:rust_original_delimitMate_excluded_regions') |
| 56 | + \|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions |
| 57 | + \|unlet b:rust_original_delimitMate_excluded_regions |
| 58 | + \|elseif exists('b:delimitMate_excluded_regions') |
| 59 | + \|unlet b:delimitMate_excluded_regions |
| 60 | + \|endif |
| 61 | + \|nunmap <buffer> [[ |
| 62 | + \|nunmap <buffer> ]] |
| 63 | + \|xunmap <buffer> [[ |
| 64 | + \|xunmap <buffer> ]] |
| 65 | + \|ounmap <buffer> [[ |
| 66 | + \|ounmap <buffer> ]] |
| 67 | + \" |
| 68 | + |
| 69 | +if exists('*<SID>Rust_Jump') | finish | endif |
| 70 | + |
| 71 | +function! <SID>Rust_Jump(mode, function) range |
| 72 | + let cnt = v:count1 |
| 73 | + normal! m' |
| 74 | + if a:mode ==# 'v' |
| 75 | + norm! gv |
| 76 | + endif |
| 77 | + let foldenable = &foldenable |
| 78 | + set nofoldenable |
| 79 | + while cnt > 0 |
| 80 | + execute "call <SID>Rust_Jump_" . a:function . "()" |
| 81 | + let cnt = cnt - 1 |
| 82 | + endwhile |
| 83 | + let &foldenable = foldenable |
| 84 | +endfunction |
| 85 | + |
| 86 | +function! <SID>Rust_Jump_Back() |
| 87 | + call search('{', 'b') |
| 88 | + keepjumps normal! w99[{ |
| 89 | +endfunction |
| 90 | + |
| 91 | +function! <SID>Rust_Jump_Forward() |
| 92 | + normal! j0 |
| 93 | + call search('{', 'b') |
| 94 | + keepjumps normal! w99[{% |
| 95 | + call search('{') |
| 96 | +endfunction |
0 commit comments