diff options
Diffstat (limited to 'ftplugin')
| -rw-r--r-- | ftplugin/csv.vim | 31 | ||||
| -rw-r--r-- | ftplugin/cucumber.vim | 13 | ||||
| -rw-r--r-- | ftplugin/gitcommit.vim | 11 | ||||
| -rw-r--r-- | ftplugin/latex-box/common.vim | 38 | ||||
| -rw-r--r-- | ftplugin/latex-box/complete.vim | 3 | ||||
| -rw-r--r-- | ftplugin/latex-box/findmain.vim | 10 | ||||
| -rw-r--r-- | ftplugin/latex-box/folding.vim | 115 | ||||
| -rw-r--r-- | ftplugin/latex-box/latexmk.vim | 35 | ||||
| -rw-r--r-- | ftplugin/latex-box/mappings.vim | 6 | ||||
| -rw-r--r-- | ftplugin/latex-box/motion.vim | 26 | ||||
| -rw-r--r-- | ftplugin/latextoc.vim | 7 | ||||
| -rw-r--r-- | ftplugin/markdown.vim | 2 | ||||
| -rw-r--r-- | ftplugin/ruby.vim | 23 | ||||
| -rw-r--r-- | ftplugin/rust.vim | 106 | 
14 files changed, 265 insertions, 161 deletions
| diff --git a/ftplugin/csv.vim b/ftplugin/csv.vim index b6414d9f..9d8df120 100644 --- a/ftplugin/csv.vim +++ b/ftplugin/csv.vim @@ -160,7 +160,7 @@ fu! <sid>Init(startline, endline) "{{{3   " \ delf <sid>PrepareFolding | delf <sid>OutputFilters |   " \ delf <sid>SortFilter | delf <sid>GetColumn |   " \ delf <sid>RemoveLastItem | delf <sid>DisableFolding | - " \ delf <sid>GetSID | delf <sid>CheckHeaderLine | + " \ delf <sid>CheckHeaderLine |   " \ delf <sid>AnalyzeColumn | delf <sid>Vertfold |   " \ delf <sid>InitCSVFixedWidth | delf <sid>LocalCmd |   " \ delf <sid>CommandDefinitions | delf <sid>NumberFormat | @@ -806,18 +806,18 @@ fu! <sid>GetColPat(colnr, zs_flag) "{{{3          else              if a:colnr >= len(b:csv_fixed_width_cols)              " Get last column -                let pat='\%' . b:csv_fixed_width_cols[-1] . 'c.*' +                let pat='\%' . b:csv_fixed_width_cols[-1] . 'v.*'              else              let pat='\%' . b:csv_fixed_width_cols[(a:colnr - 1)] . -            \ 'c.\{-}\%' .   b:csv_fixed_width_cols[a:colnr] . 'c' +            \ 'c.\{-}\%' .   b:csv_fixed_width_cols[a:colnr] . 'v'              endif          endif      elseif !exists("b:csv_fixed_width_cols")          let pat=b:col      else -        let pat='\%' . b:csv_fixed_width_cols[0] . 'c.\{-}' . +        let pat='\%' . b:csv_fixed_width_cols[0] . 'v.\{-}' .              \ (len(b:csv_fixed_width_cols) > 1 ? -            \ '\%' . b:csv_fixed_width_cols[1] . 'c' : +            \ '\%' . b:csv_fixed_width_cols[1] . 'v' :              \ '')      endif      return pat . (a:zs_flag ? '\zs' : '') @@ -1078,12 +1078,12 @@ fu! <sid>Sort(bang, line1, line2, colnr) range "{{{3          if !exists("b:csv_fixed_width_cols")              let pat= '^' . <SID>GetColPat(col-1,1) . b:col          else -            let pat= '^' . <SID>GetColPat(col,0) +            let pat= <SID>GetColPat(col,0)          endif      else          let pat= '^' . <SID>GetColPat(col,0)      endif -    exe a:line1 ',' a:line2 . "sort" . (a:bang ? '!' : '') . +    exe a:line1. ','. a:line2. "sort". (a:bang ? '!' : '') .          \' r ' . (numeric ? 'n' : '') . ' /' . pat . '/'      call winrestview(wsv)  endfun @@ -1488,12 +1488,11 @@ fu! <sid>PrepareFolding(add, match)  "{{{3  "    for val in sort(values(b:csv_filter), '<sid>SortFilter')  "        let @/ .= val.pat . (val.id == s:filter_count ? '' : '\&')  "    endfor -    let sid = <sid>GetSID()      " Fold settings:      call <sid>LocalSettings('fold')      " Don't put spaces between the arguments! -    exe 'setl foldexpr=<snr>' . sid . '_FoldValue(v:lnum,b:csv_filter)' +    exe 'setl foldexpr=<snr>' . s:SID . '_FoldValue(v:lnum,b:csv_filter)'      " Move folded area to the bottom, so there is only on consecutive      " non-folded area @@ -1541,8 +1540,7 @@ fu! <sid>OutputFilters(bang) "{{{3              call <sid>Warn("No filters defined currently!")              return          else -            let sid = <sid>GetSID() -            exe 'setl foldexpr=<snr>' . sid . '_FoldValue(v:lnum,b:csv_filter)' +            exe 'setl foldexpr=<snr>' . s:SID . '_FoldValue(v:lnum,b:csv_filter)'          endif      endif  endfu @@ -1588,14 +1586,11 @@ fu! <sid>DisableFolding() "{{{3      endif  endfu -fu! <sid>GetSID() "{{{3 -    if v:version > 703 || v:version == 703 && has("patch032") -        return maparg('W', "", "", 1).sid -    else -        "return substitute(maparg('W'), '\(<SNR>\d\+\)_', '\1', '') -        return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_GetSID$') -    endif +fu! <sid>DetermineSID() +    let s:SID = matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_DetermineSID$')  endfu +call s:DetermineSID() +delf s:DetermineSID  fu! <sid>NumberFormat() "{{{3      let s:nr_format = [',', '.'] diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim index f52a1b21..b2f60fdd 100644 --- a/ftplugin/cucumber.vim +++ b/ftplugin/cucumber.vim @@ -21,12 +21,13 @@ let b:undo_ftplugin = "setl fo< com< cms< ofu<"  let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??')  if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") -  nnoremap <silent><buffer> [<C-D>      :<C-U>exe <SID>jump('edit',v:count)<CR> -  nnoremap <silent><buffer> ]<C-D>      :<C-U>exe <SID>jump('edit',v:count)<CR> -  nnoremap <silent><buffer> <C-W>d      :<C-U>exe <SID>jump('split',v:count)<CR> -  nnoremap <silent><buffer> <C-W><C-D>  :<C-U>exe <SID>jump('split',v:count)<CR> -  nnoremap <silent><buffer> [d          :<C-U>exe <SID>jump('pedit',v:count)<CR> -  nnoremap <silent><buffer> ]d          :<C-U>exe <SID>jump('pedit',v:count)<CR> +  cnoremap <SID>foldopen <Bar>if &foldopen =~# 'tag'<Bar>exe 'norm! zv'<Bar>endif +  nnoremap <silent> <script> <buffer> [<C-D>      :<C-U>exe <SID>jump('edit',v:count)<SID>foldopen<CR> +  nnoremap <silent> <script> <buffer> ]<C-D>      :<C-U>exe <SID>jump('edit',v:count)<SID>foldopen<CR> +  nnoremap <silent> <script> <buffer> <C-W>d      :<C-U>exe <SID>jump('split',v:count)<SID>foldopen<CR> +  nnoremap <silent> <script> <buffer> <C-W><C-D>  :<C-U>exe <SID>jump('split',v:count)<SID>foldopen<CR> +  nnoremap <silent> <script> <buffer> [d          :<C-U>exe <SID>jump('pedit',v:count)<CR> +  nnoremap <silent> <script> <buffer> ]d          :<C-U>exe <SID>jump('pedit',v:count)<CR>    let b:undo_ftplugin .=          \ "|sil! nunmap <buffer> [<C-D>" .          \ "|sil! nunmap <buffer> ]<C-D>" . diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim index 26d63514..3c1bb4f0 100644 --- a/ftplugin/gitcommit.vim +++ b/ftplugin/gitcommit.vim @@ -11,15 +11,8 @@ endif  runtime! ftplugin/git.vim  let b:did_ftplugin = 1 -setlocal nomodeline tabstop=8 formatoptions-=croq formatoptions+=tl - -let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions<' - -if &textwidth == 0 -  " make sure that log messages play nice with git-log on standard terminals -  setlocal textwidth=72 -  let b:undo_ftplugin .= "|setl tw<" -endif +setlocal nomodeline tabstop=8 formatoptions-=croq formatoptions+=tl textwidth=72 +let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw<'  if exists("g:no_gitcommit_commands") || v:version < 700    finish diff --git a/ftplugin/latex-box/common.vim b/ftplugin/latex-box/common.vim index 72a6ef0f..bf6305cc 100644 --- a/ftplugin/latex-box/common.vim +++ b/ftplugin/latex-box/common.vim @@ -25,8 +25,20 @@ setlocal efm+=%E!\ %m  " More info for undefined control sequences  setlocal efm+=%Z<argument>\ %m +" More info for some errors +setlocal efm+=%Cl.%l\ %m +  " Show or ignore warnings  if g:LatexBox_show_warnings +	" Parse biblatex warnings +	setlocal efm+=%-C(biblatex)%.%#in\ t%.%# +	setlocal efm+=%-C(biblatex)%.%#Please\ v%.%# +	setlocal efm+=%-C(biblatex)%.%#LaTeX\ a%.%# +	setlocal efm+=%-Z(biblatex)%m + +	" Parse hyperref warnings +	setlocal efm+=%-C(hyperref)%.%#on\ input\ line\ %l. +  	for w in g:LatexBox_ignore_warnings  		let warning = escape(substitute(w, '[\,]', '%\\\\&', 'g'), ' ')  		exe 'setlocal efm+=%-G%.%#'. warning .'%.%#' @@ -44,6 +56,7 @@ endif  " Push file to file stack  setlocal efm+=%+P**%f +setlocal efm+=%+P**\"%f\"  " Ignore unmatched lines  setlocal efm+=%-G%.%# @@ -114,8 +127,8 @@ function! LatexBox_GetMainTexFile()  	endif  	" 5. borrow the Vim-Latex-Suite method of finding it -	if Tex_GetMainFileName() != expand('%:p') -		let b:main_tex_file = Tex_GetMainFileName() +	if LatexBox_GetMainFileName() != expand('%:p') +		let b:main_tex_file = LatexBox_GetMainFileName()  		return b:main_tex_file  	endif @@ -127,6 +140,8 @@ endfunction  function! s:PromptForMainFile()  	let saved_dir = getcwd()  	execute 'cd ' . fnameescape(expand('%:p:h')) + +	" Prompt for file  	let l:file = ''  	while !filereadable(l:file)  		let l:file = input('main LaTeX file: ', '', 'file') @@ -135,6 +150,16 @@ function! s:PromptForMainFile()  		endif  	endwhile  	let l:file = fnamemodify(l:file, ':p') + +	" Make persistent +	let l:persistent = '' +	while l:persistent !~ '\v^(y|n)' +		let l:persistent = input('make choice persistent? (y, n) ') +		if l:persistent == 'y' +			call writefile([], l:file . '.latexmain') +		endif +	endwhile +  	execute 'cd ' . fnameescape(saved_dir)  	return l:file  endfunction @@ -212,15 +237,16 @@ if !exists('g:LatexBox_viewer')  	endif  endif -function! LatexBox_View() +function! LatexBox_View(...) +	let lvargs = join(a:000, ' ')  	let outfile = LatexBox_GetOutputFile()  	if !filereadable(outfile)  		echomsg fnamemodify(outfile, ':.') . ' is not readable'  		return  	endif -	let cmd = g:LatexBox_viewer . ' ' . shellescape(outfile) +	let cmd = g:LatexBox_viewer . ' ' . lvargs . ' ' . shellescape(outfile)  	if has('win32') -		let cmd = '!start /b' . cmd . ' >nul' +		let cmd = '!start /b ' . cmd . ' >nul'  	else  		let cmd = '!' . cmd . ' &>/dev/null &'  	endif @@ -230,7 +256,7 @@ function! LatexBox_View()  	endif  endfunction -command! LatexView call LatexBox_View() +command! -nargs=* LatexView call LatexBox_View('<args>')  " }}}  " In Comment {{{ diff --git a/ftplugin/latex-box/complete.vim b/ftplugin/latex-box/complete.vim index 866ffc3c..458e8d81 100644 --- a/ftplugin/latex-box/complete.vim +++ b/ftplugin/latex-box/complete.vim @@ -328,6 +328,7 @@ function! LatexBox_BibComplete(regexp)  		let type = printf('%-' . s:type_length . 's', type)  		let auth = m['author'] == '' ? ''    :       m['author'][:20] . ' '  		let auth = substitute(auth, '\~', ' ', 'g') +		let auth = substitute(auth, ',.*\ze', ' et al. ', '')  		let year = m['year']   == '' ? ''    : '(' . m['year']   . ')'  		let w = { 'word': m['key'],  				\ 'abbr': type . auth . year, @@ -365,7 +366,7 @@ function! s:ExtractLabels()  		let curname = strpart( getline( lblline ), lblbegin, nameend - lblbegin - 1 )  		" Ignore cref entries (because they are duplicates) -		if curname =~ "\@cref\|cref\@" +		if curname =~# "@cref$"  			continue  		endif diff --git a/ftplugin/latex-box/findmain.vim b/ftplugin/latex-box/findmain.vim index 0b9c404f..622c408f 100644 --- a/ftplugin/latex-box/findmain.vim +++ b/ftplugin/latex-box/findmain.vim @@ -1,4 +1,4 @@ -" Tex_GetMainFileName: gets the name of the main file being compiled. {{{ +" LatexBox_GetMainFileName: gets the name of the main file being compiled. {{{  " Description:  returns the full path name of the main file.  "               This function checks for the existence of a .latexmain file  "               which might point to the location of a "main" latex file. @@ -13,7 +13,8 @@  "               NOTE: From version 1.6 onwards, this function always trims  "               away the .latexmain part of the file name before applying the  "               modifier argument. -function! Tex_GetMainFileName(...) +"               NOTE: This function is copied from the Latex-Suite project! +function! LatexBox_GetMainFileName(...)  	if a:0 > 0  		let modifier = a:1  	else @@ -51,10 +52,7 @@ function! Tex_GetMainFileName(...)  		let lheadfile = expand('%'.modifier)  	endif -    if lheadfile !~ '\.tex$' -        let lheadfile .= '.tex' -    endif -    exe 'cd '.s:origdir +	exe 'cd '.s:origdir  	" NOTE: The caller of this function needs to escape the file name with  	"       fnameescape() . The reason its not done here is that escaping is not diff --git a/ftplugin/latex-box/folding.vim b/ftplugin/latex-box/folding.vim index badfc137..4fe13bc8 100644 --- a/ftplugin/latex-box/folding.vim +++ b/ftplugin/latex-box/folding.vim @@ -1,29 +1,22 @@  " Folding support for LaTeX +  "  " Options -" g:LatexBox_Folding       - Turn on/off folding -" g:LatexBox_fold_preamble - Turn on/off folding of preamble -" g:LatexBox_fold_parts    - Define parts (eq. appendix, frontmatter) to fold -" g:LatexBox_fold_sections - Define section levels to fold -" g:LatexBox_fold_envs     - Turn on/off folding of environments +" g:LatexBox_Folding         - Turn on/off folding +" g:LatexBox_fold_text       - Turn on/off LatexBox fold text function +" g:LatexBox_fold_preamble   - Turn on/off folding of preamble +" g:LatexBox_fold_parts      - Define parts (eq. appendix, frontmatter) to fold +" g:LatexBox_fold_sections   - Define section levels to fold +" g:LatexBox_fold_envs       - Turn on/off folding of environments +" g:LatexBox_fold_toc        - Turn on/off folding of TOC +" g:LatexBox_fold_toc_levels - Set max TOC fold level  " - -" {{{1 Set options -if exists('g:LatexBox_Folding') && g:LatexBox_Folding == 1 -    setl foldmethod=expr -    setl foldexpr=LatexBox_FoldLevel(v:lnum) -    setl foldtext=LatexBox_FoldText() -    " -    " The foldexpr function returns "=" for most lines, which means it can become -    " slow for large files.  The following is a hack that is based on this reply to -    " a discussion on the Vim Developer list: -    " http://permalink.gmane.org/gmane.editors.vim.devel/14100 -    " -    augroup FastFold -        autocmd! -        autocmd InsertEnter *.tex setlocal foldmethod=manual -        autocmd InsertLeave *.tex setlocal foldmethod=expr -    augroup end +" {{{1 Initialize options to default values. +if !exists('g:LatexBox_Folding') +	let g:LatexBox_Folding=0 +endif +if !exists('g:LatexBox_fold_text') +    let g:LatexBox_fold_text=1  endif  if !exists('g:LatexBox_fold_preamble')      let g:LatexBox_fold_preamble=1 @@ -57,7 +50,45 @@ endif  if !exists('g:LatexBox_fold_toc_levels')      let g:LatexBox_fold_toc_levels=1  endif +if !exists('g:LatexBox_fold_automatic') +	let g:LatexBox_fold_automatic=1 +endif +" }}}1 +if g:LatexBox_Folding == 0 +    finish +endif + +" {{{1 Set folding options for vim +setl foldexpr=LatexBox_FoldLevel(v:lnum) +if g:LatexBox_fold_text == 1 +    setl foldtext=LatexBox_FoldText() +endif +if g:LatexBox_fold_automatic == 1 +    setl foldmethod=expr + +	" +	" The foldexpr function returns "=" for most lines, which means it can become +	" slow for large files.  The following is a hack that is based on this reply to +	" a discussion on the Vim Developer list: +	" http://permalink.gmane.org/gmane.editors.vim.devel/14100 +	" +	augroup FastFold +		autocmd! +		autocmd InsertEnter *.tex setlocal foldmethod=manual +		autocmd InsertLeave *.tex setlocal foldmethod=expr +	augroup end +else +	setl foldmethod=manual +endif + +function! LatexBox_FoldOnDemand() +	setl foldmethod=expr +	normal! zx +	setl foldmethod=manual +endfunction + +command! LatexFold  call LatexBox_FoldOnDemand()  " {{{1 LatexBox_FoldLevel help functions @@ -137,9 +168,9 @@ function! LatexBox_FoldLevel(lnum)      " Fold preamble      if g:LatexBox_fold_preamble == 1 -        if line =~# '\s*\\documentclass' +        if line =~# s:notcomment . s:notbslash . '\s*\\documentclass'              return ">1" -        elseif line =~# '^\s*\\begin\s*{\s*document\s*}' +        elseif line =~# s:notcomment . s:notbslash . '\s*\\begin\s*{\s*document\s*}'              return "0"          endif      endif @@ -247,24 +278,13 @@ function! s:CaptionFrame(line)      endif  endfunction -" {{{1 LatexBox_FoldText -function! LatexBox_FoldText() -    " Initialize +function! LatexBox_FoldText_title()      let line = getline(v:foldstart) -    let nlines = v:foldend - v:foldstart + 1 -    let level = ''      let title = 'Not defined' -    " Fold level -    let level = strpart(repeat('-', v:foldlevel-1) . '*',0,3) -    if v:foldlevel > 3 -        let level = strpart(level, 1) . v:foldlevel -    endif -    let level = printf('%-3s', level) -      " Preamble      if line =~ '\s*\\documentclass' -        let title = "Preamble" +        return "Preamble"      endif      " Parts, sections and fakesections @@ -280,11 +300,11 @@ function! LatexBox_FoldText()      elseif line =~ '\\appendix'          let title = "Appendix"      elseif line =~ secpat1 . '.*}' -        let title =  matchstr(line, secpat1 . '\zs.*\ze}') +        let title =  matchstr(line, secpat1 . '\zs.\{-}\ze}')      elseif line =~ secpat1          let title =  matchstr(line, secpat1 . '\zs.*')      elseif line =~ secpat2 . '.*\]' -        let title =  matchstr(line, secpat2 . '\zs.*\ze\]') +        let title =  matchstr(line, secpat2 . '\zs.\{-}\ze\]')      elseif line =~ secpat2          let title =  matchstr(line, secpat2 . '\zs.*')      elseif line =~ 'Fake' . sections . ':' @@ -330,7 +350,22 @@ function! LatexBox_FoldText()          endif      endif -    let title = strpart(title, 0, 68) +    return title +endfunction + +" {{{1 LatexBox_FoldText +function! LatexBox_FoldText() +    let nlines = v:foldend - v:foldstart + 1 +    let title = strpart(LatexBox_FoldText_title(), 0, 68) +    let level = '' + +    " Fold level +    let level = strpart(repeat('-', v:foldlevel-1) . '*',0,3) +    if v:foldlevel > 3 +        let level = strpart(level, 1) . v:foldlevel +    endif +    let level = printf('%-3s', level) +      return printf('%-3s %-68s #%5d', level, title, nlines)  endfunction diff --git a/ftplugin/latex-box/latexmk.vim b/ftplugin/latex-box/latexmk.vim index dfa55f0e..bb70f83d 100644 --- a/ftplugin/latex-box/latexmk.vim +++ b/ftplugin/latex-box/latexmk.vim @@ -413,23 +413,38 @@ function! LatexBox_LatexErrors(status, ...)  	if a:status < 0  		botright copen  	else -		" Write status message to screen -		redraw -		if a:status > 0 || len(getqflist())>1 -			echomsg 'Compiling to ' . g:LatexBox_output_type . ' ... failed!' -		else -			echomsg 'Compiling to ' . g:LatexBox_output_type . ' ... success!' -		endif -  		" Only open window when an error/warning is detected -		if g:LatexBox_quickfix +		if g:LatexBox_quickfix >= 3 +					\ ? s:log_contains_error(log) +					\ : g:LatexBox_quickfix > 0  			belowright cw -			if g:LatexBox_quickfix==2 +			if g:LatexBox_quickfix == 2 || g:LatexBox_quickfix == 4  				wincmd p  			endif  		endif +		redraw + +		" Write status message to screen +		if a:status > 0 || len(getqflist())>1 +			if s:log_contains_error(log) +				let l:status_msg = ' ... failed!' +			else +				let l:status_msg = ' ... there were warnings!' +			endif +		else +			let l:status_msg = ' ... success!' +		endif +		echomsg 'Compiling to ' . g:LatexBox_output_type . l:status_msg  	endif  endfunction + +function! s:log_contains_error(file) +	let lines = readfile(a:file) +	let lines = filter(lines, 'v:val =~ ''^.*:\d\+: ''') +	let lines = uniq(map(lines, 'matchstr(v:val, ''^.*\ze:\d\+:'')')) +	let lines = filter(lines, 'filereadable(fnameescape(v:val))') +	return len(lines) > 0 +endfunction  " }}}  " LatexmkStatus {{{ diff --git a/ftplugin/latex-box/mappings.vim b/ftplugin/latex-box/mappings.vim index 6ff621c1..648d9b56 100644 --- a/ftplugin/latex-box/mappings.vim +++ b/ftplugin/latex-box/mappings.vim @@ -27,6 +27,12 @@ map <silent> <buffer> <LocalLeader>lt :LatexTOC<CR>  map <silent> <buffer> <LocalLeader>lj :LatexLabels<CR>  " }}} +" Folding {{{ +if g:LatexBox_Folding == 1 +	map <buffer> <LocalLeader>lf :LatexFold<CR> +endif +" }}} +  " Jump to match {{{  if !exists('g:LatexBox_loaded_matchparen')  	nmap <buffer> % <Plug>LatexBox_JumpToMatch diff --git a/ftplugin/latex-box/motion.vim b/ftplugin/latex-box/motion.vim index 04275aca..41605aea 100644 --- a/ftplugin/latex-box/motion.vim +++ b/ftplugin/latex-box/motion.vim @@ -345,24 +345,22 @@ function! s:ReadTOC(auxfile, texfile, ...)  		endif  		" parse section number  		let secnum = '' -		if len(tree[1]) > 3 && empty(tree[1][1]) -			call remove(tree[1], 1) +		let tree = tree[1] +		if len(tree) > 3 && empty(tree[1]) +			call remove(tree, 1)  		endif -		if len(tree[1]) > 1 && tree[1][0] =~ '\(numberline\|tocsection\)' -			if !empty(tree[1][1]) -				let secnum = LatexBox_TreeToTex(tree[1][1]) -				let secnum = substitute(secnum, '\\\S\+\s', '', 'g') -				let secnum = substitute(secnum, '\\\S\+{\(.\{-}\)}', '\1', 'g') -				let secnum = substitute(secnum, '^{\+\|}\+$', '', 'g') -			endif -			let tree = tree[1][2:] -		else -			let tree = tree[1] +		if len(tree) > 1 && tree[0] =~ '^\\\(numberline\|tocsection\)' +			let secnum = LatexBox_TreeToTex(tree[1]) +			let secnum = substitute(secnum, '\\\S\+\s', '', 'g') +			let secnum = substitute(secnum, '\\\S\+{\(.\{-}\)}', '\1', 'g') +			let secnum = substitute(secnum, '^{\+\|}\+$', '', 'g') +			call remove(tree, 1)  		endif  		" parse section title  		let text = LatexBox_TreeToTex(tree) -		let text = substitute(text, '^{\+\|}\+$', '', 'g') -		let text = substitute(text, '\*',         '', 'g') +		let text = substitute(text, '^{\+\|}\+$',                 '', 'g') +		let text = substitute(text, '\m^\\\(no\)\?numberline\s*', '', '') +		let text = substitute(text, '\*',                         '', 'g')  		" add TOC entry  		call add(fileindices[texfile], len(toc)) diff --git a/ftplugin/latextoc.vim b/ftplugin/latextoc.vim index d5d7e58c..8edf23d1 100644 --- a/ftplugin/latextoc.vim +++ b/ftplugin/latextoc.vim @@ -76,9 +76,14 @@ function! s:TOCActivate(close)      execute b:calling_win . 'wincmd w' +    let root = fnamemodify(entry['file'], ':h') . '/'      let files = [entry['file']]      for line in filter(readfile(entry['file']), 'v:val =~ ''\\input{''') -        call add(files, matchstr(line, '{\zs.*\ze\(\.tex\)\?}') . '.tex') +        let file = matchstr(line, '{\zs.\{-}\ze\(\.tex\)\?}') . '.tex' +        if file[0] != '/' +            let file = root . file +        endif +        call add(files, file)      endfor      " Find section in buffer (or inputted files) diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index ae3bd262..e8627ccc 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -11,7 +11,7 @@ runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim  setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s  setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o -setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+ +setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:  if exists('b:undo_ftplugin')    let b:undo_ftplugin .= "|setl cms< com< fo< flp<" diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index a8ef8866..f406cc88 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -69,8 +69,8 @@ endif  function! s:query_path(root)    let code = "print $:.join %q{,}" -  if &shell =~# 'sh' && $PATH !~# '\s' -    let prefix = 'env PATH='.$PATH.' ' +  if &shell =~# 'sh' +    let prefix = 'env PATH='.shellescape($PATH).' '    else      let prefix = ''    endif @@ -190,15 +190,16 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")    endif    if maparg("\<C-]>",'n') == '' -    nnoremap <silent> <buffer> <C-]>       :<C-U>exe  v:count1."tag <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> g<C-]>      :<C-U>exe         "tjump <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> g]          :<C-U>exe       "tselect <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> <C-W>]      :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> <C-W><C-]>  :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> <C-W>g<C-]> :<C-U>exe        "stjump <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> <C-W>g]     :<C-U>exe      "stselect <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> <C-W>}      :<C-U>exe          "ptag <C-R>=RubyCursorIdentifier()<CR>"<CR> -    nnoremap <silent> <buffer> <C-W>g}     :<C-U>exe        "ptjump <C-R>=RubyCursorIdentifier()<CR>"<CR> +    cnoremap <buffer> <SID>foldopen <Bar>if &foldopen =~# 'tag'<Bar>exe 'norm! zv'<Bar>endif +    nnoremap <silent> <script> <buffer> <C-]>       :<C-U>exe  v:count1."tag <C-R>=RubyCursorIdentifier()<CR>"<SID>foldopen<CR> +    nnoremap <silent> <script> <buffer> g<C-]>      :<C-U>exe         "tjump <C-R>=RubyCursorIdentifier()<CR>"<SID>foldopen<CR> +    nnoremap <silent> <script> <buffer> g]          :<C-U>exe       "tselect <C-R>=RubyCursorIdentifier()<CR>"<SID>foldopen<CR> +    nnoremap <silent> <script> <buffer> <C-W>]      :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<SID>foldopen<CR> +    nnoremap <silent> <script> <buffer> <C-W><C-]>  :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<SID>foldopen<CR> +    nnoremap <silent> <script> <buffer> <C-W>g<C-]> :<C-U>exe        "stjump <C-R>=RubyCursorIdentifier()<CR>"<SID>foldopen<CR> +    nnoremap <silent> <script> <buffer> <C-W>g]     :<C-U>exe      "stselect <C-R>=RubyCursorIdentifier()<CR>"<SID>foldopen<CR> +    nnoremap <silent> <script> <buffer> <C-W>}      :<C-U>exe          "ptag <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <script> <buffer> <C-W>g}     :<C-U>exe        "ptjump <C-R>=RubyCursorIdentifier()<CR>"<CR>      let b:undo_ftplugin = b:undo_ftplugin            \."| sil! exe 'nunmap <buffer> <C-]>'| sil! exe 'nunmap <buffer> g<C-]>'| sil! exe 'nunmap <buffer> g]'"            \."| sil! exe 'nunmap <buffer> <C-W>]'| sil! exe 'nunmap <buffer> <C-W><C-]>'" diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim index b70cda9b..39edc1f9 100644 --- a/ftplugin/rust.vim +++ b/ftplugin/rust.vim @@ -1,13 +1,19 @@ -" Vim syntax file  " Language:     Rust +" Description:  Vim syntax file for Rust  " Maintainer:   Chris Morgan <me@chrismorgan.info> -" Last Change:  2014 Feb 27 +" 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 @@ -25,6 +31,14 @@ 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') @@ -42,22 +56,60 @@ if exists("g:loaded_delimitMate")  	let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'  endif +" Motion Commands {{{1 +  " Bind motion commands to support hanging indents -nnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('n', 'Back')<CR> -nnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('n', 'Forward')<CR> -xnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('v', 'Back')<CR> -xnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('v', 'Forward')<CR> -onoremap <silent> <buffer> [[ :call <SID>Rust_Jump('o', 'Back')<CR> -onoremap <silent> <buffer> ]] :call <SID>Rust_Jump('o', 'Forward')<CR> +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 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 -		\|elseif exists('b:delimitMate_excluded_regions') -		  \|unlet b:delimitMate_excluded_regions +		\|else +		  \|unlet! b:delimitMate_excluded_regions  		\|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> [[ @@ -66,31 +118,9 @@ let b:undo_ftplugin = "  		\|ounmap <buffer> ]]  		\" -if exists('*<SID>Rust_Jump') | finish | endif +" }}}1 -function! <SID>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>Rust_Jump_" . a:function . "()" -		let cnt = cnt - 1 -	endwhile -	let &foldenable = foldenable -endfunction - -function! <SID>Rust_Jump_Back() -	call search('{', 'b') -	keepjumps normal! w99[{ -endfunction - -function! <SID>Rust_Jump_Forward() -	normal! j0 -	call search('{', 'b') -	keepjumps normal! w99[{% -	call search('{') -endfunction +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set noet sw=4 ts=4: | 
