Skip to content

Commit b7af308

Browse files
chris-morganalexcrichton
authored andcommitted
---
yaml --- r: 102251 b: refs/heads/master c: 879ac43 h: refs/heads/master i: 102249: 6bb6386 102247: d01aebf v: v3
1 parent 6f306bc commit b7af308

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0a663a2d3173832d656f4b2a31009407444defe7
2+
refs/heads/master: 879ac436890ca8f810b9b8275e4e0ec488f9c5d5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff

trunk/src/etc/vim/ftplugin/rust.vim

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim syntax file
22
" Language: Rust
33
" Maintainer: Chris Morgan <[email protected]>
4-
" Last Change: 2013 Jul 10
4+
" Last Change: 2014 Feb 27
55

66
if exists("b:did_ftplugin")
77
finish
@@ -42,4 +42,55 @@ if exists("g:loaded_delimitMate")
4242
let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
4343
endif
4444

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

Comments
 (0)