diff options
Diffstat (limited to 'ftplugin')
-rw-r--r-- | ftplugin/elm.vim | 28 | ||||
-rw-r--r-- | ftplugin/eruby.vim | 46 | ||||
-rw-r--r-- | ftplugin/ruby.vim | 48 | ||||
-rw-r--r-- | ftplugin/rust.vim | 363 | ||||
-rw-r--r-- | ftplugin/rust/tagbar.vim | 38 | ||||
-rw-r--r-- | ftplugin/vue.vim | 12 |
6 files changed, 316 insertions, 219 deletions
diff --git a/ftplugin/elm.vim b/ftplugin/elm.vim index c989d922..b2423c29 100644 --- a/ftplugin/elm.vim +++ b/ftplugin/elm.vim @@ -43,14 +43,26 @@ setlocal comments=:-- setlocal commentstring=--\ %s " Commands -command! -buffer -nargs=? -complete=file ElmMake call elm#Make(<f-args>) -command! -buffer ElmMakeMain call elm#Make("Main.elm") -command! -buffer -nargs=? -complete=file ElmTest call elm#Test(<f-args>) -command! -buffer ElmRepl call elm#Repl() -command! -buffer ElmErrorDetail call elm#ErrorDetail() -command! -buffer ElmShowDocs call elm#ShowDocs() -command! -buffer ElmBrowseDocs call elm#BrowseDocs() -command! -buffer ElmFormat call elm#Format() +command -buffer -nargs=? -complete=file ElmMake call elm#Make(<f-args>) +command -buffer ElmMakeMain call elm#Make("Main.elm") +command -buffer -nargs=? -complete=file ElmTest call elm#Test(<f-args>) +command -buffer ElmRepl call elm#Repl() +command -buffer ElmErrorDetail call elm#ErrorDetail() +command -buffer ElmShowDocs call elm#ShowDocs() +command -buffer ElmBrowseDocs call elm#BrowseDocs() +command -buffer ElmFormat call elm#Format() + +" Commands cleanup +let b:undo_ftplugin = " + \ delcommand ElmMake + \|delcommand ElmMakeMain + \|delcommand ElmTest + \|delcommand ElmRepl + \|delcommand ElmErrorDetail + \|delcommand ElmShowDocs + \|delcommand ElmBrowseDocs + \|delcommand ElmFormat + \" if get(g:, 'elm_setup_keybindings', 1) nmap <buffer> <LocalLeader>m <Plug>(elm-make) diff --git a/ftplugin/eruby.vim b/ftplugin/eruby.vim index bf380e8a..12d3245f 100644 --- a/ftplugin/eruby.vim +++ b/ftplugin/eruby.vim @@ -7,7 +7,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> " Only do this when not done yet for this buffer -if exists("b:did_ftplugin") +if get(b:, 'did_ftplugin') =~# '\<eruby\>' finish endif @@ -25,6 +25,8 @@ endif if &filetype =~ '^eruby\.' let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') +elseif &filetype =~ '^.*\.eruby\>' + let b:eruby_subtype = matchstr(&filetype,'^.\{-\}\ze\.eruby\>') elseif !exists("b:eruby_subtype") let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') @@ -47,11 +49,14 @@ elseif !exists("b:eruby_subtype") endif endif -if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby' - exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" -else - runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim +if &filetype =~# '^eruby\>' + if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby' + exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" + else + runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim + endif endif +let s:did_ftplugin = get(b:, 'did_ftplugin', 1) unlet! b:did_ftplugin " Override our defaults if these were set by an included ftplugin. @@ -68,8 +73,23 @@ if exists("b:match_words") unlet b:match_words endif +let s:cfilemap = v:version >= 704 ? maparg('<Plug><cfile>', 'c', 0, 1) : {} +if !get(s:cfilemap, 'buffer') || !s:cfilemap.expr || s:cfilemap.rhs =~# 'ErubyAtCursor()' + let s:cfilemap = {} +endif +if !has_key(s:cfilemap, 'rhs') + let s:cfilemap.rhs = "substitute(&l:inex =~# '\\<v:fname\\>' && len(expand('<cfile>')) ? eval(substitute(&l:inex, '\\<v:fname\\>', '\\=string(expand(\"<cfile>\"))', 'g')) : '', '^$', \"\\022\\006\",'')" +endif +let s:ctagmap = v:version >= 704 ? maparg('<Plug><ctag>', 'c', 0, 1) : {} +if !get(s:ctagmap, 'buffer') || !s:ctagmap.expr || s:ctagmap.rhs =~# 'ErubyAtCursor()' + let s:ctagmap = {} +endif +let s:include = &l:include +let s:path = &l:path +let s:suffixesadd = &l:suffixesadd + runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim -let b:did_ftplugin = 1 +let b:did_ftplugin = s:did_ftplugin . '.eruby' " Combine the new set of values with those previously included. if exists("b:undo_ftplugin") @@ -82,6 +102,15 @@ if exists("b:match_words") let s:match_words = b:match_words . ',' . s:match_words endif +if len(s:include) + let &l:include = s:include +endif +let &l:path = s:path . (s:path =~# ',$\|^$' ? '' : ',') . &l:path +let &l:suffixesadd = s:suffixesadd . (s:suffixesadd =~# ',$\|^$' ? '' : ',') . &l:suffixesadd +exe 'cmap <buffer><script><expr> <Plug><cfile> ErubyAtCursor() ? ' . maparg('<Plug><cfile>', 'c') . ' : ' . s:cfilemap.rhs +exe 'cmap <buffer><script><expr> <Plug><ctag> ErubyAtCursor() ? ' . maparg('<Plug><ctag>', 'c') . ' : ' . get(s:ctagmap, 'rhs', '"\022\027"') +unlet s:cfilemap s:ctagmap s:include s:path s:suffixesadd + " Change the browse dialog on Win32 to show mainly eRuby-related files if has("gui_win32") let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter @@ -101,6 +130,11 @@ let b:undo_ftplugin = "setl cms< " let &cpo = s:save_cpo unlet s:save_cpo +function! ErubyAtCursor() abort + let groups = map(['erubyBlock', 'erubyComment', 'erubyExpression', 'erubyOneLiner'], 'hlID(v:val)') + return !empty(filter(synstack(line('.'), col('.')), 'index(groups, v:val) >= 0')) +endfunction + " vim: nowrap sw=2 sts=2 ts=8: endif diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index b844bfdf..5b763e16 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -46,19 +46,12 @@ endif setlocal formatoptions-=t formatoptions+=croql setlocal include=^\\s*\\<\\(load\\>\\\|require\\>\\\|autoload\\s*:\\=[\"']\\=\\h\\w*[\"']\\=,\\) -setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'\\%(\\.rb\\)\\=$','.rb','') setlocal suffixesadd=.rb if exists("&ofu") && has("ruby") setlocal omnifunc=rubycomplete#Complete endif -" To activate, :set ballooneval -if has('balloon_eval') && exists('+balloonexpr') - setlocal balloonexpr=RubyBalloonexpr() -endif - - " TODO: "setlocal define=^\\s*def @@ -143,10 +136,20 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") \ "All Files (*.*)\t*.*\n" endif -let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< tags< kp<" +let b:undo_ftplugin = "setl inc= sua= path= tags= fo< com< cms< kp=" \."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" \."| if exists('&ofu') && has('ruby') | setl ofu< | endif" - \."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif" + +if get(g:, 'ruby_recommended_style', 1) + setlocal shiftwidth=2 softtabstop=2 expandtab + let b:undo_ftplugin .= ' | setl sw< sts< et<' +endif + +" To activate, :set ballooneval +if exists('+balloonexpr') && get(g:, 'ruby_balloonexpr') + setlocal balloonexpr=RubyBalloonexpr() + let b:undo_ftplugin .= "| setl bexpr=" +endif function! s:map(mode, flags, map) abort let from = matchstr(a:map, '\S\+') @@ -156,9 +159,9 @@ function! s:map(mode, flags, map) abort endif endfunction -cmap <buffer><script><expr> <Plug><cword> substitute(RubyCursorIdentifier(),'^$',"\022\027",'') +cmap <buffer><script><expr> <Plug><ctag> substitute(RubyCursorTag(),'^$',"\022\027",'') cmap <buffer><script><expr> <Plug><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'') -let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><cword>| sil! cunmap <buffer> <Plug><cfile>" +let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><ctag>| sil! cunmap <buffer> <Plug><cfile>" if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps") nmap <buffer><script> <SID>: :<C-U> @@ -206,19 +209,18 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps") \."| sil! exe 'xunmap <buffer> iM' | sil! exe 'xunmap <buffer> aM'" endif - call s:map('c', '', '<C-R><C-W> <Plug><cword>') call s:map('c', '', '<C-R><C-F> <Plug><cfile>') cmap <buffer><script><expr> <SID>tagzv &foldopen =~# 'tag' ? '<Bar>norm! zv' : '' - call s:map('n', '<silent>', '<C-]> <SID>:exe v:count1."tag <Plug><cword>"<SID>tagzv<CR>') - call s:map('n', '<silent>', 'g<C-]> <SID>:exe "tjump <Plug><cword>"<SID>tagzv<CR>') - call s:map('n', '<silent>', 'g] <SID>:exe "tselect <Plug><cword>"<SID>tagzv<CR>') - call s:map('n', '<silent>', '<C-W>] <SID>:exe v:count1."stag <Plug><cword>"<SID>tagzv<CR>') - call s:map('n', '<silent>', '<C-W><C-]> <SID>:exe v:count1."stag <Plug><cword>"<SID>tagzv<CR>') - call s:map('n', '<silent>', '<C-W>g<C-]> <SID>:exe "stjump <Plug><cword>"<SID>tagzv<CR>') - call s:map('n', '<silent>', '<C-W>g] <SID>:exe "stselect <Plug><cword>"<SID>tagzv<CR>') - call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><cword>"<CR>') - call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><cword>"<CR>') + call s:map('n', '<silent>', '<C-]> <SID>:exe v:count1."tag <Plug><ctag>"<SID>tagzv<CR>') + call s:map('n', '<silent>', 'g<C-]> <SID>:exe "tjump <Plug><ctag>"<SID>tagzv<CR>') + call s:map('n', '<silent>', 'g] <SID>:exe "tselect <Plug><ctag>"<SID>tagzv<CR>') + call s:map('n', '<silent>', '<C-W>] <SID>:exe v:count1."stag <Plug><ctag>"<SID>tagzv<CR>') + call s:map('n', '<silent>', '<C-W><C-]> <SID>:exe v:count1."stag <Plug><ctag>"<SID>tagzv<CR>') + call s:map('n', '<silent>', '<C-W>g<C-]> <SID>:exe "stjump <Plug><ctag>"<SID>tagzv<CR>') + call s:map('n', '<silent>', '<C-W>g] <SID>:exe "stselect <Plug><ctag>"<SID>tagzv<CR>') + call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><ctag>"<CR>') + call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><ctag>"<CR>') call s:map('n', '<silent>', 'gf <SID>c:find <Plug><cfile><CR>') call s:map('n', '<silent>', '<C-W>f <SID>c:sfind <Plug><cfile><CR>') @@ -352,6 +354,10 @@ function! RubyCursorIdentifier() abort return stripped == '' ? expand("<cword>") : stripped endfunction +function! RubyCursorTag() abort + return substitute(RubyCursorIdentifier(), '^[$@]*', '', '') +endfunction + function! RubyCursorFile() abort let isfname = &isfname try diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim index d1765d07..acf4d71d 100644 --- a/ftplugin/rust.vim +++ b/ftplugin/rust.vim @@ -8,7 +8,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 " For bugs, patches and license go to https://github.com/rust-lang/rust.vim if exists("b:did_ftplugin") - finish + finish endif let b:did_ftplugin = 1 @@ -16,181 +16,190 @@ let s:save_cpo = &cpo set cpo&vim augroup rust.vim -autocmd! - -" 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 != 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. - 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 - -if !exists("g:rust_recommended_style") || g:rust_recommended_style != 0 - setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab - setlocal textwidth=99 -endif - -" This includeexpr isn't perfect, but it's a good start -setlocal includeexpr=substitute(v:fname,'::','/','g') - -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 s:delimitMate_extra_excluded_regions = ',rustLifetimeCandidate,rustGenericLifetimeCandidate' - - " For this buffer, when delimitMate issues the `User delimitMate_map` - " event in the autocommand system, add the above-defined extra excluded - " regions to delimitMate's state, if they have not already been added. - autocmd User <buffer> - \ if expand('<afile>') ==# 'delimitMate_map' && match( - \ delimitMate#Get("excluded_regions"), - \ s:delimitMate_extra_excluded_regions) == -1 - \| let b:delimitMate_excluded_regions = - \ delimitMate#Get("excluded_regions") - \ . s:delimitMate_extra_excluded_regions - \|endif - - " For this buffer, when delimitMate issues the `User delimitMate_unmap` - " event in the autocommand system, delete the above-defined extra excluded - " regions from delimitMate's state (the deletion being idempotent and - " having no effect if the extra excluded regions are not present in the - " targeted part of delimitMate's state). - autocmd User <buffer> - \ if expand('<afile>') ==# 'delimitMate_unmap' - \| let b:delimitMate_excluded_regions = substitute( - \ delimitMate#Get("excluded_regions"), - \ '\C\V' . s:delimitMate_extra_excluded_regions, - \ '', 'g') - \|endif -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') && g:rust_conceal != 0 - 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 -buffer RustRun call rust#Run(<bang>0, <q-args>) - -" See |:RustExpand| for docs -command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -buffer RustExpand call rust#Expand(<bang>0, <q-args>) - -" See |:RustEmitIr| for docs -command! -nargs=* -buffer RustEmitIr call rust#Emit("llvm-ir", <q-args>) - -" See |:RustEmitAsm| for docs -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() - -" See |:RustFmtRange| for docs -command! -range -buffer RustFmtRange call rustfmt#FormatRange(<line1>, <line2>) - -" 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 - \|delcommand RustPlay - \|nunmap <buffer> <D-r> - \|nunmap <buffer> <D-R> - \|nunmap <buffer> [[ - \|nunmap <buffer> ]] - \|xunmap <buffer> [[ - \|xunmap <buffer> ]] - \|ounmap <buffer> [[ - \|ounmap <buffer> ]] - \|set matchpairs-=<:> - \|unlet b:match_skip - \" - -" }}}1 - -" Code formatting on save -if get(g:, "rustfmt_autosave", 0) - autocmd BufWritePre *.rs silent! call rustfmt#Format() -endif + autocmd! + + if get(b:, 'current_compiler', '') ==# '' + if strlen(findfile('Cargo.toml', '.;')) > 0 + compiler cargo + else + compiler rustc + endif + endif + + " 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 get(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. + 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 + + if get(g:, 'rust_recommended_style', 1) + let b:rust_set_style = 1 + setlocal tabstop=8 shiftwidth=4 softtabstop=4 expandtab + setlocal textwidth=99 + endif + + " This includeexpr isn't perfect, but it's a good start + setlocal includeexpr=substitute(v:fname,'::','/','g') + + 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 s:delimitMate_extra_excluded_regions = ',rustLifetimeCandidate,rustGenericLifetimeCandidate' + + " For this buffer, when delimitMate issues the `User delimitMate_map` + " event in the autocommand system, add the above-defined extra excluded + " regions to delimitMate's state, if they have not already been added. + autocmd User <buffer> + \ if expand('<afile>') ==# 'delimitMate_map' && match( + \ delimitMate#Get("excluded_regions"), + \ s:delimitMate_extra_excluded_regions) == -1 + \| let b:delimitMate_excluded_regions = + \ delimitMate#Get("excluded_regions") + \ . s:delimitMate_extra_excluded_regions + \|endif + + " For this buffer, when delimitMate issues the `User delimitMate_unmap` + " event in the autocommand system, delete the above-defined extra excluded + " regions from delimitMate's state (the deletion being idempotent and + " having no effect if the extra excluded regions are not present in the + " targeted part of delimitMate's state). + autocmd User <buffer> + \ if expand('<afile>') ==# 'delimitMate_unmap' + \| let b:delimitMate_excluded_regions = substitute( + \ delimitMate#Get("excluded_regions"), + \ '\C\V' . s:delimitMate_extra_excluded_regions, + \ '', 'g') + \|endif + endif + + if has("folding") && get(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') && get(g:, 'rust_conceal', 0) + 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 -buffer RustRun call rust#Run(<bang>0, <q-args>) + + " See |:RustExpand| for docs + command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -buffer RustExpand call rust#Expand(<bang>0, <q-args>) + + " See |:RustEmitIr| for docs + command! -nargs=* -buffer RustEmitIr call rust#Emit("llvm-ir", <q-args>) + + " See |:RustEmitAsm| for docs + 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() + + " See |:RustFmtRange| for docs + command! -range -buffer RustFmtRange call rustfmt#FormatRange(<line1>, <line2>) + + " See |:RustInfo| for docs + command! -bar RustInfo call rust#debugging#Info() + + " See |:RustInfoToClipboard| for docs + command! -bar RustInfoToClipboard call rust#debugging#InfoToClipboard() + + " See |:RustInfoToFile| for docs + command! -bar -nargs=1 RustInfoToFile call rust#debugging#InfoToFile(<f-args>) + + 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< + \|if exists('b:rust_set_style') + \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< + \|endif + \|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 + \|delcommand RustPlay + \|nunmap <buffer> [[ + \|nunmap <buffer> ]] + \|xunmap <buffer> [[ + \|xunmap <buffer> ]] + \|ounmap <buffer> [[ + \|ounmap <buffer> ]] + \|set matchpairs-=<:> + \|unlet b:match_skip + \" + + " }}}1 + + " Code formatting on save + autocmd BufWritePre *.rs silent! call rustfmt#PreWrite() augroup END @@ -201,6 +210,6 @@ let b:match_skip = 's:comment\|string\|rustArrow' let &cpo = s:save_cpo unlet s:save_cpo -" vim: set noet sw=8 ts=8: +" vim: set et sw=4 sts=4 ts=8: endif diff --git a/ftplugin/rust/tagbar.vim b/ftplugin/rust/tagbar.vim new file mode 100644 index 00000000..5c95f357 --- /dev/null +++ b/ftplugin/rust/tagbar.vim @@ -0,0 +1,38 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 + +" +" Support for Tagbar -- https://github.com/majutsushi/tagbar +" +if !exists(':Tagbar') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +let g:tagbar_type_rust = { + \ 'ctagstype' : 'rust', + \ 'kinds' : [ + \'T:types', + \'f:functions', + \'g:enumerations', + \'s:structures', + \'m:modules', + \'c:constants', + \'t:traits', + \'i:trait implementations', + \ ] + \ } + +" In case you've updated/customized your ~/.ctags and prefer to use it. +if !get(g:, 'rust_use_custom_ctags_defs', 0) + let g:tagbar_type_rust.deffile = expand('<sfile>:p:h:h:h') . '/ctags/rust.ctags' +endif + +let &cpo = s:save_cpo +unlet s:save_cpo + + +" vim: set et sw=4 sts=4 ts=8: + +endif diff --git a/ftplugin/vue.vim b/ftplugin/vue.vim index cc10c561..959dca4e 100644 --- a/ftplugin/vue.vim +++ b/ftplugin/vue.vim @@ -5,7 +5,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vue') == -1 " Maintainer: Eduardo San Martin Morote " Author: Adriaan Zonnenberg -if exists("b:did_ftplugin") +if exists('b:did_ftplugin') finish endif @@ -20,11 +20,9 @@ if !exists('g:no_plugin_maps') && !exists('g:no_vue_maps') nnoremap <silent> <buffer> ][ :call search('^</\(template\<Bar>script\<Bar>style\)', 'W')<CR> endif -if exists('g:loaded_ale') - let g:ale_linters = get(g:, 'ale_linters', {}) - let g:ale_linters.vue = get(g:ale_linters, 'vue', ['eslint']) - let g:ale_linter_aliases = get(g:, 'ale_linter_aliases', {}) - let g:ale_linter_aliases.vue = get(g:ale_linter_aliases, 'vue', 'javascript') -endif +" Run only ESLint for Vue files by default. +" linters specifically for Vue can still be loaded. +let b:ale_linter_aliases = ['vue', 'javascript'] +let b:ale_linters = ['eslint'] endif |