diff options
Diffstat (limited to 'ftplugin')
-rw-r--r-- | ftplugin/csv.vim | 99 | ||||
-rw-r--r-- | ftplugin/jade.vim | 2 | ||||
-rw-r--r-- | ftplugin/latex-box/common.vim | 32 | ||||
-rw-r--r-- | ftplugin/latex-box/complete.vim | 3 | ||||
-rw-r--r-- | ftplugin/latex-box/folding.vim | 4 | ||||
-rw-r--r-- | ftplugin/latex-box/motion.vim | 25 | ||||
-rw-r--r-- | ftplugin/perl.vim | 2 | ||||
-rw-r--r-- | ftplugin/perl6.vim | 15 | ||||
-rw-r--r-- | ftplugin/scala.vim | 81 | ||||
-rw-r--r-- | ftplugin/scala/tagbar.vim | 47 | ||||
-rw-r--r-- | ftplugin/toml.vim | 2 |
11 files changed, 212 insertions, 100 deletions
diff --git a/ftplugin/csv.vim b/ftplugin/csv.vim index 95b609c9..e7455cb1 100644 --- a/ftplugin/csv.vim +++ b/ftplugin/csv.vim @@ -41,7 +41,9 @@ fu! <sid>Warn(mess) "{{{3 echohl Normal endfu -fu! <sid>Init(startline, endline) "{{{3 +fu! <sid>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! <sid>Init(startline, endline) "{{{3 exe "hi link CSVHeaderLine" s:hiHeader " Determine default Delimiter - if !exists("g:csv_delim") - let b:delimiter=<SID>GetDelimiter(a:startline, a:endline) - else - let b:delimiter=g:csv_delim + if !keep + if !exists("g:csv_delim") + let b:delimiter=<SID>GetDelimiter(a:startline, a:endline) + else + let b:delimiter=g:csv_delim + endif endif " Define custom commentstring @@ -579,7 +583,15 @@ fu! <sid>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 <sid>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! <sid>ArrangeCol(first, last, bang, limit) range "{{{3 else let ro = 0 endif - exe "sil". a:first . ',' . a:last .'s/' . (b:col) . - \ '/\=<SID>Columnize(submatch(0))/' . (&gd ? '' : 'g') - " Clean up variables, that were only needed for <sid>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) . + \ '/\=<SID>Columnize(submatch(0))/' . (&gd ? '' : 'g') + finally + " Clean up variables, that were only needed for <sid>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! <sid>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! <sid>PrepUnArrangeCol(first, last) "{{{3 @@ -706,9 +743,7 @@ fu! <sid>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! <sid>Columnize(field) "{{{3 @@ -725,6 +760,7 @@ fu! <sid>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! <sid>Columnize(field) "{{{3 " let width=get(b:col_width,<SID>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! <sid>Columnize(field) "{{{3 \ align isnot? 'c' && align isnot? '.') || get(b:, 'csv_arrange_leftalign', 0)) let align = 'r' endif + call <sid>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! <sid>CommandDefinitions() "{{{3 call <sid>LocalCmd("UnArrangeColumn", \':call <sid>PrepUnArrangeCol(<line1>, <line2>)', \ '-range') - call <sid>LocalCmd("InitCSV", ':call <sid>Init(<line1>,<line2>)', '-range=%') + call <sid>LocalCmd("InitCSV", ':call <sid>Init(<line1>,<line2>,<bang>0)', + \ '-bang -range=%') call <sid>LocalCmd('Header', \ ':call <sid>SplitHeaderLine(<q-args>,<bang>0,1)', \ '-nargs=? -bang') @@ -2232,6 +2270,10 @@ fu! <sid>NrColumns(bang) "{{{3 endfu fu! <sid>Tabularize(bang, first, last) "{{{3 + if match(split(&ft, '\.'),'csv') == -1 + call <sid>Warn("No CSV filetype, aborting!") + return + endif let _c = winsaveview() " Table delimiter definition "{{{4 if !exists("s:td") @@ -2307,10 +2349,7 @@ fu! <sid>Tabularize(bang, first, last) "{{{3 call <sid>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! <sid>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 <sid>CheckHeaderLine() + "let b:csv_headerline = (exists('b:csv_headerline')?b:csv_headerline+2:3) + "call <sid>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 235770d0..577f5547 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 bf6305cc..59cf95d6 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 150b00e7..0ab8f974 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 5d733c23..aedca8f6 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 41605aea..7e5b0011 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 d52015e3..89ce8a1b 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 4082ef24..ebb39555 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 3f0de967..d723eece 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 <buffer> <Leader>jt :call JustifyCurrentLine()<cr> -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 <script> <buffer> <silent> ]] :call <SID>NextSection(0)<cr> - noremap <script> <buffer> <silent> [[ :call <SID>NextSection(1)<cr> + +" vim:set sw=2 sts=2 ts=8 et: diff --git a/ftplugin/scala/tagbar.vim b/ftplugin/scala/tagbar.vim new file mode 100644 index 00000000..19353ef1 --- /dev/null +++ b/ftplugin/scala/tagbar.vim @@ -0,0 +1,47 @@ +" +" Support for Tagbar -- https://github.com/majutsushi/tagbar +" +" Hat tip to Leonard Ehrenfried for the built-in ctags deffile: +" https://leonard.io/blog/2013/04/editing-scala-with-vim/ +" +if !exists(':Tagbar') + finish +endif + +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' + \ } +\ } + +" In case you've updated/customized your ~/.ctags and prefer to use it. +if get(g:, 'scala_use_builtin_tagbar_defs', 1) + let g:tagbar_type_scala.deffile = expand('<sfile>:p:h:h:h') . '/ctags/scala.ctags' +endif diff --git a/ftplugin/toml.vim b/ftplugin/toml.vim index 141157dd..6e205c23 100644 --- a/ftplugin/toml.vim +++ b/ftplugin/toml.vim @@ -11,6 +11,8 @@ let b:did_ftplugin = 1 let s:save_cpo = &cpo set cpo&vim +setlocal commentstring=#\ %s + " Add NERDCommenter delimiters let s:delims = { 'left': '#' } |