Mercurial > vim
annotate runtime/ftplugin/rust.vim @ 16413:4734d601ebdd v8.1.1211
patch 8.1.1211: not all user command code is tested
commit https://github.com/vim/vim/commit/e61e548dd6a20471fd81160b1c2a16089505ec8c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 27 15:05:12 2019 +0200
patch 8.1.1211: not all user command code is tested
Problem: Not all user command code is tested.
Solution: Add more tests.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Apr 2019 15:15:07 +0200 |
parents | 146a1e213b60 |
children | ef1c4fa8fc11 |
rev | line source |
---|---|
11229
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Language: Rust |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " Description: Vim ftplugin for Rust |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Maintainer: Chris Morgan <me@chrismorgan.info> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " Maintainer: Kevin Ballard <kevin@sb.org> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " Last Change: June 08, 2016 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 " For bugs, patches and license go to https://github.com/rust-lang/rust.vim |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 if exists("b:did_ftplugin") |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 finish |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 let b:did_ftplugin = 1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 let s:save_cpo = &cpo |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 set cpo&vim |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 augroup rust.vim |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 autocmd! |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 " Variables {{{1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 " The rust source code at present seems to typically omit a leader on /*! |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 " comments, so we'll use that as our default, but make it easy to switch. |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " This does not affect indentation at all (I tested it with and without |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 " leader), merely whether a leader is inserted by default or not. |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader != 0 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why, |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 " but without it, */ gets indented one space even if there were no |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 " leaders. I'm fairly sure that's a Vim bug. |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,:// |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 else |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,:// |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 setlocal commentstring=//%s |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 setlocal formatoptions-=t formatoptions+=croqnl |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 " j was only added in 7.3.541, so stop complaints about its nonexistence |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 silent! setlocal formatoptions+=j |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 " smartindent will be overridden by indentexpr if filetype indent is on, but |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 " otherwise it's better than nothing. |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 setlocal smartindent nocindent |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 if !exists("g:rust_recommended_style") || g:rust_recommended_style != 0 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 setlocal textwidth=99 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 " This includeexpr isn't perfect, but it's a good start |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 setlocal includeexpr=substitute(v:fname,'::','/','g') |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 setlocal suffixesadd=.rs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 if exists("g:ftplugin_rust_source_path") |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 let &l:path=g:ftplugin_rust_source_path . ',' . &l:path |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 if exists("g:loaded_delimitMate") |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 if exists("b:delimitMate_excluded_regions") |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 let b:rust_original_delimitMate_excluded_regions = b:delimitMate_excluded_regions |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 let s:delimitMate_extra_excluded_regions = ',rustLifetimeCandidate,rustGenericLifetimeCandidate' |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 " For this buffer, when delimitMate issues the `User delimitMate_map` |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 " event in the autocommand system, add the above-defined extra excluded |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 " regions to delimitMate's state, if they have not already been added. |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 autocmd User <buffer> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 \ if expand('<afile>') ==# 'delimitMate_map' && match( |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 \ delimitMate#Get("excluded_regions"), |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 \ s:delimitMate_extra_excluded_regions) == -1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 \| let b:delimitMate_excluded_regions = |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 \ delimitMate#Get("excluded_regions") |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 \ . s:delimitMate_extra_excluded_regions |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 \|endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 " For this buffer, when delimitMate issues the `User delimitMate_unmap` |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 " event in the autocommand system, delete the above-defined extra excluded |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 " regions from delimitMate's state (the deletion being idempotent and |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 " having no effect if the extra excluded regions are not present in the |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 " targeted part of delimitMate's state). |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 autocmd User <buffer> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 \ if expand('<afile>') ==# 'delimitMate_unmap' |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 \| let b:delimitMate_excluded_regions = substitute( |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 \ delimitMate#Get("excluded_regions"), |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 \ '\C\V' . s:delimitMate_extra_excluded_regions, |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 \ '', 'g') |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 \|endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 if has("folding") && exists('g:rust_fold') && g:rust_fold != 0 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 let b:rust_set_foldmethod=1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 setlocal foldmethod=syntax |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 if g:rust_fold == 2 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 setlocal foldlevel< |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 else |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 setlocal foldlevel=99 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 if has('conceal') && exists('g:rust_conceal') && g:rust_conceal != 0 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 let b:rust_set_conceallevel=1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 setlocal conceallevel=2 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 " Motion Commands {{{1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 " Bind motion commands to support hanging indents |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 nnoremap <silent> <buffer> [[ :call rust#Jump('n', 'Back')<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 nnoremap <silent> <buffer> ]] :call rust#Jump('n', 'Forward')<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 xnoremap <silent> <buffer> [[ :call rust#Jump('v', 'Back')<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 xnoremap <silent> <buffer> ]] :call rust#Jump('v', 'Forward')<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 onoremap <silent> <buffer> [[ :call rust#Jump('o', 'Back')<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 onoremap <silent> <buffer> ]] :call rust#Jump('o', 'Forward')<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 " Commands {{{1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 " See |:RustRun| for docs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 command! -nargs=* -complete=file -bang -buffer RustRun call rust#Run(<bang>0, <q-args>) |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 " See |:RustExpand| for docs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -buffer RustExpand call rust#Expand(<bang>0, <q-args>) |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 " See |:RustEmitIr| for docs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 command! -nargs=* -buffer RustEmitIr call rust#Emit("llvm-ir", <q-args>) |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 " See |:RustEmitAsm| for docs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 command! -nargs=* -buffer RustEmitAsm call rust#Emit("asm", <q-args>) |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 " See |:RustPlay| for docs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
129 command! -range=% RustPlay :call rust#Play(<count>, <line1>, <line2>, <f-args>) |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
130 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 " See |:RustFmt| for docs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
132 command! -buffer RustFmt call rustfmt#Format() |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
133 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
134 " See |:RustFmtRange| for docs |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 command! -range -buffer RustFmtRange call rustfmt#FormatRange(<line1>, <line2>) |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
137 " Mappings {{{1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
139 " Bind ⌘R in MacVim to :RustRun |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 nnoremap <silent> <buffer> <D-r> :RustRun<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 " Bind ⌘⇧R in MacVim to :RustRun! pre-filled with the last args |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 nnoremap <buffer> <D-R> :RustRun! <C-r>=join(b:rust_last_rustc_args)<CR><C-\>erust#AppendCmdLine(' -- ' . join(b:rust_last_args))<CR> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 if !exists("b:rust_last_rustc_args") || !exists("b:rust_last_args") |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
145 let b:rust_last_rustc_args = [] |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 let b:rust_last_args = [] |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
147 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
148 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
149 " Cleanup {{{1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
150 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
151 let b:undo_ftplugin = " |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
152 \ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
153 \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
154 \|if exists('b:rust_original_delimitMate_excluded_regions') |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 \|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 \|unlet b:rust_original_delimitMate_excluded_regions |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 \|else |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
158 \|unlet! b:delimitMate_excluded_regions |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
159 \|endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 \|if exists('b:rust_set_foldmethod') |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 \|setlocal foldmethod< foldlevel< |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
162 \|unlet b:rust_set_foldmethod |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 \|endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 \|if exists('b:rust_set_conceallevel') |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 \|setlocal conceallevel< |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 \|unlet b:rust_set_conceallevel |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
167 \|endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 \|unlet! b:rust_last_rustc_args b:rust_last_args |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 \|delcommand RustRun |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 \|delcommand RustExpand |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 \|delcommand RustEmitIr |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 \|delcommand RustEmitAsm |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
173 \|delcommand RustPlay |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 \|nunmap <buffer> <D-r> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 \|nunmap <buffer> <D-R> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 \|nunmap <buffer> [[ |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 \|nunmap <buffer> ]] |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 \|xunmap <buffer> [[ |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 \|xunmap <buffer> ]] |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 \|ounmap <buffer> [[ |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 \|ounmap <buffer> ]] |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 \|set matchpairs-=<:> |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 \" |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 " }}}1 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 " Code formatting on save |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 if get(g:, "rustfmt_autosave", 0) |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 autocmd BufWritePre *.rs silent! call rustfmt#Format() |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 endif |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 augroup END |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 let &cpo = s:save_cpo |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 unlet s:save_cpo |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 |
146a1e213b60
Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 " vim: set noet sw=8 ts=8: |