summaryrefslogtreecommitdiffstats
path: root/ftplugin/rust.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ftplugin/rust.vim')
-rw-r--r--ftplugin/rust.vim35
1 files changed, 27 insertions, 8 deletions
diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim
index ace67889..e7c604ec 100644
--- a/ftplugin/rust.vim
+++ b/ftplugin/rust.vim
@@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
" Description: Vim syntax file for Rust
" Maintainer: Chris Morgan <me@chrismorgan.info>
" Maintainer: Kevin Ballard <kevin@sb.org>
-" Last Change: Jul 07, 2014
+" Last Change: January 29, 2015
if exists("b:did_ftplugin")
finish
@@ -20,7 +20,7 @@ set cpo&vim
" comments, so we'll use that as our default, but make it easy to switch.
" This does not affect indentation at all (I tested it with and without
" leader), merely whether a leader is inserted by default or not.
-if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader == 1
+if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader != 0
" Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why,
" but without it, */ gets indented one space even if there were no
" leaders. I'm fairly sure that's a Vim bug.
@@ -37,7 +37,7 @@ silent! setlocal formatoptions+=j
" otherwise it's better than nothing.
setlocal smartindent nocindent
-if !exists("g:rust_recommended_style") || g:rust_recommended_style == 1
+if !exists("g:rust_recommended_style") || g:rust_recommended_style != 0
setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
setlocal textwidth=99
endif
@@ -69,7 +69,7 @@ if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
endif
endif
-if has('conceal') && exists('g:rust_conceal')
+if has('conceal') && exists('g:rust_conceal') && g:rust_conceal != 0
let b:rust_set_conceallevel=1
setlocal conceallevel=2
endif
@@ -84,19 +84,35 @@ xnoremap <silent> <buffer> ]] :call rust#Jump('v', 'Forward')<CR>
onoremap <silent> <buffer> [[ :call rust#Jump('o', 'Back')<CR>
onoremap <silent> <buffer> ]] :call rust#Jump('o', 'Forward')<CR>
+" %-matching. <:> is handy for generics.
+set matchpairs+=<:>
+" There are two minor issues with it; (a) comparison operators in expressions,
+" where a less-than may match a greater-than later on—this is deemed a trivial
+" issue—and (b) `Fn() -> X` syntax. This latter issue is irremediable from the
+" highlighting perspective (built into Vim), but the actual % functionality
+" can be fixed by this use of matchit.vim.
+let b:match_skip = 's:comment\|string\|rustArrow'
+source $VIMRUNTIME/macros/matchit.vim
+
" Commands {{{1
" See |:RustRun| for docs
-command! -nargs=* -complete=file -bang -bar -buffer RustRun call rust#Run(<bang>0, [<f-args>])
+command! -nargs=* -complete=file -bang -buffer RustRun call rust#Run(<bang>0, <q-args>)
" See |:RustExpand| for docs
-command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -bar -buffer RustExpand call rust#Expand(<bang>0, [<f-args>])
+command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -buffer RustExpand call rust#Expand(<bang>0, <q-args>)
" See |:RustEmitIr| for docs
-command! -nargs=* -bar -buffer RustEmitIr call rust#Emit("ir", [<f-args>])
+command! -nargs=* -buffer RustEmitIr call rust#Emit("llvm-ir", <q-args>)
" See |:RustEmitAsm| for docs
-command! -nargs=* -bar -buffer RustEmitAsm call rust#Emit("asm", [<f-args>])
+command! -nargs=* -buffer RustEmitAsm call rust#Emit("asm", <q-args>)
+
+" See |:RustPlay| for docs
+command! -range=% RustPlay :call rust#Play(<count>, <line1>, <line2>, <f-args>)
+
+" See |:RustFmt| for docs
+command! -buffer RustFmt call rustfmt#Format()
" Mappings {{{1
@@ -134,6 +150,7 @@ let b:undo_ftplugin = "
\|delcommand RustExpand
\|delcommand RustEmitIr
\|delcommand RustEmitAsm
+ \|delcommand RustPlay
\|nunmap <buffer> <D-r>
\|nunmap <buffer> <D-R>
\|nunmap <buffer> [[
@@ -142,6 +159,8 @@ let b:undo_ftplugin = "
\|xunmap <buffer> ]]
\|ounmap <buffer> [[
\|ounmap <buffer> ]]
+ \|set matchpairs-=<:>
+ \|unlet b:match_skip
\"
" }}}1