From edd5ee63e66d9ef166034d9ac5bed132f501ecb9 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 13 Dec 2013 01:37:01 +0100 Subject: Update --- autoload/xml/html5.vim | 18 ++- ftdetect/polyglot.vim | 1 - ftplugin/csv.vim | 194 +++++++++++++++++++---------- ftplugin/go/fmt.vim | 12 +- ftplugin/jade.vim | 2 +- ftplugin/latex-box/complete.vim | 2 +- ftplugin/latex-box/latexmk.vim | 67 +++++++--- ftplugin/scala.vim | 13 +- indent/html.vim | 4 +- indent/less.vim | 32 ++++- syntax/elixir.vim | 4 +- syntax/html.vim | 9 +- syntax/less.vim | 2 +- syntax/mason.vim | 16 +-- syntax/perl.vim | 12 +- syntax/rust.vim | 91 +++++++------- syntax/scala.vim | 264 ++++++++++++++-------------------------- 17 files changed, 410 insertions(+), 333 deletions(-) diff --git a/autoload/xml/html5.vim b/autoload/xml/html5.vim index 270b1e30..0452ba49 100644 --- a/autoload/xml/html5.vim +++ b/autoload/xml/html5.vim @@ -61,7 +61,7 @@ let charset = [ " }}} " Attributes_and_Settings: {{{ -let core_attributes = {'accesskey': [], 'class': [], 'contenteditable': ['true', 'false', ''], 'contextmenu': [], 'dir': ['ltr', 'rtl'], 'draggable': ['true', 'false'], 'hidden': ['hidden', ''], 'id': [], 'lang': lang_tag, 'spellcheck': ['true', 'false', ''], 'style': [], 'tabindex': [], 'title': []} +let core_attributes = {'accesskey': [], 'class': [], 'contenteditable': ['true', 'false', ''], 'contextmenu': [], 'dir': ['ltr', 'rtl'], 'draggable': ['true', 'false'], 'hidden': ['hidden', ''], 'id': [], 'is': [], 'lang': lang_tag, 'spellcheck': ['true', 'false', ''], 'style': [], 'tabindex': [], 'title': []} let xml_attributes = {'xml:lang': lang_tag, 'xml:space': ['preserve'], 'xml:base': [], 'xmlns': ['http://www.w3.org/1999/xhtml', 'http://www.w3.org/1998/Math/MathML', 'http://www.w3.org/2000/svg', 'http://www.w3.org/1999/xlink']} let body_attributes = {} @@ -101,6 +101,7 @@ let attributes_value = { \ 'disabled': ['Bool', ''], \ 'draggable': ['true/false', ''], \ 'enctype': ['Token', ''], + \ 'extends': ['Text', ''], \ 'for': ['ID', ''], \ 'form': ['ID', ''], \ 'formaction': ['URL', ''], @@ -152,6 +153,7 @@ let attributes_value = { \ 'scope': ['Token', ''], \ 'scoped': ['Bool', ''], \ 'seamless': ['Bool', ''], + \ 'select': ['Text', ''], \ 'selected': ['Bool', ''], \ 'shape': ['Token', ''], \ 'size': ['Int', ''], @@ -322,16 +324,16 @@ endif " Ref: http://dev.w3.org/html5/markup/ " Version: Draft 05 April 2011 -let phrasing_elements = ['a', 'em', 'strong', 'small', 'mark', 'abbr', 'dfn', 'i', 'b', 'u', 'code', 'var', 'samp', 'kbd', 'sup', 'sub', 'q', 'cite', 'span', 'bdo', 'bdi', 'br', 'wbr', 'ins', 'del', 'img', 'embed', 'object', 'iframe', 'map', 'area', 'script', 'noscript', 'ruby', 'video', 'audio', 'input', 'textarea', 'select', 'button', 'label', 'output', 'datalist', 'keygen', 'progress', 'command', 'canvas', 'time', 'meter', 'data'] +let phrasing_elements = ['a', 'em', 'strong', 'small', 'mark', 'abbr', 'dfn', 'i', 'b', 'u', 'code', 'var', 'samp', 'kbd', 'sup', 'sub', 'q', 'cite', 'span', 'bdo', 'bdi', 'br', 'wbr', 'ins', 'del', 'img', 'embed', 'object', 'iframe', 'map', 'area', 'script', 'noscript', 'ruby', 'video', 'audio', 'input', 'textarea', 'select', 'button', 'label', 'output', 'datalist', 'keygen', 'progress', 'command', 'canvas', 'time', 'meter', 'data', 'content', 'shadow'] let metadata_elements = ['link', 'style', 'meta', 'script', 'noscript', 'command'] -let flow_elements = phrasing_elements + ['p', 'hr', 'pre', 'ul', 'ol', 'dl', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup', 'address', 'blockquote', 'ins', 'del', 'object', 'main', 'map', 'noscript', 'section', 'nav', 'article', 'aside', 'header', 'footer', 'video', 'audio', 'figure', 'table', 'template', 'form', 'fieldset', 'menu', 'canvas', 'details'] +let flow_elements = phrasing_elements + ['p', 'hr', 'pre', 'ul', 'ol', 'dl', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup', 'address', 'blockquote', 'ins', 'del', 'element', 'object', 'main', 'map', 'noscript', 'section', 'nav', 'article', 'aside', 'header', 'footer', 'video', 'audio', 'figure', 'table', 'template', 'form', 'fieldset', 'menu', 'canvas', 'details'] " http://dev.w3.org/html5/spec/Overview.html#linkTypes let linktypes = ['alternate', 'author', 'bookmark', 'external', 'help', 'icon', 'license', 'next', 'nofollow', 'noreferrer', 'pingback', 'prefetch', 'prev', 'search', 'stylesheet', 'sidebar', 'tag'] " http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html -let linkreltypes = linktypes + ['canonical'] +let linkreltypes = linktypes + ['canonical', 'import'] " a and button are special elements for interactive, some element can't be its descendent let abutton_dec = 'details\\|embed\\|iframe\\|keygen\\|label\\|menu\\|select\\|textarea' @@ -425,6 +427,10 @@ let g:xmldata_html5 = { \ [], \ extend(copy(global_attributes), {'span': []}) \ ], +\ 'content': [ + \ [], + \ extend(copy(global_attributes), {'select': []}) +\ ], \ 'command': [ \ ['col'], \ extend(copy(global_attributes), {'type': ['command', 'radio', 'checkbox'], 'radiogroup': [], 'checked': ['checked', ''], 'label': [], 'icon': [], 'disabled': ['disabled', '']}) @@ -677,6 +683,10 @@ let g:xmldata_html5 = { \ ['optgroup', 'option'], \ extend(copy(global_attributes), {'name': [], 'disabled': ['disabled', ''], 'form': [], 'size': [], 'multiple': ['multiple', '']}) \ ], +\ 'shadow': [ + \ [], + \ global_attributes +\ ], \ 'small': [ \ phrasing_elements, \ global_attributes diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 457fd19a..bcccd785 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -56,7 +56,6 @@ endif autocmd BufNewFile,BufReadPost *.jade set filetype=jade au BufNewFile,BufRead *.js setf javascript au BufNewFile,BufRead *.jsm setf javascript -au BufNewFile,BufRead *.json setf javascript au BufNewFile,BufRead Jakefile setf javascript fun! s:SelectJavascript() if getline(1) =~# '^#!.*/bin/env\s\+node\>' diff --git a/ftplugin/csv.vim b/ftplugin/csv.vim index 1ba27722..596012a3 100644 --- a/ftplugin/csv.vim +++ b/ftplugin/csv.vim @@ -136,7 +136,7 @@ fu! Init(startline, endline) "{{{3 \ . "| unlet! b:csv_fixed_width b:csv_list b:col_width" \ . "| unlet! b:csv_SplitWindow b:csv_headerline" \ . "| unlet! b:csv_thousands_sep b:csv_decimal_sep" - \. " | unlet! b:browsefilter b:csv_start b:csv_end" + \. " | unlet! b:browsefilter b:csv_cmt" " Delete all functions " disabled currently, because otherwise when switching ft @@ -168,6 +168,7 @@ fu! Init(startline, endline) "{{{3 " \ delf SaveOptions | delf CheckDuplicates | " \ delf CompleteColumnNr | delf CSVPat | delf Transpose | " \ delf LocalSettings() | delf AddColumn | delf SubstituteInColumn + " \ delf SetupQuitPre() | delf CSV_CloseBuffer endfu fu! LocalSettings(type) "{{{3 @@ -275,7 +276,9 @@ fu! DoAutoCommands() "{{{3 au BufNewFile,BufNew * call Menu(0) augroup END "let b:undo_ftplugin .= '| sil! amenu disable CSV' - let b:undo_ftplugin .= '| sil! call Menu(0)' + " + " b:undo_ftplugin does not support calling Functions + "let b:undo_ftplugin .= '| sil! call Menu(0)' endif endfu @@ -658,7 +661,7 @@ fu! ArrangeCol(first, last, bang) range "{{{3 else let ro = 0 endif - exe a:first . ',' . a:last .'s/' . (b:col) . + 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 @@ -795,16 +798,13 @@ fu! GetColPat(colnr, zs_flag) "{{{3 return pat . (a:zs_flag ? '\zs' : '') endfu -fu! SetupQuitPre() "{{{3 +fu! SetupQuitPre(window) "{{{3 " Setup QuitPre autocommand to quit cleanly if exists("##QuitPre") - let bufnr=bufnr('') - noa wincmd p augroup CSV_QuitPre au! - exe "au QuitPre * ". bufnr. "bw" + exe "au QuitPre * call CSV_CloseBuffer(".winbufnr(a:window).")" augroup end - noa wincmd p endif endfu @@ -839,7 +839,7 @@ fu! SplitHeaderLine(lines, bang, hor) "{{{3 "let b:col=b "setl syntax=csv sil! doautocmd FileType csv - 1 + noa 1 exe "resize" . lines setl scrollopt=hor winfixheight nowrap "let &l:stl=repeat(' ', winwidth(0)) @@ -848,31 +848,31 @@ fu! SplitHeaderLine(lines, bang, hor) "{{{3 let &l:fdc = _fdc else setl scrollopt=ver scrollbind - 0 - let a=CopyCol('',1) - " Force recalculating columns width - unlet! b:csv_list - try - let width = ColWidth(1) - catch /ColWidth/ - call Warn("Error: getting Column Width, using default!") - endtry + noa 0 + let a=CopyCol('',1,a:lines) " Does it make sense to use the preview window? "vert sil! pedit |wincmd w | enew! above vsp +enew call append(0, a) $d _ - sil %s/.*/\=printf("%.*s", width, submatch(0))/eg - 0 - exe "vert res" width - let b:col=b + let b:col = b + sil! doautocmd FileType csv + " remove leading delimiter + exe "sil :%s/^". b:delimiter. "//e" + " remove trailing delimiter + exe "sil :%s/". b:delimiter. "\s*$//e" + syn clear + noa 0 + let b:csv_SplitWindow = winnr() + sil :call ArrangeCol(1,line('$'), 1) + exe "vert res" . len(split(getline(1), '\zs')) call matchadd("CSVHeaderLine", b:col) setl scrollopt=ver winfixwidth endif - call SetupQuitPre() + call SetupQuitPre(winnr()) let win = winnr() setl scrollbind buftype=nowrite bufhidden=wipe noswapfile nobuflisted - wincmd p + noa wincmd p let b:csv_SplitWindow = win aug CSV_Preview au! @@ -891,7 +891,12 @@ fu! SplitHeaderLine(lines, bang, hor) "{{{3 let &sbo = _sbo endif setl noscrollbind - wincmd c + try + wincmd c + catch /^Vim\%((\a\+)\)\=:E444/ " cannot close last window + catch /^Vim\%((\a\+)\)\=:E517/ " buffer already wiped + " no-op + endtry "pclose! unlet! b:csv_SplitWindow aug CSV_Preview @@ -910,8 +915,11 @@ fu! SplitHeaderToggle(hor) "{{{3 endfu " TODO: from here on add logic for fixed-width csv files! -fu! MoveCol(forward, line) "{{{3 +fu! MoveCol(forward, line, ...) "{{{3 " Move cursor position upwards/downwards left/right + " a:1 is there to have some mappings move in the same + " direction but still stop at a different position + " see :h csv-mapping-H let colnr=WColumn() let maxcol=MaxColumns() let cpos=getpos('.')[2] @@ -982,6 +990,17 @@ fu! MoveCol(forward, line) "{{{3 norm! 0 endif endw + if (exists("a:1") && a:1) + " H also stops at the beginning of the content + " of a field. + let epos = getpos('.') + if getline('.')[col('.')-1] == ' ' + call search('\S', 'W', line('.')) + if getpos('.')[2] > spos + call setpos('.', epos) + endif + endif + endif else norm! 0 endif @@ -1043,13 +1062,19 @@ fu! Sort(bang, line1, line2, colnr) range "{{{3 call winrestview(wsv) endfun -fu! CopyCol(reg, col) "{{{3 +fu! CopyCol(reg, col, cnt) "{{{3 " Return Specified Column into register reg let col = a:col == "0" ? WColumn() : a:col+0 let mcol = MaxColumns() if col == '$' || col > mcol let col = mcol endif + " The number of columns to return + " by default (value of zero, will only return that specific column) + let cnt_cols = col - 1 + if !empty(a:cnt) && a:cnt > 0 && col + a:cnt <= mcol + let cnt_cols = col + a:cnt - 1 + endif let a = [] " Don't get lines, that are currently filtered away if !exists("b:csv_filter") || empty(b:csv_filter) @@ -1068,9 +1093,12 @@ fu! CopyCol(reg, col) "{{{3 call filter(a, 'v:val !~ pat') if !exists("b:csv_fixed_width_cols") - call map(a, 'split(v:val, ''^'' . b:col . ''\zs'')[col-1]') + call map(a, 'split(v:val, ''^'' . b:col . ''\zs'')[col-1:cnt_cols]') else - call map(a, 'matchstr(v:val, GetColPat(col, 0))') + call map(a, 'matchstr(v:val, GetColPat(col, 0)).*GetColPat(col+cnt_cols, 0)') + endif + if type(a[0]) == type([]) + call map(a, 'join(v:val, "")') endif if a:reg =~ '[-"0-9a-zA-Z*+]' "exe ':let @' . a:reg . ' = "' . join(a, "\n") . '"' @@ -1574,7 +1602,7 @@ fu! AnalyzeColumn(...) "{{{3 " Initialize s:fold_headerline call CheckHeaderLine() - let data = CopyCol('', colnr)[s:csv_fold_headerline : -1] + let data = CopyCol('', colnr, '')[s:csv_fold_headerline : -1] let qty = len(data) let res = {} for item in data @@ -1665,59 +1693,56 @@ fu! InitCSVFixedWidth() "{{{3 endif " Turn off syntax highlighting syn clear + let max_len = len(split(getline(1), '\zs')) let _cc = &l:cc let &l:cc = 1 redraw! - let list = [] + let Dict = {'1': 1} " first column is always the start of a new column let tcc = &l:cc + let &l:cc = 1 echo ", , , , ..." let char=getchar() while 1 if char == "\" || char == "\" let tcc = eval('tcc'.(char=="\" ? '-' : '+').'1') + if tcc < 0 + let tcc=0 + elseif tcc > max_len + let tcc = max_len + endif elseif char == "\" || char == 32 " Space - call add(list, tcc) + let Dict[tcc] = 1 elseif char == "\" || char == 127 - call remove(list, -1) + try + call remove(Dict, reverse(sort(keys(Dict)))[0]) + catch /^Vim\%((\a\+)\)\=:E\(\%(716\)\|\%(684\)\)/ " Dict or List empty + break + endtry elseif char == "\" || char == 27 let &l:cc=_cc redraw! return + elseif char == "\" || char == "\n" || char == "\r" " Enter + let Dict[tcc] = 1 + break else break endif - let &l:cc=tcc . (!empty(list)? ',' . join(list, ','):'') + let &l:cc=tcc . (!empty(keys(Dict))? ',' . join(keys(Dict), ','):'') redraw! echo ", , , , ..." let char=getchar() endw - if tcc > 0 - call add(list,tcc) - endif let b:csv_fixed_width_cols=[] let tcc=0 - if !empty(list) - call Break() - " Remove duplicate entries - for val in sort(list, "SortList") - if val==tcc - continue - endif - call add(b:csv_fixed_width_cols, val) - let tcc=val - endfor - let b:csv_fixed_width=join(sort(b:csv_fixed_width_cols, - \ "SortList"), ',') - call Init(1, line('$')) - endif + let b:csv_fixed_width_cols = sort(keys(Dict), "SortList") + let b:csv_fixed_width = join(sort(keys(Dict), "SortList"), ',') + call Init(1, line('$')) + let &l:cc=_cc redraw! endfu -fu! Break() - return -endfu - fu! NewRecord(line1, line2, count) "{{{3 if a:count =~ "\D" call WarningMsg("Invalid count specified") @@ -1757,22 +1782,35 @@ fu! MoveOver(outer) "{{{3 " Move over a field " a:outer means include the delimiter let last = 0 - let mode = a:outer + let outer_field = a:outer + let cur_field = WColumn() + let _wsv = winsaveview() - if WColumn() == MaxColumns() + if cur_field == MaxColumns() let last = 1 - if !mode && getline('.')[-1:] != b:delimiter + if !outer_field && getline('.')[-1:] != b:delimiter " No trailing delimiter, so inner == outer - let mode = 1 + let outer_field = 1 endif endif - call MoveCol(-1, line(".")) + " Move 1 column backwards, unless the cursor is in the first column + " or in front of a delimiter + if matchstr(getline('.'), '.\%'.virtcol('.').'v') != b:delimiter && virtcol('.') > 1 + call MoveCol(-1, line('.')) + endif +" if cur_field != WColumn() + " cursor was at the beginning of the field, and moved back to the + " previous field, move back to original position +" call cursor(_wsv.lnum, _wsv.col) +" endif let _s = @/ if last - exe "sil! norm! /" . b:col . "\v$h" . (mode ? "" : "\") + exe "sil! norm! v$h" . (outer_field ? "" : "h") . (&sel ==# 'exclusive' ? "l" : '') else - exe "sil! norm! /" . b:col . "\vn\" . (mode ? "" : "\") + exe "sil! norm! v/." . b:col . "\h" . (outer_field ? "" : "h") . (&sel ==# 'exclusive' ? "l" : '') endif + let _wsv.col = col('.')-1 + call winrestview(_wsv) let @/ = _s endfu @@ -1782,7 +1820,7 @@ fu! CSVMappings() "{{{3 call Map('noremap', 'L', ':call MoveCol(1, line("."))') call Map('noremap', 'E', ':call MoveCol(-1, line("."))') call Map('noremap', '', ':call MoveCol(-1, line("."))') - call Map('noremap', 'H', ':call MoveCol(-1, line("."))') + call Map('noremap', 'H', ':call MoveCol(-1, line("."), 1)') call Map('noremap', 'K', ':call MoveCol(0, \ line(".")-v:count1)') call Map('noremap', '', ':call MoveCol(0, @@ -1846,8 +1884,8 @@ fu! CommandDefinitions() "{{{3 \ ':call Sort(0, ,,)', \ '-nargs=* -bang -range=% -complete=custom,SortComplete') call LocalCmd("Column", - \ ':call CopyCol(empty()?''"'':,)', - \ '-count -register') + \ ':call CopyCol(empty()?''"'':,,)', + \ '-count -register -nargs=?') call LocalCmd("MoveColumn", \ ':call MoveColumn(,,)', \ '-range=% -nargs=* -complete=custom,SortComplete') @@ -2328,6 +2366,11 @@ endfu " Global functions "{{{2 fu! csv#EvalColumn(nr, func, first, last) range "{{{3 + " Make sure, the function is called for the correct filetype. + if match(split(&ft, '\.'), 'csv') == -1 + call Warn("File is no CSV file!") + return + endif let save = winsaveview() call CheckHeaderLine() let nr = matchstr(a:nr, '^\d\+') @@ -2336,7 +2379,7 @@ fu! csv#EvalColumn(nr, func, first, last) range "{{{3 let start = a:first - 1 + s:csv_fold_headerline let stop = a:last - 1 + s:csv_fold_headerline - let column = CopyCol('', col)[start : stop] + let column = CopyCol('', col, '')[start : stop] " Delete delimiter call map(column, 'substitute(v:val, b:delimiter . "$", "", "g")') " Revmoe trailing whitespace @@ -2396,7 +2439,7 @@ fu! CSVField(x, y, ...) "{{{3 let orig = !empty(a:0) let y = (y < 0 ? 0 : y) let x = (x > (MaxColumns()) ? (MaxColumns()) : x) - let col = CopyCol('',x) + let col = CopyCol('',x,'') if !orig " remove leading and trainling whitespace and the delimiter return matchstr(col[y], '^\s*\zs.\{-}\ze\s*'.b:delimiter.'\?$') @@ -2435,6 +2478,23 @@ fu! CSV_WCol(...) "{{{3 endtry endfun +fu! CSV_CloseBuffer(buffer) "{{{3 + " Setup by SetupQuitPre autocommand + try + if bufnr((a:buffer)+0) > -1 + exe a:buffer. "bw" + endif + catch /^Vim\%((\a\+)\)\=:E517/ " buffer already wiped + " no-op + finally + augroup CSV_QuitPre + au! + augroup END + augroup! CSV_QuitPre + endtry +endfu + + " Initialize Plugin "{{{2 let b:csv_start = exists("b:csv_start") ? b:csv_start : 1 let b:csv_end = exists("b:csv_end") ? b:csv_end : line('$') diff --git a/ftplugin/go/fmt.vim b/ftplugin/go/fmt.vim index 5447d457..359545bd 100644 --- a/ftplugin/go/fmt.vim +++ b/ftplugin/go/fmt.vim @@ -18,15 +18,21 @@ " " Flag to indicate whether to enable the commands listed above. " +" g:gofmt_command [default="gofmt"] +" +" Flag naming the gofmt executable to use. +" if exists("b:did_ftplugin_go_fmt") finish endif - if !exists("g:go_fmt_commands") let g:go_fmt_commands = 1 endif +if !exists("g:gofmt_command") + let g:gofmt_command = "gofmt" +endif if g:go_fmt_commands command! -buffer Fmt call s:GoFormat() @@ -34,7 +40,7 @@ endif function! s:GoFormat() let view = winsaveview() - silent %!gofmt + silent execute "%!" . g:gofmt_command if v:shell_error let errors = [] for line in getline(1, line('$')) @@ -51,7 +57,7 @@ function! s:GoFormat() endif undo if !empty(errors) - call setloclist(0, errors, 'r') + call setqflist(errors, 'r') endif echohl Error | echomsg "Gofmt returned error" | echohl None endif diff --git a/ftplugin/jade.vim b/ftplugin/jade.vim index a6ff9b9a..235770d0 100644 --- a/ftplugin/jade.vim +++ b/ftplugin/jade.vim @@ -45,7 +45,7 @@ endif setlocal comments=://-,:// commentstring=//\ %s -setlocal suffixesadd=.jade +setlocal suffixesadd+=.jade let b:undo_ftplugin = "setl cms< com< " \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin diff --git a/ftplugin/latex-box/complete.vim b/ftplugin/latex-box/complete.vim index af894777..9f4f55d5 100644 --- a/ftplugin/latex-box/complete.vim +++ b/ftplugin/latex-box/complete.vim @@ -291,7 +291,7 @@ function! LatexBox_BibSearch(regexp) " Find data from 'thebibliography' environments let lines = readfile(LatexBox_GetMainTexFile()) - if match(lines, '\C\\begin{thebibliography}') + if match(lines, '\C\\begin{thebibliography}') >= 0 for line in filter(filter(lines, 'v:val =~ ''\C\\bibitem'''), \ 'v:val =~ a:regexp') let match = matchlist(line, '\\bibitem{\([^}]*\)')[1] diff --git a/ftplugin/latex-box/latexmk.vim b/ftplugin/latex-box/latexmk.vim index 87ac2a99..2ce16d26 100644 --- a/ftplugin/latex-box/latexmk.vim +++ b/ftplugin/latex-box/latexmk.vim @@ -92,8 +92,8 @@ function! s:LatexmkCallback(basename, status) " Only remove the pid if not in continuous mode if !g:LatexBox_latexmk_preview_continuously call remove(g:latexmk_running_pids, a:basename) - call LatexBox_LatexErrors(a:status, a:basename) endif + call LatexBox_LatexErrors(a:status, a:basename) endfunction function! s:setup_vim_server() @@ -104,7 +104,7 @@ function! s:setup_vim_server() if has('win32') " Just drop through to the default for windows else - if match(&shell, '/\(bash\|zsh\)$') >= 0 + if match(&shell, '\(bash\|zsh\)$') >= 0 let ppid = '$PPID' else let ppid = '$$' @@ -188,6 +188,10 @@ function! LatexBox_Latexmk(force) endif let cmd .= ' -e ' . shellescape('$pdflatex =~ s/ / -file-line-error /') let cmd .= ' -e ' . shellescape('$latex =~ s/ / -file-line-error /') + if g:LatexBox_latexmk_preview_continuously + let cmd .= ' -e ' . shellescape('$success_cmd = $ENV{SUCCESSCMD}') + let cmd .= ' -e ' . shellescape('$failure_cmd = $ENV{FAILURECMD}') + endif let cmd .= ' ' . mainfile " Redirect output to null @@ -223,19 +227,39 @@ function! LatexBox_Latexmk(force) let callback = callbackfunc . '(''' . basepath . ''', %LATEXERR%)' let vimcmd = vim_program . ' --servername ' . v:servername \ . ' --remote-expr ' . shellescape(callback) + let scallback = callbackfunc . '(''' . basepath . ''', 0)' + let svimcmd = vim_program . ' --servername ' . v:servername + \ . ' --remote-expr ' . shellescape(scallback) + let fcallback = callbackfunc . '(''' . basepath . ''', 1)' + let fvimcmd = vim_program . ' --servername ' . v:servername + \ . ' --remote-expr ' . shellescape(fcallback) let asyncbat = tempname() . '.bat' - call writefile(['setlocal', - \ 'set T=%TEMP%\sthUnique.tmp', - \ 'wmic process where (Name="WMIC.exe" AND CommandLine LIKE "%%%TIME%%%") ' - \ . 'get ParentProcessId /value | find "ParentProcessId" >%T%', - \ 'set /P A=<%T%', - \ 'set CMDPID=%A:~16% & del %T%', - \ vimsetpid, - \ cmd, - \ 'set LATEXERR=%ERRORLEVEL%', - \ vimcmd, - \ 'endlocal'], asyncbat) + if g:LatexBox_latexmk_preview_continuously + call writefile(['setlocal', + \ 'set T=%TEMP%\sthUnique.tmp', + \ 'wmic process where (Name="WMIC.exe" AND CommandLine LIKE "%%%TIME%%%") ' + \ . 'get ParentProcessId /value | find "ParentProcessId" >%T%', + \ 'set /P A=<%T%', + \ 'set CMDPID=%A:~16% & del %T%', + \ vimsetpid, + \ 'set SUCCESSCMD='.svimcmd, + \ 'set FAILURECMD='.fvimcmd, + \ cmd, + \ 'endlocal'], asyncbat) + else + call writefile(['setlocal', + \ 'set T=%TEMP%\sthUnique.tmp', + \ 'wmic process where (Name="WMIC.exe" AND CommandLine LIKE "%%%TIME%%%") ' + \ . 'get ParentProcessId /value | find "ParentProcessId" >%T%', + \ 'set /P A=<%T%', + \ 'set CMDPID=%A:~16% & del %T%', + \ vimsetpid, + \ cmd, + \ 'set LATEXERR=%ERRORLEVEL%', + \ vimcmd, + \ 'endlocal'], asyncbat) + endif " Define command let cmd = '!start /b ' . asyncbat . ' & del ' . asyncbat @@ -248,13 +272,26 @@ function! LatexBox_Latexmk(force) " Define callback after latexmk is finished let callback = shellescape(callbackfunc).'"(\"'.basepath.'\",$?)"' let vimcmd = g:vim_program . ' --servername ' . v:servername - \ . ' --remote-expr ' . callback + \ . ' --remote-expr ' . callback + let scallback = shellescape(callbackfunc).'"(\"'.basepath.'\",0)"' + let svimcmd = g:vim_program . ' --servername ' . v:servername + \ . ' --remote-expr ' . scallback + let fcallback = shellescape(callbackfunc).'"(\"'.basepath.'\",1)"' + let fvimcmd = g:vim_program . ' --servername ' . v:servername + \ . ' --remote-expr ' . fcallback " Define command " Note: Here we escape '%' because it may be given as a user option " through g:LatexBox_latexmk_options, for instance with " g:Latex..._options = "-pdflatex='pdflatex -synctex=1 \%O \%S'" - let cmd = vimsetpid . ' ; ' . escape(cmd, '%') . ' ; ' . vimcmd + if g:LatexBox_latexmk_preview_continuously + let cmd = vimsetpid . ' ; ' + \ . 'export SUCCESSCMD=' . shellescape(svimcmd) . ' ' + \ . ' FAILURECMD=' . shellescape(fvimcmd) . ' ; ' + \ . escape(cmd, '%') + else + let cmd = vimsetpid . ' ; ' . escape(cmd, '%') . ' ; ' . vimcmd + endif let cmd = '! (' . cmd . ') >/dev/null &' endif diff --git a/ftplugin/scala.vim b/ftplugin/scala.vim index cdd1a74d..6db56d04 100644 --- a/ftplugin/scala.vim +++ b/ftplugin/scala.vim @@ -117,16 +117,21 @@ if globpath(&rtp, 'plugin/fuf.vim') != '' return scala#GetDirForFuzzyFinder(a:from, 'src/../') endfunction - nnoremap ,ft :FufFile =scala#GetTestDirForFuzzyFinder('%:p:h') - nnoremap ,fs :FufFile =scala#GetMainDirForFuzzyFinder('%:p:h') - nnoremap ,fr :FufFile =scala#GetRootDirForFuzzyFinder('%:p:h') + " 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 ft :FufFile =scala#GetTestDirForFuzzyFinder('%:p:h') + nnoremap fs :FufFile =scala#GetMainDirForFuzzyFinder('%:p:h') + nnoremap fr :FufFile =scala#GetRootDirForFuzzyFinder('%:p:h') + 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() + nnoremap jt :call JustifyCurrentLine() endif " diff --git a/indent/html.vim b/indent/html.vim index 466c6bd8..1c34cf68 100644 --- a/indent/html.vim +++ b/indent/html.vim @@ -130,12 +130,14 @@ call add(s:tags, 'rt') call add(s:tags, 'ruby') call add(s:tags, 'section') call add(s:tags, 'summary') -call add(s:tags, 'template') call add(s:tags, 'time') call add(s:tags, 'video') call add(s:tags, 'bdi') call add(s:tags, 'data') +" Web Component +call add(s:tags, 'template') + " Common inline used SVG elements call add(s:tags, 'clipPath') call add(s:tags, 'defs') diff --git a/indent/less.vim b/indent/less.vim index fea8846d..6161c93c 100644 --- a/indent/less.vim +++ b/indent/less.vim @@ -6,6 +6,36 @@ if exists("b:did_indent") finish endif +let b:did_indent = 1 + +setlocal autoindent sw=2 et +setlocal indentexpr=GetLessIndent() +setlocal indentkeys=o,O,*,<:>,!^F + +" Only define the function once. +if exists("*GetLessIndent") + finish +endif + +let s:property = '^\s*:\|^\s*[[:alnum:]#{}-]\+\%(:\|\s*=\)' + +function! GetLessIndent() + let lnum = prevnonblank(v:lnum-1) + let line = substitute(getline(lnum),'\s\+$','','') + let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') + let lastcol = strlen(line) + let line = substitute(line,'^\s\+','','') + let indent = indent(lnum) + let cindent = indent(v:lnum) + if line !~ s:property && cline =~ s:property + return indent + &sw + "elseif line =~ s:property && cline !~ s:property + "return indent - &sw + else + return -1 + endif +endfunction + +" vim:set sw=2: -runtime! indent/css.vim diff --git a/syntax/elixir.vim b/syntax/elixir.vim index 7dc428ef..2e3a0e0e 100644 --- a/syntax/elixir.vim +++ b/syntax/elixir.vim @@ -18,10 +18,10 @@ syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained syn keyword elixirKeyword is_atom is_binary is_bitstring is_boolean is_float is_function is_integer is_list is_number is_pid is_port is_record is_reference is_tuple is_exception syn keyword elixirKeyword case cond bc lc inlist inbits if unless try receive function syn keyword elixirKeyword exit raise throw after rescue catch else -syn keyword elixirKeyword use quote unquote super alias +syn keyword elixirKeyword quote unquote super syn match elixirKeyword '\<\%(->\)\>\s*' -syn keyword elixirInclude import require +syn keyword elixirInclude import require alias use syn keyword elixirOperator and not or when xor in syn match elixirOperator '%=\|\*=\|\*\*=\|+=\|-=\|\^=\|||=' diff --git a/syntax/html.vim b/syntax/html.vim index 1cd86010..b9b4d86f 100644 --- a/syntax/html.vim +++ b/syntax/html.vim @@ -21,7 +21,8 @@ syn keyword htmlTagName contained article aside audio canvas command syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer syn keyword htmlTagName contained header hgroup keygen main mark meter menu nav output -syn keyword htmlTagName contained progress ruby rt rp section source summary template time track video data +syn keyword htmlTagName contained progress ruby rt rp section source summary time track video data +syn keyword htmlTagName contained template content shadow syn keyword htmlTagName contained wbr bdi " SVG tags @@ -40,10 +41,12 @@ syn keyword htmlTagName contained linearGradient marker mask pattern radialGradi syn keyword htmlTagName contained missing-glyph mpath syn keyword htmlTagName contained text textPath tref tspan vkern +syn match htmlTagName contained "\<[a-z_]\+\(\-[a-z_]\+\)\+\>" + " HTML 5 arguments " Core Attributes syn keyword htmlArg contained accesskey class contenteditable contextmenu dir -syn keyword htmlArg contained draggable hidden id lang spellcheck style tabindex title translate +syn keyword htmlArg contained draggable hidden id is lang spellcheck style tabindex title translate " Event-handler Attributes syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover @@ -69,6 +72,8 @@ syn keyword htmlArg contained required placeholder syn keyword htmlArg contained label icon open datetime pubdate "