diff options
author | Jesse Luehrs <doy@tozt.net> | 2015-03-17 08:34:53 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2015-03-17 08:39:44 -0400 |
commit | 30e7537feb8e7d5331785bd4e49e066a008fc430 (patch) | |
tree | 47ab6a39fe2f640f66326b4cacbd62265db31e98 /vim | |
parent | b797fa3f155648d57817a3e9bc5d1262ac9d2d93 (diff) | |
download | conf-30e7537feb8e7d5331785bd4e49e066a008fc430.tar.gz conf-30e7537feb8e7d5331785bd4e49e066a008fc430.zip |
remove manual copy of rust vim plugin
Diffstat (limited to 'vim')
-rw-r--r-- | vim/bundle/rust/.gitignore | 1 | ||||
-rw-r--r-- | vim/bundle/rust/after/syntax/rust.vim | 31 | ||||
-rw-r--r-- | vim/bundle/rust/autoload/rust.vim | 225 | ||||
-rw-r--r-- | vim/bundle/rust/compiler/rustc.vim | 33 | ||||
-rw-r--r-- | vim/bundle/rust/doc/rust.txt | 162 | ||||
-rw-r--r-- | vim/bundle/rust/ftdetect/rust.vim | 1 | ||||
-rw-r--r-- | vim/bundle/rust/ftplugin/rust.vim | 149 | ||||
-rw-r--r-- | vim/bundle/rust/indent/rust.vim | 194 | ||||
-rw-r--r-- | vim/bundle/rust/plugin/rust.vim | 22 | ||||
-rw-r--r-- | vim/bundle/rust/syntax/rust.vim | 291 | ||||
-rw-r--r-- | vim/bundle/rust/syntax_checkers/rust/rustc.vim | 35 |
11 files changed, 0 insertions, 1144 deletions
diff --git a/vim/bundle/rust/.gitignore b/vim/bundle/rust/.gitignore deleted file mode 100644 index 926ccaa..0000000 --- a/vim/bundle/rust/.gitignore +++ /dev/null @@ -1 +0,0 @@ -doc/tags diff --git a/vim/bundle/rust/after/syntax/rust.vim b/vim/bundle/rust/after/syntax/rust.vim deleted file mode 100644 index 735c1e1..0000000 --- a/vim/bundle/rust/after/syntax/rust.vim +++ /dev/null @@ -1,31 +0,0 @@ -if !exists('g:rust_conceal') || !has('conceal') || &enc != 'utf-8' - finish -endif - -" For those who don't want to see `::`... -if exists('g:rust_conceal_mod_path') - syn match rustNiceOperator "::" conceal cchar=ㆍ -endif - -syn match rustRightArrowHead contained ">" conceal cchar= -syn match rustRightArrowTail contained "-" conceal cchar=⟶ -syn match rustNiceOperator "->" contains=rustRightArrowHead,rustRightArrowTail - -syn match rustFatRightArrowHead contained ">" conceal cchar= -syn match rustFatRightArrowTail contained "=" conceal cchar=⟹ -syn match rustNiceOperator "=>" contains=rustFatRightArrowHead,rustFatRightArrowTail - -syn match rustNiceOperator /\<\@!_\(_*\>\)\@=/ conceal cchar=′ - -" For those who don't want to see `pub`... -if exists('g:rust_conceal_pub') - syn match rustPublicSigil contained "pu" conceal cchar=* - syn match rustPublicRest contained "b" conceal cchar= - syn match rustNiceOperator "pub " contains=rustPublicSigil,rustPublicRest -endif - -hi link rustNiceOperator Operator - -if !exists('g:rust_conceal_mod_path') - hi! link Conceal Operator -endif diff --git a/vim/bundle/rust/autoload/rust.vim b/vim/bundle/rust/autoload/rust.vim deleted file mode 100644 index c6b9b31..0000000 --- a/vim/bundle/rust/autoload/rust.vim +++ /dev/null @@ -1,225 +0,0 @@ -" Author: Kevin Ballard -" Description: Helper functions for Rust commands/mappings -" Last Modified: May 27, 2014 - -" Jump {{{1 - -function! rust#Jump(mode, function) range - let cnt = v:count1 - normal! m' - if a:mode ==# 'v' - norm! gv - endif - let foldenable = &foldenable - set nofoldenable - while cnt > 0 - execute "call <SID>Jump_" . a:function . "()" - let cnt = cnt - 1 - endwhile - let &foldenable = foldenable -endfunction - -function! s:Jump_Back() - call search('{', 'b') - keepjumps normal! w99[{ -endfunction - -function! s:Jump_Forward() - normal! j0 - call search('{', 'b') - keepjumps normal! w99[{% - call search('{') -endfunction - -" Run {{{1 - -function! rust#Run(bang, args) - if a:bang - let idx = index(a:args, '--') - if idx != -1 - let rustc_args = idx == 0 ? [] : a:args[:idx-1] - let args = a:args[idx+1:] - else - let rustc_args = a:args - let args = [] - endif - else - let rustc_args = [] - let args = a:args - endif - - let b:rust_last_rustc_args = rustc_args - let b:rust_last_args = args - - call s:WithPath(function("s:Run"), rustc_args, args) -endfunction - -function! s:Run(path, rustc_args, args) - try - let exepath = tempname() - if has('win32') - let exepath .= '.exe' - endif - - let rustc_args = [a:path, '-o', exepath] + a:rustc_args - - let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" - - let output = system(shellescape(rustc) . " " . join(map(rustc_args, 'shellescape(v:val)'))) - if output != '' - echohl WarningMsg - echo output - echohl None - endif - if !v:shell_error - exe '!' . shellescape(exepath) . " " . join(map(a:args, 'shellescape(v:val)')) - endif - finally - if exists("exepath") - silent! call delete(exepath) - endif - endtry -endfunction - -" Expand {{{1 - -function! rust#Expand(bang, args) - if a:bang && !empty(a:args) - let pretty = a:args[0] - let args = a:args[1:] - else - let pretty = "expanded" - let args = a:args - endif - call s:WithPath(function("s:Expand"), pretty, args) -endfunction - -function! s:Expand(path, pretty, args) - try - let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" - - let args = [a:path, '--pretty', a:pretty] + a:args - let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) - if v:shell_error - echohl WarningMsg - echo output - echohl None - else - new - silent put =output - 1 - d - setl filetype=rust - setl buftype=nofile - setl bufhidden=hide - setl noswapfile - endif - endtry -endfunction - -function! rust#CompleteExpand(lead, line, pos) - if a:line[: a:pos-1] =~ '^RustExpand!\s*\S*$' - " first argument and it has a ! - let list = ["normal", "expanded", "typed", "expanded,identified", "flowgraph="] - if !empty(a:lead) - call filter(list, "v:val[:len(a:lead)-1] == a:lead") - endif - return list - endif - - return glob(escape(a:lead, "*?[") . '*', 0, 1) -endfunction - -" Emit {{{1 - -function! rust#Emit(type, args) - call s:WithPath(function("s:Emit"), a:type, a:args) -endfunction - -function! s:Emit(path, type, args) - try - let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" - - let args = [a:path, '--emit', a:type, '-o', '-'] + a:args - let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) - if v:shell_error - echohl WarningMsg - echo output - echohl None - else - new - silent put =output - 1 - d - if a:type == "ir" - setl filetype=llvm - elseif a:type == "asm" - setl filetype=asm - endif - setl buftype=nofile - setl bufhidden=hide - setl noswapfile - endif - endtry -endfunction - -" Utility functions {{{1 - -function! s:WithPath(func, ...) - try - let save_write = &write - set write - let path = expand('%') - let pathisempty = empty(path) - if pathisempty || !save_write - " use a temporary file named 'unnamed.rs' inside a temporary - " directory. This produces better error messages - let tmpdir = tempname() - call mkdir(tmpdir) - - let save_cwd = getcwd() - silent exe 'lcd' tmpdir - - let path = 'unnamed.rs' - - let save_mod = &mod - set nomod - - silent exe 'keepalt write! ' . path - if pathisempty - silent keepalt 0file - endif - else - update - endif - - call call(a:func, [path] + a:000) - finally - if exists("save_mod") | let &mod = save_mod | endif - if exists("save_write") | let &write = save_write | endif - if exists("save_cwd") | silent exe 'lcd' save_cwd | endif - if exists("tmpdir") | silent call s:RmDir(tmpdir) | endif - endtry -endfunction - -function! rust#AppendCmdLine(text) - call setcmdpos(getcmdpos()) - let cmd = getcmdline() . a:text - return cmd -endfunction - -function! s:RmDir(path) - " sanity check; make sure it's not empty, /, or $HOME - if empty(a:path) - echoerr 'Attempted to delete empty path' - return 0 - elseif a:path == '/' || a:path == $HOME - echoerr 'Attempted to delete protected path: ' . a:path - return 0 - endif - silent exe "!rm -rf " . shellescape(a:path) -endfunction - -" }}}1 - -" vim: set noet sw=4 ts=4: diff --git a/vim/bundle/rust/compiler/rustc.vim b/vim/bundle/rust/compiler/rustc.vim deleted file mode 100644 index f9b854e..0000000 --- a/vim/bundle/rust/compiler/rustc.vim +++ /dev/null @@ -1,33 +0,0 @@ -" Vim compiler file -" Compiler: Rust Compiler -" Maintainer: Chris Morgan <me@chrismorgan.info> -" Latest Revision: 2013 Jul 12 - -if exists("current_compiler") - finish -endif -let current_compiler = "rustc" - -let s:cpo_save = &cpo -set cpo&vim - -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - -if exists("g:rustc_makeprg_no_percent") && g:rustc_makeprg_no_percent == 1 - CompilerSet makeprg=rustc -else - CompilerSet makeprg=rustc\ \% -endif - -CompilerSet errorformat= - \%f:%l:%c:\ %t%*[^:]:\ %m, - \%f:%l:%c:\ %*\\d:%*\\d\ %t%*[^:]:\ %m, - \%-G%f:%l\ %s, - \%-G%*[\ ]^, - \%-G%*[\ ]^%*[~], - \%-G%*[\ ]... - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/vim/bundle/rust/doc/rust.txt b/vim/bundle/rust/doc/rust.txt deleted file mode 100644 index 80f8c3c..0000000 --- a/vim/bundle/rust/doc/rust.txt +++ /dev/null @@ -1,162 +0,0 @@ -*rust.txt* Filetype plugin for Rust - -============================================================================== -CONTENTS *rust* *ft-rust* - -1. Introduction |rust-intro| -2. Settings |rust-settings| -3. Commands |rust-commands| -4. Mappings |rust-mappings| - -============================================================================== -INTRODUCTION *rust-intro* - -This plugin provides syntax and supporting functionality for the Rust -filetype. - -============================================================================== -SETTINGS *rust-settings* - -This plugin has a few variables you can define in your vimrc that change the -behavior of the plugin. - - *g:rustc_path* -g:rustc_path~ - Set this option to the path to rustc for use in the |:RustRun| and - |:RustExpand| commands. If unset, "rustc" will be located in $PATH: > - let g:rustc_path = $HOME."/bin/rustc" -< - - *g:rustc_makeprg_no_percent* -g:rustc_makeprg_no_percent~ - Set this option to 1 to have 'makeprg' default to "rustc" instead of - "rustc %": > - let g:rustc_makeprg_no_percent = 1 -< - - *g:rust_conceal* -g:rust_conceal~ - Set this option to turn on the basic |conceal| support: > - let g:rust_conceal = 1 -< - - *g:rust_conceal_mod_path* -g:rust_conceal_mod_path~ - Set this option to turn on |conceal| for the path connecting token - "::": > - let g:rust_conceal_mod_path = 1 -< - - *g:rust_conceal_pub* -g:rust_conceal_pub~ - Set this option to turn on |conceal| for the "pub" token: > - let g:rust_conceal_pub = 1 -< - - *g:rust_fold* -g:rust_fold~ - Set this option to turn on |folding|: > - let g:rust_fold = 1 -< - Value Effect ~ - 0 No folding - 1 Braced blocks are folded. All folds are open by - default. - 2 Braced blocks are folded. 'foldlevel' is left at the - global value (all folds are closed by default). - - *g:rust_bang_comment_leader* -g:rust_bang_comment_leader~ - Set this option to 1 to preserve the leader on multi-line doc comments - using the /*! syntax: > - let g:rust_bang_comment_leader = 1 -< - - *g:ftplugin_rust_source_path* -g:ftplugin_rust_source_path~ - Set this option to a path that should be prepended to 'path' for Rust - source files: > - let g:ftplugin_rust_source_path = $HOME.'/dev/rust' -< - -============================================================================== -COMMANDS *rust-commands* - -:RustRun [args] *:RustRun* -:RustRun! [rustc-args] [--] [args] - Compiles and runs the current file. If it has unsaved changes, - it will be saved first using |:update|. If the current file is - an unnamed buffer, it will be written to a temporary file - first. The compiled binary is always placed in a temporary - directory, but is run from the current directory. - - The arguments given to |:RustRun| will be passed to the - compiled binary. - - If ! is specified, the arguments are passed to rustc instead. - A "--" argument will separate the rustc arguments from the - arguments passed to the binary. - - If |g:rustc_path| is defined, it is used as the path to rustc. - Otherwise it is assumed rustc can be found in $PATH. - -:RustExpand [args] *:RustExpand* -:RustExpand! [TYPE] [args] - Expands the current file using --pretty and displays the - results in a new split. If the current file has unsaved - changes, it will be saved first using |:update|. If the - current file is an unnamed buffer, it will be written to a - temporary file first. - - The arguments given to |:RustExpand| will be passed to rustc. - This is largely intended for specifying various --cfg - configurations. - - If ! is specified, the first argument is the expansion type to - pass to rustc --pretty. Otherwise it will default to - "expanded". - - If |g:rustc_path| is defined, it is used as the path to rustc. - Otherwise it is assumed rustc can be found in $PATH. - -:RustEmitIr [args] *:RustEmitIr* - Compiles the current file to LLVM IR and displays the results - in a new split. If the current file has unsaved changes, it - will be saved first using |:update|. If the current file is an - unnamed buffer, it will be written to a temporary file first. - - The arguments given to |:RustEmitIr| will be passed to rustc. - - If |g:rustc_path| is defined, it is used as the path to rustc. - Otherwise it is assumed rustc can be found in $PATH. - -:RustEmitAsm [args] *:RustEmitAsm* - Compiles the current file to assembly and displays the results - in a new split. If the current file has unsaved changes, it - will be saved first using |:update|. If the current file is an - unnamed buffer, it will be written to a temporary file first. - - The arguments given to |:RustEmitAsm| will be passed to rustc. - - If |g:rustc_path| is defined, it is used as the path to rustc. - Otherwise it is assumed rustc can be found in $PATH. - -============================================================================== -MAPPINGS *rust-mappings* - -This plugin defines mappings for |[[| and |]]| to support hanging indents. - -It also has a few other mappings: - - *rust_<D-r>* -<D-r> Executes |:RustRun| with no arguments. - Note: This binding is only available in MacVim. - - *rust_<D-R>* -<D-R> Populates the command line with |:RustRun|! using the - arguments given to the last invocation, but does not - execute it. - Note: This binding is only available in MacVim. - -============================================================================== - vim:tw=78:sw=4:noet:ts=8:ft=help:norl: diff --git a/vim/bundle/rust/ftdetect/rust.vim b/vim/bundle/rust/ftdetect/rust.vim deleted file mode 100644 index bf685d4..0000000 --- a/vim/bundle/rust/ftdetect/rust.vim +++ /dev/null @@ -1 +0,0 @@ -au BufRead,BufNewFile *.rs set filetype=rust diff --git a/vim/bundle/rust/ftplugin/rust.vim b/vim/bundle/rust/ftplugin/rust.vim deleted file mode 100644 index 09eaf62..0000000 --- a/vim/bundle/rust/ftplugin/rust.vim +++ /dev/null @@ -1,149 +0,0 @@ -" Language: Rust -" Description: Vim syntax file for Rust -" Maintainer: Chris Morgan <me@chrismorgan.info> -" Maintainer: Kevin Ballard <kevin@sb.org> -" Last Change: Jul 07, 2014 - -if exists("b:did_ftplugin") - finish -endif -let b:did_ftplugin = 1 - -let s:save_cpo = &cpo -set cpo&vim - -" Variables {{{1 - -" The rust source code at present seems to typically omit a leader on /*! -" 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 - " 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. - setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,:// -else - setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,:// -endif -setlocal commentstring=//%s -setlocal formatoptions-=t formatoptions+=croqnl -" j was only added in 7.3.541, so stop complaints about its nonexistence -silent! setlocal formatoptions+=j - -" smartindent will be overridden by indentexpr if filetype indent is on, but -" otherwise it's better than nothing. -setlocal smartindent nocindent - -setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab - -setlocal textwidth=99 - -" This includeexpr isn't perfect, but it's a good start -setlocal includeexpr=substitute(v:fname,'::','/','g') - -" NOT adding .rc as it's being phased out (0.7) -setlocal suffixesadd=.rs - -if exists("g:ftplugin_rust_source_path") - let &l:path=g:ftplugin_rust_source_path . ',' . &l:path -endif - -if exists("g:loaded_delimitMate") - if exists("b:delimitMate_excluded_regions") - let b:rust_original_delimitMate_excluded_regions = b:delimitMate_excluded_regions - endif - let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate' -endif - -if has("folding") && exists('g:rust_fold') && g:rust_fold != 0 - let b:rust_set_foldmethod=1 - setlocal foldmethod=syntax - if g:rust_fold == 2 - setlocal foldlevel< - else - setlocal foldlevel=99 - endif -endif - -if has('conceal') && exists('g:rust_conceal') - let b:rust_set_conceallevel=1 - setlocal conceallevel=2 -endif - -" Motion Commands {{{1 - -" Bind motion commands to support hanging indents -nnoremap <silent> <buffer> [[ :call rust#Jump('n', 'Back')<CR> -nnoremap <silent> <buffer> ]] :call rust#Jump('n', 'Forward')<CR> -xnoremap <silent> <buffer> [[ :call rust#Jump('v', 'Back')<CR> -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> - -" Commands {{{1 - -" See |:RustRun| for docs -command! -nargs=* -complete=file -bang -bar -buffer RustRun call rust#Run(<bang>0, [<f-args>]) - -" See |:RustExpand| for docs -command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -bar -buffer RustExpand call rust#Expand(<bang>0, [<f-args>]) - -" See |:RustEmitIr| for docs -command! -nargs=* -bar -buffer RustEmitIr call rust#Emit("ir", [<f-args>]) - -" See |:RustEmitAsm| for docs -command! -nargs=* -bar -buffer RustEmitAsm call rust#Emit("asm", [<f-args>]) - -" Mappings {{{1 - -" Bind ⌘R in MacVim to :RustRun -nnoremap <silent> <buffer> <D-r> :RustRun<CR> -" Bind ⌘⇧R in MacVim to :RustRun! pre-filled with the last args -nnoremap <buffer> <D-R> :RustRun! <C-r>=join(b:rust_last_rustc_args)<CR><C-\>erust#AppendCmdLine(' -- ' . join(b:rust_last_args))<CR> - -if !exists("b:rust_last_rustc_args") || !exists("b:rust_last_args") - let b:rust_last_rustc_args = [] - let b:rust_last_args = [] -endif - -" Cleanup {{{1 - -let b:undo_ftplugin = " - \ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< - \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< - \|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 - \|else - \|unlet! b:delimitMate_excluded_regions - \|endif - \|if exists('b:rust_set_foldmethod') - \|setlocal foldmethod< foldlevel< - \|unlet b:rust_set_foldmethod - \|endif - \|if exists('b:rust_set_conceallevel') - \|setlocal conceallevel< - \|unlet b:rust_set_conceallevel - \|endif - \|unlet! b:rust_last_rustc_args b:rust_last_args - \|delcommand RustRun - \|delcommand RustExpand - \|delcommand RustEmitIr - \|delcommand RustEmitAsm - \|nunmap <buffer> <D-r> - \|nunmap <buffer> <D-R> - \|nunmap <buffer> [[ - \|nunmap <buffer> ]] - \|xunmap <buffer> [[ - \|xunmap <buffer> ]] - \|ounmap <buffer> [[ - \|ounmap <buffer> ]] - \" - -" }}}1 - -let &cpo = s:save_cpo -unlet s:save_cpo - -" vim: set noet sw=4 ts=4: diff --git a/vim/bundle/rust/indent/rust.vim b/vim/bundle/rust/indent/rust.vim deleted file mode 100644 index b9d6330..0000000 --- a/vim/bundle/rust/indent/rust.vim +++ /dev/null @@ -1,194 +0,0 @@ -" Vim indent file -" Language: Rust -" Author: Chris Morgan <me@chrismorgan.info> -" Last Change: 2013 Oct 29 - -" Only load this indent file when no other was loaded. -if exists("b:did_indent") - finish -endif -let b:did_indent = 1 - -setlocal cindent -setlocal cinoptions=L0,(0,Ws,JN,j1 -setlocal cinkeys=0{,0},!^F,o,O,0[,0] -" Don't think cinwords will actually do anything at all... never mind -setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern - -" Some preliminary settings -setlocal nolisp " Make sure lisp indenting doesn't supersede us -setlocal autoindent " indentexpr isn't much help otherwise -" Also do indentkeys, otherwise # gets shoved to column 0 :-/ -setlocal indentkeys=0{,0},!^F,o,O,0[,0] - -setlocal indentexpr=GetRustIndent(v:lnum) - -" Only define the function once. -if exists("*GetRustIndent") - finish -endif - -" Come here when loading the script the first time. - -function! s:get_line_trimmed(lnum) - " Get the line and remove a trailing comment. - " Use syntax highlighting attributes when possible. - " NOTE: this is not accurate; /* */ or a line continuation could trick it - let line = getline(a:lnum) - let line_len = strlen(line) - if has('syntax_items') - " If the last character in the line is a comment, do a binary search for - " the start of the comment. synID() is slow, a linear search would take - " too long on a long line. - if synIDattr(synID(a:lnum, line_len, 1), "name") =~ 'Comment\|Todo' - let min = 1 - let max = line_len - while min < max - let col = (min + max) / 2 - if synIDattr(synID(a:lnum, col, 1), "name") =~ 'Comment\|Todo' - let max = col - else - let min = col + 1 - endif - endwhile - let line = strpart(line, 0, min - 1) - endif - return substitute(line, "\s*$", "", "") - else - " Sorry, this is not complete, nor fully correct (e.g. string "//"). - " Such is life. - return substitute(line, "\s*//.*$", "", "") - endif -endfunction - -function! s:is_string_comment(lnum, col) - if has('syntax_items') - for id in synstack(a:lnum, a:col) - let synname = synIDattr(id, "name") - if synname == "rustString" || synname =~ "^rustComment" - return 1 - endif - endfor - else - " without syntax, let's not even try - return 0 - endif -endfunction - -function GetRustIndent(lnum) - - " Starting assumption: cindent (called at the end) will do it right - " normally. We just want to fix up a few cases. - - let line = getline(a:lnum) - - if has('syntax_items') - let synname = synIDattr(synID(a:lnum, 1, 1), "name") - if synname == "rustString" - " If the start of the line is in a string, don't change the indent - return -1 - elseif synname =~ '\(Comment\|Todo\)' - \ && line !~ '^\s*/\*' " not /* opening line - if synname =~ "CommentML" " multi-line - if line !~ '^\s*\*' && getline(a:lnum - 1) =~ '^\s*/\*' - " This is (hopefully) the line after a /*, and it has no - " leader, so the correct indentation is that of the - " previous line. - return GetRustIndent(a:lnum - 1) - endif - endif - " If it's in a comment, let cindent take care of it now. This is - " for cases like "/*" where the next line should start " * ", not - " "* " as the code below would otherwise cause for module scope - " Fun fact: " /*\n*\n*/" takes two calls to get right! - return cindent(a:lnum) - endif - endif - - " cindent gets second and subsequent match patterns/struct members wrong, - " as it treats the comma as indicating an unfinished statement:: - " - " match a { - " b => c, - " d => e, - " f => g, - " }; - - " Search backwards for the previous non-empty line. - let prevlinenum = prevnonblank(a:lnum - 1) - let prevline = s:get_line_trimmed(prevlinenum) - while prevlinenum > 1 && prevline !~ '[^[:blank:]]' - let prevlinenum = prevnonblank(prevlinenum - 1) - let prevline = s:get_line_trimmed(prevlinenum) - endwhile - if prevline[len(prevline) - 1] == "," - \ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]' - \ && prevline !~ '^\s*fn\s' - \ && prevline !~ '([^()]\+,$' - " Oh ho! The previous line ended in a comma! I bet cindent will try to - " take this too far... For now, let's normally use the previous line's - " indent. - - " One case where this doesn't work out is where *this* line contains - " square or curly brackets; then we normally *do* want to be indenting - " further. - " - " Another case where we don't want to is one like a function - " definition with arguments spread over multiple lines: - " - " fn foo(baz: Baz, - " baz: Baz) // <-- cindent gets this right by itself - " - " Another case is similar to the previous, except calling a function - " instead of defining it, or any conditional expression that leaves - " an open paren: - " - " foo(baz, - " baz); - " - " if baz && (foo || - " bar) { - " - " There are probably other cases where we don't want to do this as - " well. Add them as needed. - return GetRustIndent(a:lnum - 1) - endif - - " cindent doesn't do the module scope well at all; e.g.:: - " - " static FOO : &'static [bool] = [ - " true, - " false, - " false, - " true, - " ]; - " - " uh oh, next statement is indented further! - - " Note that this does *not* apply the line continuation pattern properly; - " that's too hard to do correctly for my liking at present, so I'll just - " start with these two main cases (square brackets and not returning to - " column zero) - - call cursor(a:lnum, 1) - if searchpair('{\|(', '', '}\|)', 'nbW', - \ 's:is_string_comment(line("."), col("."))') == 0 - if searchpair('\[', '', '\]', 'nbW', - \ 's:is_string_comment(line("."), col("."))') == 0 - " Global scope, should be zero - return 0 - else - " At the module scope, inside square brackets only - "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum - if line =~ "^\\s*]" - " It's the closing line, dedent it - return 0 - else - return &shiftwidth - endif - endif - endif - - " Fall back on cindent, which does it mostly right - return cindent(a:lnum) -endfunction diff --git a/vim/bundle/rust/plugin/rust.vim b/vim/bundle/rust/plugin/rust.vim deleted file mode 100644 index 4ec4f33..0000000 --- a/vim/bundle/rust/plugin/rust.vim +++ /dev/null @@ -1,22 +0,0 @@ -" Vim syntastic plugin helper -" Language: Rust -" Maintainer: Andrew Gallant <jamslam@gmail.com> - -if exists("g:loaded_syntastic_rust_filetype") - finish -endif -let g:loaded_syntastic_rust_filetype = 1 -let s:save_cpo = &cpo -set cpo&vim - -" This is to let Syntastic know about the Rust filetype. -" It enables tab completion for the 'SyntasticInfo' command. -" (This does not actually register the syntax checker.) -if exists('g:syntastic_extra_filetypes') - call add(g:syntastic_extra_filetypes, 'rust') -else - let g:syntastic_extra_filetypes = ['rust'] -endif - -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/vim/bundle/rust/syntax/rust.vim b/vim/bundle/rust/syntax/rust.vim deleted file mode 100644 index 6ee610d..0000000 --- a/vim/bundle/rust/syntax/rust.vim +++ /dev/null @@ -1,291 +0,0 @@ -" Vim syntax file -" Language: Rust -" Maintainer: Patrick Walton <pcwalton@mozilla.com> -" Maintainer: Ben Blum <bblum@cs.cmu.edu> -" Maintainer: Chris Morgan <me@chrismorgan.info> -" Last Change: July 18, 2014 - -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -" Syntax definitions {{{1 -" Basic keywords {{{2 -syn keyword rustConditional match if else -syn keyword rustOperator as - -syn match rustAssert "\<assert\(\w\)*!" contained -syn match rustFail "\<fail\(\w\)*!" contained -syn keyword rustKeyword break -syn keyword rustKeyword box nextgroup=rustBoxPlacement skipwhite skipempty -syn keyword rustKeyword continue -syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite skipempty -syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite skipempty -syn keyword rustKeyword for in if impl let -syn keyword rustKeyword loop once proc pub -syn keyword rustKeyword return super -syn keyword rustKeyword unsafe virtual where while -syn keyword rustKeyword use nextgroup=rustModPath,rustModPathInUse skipwhite skipempty -" FIXME: Scoped impl's name is also fallen in this category -syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite skipempty -syn keyword rustStorage mut ref static const - -syn keyword rustInvalidBareKeyword crate - -syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite skipempty -syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty - -syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained - -syn region rustBoxPlacement matchgroup=rustBoxPlacementParens start="(" end=")" contains=TOP contained -syn keyword rustBoxPlacementExpr GC containedin=rustBoxPlacement -" Ideally we'd have syntax rules set up to match arbitrary expressions. Since -" we don't, we'll just define temporary contained rules to handle balancing -" delimiters. -syn region rustBoxPlacementBalance start="(" end=")" containedin=rustBoxPlacement transparent -syn region rustBoxPlacementBalance start="\[" end="\]" containedin=rustBoxPlacement transparent -" {} are handled by rustFoldBraces - -syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end=")" contains=TOP nextgroup=rustMacroRepeatCount -syn match rustMacroRepeatCount ".\?[*+]" contained -syn match rustMacroVariable "$\w\+" - -" Reserved (but not yet used) keywords {{{2 -syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield - -" Built-in types {{{2 -syn keyword rustType int uint float char bool u8 u16 u32 u64 f32 -syn keyword rustType f64 i8 i16 i32 i64 str Self - -" Things from the prelude (src/libstd/prelude.rs) {{{2 -" This section is just straight transformation of the contents of the prelude, -" to make it easy to update. - -" Core operators {{{3 -syn keyword rustTrait Copy Send Sized Sync -syn keyword rustTrait Add Sub Mul Div Rem Neg Not -syn keyword rustTrait BitAnd BitOr BitXor -syn keyword rustTrait Drop Deref DerefMut -syn keyword rustTrait Shl Shr Index IndexMut -syn keyword rustEnum Option -syn keyword rustEnumVariant Some None -syn keyword rustEnum Result -syn keyword rustEnumVariant Ok Err - -" Functions {{{3 -"syn keyword rustFunction from_str -"syn keyword rustFunction range -"syn keyword rustFunction drop - -" Types and traits {{{3 -syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr -syn keyword rustTrait IntoBytes -syn keyword rustTrait ToCStr -syn keyword rustTrait Char UnicodeChar -syn keyword rustTrait Clone -syn keyword rustTrait PartialEq PartialOrd Eq Ord Equiv -syn keyword rustEnum Ordering -syn keyword rustEnumVariant Less Equal Greater -syn keyword rustTrait Collection Mutable Map MutableMap MutableSeq -syn keyword rustTrait Set MutableSet -syn keyword rustTrait FromIterator Extendable ExactSize -syn keyword rustTrait Iterator DoubleEndedIterator -syn keyword rustTrait RandomAccessIterator CloneableIterator -syn keyword rustTrait OrdIterator MutableDoubleEndedIterator -syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul CheckedDiv -syn keyword rustTrait Signed Unsigned Primitive Int Float -syn keyword rustTrait FloatMath ToPrimitive FromPrimitive -syn keyword rustTrait Box -syn keyword rustTrait GenericPath Path PosixPath WindowsPath -syn keyword rustTrait RawPtr -syn keyword rustTrait Buffer Writer Reader Seek -syn keyword rustTrait Str StrVector StrSlice -syn keyword rustTrait IntoMaybeOwned StrAllocating UnicodeStrSlice -syn keyword rustTrait ToString IntoStr -syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4 -syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8 -syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12 -syn keyword rustTrait CloneableVector ImmutableCloneableVector -syn keyword rustTrait MutableCloneableSlice MutableOrdSlice -syn keyword rustTrait ImmutableSlice MutableSlice -syn keyword rustTrait ImmutablePartialEqSlice ImmutableOrdSlice -syn keyword rustTrait Slice VectorVector -syn keyword rustTrait MutableSliceAllocating -syn keyword rustTrait String -syn keyword rustTrait Vec - -"syn keyword rustFunction sync_channel channel -syn keyword rustTrait SyncSender Sender Receiver -"syn keyword rustFunction spawn - -"syn keyword rustConstant GC - -syn keyword rustSelf self -syn keyword rustBoolean true false - -" Other syntax {{{2 - -" If foo::bar changes to foo.bar, change this ("::" to "\."). -" If foo::bar changes to Foo::bar, change this (first "\w" to "\u"). -syn match rustModPath "\w\(\w\)*::[^<]"he=e-3,me=e-3 -syn match rustModPathInUse "\w\(\w\)*" contained " only for 'use path;' -syn match rustModPathSep "::" -" rustModPathInUse is split out from rustModPath so that :syn-include can get the group list right. - -syn match rustFuncCall "\w\(\w\)*("he=e-1,me=e-1 -syn match rustFuncCall "\w\(\w\)*::<"he=e-3,me=e-3 " foo::<T>(); - -" This is merely a convention; note also the use of [A-Z], restricting it to -" latin identifiers rather than the full Unicode uppercase. I have not used -" [:upper:] as it depends upon 'noignorecase' -"syn match rustCapsIdent display "[A-Z]\w\(\w\)*" - -syn match rustOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\)=\?" -" This one isn't *quite* right, as we could have binary-& with a reference -syn match rustSigil display /&\s\+[&~@*][^)= \t\r\n]/he=e-1,me=e-1 -syn match rustSigil display /[&~@*][^)= \t\r\n]/he=e-1,me=e-1 -" This isn't actually correct; a closure with no arguments can be `|| { }`. -" Last, because the & in && isn't a sigil -syn match rustOperator display "&&\|||" - -syn match rustMacro '\w\(\w\)*!' contains=rustAssert,rustFail -syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustFail - -syn match rustEscapeError display contained /\\./ -syn match rustEscape display contained /\\\([nrt0\\'"]\|x\x\{2}\)/ -syn match rustEscapeUnicode display contained /\\\(u\x\{4}\|U\x\{8}\)/ -syn match rustStringContinuation display contained /\\\n\s*/ -syn region rustString start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeError,rustStringContinuation -syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustStringContinuation,@Spell -syn region rustString start='b\?r\z(#*\)"' end='"\z1' contains=@Spell - -syn region rustAttribute start="#!\?\[" end="\]" contains=rustString,rustDeriving -syn region rustDeriving start="deriving(" end=")" contained contains=rustTrait - -" Number literals -syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(8\|16\|32\|64\)\=\)\=" -syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\=" -syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\=" -syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\=" - -" Special case for numbers of the form "1." which are float literals, unless followed by -" an identifier, which makes them integer literals with a method call or field access. -" (This must go first so the others take precedence.) -syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\@!" -" To mark a number as a normal float, it must have at least one of the three things integral values don't have: -" a decimal point and more numbers; an exponent; and a type suffix. -syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\=" -syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\=" -syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)" - -" For the benefit of delimitMate -syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime -syn region rustGenericRegion display start=/<\%('\|[^[cntrl:][:space:][:punct:]]\)\@=')\S\@=/ end=/>/ contains=rustGenericLifetimeCandidate -syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime - -"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting -syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" -syn match rustCharacterInvalid display contained /b\?'\zs[\n\r\t']\ze'/ -" The groups negated here add up to 0-255 but nothing else (they do not seem to go beyond ASCII). -syn match rustCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:graph:][:alnum:][:space:]]\ze'/ -syn match rustCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=rustEscape,rustEscapeError,rustCharacterInvalid,rustCharacterInvalidUnicode -syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid - -syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell -syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell -syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell -syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell -syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent -syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent -" FIXME: this is a really ugly and not fully correct implementation. Most -" importantly, a case like ``/* */*`` should have the final ``*`` not being in -" a comment, but in practice at present it leaves comments open two levels -" deep. But as long as you stay away from that particular case, I *believe* -" the highlighting is correct. Due to the way Vim's syntax engine works -" (greedy for start matches, unlike Rust's tokeniser which is searching for -" the earliest-starting match, start or end), I believe this cannot be solved. -" Oh you who would fix it, don't bother with things like duplicating the Block -" rules and putting ``\*\@<!`` at the start of them; it makes it worse, as -" then you must deal with cases like ``/*/**/*/``. And don't try making it -" worse with ``\%(/\@<!\*\)\@<!``, either... - -syn keyword rustTodo contained TODO FIXME XXX NB NOTE - -" Folding rules {{{2 -" Trivial folding rules to begin with. -" TODO: use the AST to make really good folding -syn region rustFoldBraces start="{" end="}" transparent fold - -" Default highlighting {{{1 -hi def link rustDecNumber rustNumber -hi def link rustHexNumber rustNumber -hi def link rustOctNumber rustNumber -hi def link rustBinNumber rustNumber -hi def link rustIdentifierPrime rustIdentifier -hi def link rustTrait rustType - -hi def link rustMacroRepeatCount rustMacroRepeatDelimiters -hi def link rustMacroRepeatDelimiters Macro -hi def link rustMacroVariable Define -hi def link rustSigil StorageClass -hi def link rustEscape Special -hi def link rustEscapeUnicode rustEscape -hi def link rustEscapeError Error -hi def link rustStringContinuation Special -hi def link rustString String -hi def link rustCharacterInvalid Error -hi def link rustCharacterInvalidUnicode rustCharacterInvalid -hi def link rustCharacter Character -hi def link rustNumber Number -hi def link rustBoolean Boolean -hi def link rustEnum rustType -hi def link rustEnumVariant rustConstant -hi def link rustConstant Constant -hi def link rustSelf Constant -hi def link rustFloat Float -hi def link rustOperator Operator -hi def link rustKeyword Keyword -hi def link rustReservedKeyword Error -hi def link rustConditional Conditional -hi def link rustIdentifier Identifier -hi def link rustCapsIdent rustIdentifier -hi def link rustModPathInUse rustModPath -hi def link rustModPath Include -hi def link rustModPathSep Delimiter -hi def link rustFunction Function -hi def link rustFuncName Function -hi def link rustFuncCall Function -hi def link rustCommentLine Comment -hi def link rustCommentLineDoc SpecialComment -hi def link rustCommentBlock rustCommentLine -hi def link rustCommentBlockDoc rustCommentLineDoc -hi def link rustAssert PreCondit -hi def link rustFail PreCondit -hi def link rustMacro Macro -hi def link rustType Type -hi def link rustTodo Todo -hi def link rustAttribute PreProc -hi def link rustDeriving PreProc -hi def link rustStorage StorageClass -hi def link rustObsoleteStorage Error -hi def link rustLifetime Special -hi def link rustInvalidBareKeyword Error -hi def link rustExternCrate rustKeyword -hi def link rustObsoleteExternMod Error -hi def link rustBoxPlacementParens Delimiter -hi def link rustBoxPlacementExpr rustKeyword - -" Other Suggestions: -" hi rustAttribute ctermfg=cyan -" hi rustDeriving ctermfg=cyan -" hi rustAssert ctermfg=yellow -" hi rustFail ctermfg=red -" hi rustMacro ctermfg=magenta - -syn sync minlines=200 -syn sync maxlines=500 - -let b:current_syntax = "rust" diff --git a/vim/bundle/rust/syntax_checkers/rust/rustc.vim b/vim/bundle/rust/syntax_checkers/rust/rustc.vim deleted file mode 100644 index 5cd419c..0000000 --- a/vim/bundle/rust/syntax_checkers/rust/rustc.vim +++ /dev/null @@ -1,35 +0,0 @@ -" Vim syntastic plugin -" Language: Rust -" Maintainer: Andrew Gallant <jamslam@gmail.com> -" -" See for details on how to add an external Syntastic checker: -" https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external - -if exists("g:loaded_syntastic_rust_rustc_checker") - finish -endif -let g:loaded_syntastic_rust_rustc_checker = 1 - -let s:save_cpo = &cpo -set cpo&vim - -function! SyntaxCheckers_rust_rustc_GetLocList() dict - let makeprg = self.makeprgBuild({ 'args': '--parse-only' }) - - let errorformat = - \ '%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' . - \ '%W%f:%l:%c: %\d%#:%\d%# %.%\{-}warning:%.%\{-} %m,' . - \ '%C%f:%l %m,' . - \ '%-Z%.%#' - - return SyntasticMake({ - \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) -endfunction - -call g:SyntasticRegistry.CreateAndRegisterChecker({ - \ 'filetype': 'rust', - \ 'name': 'rustc'}) - -let &cpo = s:save_cpo -unlet s:save_cpo |