From 6cd2d5417d728ea96c5c52b34629c944a89eec60 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 11 Feb 2015 11:27:11 -0800 Subject: [PATCH] Update --- after/syntax/help.vim | 10 +- compiler/sbt.vim | 30 ++++ ftdetect/polyglot.vim | 6 +- ftplugin/csv.vim | 99 +++++++---- ftplugin/jade.vim | 2 + ftplugin/latex-box/common.vim | 32 +++- ftplugin/latex-box/complete.vim | 3 +- ftplugin/latex-box/folding.vim | 4 +- ftplugin/latex-box/motion.vim | 25 ++- ftplugin/perl.vim | 2 +- ftplugin/perl6.vim | 15 +- ftplugin/scala.vim | 81 ++++----- ftplugin/scala/tagbar.vim | 47 ++++++ ftplugin/toml.vim | 2 + indent/go.vim | 9 +- indent/javascript.vim | 4 +- indent/scala.vim | 11 +- syntax/javascript.vim | 76 +++++---- syntax/jst.vim | 12 ++ syntax/ruby.vim | 11 +- syntax/scala.vim | 50 +++++- syntax/tmux.vim | 289 ++++++++++++++++++++++++++------ 22 files changed, 611 insertions(+), 209 deletions(-) create mode 100644 compiler/sbt.vim create mode 100644 ftplugin/scala/tagbar.vim diff --git a/after/syntax/help.vim b/after/syntax/help.vim index b352a1e..e323212 100644 --- a/after/syntax/help.vim +++ b/after/syntax/help.vim @@ -1,6 +1,12 @@ -let b:current_syntax = '' -unlet b:current_syntax +" Extends standard help syntax with highlighting of Scala code. +" +" Place code between !sc! and !/sc! delimiters. These will be hidden if Vim is +" built with conceal support. + +unlet! b:current_syntax + syntax include @ScalaCode syntax/scala.vim + if has('conceal') syntax region rgnScala matchgroup=Ignore concealends start='!sc!' end='!/sc!' contains=@ScalaCode else diff --git a/compiler/sbt.vim b/compiler/sbt.vim new file mode 100644 index 0000000..4c62192 --- /dev/null +++ b/compiler/sbt.vim @@ -0,0 +1,30 @@ +" Vim compiler file +" Language: Scala SBT (http://www.scala-sbt.org/) +" Maintainer: Derek Wyatt +" URL: https://github.com/derekwyatt/vim-scala +" License: Apache 2 +" ---------------------------------------------------------------------------- + +if exists('current_compiler') + finish +endif +let current_compiler = 'sbt' + +if exists(':CompilerSet') != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=sbt\ -Dsbt.log.noformat=true\ compile + +CompilerSet errorformat= + \%E\ %#[error]\ %f:%l:\ %m,%C\ %#[error]\ %p^,%-C%.%#,%Z, + \%W\ %#[warn]\ %f:%l:\ %m,%C\ %#[warn]\ %p^,%-C%.%#,%Z, + \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2 ts=8 et: diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 168b9d2..eb2ab69 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -86,6 +86,7 @@ augroup END au BufNewFile,BufRead *.ejs set filetype=jst au BufNewFile,BufRead *.jst set filetype=jst au BufNewFile,BufRead *.hamljs set filetype=jst +au BufNewFile,BufRead *.ect set filetype=jst autocmd BufNewFile,BufRead *.less setf less au BufNewFile,BufRead *.liquid set ft=liquid au BufNewFile,BufRead */_layouts/*.html,*/_includes/*.html set ft=liquid @@ -178,14 +179,15 @@ au BufNewFile,BufRead [Bb]uildfile call s:setf('ruby') au BufNewFile,BufRead Appraisals call s:setf('ruby') au BufNewFile,BufRead Podfile,*.podspec call s:setf('ruby') au BufRead,BufNewFile *.rs set filetype=rust -au BufRead,BufNewFile *.sbt set filetype=sbt +au BufRead,BufNewFile *.sbt set filetype=sbt.scala fun! s:DetectScala() if getline(1) == '#!/usr/bin/env scala' set filetype=scala endif endfun -au BufRead,BufNewFile *.scala,*.sbt set filetype=scala +au BufRead,BufNewFile *.scala set filetype=scala au BufRead,BufNewFile * call s:DetectScala() +au BufRead,BufNewFile *.sbt setfiletype sbt.scala autocmd BufNewFile,BufRead *.slim set filetype=slim autocmd BufNewFile,BufReadPost *.styl set filetype=stylus autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus diff --git a/ftplugin/csv.vim b/ftplugin/csv.vim index 95b609c..e7455cb 100644 --- a/ftplugin/csv.vim +++ b/ftplugin/csv.vim @@ -41,7 +41,9 @@ fu! Warn(mess) "{{{3 echohl Normal endfu -fu! Init(startline, endline) "{{{3 +fu! Init(startline, endline, ...) "{{{3 + " if a:1 is set, keep the b:delimiter + let keep = exists("a:1") && a:1 " Hilight Group for Columns if exists("g:csv_hiGroup") let s:hiGroup = g:csv_hiGroup @@ -56,10 +58,12 @@ fu! Init(startline, endline) "{{{3 exe "hi link CSVHeaderLine" s:hiHeader " Determine default Delimiter - if !exists("g:csv_delim") - let b:delimiter=GetDelimiter(a:startline, a:endline) - else - let b:delimiter=g:csv_delim + if !keep + if !exists("g:csv_delim") + let b:delimiter=GetDelimiter(a:startline, a:endline) + else + let b:delimiter=g:csv_delim + endif endif " Define custom commentstring @@ -579,7 +583,15 @@ fu! ColWidth(colnr) "{{{3 if !exists("b:csv_fixed_width_cols") if !exists("b:csv_list") - let b:csv_list=getline(1,'$') + " only check first 10000 lines, to be faster + let last = line('$') + if !get(b:, 'csv_arrange_use_all_rows', 0) + if last > 10000 + let last = 10000 + call Warn('File too large, only checking the first 10000 rows for the width') + endif + endif + let b:csv_list=getline(1,last) let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') call filter(b:csv_list, 'v:val !~ pat') call filter(b:csv_list, '!empty(v:val)') @@ -646,15 +658,40 @@ fu! ArrangeCol(first, last, bang, limit) range "{{{3 else let ro = 0 endif - exe "sil". a:first . ',' . a:last .'s/' . (b:col) . - \ '/\=Columnize(submatch(0))/' . (&gd ? '' : 'g') - " Clean up variables, that were only needed for Columnize() function - unlet! s:columnize_count s:max_cols s:prev_line - if ro - setl ro - unlet ro + let s:count = 0 + let _stl = &stl + let s:max = (a:last - a:first + 1) * len(b:col_width) + let s:temp = 0 + try + exe "sil". a:first . ',' . a:last .'s/' . (b:col) . + \ '/\=Columnize(submatch(0))/' . (&gd ? '' : 'g') + finally + " Clean up variables, that were only needed for Columnize() function + unlet! s:columnize_count s:max_cols s:prev_line s:max s:count s:temp s:val + if ro + setl ro + unlet ro + endif + let &stl = _stl + call winrestview(cur) + endtry +endfu + +fu! ProgressBar(cnt, max) "{{{3 + if get(g:, 'csv_no_progress', 0) + return + endif + let width = 40 " max width of progressbar + if width > &columns + let width = &columns + endif + let s:val = a:cnt * width / a:max + if (s:val > s:temp || a:cnt==1) + let &stl='%#DiffAdd#['.repeat('=', s:val).'>'. repeat(' ', width-s:val).']'. + \ (width < &columns ? ' '.100*s:val/width. '%%' : '') + redrawstatus + let s:temp = s:val endif - call winrestview(cur) endfu fu! PrepUnArrangeCol(first, last) "{{{3 @@ -706,9 +743,7 @@ fu! CalculateColumnWidth() "{{{3 endtry " delete buffer content in variable b:csv_list, " this was only necessary for calculating the max width - unlet! b:csv_list - unlet! s:columnize_count - unlet! s:decimal_column + unlet! b:csv_list s:columnize_count s:decimal_column endfu fu! Columnize(field) "{{{3 @@ -725,6 +760,7 @@ fu! Columnize(field) "{{{3 if exists("s:prev_line") && s:prev_line != line('.') let s:columnize_count = 0 endif + let s:count+=1 let s:prev_line = line('.') " convert zero based indexed list to 1 based indexed list, @@ -733,8 +769,8 @@ fu! Columnize(field) "{{{3 " let width=get(b:col_width,WColumn()-1,20) " is too slow, so we are using: let colnr = s:columnize_count % s:max_cols - let width=get(b:col_width, colnr, 20) - let align='r' + let width = get(b:col_width, colnr, 20) + let align = 'r' if exists('b:csv_arrange_align') let align_list=split(get(b:, 'csv_arrange_align', " "), '\zs') try @@ -747,9 +783,10 @@ fu! Columnize(field) "{{{3 \ align isnot? 'c' && align isnot? '.') || get(b:, 'csv_arrange_leftalign', 0)) let align = 'r' endif + call ProgressBar(s:count,s:max) let s:columnize_count += 1 - let has_delimiter = (a:field =~# b:delimiter.'$') + let has_delimiter = (a:field[-1:] is? b:delimiter) if align is? 'l' " left-align content return printf("%-*S%s", width+1 , @@ -1910,7 +1947,8 @@ fu! CommandDefinitions() "{{{3 call LocalCmd("UnArrangeColumn", \':call PrepUnArrangeCol(, )', \ '-range') - call LocalCmd("InitCSV", ':call Init(,)', '-range=%') + call LocalCmd("InitCSV", ':call Init(,,0)', + \ '-bang -range=%') call LocalCmd('Header', \ ':call SplitHeaderLine(,0,1)', \ '-nargs=? -bang') @@ -2232,6 +2270,10 @@ fu! NrColumns(bang) "{{{3 endfu fu! Tabularize(bang, first, last) "{{{3 + if match(split(&ft, '\.'),'csv') == -1 + call Warn("No CSV filetype, aborting!") + return + endif let _c = winsaveview() " Table delimiter definition "{{{4 if !exists("s:td") @@ -2307,10 +2349,7 @@ fu! Tabularize(bang, first, last) "{{{3 call Warn('An error occured, aborting!') return endif - if get(b:, 'csv_arrange_leftalign', 0) - call map(b:col_width, 'v:val+1') - endif - if b:delimiter == "\t" && !get(b:, 'csv_arrange_leftalign',0) + if getline(a:first)[-1:] isnot? b:delimiter let b:col_width[-1] += 1 endif let marginline = s:td.scol. join(map(copy(b:col_width), 'repeat(s:td.hbar, v:val)'), s:td.cros). s:td.ecol @@ -2335,12 +2374,14 @@ fu! Tabularize(bang, first, last) "{{{3 call append(a:first + s:csv_fold_headerline, marginline) let adjust_last += 1 endif + " Syntax will be turned off, so disable this part + " " Adjust headerline to header of new table - let b:csv_headerline = (exists('b:csv_headerline')?b:csv_headerline+2:3) - call CheckHeaderLine() + "let b:csv_headerline = (exists('b:csv_headerline')?b:csv_headerline+2:3) + "call CheckHeaderLine() " Adjust syntax highlighting - unlet! b:current_syntax - ru syntax/csv.vim + "unlet! b:current_syntax + "ru syntax/csv.vim if a:bang exe printf('sil %d,%ds/^%s\zs\n/&%s&/e', a:first + s:csv_fold_headerline, a:last + adjust_last, diff --git a/ftplugin/jade.vim b/ftplugin/jade.vim index 235770d..577f554 100644 --- a/ftplugin/jade.vim +++ b/ftplugin/jade.vim @@ -11,6 +11,8 @@ endif let s:save_cpo = &cpo set cpo-=C +setlocal iskeyword+=- + " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" let s:browsefilter = "All Files (*.*)\t*.*\n" diff --git a/ftplugin/latex-box/common.vim b/ftplugin/latex-box/common.vim index bf6305c..59cf95d 100644 --- a/ftplugin/latex-box/common.vim +++ b/ftplugin/latex-box/common.vim @@ -64,14 +64,24 @@ setlocal efm+=%-G%.%# " Vim Windows {{{ -" Width of vertical splits +" Type of split, "new" for horiz. "vnew" for vert. +if !exists('g:LatexBox_split_type') + let g:LatexBox_split_type = "vnew" +endif + +" Length of vertical splits +if !exists('g:LatexBox_split_length') + let g:LatexBox_split_length = 15 +endif + +" Width of horizontal splits if !exists('g:LatexBox_split_width') let g:LatexBox_split_width = 30 endif -" Where vertical splits appear +" Where splits appear if !exists('g:LatexBox_split_side') - let g:LatexBox_split_side = "leftabove" + let g:LatexBox_split_side = "aboveleft" endif " Resize when split? @@ -229,12 +239,18 @@ endfunction " Default pdf viewer if !exists('g:LatexBox_viewer') - if has('win32') - " On windows, 'running' a file will open it with the default program - let g:LatexBox_viewer = '' - else - let g:LatexBox_viewer = 'xdg-open' + " On windows, 'running' a file will open it with the default program + let s:viewer = '' + if has('unix') + " echo -n necessary as uname -s will append \n otherwise + let s:uname = system('echo -n $(uname -s)') + if s:uname == "Darwin" + let s:viewer = 'open' + else + let s:viewer = 'xdg-open' + endif endif + let g:LatexBox_viewer = s:viewer endif function! LatexBox_View(...) diff --git a/ftplugin/latex-box/complete.vim b/ftplugin/latex-box/complete.vim index 150b00e..0ab8f97 100644 --- a/ftplugin/latex-box/complete.vim +++ b/ftplugin/latex-box/complete.vim @@ -459,7 +459,8 @@ function! s:GetLabelCache(file) if !has_key(s:LabelCache , a:file) || s:LabelCache[a:file][0] != getftime(a:file) " Open file in temporary split window for label extraction. - silent execute '1sp +let\ labels=s:ExtractLabels()|let\ inputs=s:ExtractInputs()|quit! ' . fnameescape(a:file) + let main_tex_file = LatexBox_GetMainTexFile() + silent execute '1sp +let\ b:main_tex_file=main_tex_file|let\ labels=s:ExtractLabels()|let\ inputs=s:ExtractInputs()|quit! ' . fnameescape(a:file) let s:LabelCache[a:file] = [ getftime(a:file), labels, inputs ] endif diff --git a/ftplugin/latex-box/folding.vim b/ftplugin/latex-box/folding.vim index 5d733c2..aedca8f 100644 --- a/ftplugin/latex-box/folding.vim +++ b/ftplugin/latex-box/folding.vim @@ -75,8 +75,8 @@ if g:LatexBox_fold_automatic == 1 " augroup FastFold autocmd! - autocmd InsertEnter *.tex setlocal foldmethod=manual - autocmd InsertLeave *.tex setlocal foldmethod=expr + autocmd InsertEnter *.tex if !&diff | setlocal foldmethod=manual | endif + autocmd InsertLeave *.tex if !&diff | setlocal foldmethod=expr | endif augroup end else setl foldmethod=manual diff --git a/ftplugin/latex-box/motion.vim b/ftplugin/latex-box/motion.vim index 41605ae..7e5b001 100644 --- a/ftplugin/latex-box/motion.vim +++ b/ftplugin/latex-box/motion.vim @@ -349,7 +349,7 @@ function! s:ReadTOC(auxfile, texfile, ...) if len(tree) > 3 && empty(tree[1]) call remove(tree, 1) endif - if len(tree) > 1 && tree[0] =~ '^\\\(numberline\|tocsection\)' + if len(tree) > 1 && type(tree[0]) == type("") && tree[0] =~ '^\\\(numberline\|tocsection\)' let secnum = LatexBox_TreeToTex(tree[1]) let secnum = substitute(secnum, '\\\S\+\s', '', 'g') let secnum = substitute(secnum, '\\\S\+{\(.\{-}\)}', '\1', 'g') @@ -379,6 +379,21 @@ function! LatexBox_TOC(...) " Check if window already exists let winnr = bufwinnr(bufnr('LaTeX TOC')) + " Two types of splits, horizontal and vertical + let l:hori = "new" + let l:vert = "vnew" + + " Set General Vars and initialize size + let l:type = g:LatexBox_split_type + let l:size = 10 + + " Size detection + if l:type == l:hori + let l:size = g:LatexBox_split_length + elseif l:type == l:vert + let l:size = g:LatexBox_split_width + endif + if winnr >= 0 if a:0 == 0 silent execute winnr . 'wincmd w' @@ -386,13 +401,12 @@ function! LatexBox_TOC(...) " Supplying an argument to this function causes toggling instead " of jumping to the TOC window if g:LatexBox_split_resize - silent exe "set columns-=" . g:LatexBox_split_width + silent exe "set columns-=" . l:size endif silent execute 'bwipeout' . bufnr('LaTeX TOC') endif return endif - " Read TOC let [toc, fileindices] = s:ReadTOC(LatexBox_GetAuxFile(), \ LatexBox_GetMainTexFile()) @@ -403,9 +417,10 @@ function! LatexBox_TOC(...) " Create TOC window and set local settings if g:LatexBox_split_resize - silent exe "set columns+=" . g:LatexBox_split_width + silent exe "set columns+=" . l:size endif - silent exe g:LatexBox_split_side g:LatexBox_split_width . 'vnew LaTeX\ TOC' + silent exe g:LatexBox_split_side l:size . l:type . ' LaTeX\ TOC' + let b:toc = toc let b:toc_numbers = 1 let b:calling_win = bufwinnr(calling_buf) diff --git a/ftplugin/perl.vim b/ftplugin/perl.vim index d52015e..89ce8a1 100644 --- a/ftplugin/perl.vim +++ b/ftplugin/perl.vim @@ -77,7 +77,7 @@ endif "--------------------------------------------- " Undo the stuff we changed. -let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< kp< path<" . +let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk< isf< kp< path<" . \ " | unlet! b:browsefilter" " proper matching for matchit plugin diff --git a/ftplugin/perl6.vim b/ftplugin/perl6.vim index 4082ef2..ebb3955 100644 --- a/ftplugin/perl6.vim +++ b/ftplugin/perl6.vim @@ -65,11 +65,22 @@ if !exists("perlpath") endif endif -let &l:path=perlpath +" Append perlpath to the existing path value, if it is set. Since we don't +" use += to do it because of the commas in perlpath, we have to handle the +" global / local settings, too. +if &l:path == "" + if &g:path == "" + let &l:path=perlpath + else + let &l:path=&g:path.",".perlpath + endif +else + let &l:path=&l:path.",".perlpath +endif "--------------------------------------------- " Undo the stuff we changed. -let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk<" . +let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< isk< kp< path<" . \ " | unlet! b:browsefilter" " Restore the saved compatibility options. diff --git a/ftplugin/scala.vim b/ftplugin/scala.vim index 3f0de96..d723eec 100644 --- a/ftplugin/scala.vim +++ b/ftplugin/scala.vim @@ -1,14 +1,33 @@ -setlocal formatoptions+=ro -setlocal commentstring=//%s -let &l:include = '^\s*import' -let &l:includeexpr = 'substitute(v:fname,"\\.","/","g")' +" Vim filetype plugin +" Language: Scala +" Maintainer: Derek Wyatt +" URL: https://github.com/derekwyatt/vim-scala +" License: Apache 2 +" ---------------------------------------------------------------------------- + +if exists('b:did_ftplugin') || &cp + finish +endif +let b:did_ftplugin = 1 + +" j is fairly new in Vim, so don't complain if it's not there +setlocal formatoptions-=t formatoptions+=croqnl +silent! setlocal formatoptions+=j + +" Just like c.vim, but additionally doesn't wrap text onto /** line when +" formatting. Doesn't bungle bulleted lists when formatting. +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/**,mb:*,ex:*/,s1:/*,mb:*,ex:*/,:// +setlocal commentstring=//\ %s + +setlocal shiftwidth=2 softtabstop=2 expandtab + +setlocal include='^\s*import' +setlocal includeexpr='substitute(v:fname,"\\.","/","g")' + setlocal path+=src/main/scala,src/test/scala setlocal suffixesadd=.scala -set makeprg=sbt\ -Dsbt.log.noformat=true\ compile -set efm=%E\ %#[error]\ %f:%l:\ %m,%C\ %#[error]\ %p^,%-C%.%#,%Z, - \%W\ %#[warn]\ %f:%l:\ %m,%C\ %#[warn]\ %p^,%-C%.%#,%Z, - \%-G%.%# +compiler sbt if globpath(&rtp, 'plugin/fuf.vim') != '' " @@ -127,49 +146,6 @@ if globpath(&rtp, 'plugin/fuf.vim') != '' endif endif -" If you want to disable the default key mappings, write the following line in -" your ~/.vimrc -" let g:scala_use_default_keymappings = 0 -if get(g:, 'scala_use_default_keymappings', 1) - nnoremap jt :call JustifyCurrentLine() -endif - -" -" TagBar -" -let g:tagbar_type_scala = { - \ 'ctagstype' : 'scala', - \ 'kinds' : [ - \ 'p:packages:1', - \ 'V:values', - \ 'v:variables', - \ 'T:types', - \ 't:traits', - \ 'o:objects', - \ 'a:aclasses', - \ 'c:classes', - \ 'r:cclasses', - \ 'm:methods' - \ ], - \ 'sro' : '.', - \ 'kind2scope' : { - \ 'T' : 'type', - \ 't' : 'trait', - \ 'o' : 'object', - \ 'a' : 'abstract class', - \ 'c' : 'class', - \ 'r' : 'case class' - \ }, - \ 'scope2kind' : { - \ 'type' : 'T', - \ 'trait' : 't', - \ 'object' : 'o', - \ 'abstract class' : 'a', - \ 'class' : 'c', - \ 'case class' : 'r' - \ } -\ } - function! s:CreateOrExpression(keywords) return '('.join(a:keywords, '|').')' endfunction @@ -191,5 +167,6 @@ function! s:NextSection(backwards) endfunction noremap