diff options
Diffstat (limited to '')
| -rw-r--r-- | ftplugin/ruby.vim | 6 | ||||
| -rw-r--r-- | ftplugin/rust.vim | 35 | ||||
| -rw-r--r-- | ftplugin/swift.vim | 8 | 
3 files changed, 38 insertions, 11 deletions
| diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index 0eb32b66..9a2283ef 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -46,7 +46,7 @@ endif  setlocal formatoptions-=t formatoptions+=croql  setlocal include=^\\s*\\<\\(load\\>\\\|require\\>\\\|autoload\\s*:\\=[\"']\\=\\h\\w*[\"']\\=,\\) -setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.rb','') +setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'\%(\.rb\)\=$','.rb','')  setlocal suffixesadd=.rb  if exists("&ofu") && has("ruby") @@ -361,7 +361,7 @@ function! RubyCursorFile() abort    endtry    let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!')    let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*') -  let ext = getline('.') =~# '^\s*\%(require\|autoload\)\>' ? '.rb' : '' +  let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''    if s:synname() ==# 'rubyConstant'      let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')      let cfile = substitute(cfile,'::','/','g') @@ -369,7 +369,7 @@ function! RubyCursorFile() abort      let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')      return tolower(cfile) . '.rb'    elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$' -    let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . '.rb' +    let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext    elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$'      let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1')      let cfile = expand('%:p:h') . target . ext 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 diff --git a/ftplugin/swift.vim b/ftplugin/swift.vim new file mode 100644 index 00000000..f24535e2 --- /dev/null +++ b/ftplugin/swift.vim @@ -0,0 +1,8 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1 +   +setlocal commentstring=//\ %s +" @-@ adds the literal @ to iskeyword for @IBAction and similar +setlocal iskeyword+=@-@,# +setlocal completefunc=syntaxcomplete#Complete + +endif | 
