mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-14 22:43:49 -05:00
Update all packages
This commit is contained in:
268
ftplugin/csv.vim
268
ftplugin/csv.vim
@@ -1,11 +1,11 @@
|
||||
" Filetype plugin for editing CSV files. "{{{1
|
||||
" Author: Christian Brabandt <cb@256bit.org>
|
||||
" Version: 0.30
|
||||
" Version: 0.31
|
||||
" Script: http://www.vim.org/scripts/script.php?script_id=2830
|
||||
" License: VIM License
|
||||
" Last Change: Thu, 27 Mar 2014 23:28:40 +0100
|
||||
" Last Change: Thu, 15 Jan 2015 21:05:10 +0100
|
||||
" Documentation: see :help ft-csv.txt
|
||||
" GetLatestVimScripts: 2830 29 :AutoInstall: csv.vim
|
||||
" GetLatestVimScripts: 2830 30 :AutoInstall: csv.vim
|
||||
"
|
||||
" Some ideas are taken from the wiki http://vim.wikia.com/wiki/VimTip667
|
||||
" though, implementation differs.
|
||||
@@ -90,7 +90,7 @@ fu! <sid>Init(startline, endline) "{{{3
|
||||
" - Should work with most ugly solutions that are available
|
||||
let b:col='\%(\%(\%(' . (b:delimiter !~ '\s' ? '\s*' : '') .
|
||||
\ '"\%(' . (exists("g:csv_nl") ? '\_' : '' ) .
|
||||
\ '[^"]\|""\)*"\)' . s:del . '\)\|\%(' .
|
||||
\ '[^"]\|""\)*"\s*\)' . s:del . '\)\|\%(' .
|
||||
\ '[^' . b:delimiter . ']*' . s:del . '\)\)'
|
||||
let b:col_end='\%(\%(\%(' . (b:delimiter !~ '\s' ? '\s*' : '') .
|
||||
\ '"\%(' . (exists("g:csv_nl") ? '\_' : '' ) .
|
||||
@@ -147,7 +147,7 @@ fu! <sid>Init(startline, endline) "{{{3
|
||||
let b:undo_ftplugin .= "| unlet! b:delimiter b:col"
|
||||
\ . "| unlet! b:csv_fixed_width_cols b:csv_filter"
|
||||
\ . "| unlet! b:csv_fixed_width b:csv_list b:col_width"
|
||||
\ . "| unlet! b:csv_SplitWindow b:csv_headerline"
|
||||
\ . "| unlet! b:csv_SplitWindow b:csv_headerline b:csv_cmt"
|
||||
\ . "| unlet! b:csv_thousands_sep b:csv_decimal_sep"
|
||||
\. " | unlet! b:browsefilter b:csv_cmt"
|
||||
\. " | unlet! b:csv_arrange_leftalign"
|
||||
@@ -182,7 +182,7 @@ fu! <sid>Init(startline, endline) "{{{3
|
||||
" \ delf <sid>SaveOptions | delf <sid>CheckDuplicates |
|
||||
" \ delf <sid>CompleteColumnNr | delf <sid>CSVPat | delf <sid>Transpose |
|
||||
" \ delf <sid>LocalSettings() | delf <sid>AddColumn | delf <sid>SubstituteInColumn
|
||||
" \ delf <sid>SetupQuitPre() | delf CSV_CloseBuffer
|
||||
" \ delf <sid>SetupAutoCmd() | delf CSV_CloseBuffer
|
||||
endfu
|
||||
|
||||
fu! <sid>LocalSettings(type) "{{{3
|
||||
@@ -194,11 +194,8 @@ fu! <sid>LocalSettings(type) "{{{3
|
||||
let b:undo_ftplugin = "setlocal sol& tw< wrap<"
|
||||
|
||||
" Set browsefilter
|
||||
if (v:version > 703 || (v:version == 703 && has("patch593")))
|
||||
\ && exists("browsefilter")
|
||||
let b:browsefilter="CSV Files (*.csv, *.dat)\t*.csv;*.dat\n".
|
||||
let b:browsefilter="CSV Files (*.csv, *.dat)\t*.csv;*.dat\n".
|
||||
\ "All Files\t*.*\n"
|
||||
endif
|
||||
|
||||
if has("conceal")
|
||||
setl cole=2 cocu=nc
|
||||
@@ -341,7 +338,8 @@ fu! <sid>SearchColumn(arg) "{{{3
|
||||
endif
|
||||
let @/ = <sid>GetPat(colnr, maxcolnr, '\%('.pat. '\)')
|
||||
try
|
||||
norm! n
|
||||
" force redraw, so that the search pattern isn't shown
|
||||
exe "norm! n\<c-l>"
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
" Pattern not found
|
||||
echohl Error
|
||||
@@ -619,10 +617,6 @@ fu! <sid>ColWidth(colnr) "{{{3
|
||||
endfu
|
||||
|
||||
fu! <sid>ArrangeCol(first, last, bang, limit) range "{{{3
|
||||
"TODO: Why doesn't that work?
|
||||
" is this because of the range flag?
|
||||
" It's because of the way, Vim works with
|
||||
" a:firstline and a:lastline parameter, therefore
|
||||
" explicitly give the range as argument to the function
|
||||
if exists("b:csv_fixed_width_cols")
|
||||
" Nothing to do
|
||||
@@ -713,6 +707,8 @@ fu! <sid>CalculateColumnWidth() "{{{3
|
||||
" 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
|
||||
endfu
|
||||
|
||||
fu! <sid>Columnize(field) "{{{3
|
||||
@@ -736,51 +732,83 @@ fu! <sid>Columnize(field) "{{{3
|
||||
" Careful: Keep this fast! Using
|
||||
" let width=get(b:col_width,<SID>WColumn()-1,20)
|
||||
" is too slow, so we are using:
|
||||
let width=get(b:col_width, (s:columnize_count % s:max_cols), 20)
|
||||
let colnr = s:columnize_count % s:max_cols
|
||||
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
|
||||
let align = align_list[colnr]
|
||||
catch
|
||||
let align = 'r'
|
||||
endtry
|
||||
endif
|
||||
if ((align isnot? 'r' && align isnot? 'l' &&
|
||||
\ align isnot? 'c' && align isnot? '.') || get(b:, 'csv_arrange_leftalign', 0))
|
||||
let align = 'r'
|
||||
endif
|
||||
|
||||
let s:columnize_count += 1
|
||||
let has_delimiter = (a:field =~# b:delimiter.'$')
|
||||
if v:version > 703 || v:version == 703 && has("patch713")
|
||||
" printf knows about %S (e.g. can handle char length
|
||||
if get(b:, 'csv_arrange_leftalign',0)
|
||||
" left-align content
|
||||
return printf("%-*S%s", width+1 ,
|
||||
\ (has_delimiter ?
|
||||
\ matchstr(a:field, '.*\%('.b:delimiter.'\)\@=') : a:field),
|
||||
\ (has_delimiter ? b:delimiter : ''))
|
||||
else
|
||||
return printf("%*S", width+1 , a:field)
|
||||
if align is? 'l'
|
||||
" left-align content
|
||||
return printf("%-*S%s", width+1 ,
|
||||
\ (has_delimiter ? a:field[:-2] : a:field),
|
||||
\ (has_delimiter ? b:delimiter : ' '))
|
||||
elseif align is? 'c'
|
||||
" center the column
|
||||
let t = width - len(split(a:field, '\zs'))
|
||||
let leftwidth = t/2
|
||||
" uneven width, add one
|
||||
let rightwidth = (t%2 ? leftwidth+1 : leftwidth)
|
||||
let field = (has_delimiter ? a:field[:-2] : a:field). repeat(' ', rightwidth)
|
||||
return printf("%*S%s", width , field, (has_delimiter ? b:delimiter : ' '))
|
||||
elseif align is? '.'
|
||||
if !exists("s:decimal_column")
|
||||
let s:decimal_column = {}
|
||||
endif
|
||||
else
|
||||
" printf only handles bytes
|
||||
if !exists("g:csv_no_multibyte") &&
|
||||
\ match(a:field, '[^ -~]') != -1
|
||||
" match characters outside the ascii range
|
||||
let a = split(a:field, '\zs')
|
||||
let add = eval(join(map(a, 'len(v:val)'), '+'))
|
||||
let add -= len(a)
|
||||
else
|
||||
let add = 0
|
||||
endif
|
||||
|
||||
" Add one for the frame
|
||||
" plus additional width for multibyte chars,
|
||||
" since printf(%*s..) uses byte width!
|
||||
let width = width + add + 1
|
||||
|
||||
if width == strlen(a:field)
|
||||
" Column has correct length, don't use printf()
|
||||
return a:field
|
||||
else
|
||||
if get(b:, 'csv_arrange_leftalign',0)
|
||||
" left-align content
|
||||
return printf("%-*s%s", width,
|
||||
\ (has_delimiter ? matchstr(a:field, '.*\%('.b:delimiter.'\)\@=') : a:field),
|
||||
\ (has_delimiter ? b:delimiter : ''))
|
||||
else
|
||||
return printf("%*s", width , a:field)
|
||||
if get(s:decimal_column, colnr, 0) == 0
|
||||
call <sid>CheckHeaderLine()
|
||||
call <sid>NumberFormat()
|
||||
let data = <sid>CopyCol('', colnr+1, '')[s:csv_fold_headerline : -1]
|
||||
let pat1 = escape(s:nr_format[1], '.').'\zs[^'.s:nr_format[1].']*\ze'.
|
||||
\ (has_delimiter ? b:delimiter : '').'$'
|
||||
let pat2 = '\d\+\ze\%(\%('.escape(s:nr_format[1], '.'). '\d\+\)\|'.
|
||||
\ (has_delimiter ? b:delimiter : '').'$\)'
|
||||
let data1 = map(copy(data), 'matchstr(v:val, pat1)')
|
||||
let data2 = map(data, 'matchstr(v:val, pat2)')
|
||||
" strlen should be okay for decimals...
|
||||
let data1 = map(data1, 'strlen(v:val)')
|
||||
let data2 = map(data2, 'strlen(v:val)')
|
||||
let dec = max(data1)
|
||||
let scal = max(data2)
|
||||
if dec + scal + 1 + (has_delimiter ? 1 : 0) > width
|
||||
let width = dec + scal + 1 + (has_delimiter ? 1 :0)
|
||||
let b:col_width[colnr] = width
|
||||
endif
|
||||
|
||||
let s:decimal_column[colnr] = dec
|
||||
else
|
||||
let dec = get(s:decimal_column, colnr)
|
||||
endif
|
||||
let field = (has_delimiter ? a:field[:-2] : a:field)
|
||||
let fmt = printf("%%%d.%df", width+1, dec)
|
||||
try
|
||||
if s:nr_format[1] isnot '.'
|
||||
let field = substitute(field, s:nr_format[1], '.', 'g')
|
||||
let field = substitute(field, s:nr_format[0], '', 'g')
|
||||
endif
|
||||
if field =~? '\h' " text in the column, can't be converted to float
|
||||
throw "no decimal"
|
||||
endif
|
||||
let result = printf(fmt, str2float(field)). (has_delimiter ? b:delimiter : ' ')
|
||||
catch
|
||||
let result = printf("%*S", width+2, a:field)
|
||||
endtry
|
||||
return result
|
||||
else
|
||||
" right align
|
||||
return printf("%*S", width+1 , a:field)
|
||||
endif
|
||||
endfun
|
||||
|
||||
@@ -809,14 +837,13 @@ fu! <sid>GetColPat(colnr, zs_flag) "{{{3
|
||||
return pat . (a:zs_flag ? '\zs' : '')
|
||||
endfu
|
||||
|
||||
fu! <sid>SetupQuitPre(window) "{{{3
|
||||
fu! <sid>SetupAutoCmd(window,bufnr) "{{{3
|
||||
" Setup QuitPre autocommand to quit cleanly
|
||||
if exists("##QuitPre")
|
||||
augroup CSV_QuitPre
|
||||
au!
|
||||
exe "au QuitPre * call CSV_CloseBuffer(".winbufnr(a:window).")"
|
||||
augroup end
|
||||
endif
|
||||
aug CSV_QuitPre
|
||||
au!
|
||||
exe "au QuitPre * call CSV_CloseBuffer(".winbufnr(a:window).")"
|
||||
exe "au CursorHold <buffer=".a:bufnr."> call CSV_SetSplitOptions(".a:window.")"
|
||||
aug END
|
||||
endfu
|
||||
|
||||
fu! <sid>SplitHeaderLine(lines, bang, hor) "{{{3
|
||||
@@ -837,8 +864,9 @@ fu! <sid>SplitHeaderLine(lines, bang, hor) "{{{3
|
||||
let _sbo = &sbo
|
||||
let a = []
|
||||
let b=b:col
|
||||
let bufnr = bufnr('.')
|
||||
if a:hor
|
||||
setl scrollopt=hor scrollbind
|
||||
setl scrollopt=hor scrollbind cursorbind
|
||||
let _fdc = &l:fdc
|
||||
let lines = empty(a:lines) ? s:csv_fold_headerline : a:lines
|
||||
let a = getline(1,lines)
|
||||
@@ -851,16 +879,21 @@ fu! <sid>SplitHeaderLine(lines, bang, hor) "{{{3
|
||||
"setl syntax=csv
|
||||
sil! doautocmd FileType csv
|
||||
noa 1
|
||||
sil! sign unplace *
|
||||
exe "resize" . lines
|
||||
setl scrollopt=hor winfixheight nowrap
|
||||
"let &l:stl=repeat(' ', winwidth(0))
|
||||
setl scrollopt=hor winfixheight nowrap cursorbind
|
||||
let &l:stl="%#Normal#".repeat(' ',winwidth(0))
|
||||
let s:local_stl = &l:stl
|
||||
" set the foldcolumn to the same of the other window
|
||||
let &l:fdc = _fdc
|
||||
else
|
||||
setl scrollopt=ver scrollbind
|
||||
setl scrollopt=ver scrollbind cursorbind
|
||||
noa 0
|
||||
let a=<sid>CopyCol('',1,a:lines)
|
||||
if a:lines[-1:] is? '!'
|
||||
let a=<sid>CopyCol('',a:lines,'')
|
||||
else
|
||||
let a=<sid>CopyCol('',1, a:lines-1)
|
||||
endif
|
||||
" Does it make sense to use the preview window?
|
||||
"vert sil! pedit |wincmd w | enew!
|
||||
above vsp +enew
|
||||
@@ -876,11 +909,14 @@ fu! <sid>SplitHeaderLine(lines, bang, hor) "{{{3
|
||||
noa 0
|
||||
let b:csv_SplitWindow = winnr()
|
||||
sil :call <sid>ArrangeCol(1,line('$'), 1, -1)
|
||||
sil! sign unplace *
|
||||
exe "vert res" . len(split(getline(1), '\zs'))
|
||||
call matchadd("CSVHeaderLine", b:col)
|
||||
setl scrollopt=ver winfixwidth
|
||||
setl scrollopt=ver winfixwidth cursorbind nonu nornu fdc=0
|
||||
endif
|
||||
call <sid>SetupQuitPre(winnr())
|
||||
call <sid>SetupAutoCmd(winnr(),bufnr)
|
||||
" disable airline
|
||||
let w:airline_disabled = 1
|
||||
let win = winnr()
|
||||
setl scrollbind buftype=nowrite bufhidden=wipe noswapfile nobuflisted
|
||||
noa wincmd p
|
||||
@@ -901,9 +937,9 @@ fu! <sid>SplitHeaderLine(lines, bang, hor) "{{{3
|
||||
if exists("_sbo")
|
||||
let &sbo = _sbo
|
||||
endif
|
||||
setl noscrollbind
|
||||
setl noscrollbind nocursorbind
|
||||
try
|
||||
wincmd c
|
||||
noa wincmd c
|
||||
catch /^Vim\%((\a\+)\)\=:E444/ " cannot close last window
|
||||
catch /^Vim\%((\a\+)\)\=:E517/ " buffer already wiped
|
||||
" no-op
|
||||
@@ -959,6 +995,9 @@ fu! <sid>MoveCol(forward, line, ...) "{{{3
|
||||
elseif line > line('$')
|
||||
let line=line('$')
|
||||
endif
|
||||
if foldclosed(line) != -1
|
||||
let line = line > line('.') ? foldclosedend(line) : foldclosed(line)
|
||||
endif
|
||||
|
||||
" Generate search pattern
|
||||
if colnr == 1
|
||||
@@ -1906,7 +1945,7 @@ fu! <sid>CommandDefinitions() "{{{3
|
||||
call <sid>LocalCmd("CSVFixed", ':call <sid>InitCSVFixedWidth()', '')
|
||||
call <sid>LocalCmd("NewRecord", ':call <sid>NewRecord(<line1>,
|
||||
\ <line2>, <q-args>)', '-nargs=? -range')
|
||||
call <sid>LocalCmd("NewDelimiter", ':call <sid>NewDelimiter(<q-args>)',
|
||||
call <sid>LocalCmd("NewDelimiter", ':call <sid>NewDelimiter(<q-args>, 1, line(''$''))',
|
||||
\ '-nargs=1')
|
||||
call <sid>LocalCmd("Duplicates", ':call <sid>CheckDuplicates(<q-args>)',
|
||||
\ '-nargs=1 -complete=custom,<sid>CompleteColumnNr')
|
||||
@@ -1993,7 +2032,7 @@ fu! <sid>SaveOptions(list) "{{{3
|
||||
return save
|
||||
endfu
|
||||
|
||||
fu! <sid>NewDelimiter(newdelimiter) "{{{3
|
||||
fu! <sid>NewDelimiter(newdelimiter, firstl, lastl) "{{{3
|
||||
let save = <sid>SaveOptions(['ro', 'ma'])
|
||||
if exists("b:csv_fixed_width_cols")
|
||||
call <sid>Warn("NewDelimiter does not work with fixed width column!")
|
||||
@@ -2005,8 +2044,12 @@ fu! <sid>NewDelimiter(newdelimiter) "{{{3
|
||||
if &l:ro
|
||||
setl noro
|
||||
endif
|
||||
let line=1
|
||||
while line <= line('$')
|
||||
let delimiter = a:newdelimiter
|
||||
if a:newdelimiter is '\t'
|
||||
let delimiter="\t"
|
||||
endif
|
||||
let line=a:firstl
|
||||
while line <= a:lastl
|
||||
" Don't change delimiter for comments
|
||||
if getline(line) =~ '^\s*\V'. escape(b:csv_cmt[0], '\\')
|
||||
let line+=1
|
||||
@@ -2016,7 +2059,7 @@ fu! <sid>NewDelimiter(newdelimiter) "{{{3
|
||||
" Remove field delimiter
|
||||
call map(fields, 'substitute(v:val, b:delimiter .
|
||||
\ ''\?$'' , "", "")')
|
||||
call setline(line, join(fields, a:newdelimiter))
|
||||
call setline(line, join(fields, delimiter))
|
||||
let line+=1
|
||||
endwhile
|
||||
" reset local buffer options
|
||||
@@ -2024,7 +2067,17 @@ fu! <sid>NewDelimiter(newdelimiter) "{{{3
|
||||
call setbufvar('', '&'. key, value)
|
||||
endfor
|
||||
"reinitialize the plugin
|
||||
if exists("g:csv_delim")
|
||||
let _delim = g:csv_delim
|
||||
endif
|
||||
let g:csv_delim = delimiter
|
||||
call <sid>Init(1,line('$'))
|
||||
if exists("_delim")
|
||||
let g:csv_delim = _delim
|
||||
else
|
||||
unlet g:csv_delim
|
||||
endif
|
||||
unlet! _delim
|
||||
endfu
|
||||
|
||||
fu! <sid>IN(list, value) "{{{3
|
||||
@@ -2207,6 +2260,23 @@ fu! <sid>Tabularize(bang, first, last) "{{{3
|
||||
let adjust_last = 0
|
||||
call cursor(a:first,0)
|
||||
call <sid>CheckHeaderLine()
|
||||
let line=a:first
|
||||
if exists("g:csv_table_leftalign")
|
||||
let b:csv_arrange_leftalign = 1
|
||||
endif
|
||||
let newlines=[]
|
||||
while line <= a:last
|
||||
let curline = getline(line)
|
||||
if empty(split(curline, b:delimiter))
|
||||
" only empty delimiters, add one empty delimiter
|
||||
" (:NewDelimiter strips trailing delimiter
|
||||
let curline = repeat(b:delimiter, <sid>MaxColumns())
|
||||
call add(newlines, line)
|
||||
call setline(line, curline)
|
||||
endif
|
||||
let line+=1
|
||||
endw
|
||||
unlet! line
|
||||
if exists("b:csv_fixed_width_cols")
|
||||
let cols=copy(b:csv_fixed_width_cols)
|
||||
let pat = join(map(cols, ' ''\(\%''. v:val. ''c\)'' '), '\|')
|
||||
@@ -2223,21 +2293,35 @@ fu! <sid>Tabularize(bang, first, last) "{{{3
|
||||
" don't clear column width variable, might have been set in the
|
||||
" plugin!
|
||||
sil call <sid>ArrangeCol(a:first, a:last, 0, -1)
|
||||
if !get(b:, 'csv_arrange_leftalign',0)
|
||||
for line in newlines
|
||||
let cline = getline(line)
|
||||
let cline = substitute(cline, '\s$', ' ', '')
|
||||
call setline(line, cline)
|
||||
endfor
|
||||
unlet! line
|
||||
endif
|
||||
endif
|
||||
|
||||
if empty(b:col_width)
|
||||
call <sid>Warn('An error occured, aborting!')
|
||||
return
|
||||
endif
|
||||
let b:col_width[-1] += 1
|
||||
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)
|
||||
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
|
||||
|
||||
exe printf('sil %d,%ds/%s/%s/ge', a:first, (a:last+adjust_last),
|
||||
\ (exists("b:csv_fixed_width_cols") ? pat : b:delimiter ), s:td.vbar)
|
||||
call <sid>NewDelimiter(s:td.vbar, a:first, a:last+adjust_last)
|
||||
"exe printf('sil %d,%ds/%s/%s/ge', a:first, (a:last+adjust_last),
|
||||
" \ (exists("b:csv_fixed_width_cols") ? pat : b:delimiter ), s:td.vbar)
|
||||
" Add vertical bar in first column, if there isn't already one
|
||||
exe printf('sil %d,%ds/%s/%s/e', a:first, a:last+adjust_last,
|
||||
\ '^[^'. s:td.vbar. s:td.scol. ']', s:td.vbar.'&')
|
||||
" And add a final vertical bar, if there isn't already
|
||||
" And add a final vertical bar, if there isn't one already
|
||||
exe printf('sil %d,%ds/%s/%s/e', a:first, a:last+adjust_last,
|
||||
\ '[^'. s:td.vbar. s:td.ecol. ']$', '&'. s:td.vbar)
|
||||
" Make nice intersection graphs
|
||||
@@ -2247,11 +2331,16 @@ fu! <sid>Tabularize(bang, first, last) "{{{3
|
||||
call append(a:first-1, s:td.ltop. join(line, s:td.dhor). s:td.rtop)
|
||||
call append(a:last+adjust_last+1, s:td.lbot. join(line, s:td.uhor). s:td.rbot)
|
||||
|
||||
if s:csv_fold_headerline > 0 && !a:bang
|
||||
"call <sid>NewRecord(s:csv_fold_headerline, s:csv_fold_headerline, 1)
|
||||
if s:csv_fold_headerline > 0
|
||||
call append(a:first + s:csv_fold_headerline, marginline)
|
||||
let adjust_last += 1
|
||||
endif
|
||||
" Adjust headerline to header of new table
|
||||
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
|
||||
|
||||
if a:bang
|
||||
exe printf('sil %d,%ds/^%s\zs\n/&%s&/e', a:first + s:csv_fold_headerline, a:last + adjust_last,
|
||||
@@ -2484,8 +2573,23 @@ fu! CSV_WCol(...) "{{{3
|
||||
endtry
|
||||
endfun
|
||||
|
||||
fu! CSV_SetSplitOptions(window) "{{{3
|
||||
if exists("s:local_stl")
|
||||
" local horizontal statusline
|
||||
for opt in items({'&nu': &l:nu, '&rnu': &l:rnu, '&fdc': &fdc})
|
||||
if opt[1] != getwinvar(a:window, opt[0])
|
||||
call setwinvar(a:window, opt[0], opt[1])
|
||||
endif
|
||||
endfor
|
||||
" Check statusline (airline might change it)
|
||||
if getwinvar(a:window, '&l:stl') != s:local_stl
|
||||
call setwinvar(a:window, '&stl', s:local_stl)
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
fu! CSV_CloseBuffer(buffer) "{{{3
|
||||
" Setup by SetupQuitPre autocommand
|
||||
" Setup by SetupAutoCmd autocommand
|
||||
try
|
||||
if bufnr((a:buffer)+0) > -1
|
||||
exe a:buffer. "bw"
|
||||
|
||||
@@ -30,7 +30,7 @@ function! LatexBox_GetMainFileName(...)
|
||||
" move up the directory tree until we find a .latexmain file.
|
||||
" TODO: Should we be doing this recursion by default, or should there be a
|
||||
" setting?
|
||||
while glob('*.latexmain') == ''
|
||||
while glob('*.latexmain',1) == ''
|
||||
let dirmodifier = dirmodifier.':h'
|
||||
let dirNew = fnameescape(expand(dirmodifier))
|
||||
" break from the loop if we cannot go up any further.
|
||||
@@ -41,7 +41,7 @@ function! LatexBox_GetMainFileName(...)
|
||||
exe 'cd '.dirLast
|
||||
endwhile
|
||||
|
||||
let lheadfile = glob('*.latexmain')
|
||||
let lheadfile = glob('*.latexmain',1)
|
||||
if lheadfile != ''
|
||||
" Remove the trailing .latexmain part of the filename... We never want
|
||||
" that.
|
||||
|
||||
@@ -443,10 +443,32 @@ function! LatexBox_LatexErrors(status, ...)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Redefine uniq() for compatibility with older Vim versions (< 7.4.218)
|
||||
function! s:uniq(list)
|
||||
if exists('*uniq')
|
||||
return uniq(a:list)
|
||||
elseif len(a:list) <= 1
|
||||
return a:list
|
||||
endif
|
||||
|
||||
let last_element = get(a:list,0)
|
||||
let uniq_list = [last_element]
|
||||
|
||||
for i in range(1, len(a:list)-1)
|
||||
let next_element = get(a:list, i)
|
||||
if last_element == next_element
|
||||
continue
|
||||
endif
|
||||
let last_element = next_element
|
||||
call add(uniq_list, next_element)
|
||||
endfor
|
||||
return uniq_list
|
||||
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 = s:uniq(map(lines, 'matchstr(v:val, ''^.*\ze:\d\+:'')'))
|
||||
let lines = filter(lines, 'filereadable(fnameescape(v:val))')
|
||||
return len(lines) > 0
|
||||
endfunction
|
||||
|
||||
@@ -5,31 +5,31 @@ if exists("g:LatexBox_no_mappings")
|
||||
endif
|
||||
|
||||
" latexmk {{{
|
||||
map <buffer> <LocalLeader>ll :Latexmk<CR>
|
||||
map <buffer> <LocalLeader>lL :Latexmk!<CR>
|
||||
map <buffer> <LocalLeader>lc :LatexmkClean<CR>
|
||||
map <buffer> <LocalLeader>lC :LatexmkClean!<CR>
|
||||
map <buffer> <LocalLeader>lg :LatexmkStatus<CR>
|
||||
map <buffer> <LocalLeader>lG :LatexmkStatus!<CR>
|
||||
map <buffer> <LocalLeader>lk :LatexmkStop<CR>
|
||||
map <buffer> <LocalLeader>le :LatexErrors<CR>
|
||||
noremap <buffer> <LocalLeader>ll :Latexmk<CR>
|
||||
noremap <buffer> <LocalLeader>lL :Latexmk!<CR>
|
||||
noremap <buffer> <LocalLeader>lc :LatexmkClean<CR>
|
||||
noremap <buffer> <LocalLeader>lC :LatexmkClean!<CR>
|
||||
noremap <buffer> <LocalLeader>lg :LatexmkStatus<CR>
|
||||
noremap <buffer> <LocalLeader>lG :LatexmkStatus!<CR>
|
||||
noremap <buffer> <LocalLeader>lk :LatexmkStop<CR>
|
||||
noremap <buffer> <LocalLeader>le :LatexErrors<CR>
|
||||
" }}}
|
||||
|
||||
" View {{{
|
||||
map <buffer> <LocalLeader>lv :LatexView<CR>
|
||||
noremap <buffer> <LocalLeader>lv :LatexView<CR>
|
||||
" }}}
|
||||
|
||||
" TOC {{{
|
||||
map <silent> <buffer> <LocalLeader>lt :LatexTOC<CR>
|
||||
noremap <silent> <buffer> <LocalLeader>lt :LatexTOC<CR>
|
||||
" }}}
|
||||
|
||||
" List of labels {{{
|
||||
map <silent> <buffer> <LocalLeader>lj :LatexLabels<CR>
|
||||
noremap <silent> <buffer> <LocalLeader>lj :LatexLabels<CR>
|
||||
" }}}
|
||||
|
||||
" Folding {{{
|
||||
if g:LatexBox_Folding == 1
|
||||
map <buffer> <LocalLeader>lf :LatexFold<CR>
|
||||
noremap <buffer> <LocalLeader>lf :LatexFold<CR>
|
||||
endif
|
||||
" }}}
|
||||
|
||||
@@ -44,12 +44,12 @@ endif
|
||||
" Define text objects {{{
|
||||
vmap <buffer> ie <Plug>LatexBox_SelectCurrentEnvInner
|
||||
vmap <buffer> ae <Plug>LatexBox_SelectCurrentEnvOuter
|
||||
omap <buffer> ie :normal vie<CR>
|
||||
omap <buffer> ae :normal vae<CR>
|
||||
onoremap <buffer> ie :normal vie<CR>
|
||||
onoremap <buffer> ae :normal vae<CR>
|
||||
vmap <buffer> i$ <Plug>LatexBox_SelectInlineMathInner
|
||||
vmap <buffer> a$ <Plug>LatexBox_SelectInlineMathOuter
|
||||
omap <buffer> i$ :normal vi$<CR>
|
||||
omap <buffer> a$ :normal va$<CR>
|
||||
onoremap <buffer> i$ :normal vi$<CR>
|
||||
onoremap <buffer> a$ :normal va$<CR>
|
||||
" }}}
|
||||
|
||||
" Jump between sections {{{
|
||||
|
||||
Reference in New Issue
Block a user