diff --git a/after/syntax/less.vim b/after/syntax/less.vim index 4ed2855..7261d9e 100644 --- a/after/syntax/less.vim +++ b/after/syntax/less.vim @@ -3,4 +3,4 @@ if !( has('gui_running') || &t_Co==256 ) | finish | endif -call css_color#init('css', 'lessVariableValue') +call css_color#init('css', 'lessVariableValue,lessDefinition,lessComment') diff --git a/autoload/htmlcomplete.vim b/autoload/htmlcomplete.vim index 8b4492e..68a8038 100644 --- a/autoload/htmlcomplete.vim +++ b/autoload/htmlcomplete.vim @@ -10,7 +10,47 @@ if !exists('g:aria_attributes_complete') let g:aria_attributes_complete = 1 endif -let b:html_omni_flavor = 'html5' +" Distinguish between HTML versions. +" To use with other HTML versions add another "elseif" condition to match +" proper DOCTYPE. +function! htmlcomplete#DetectOmniFlavor() + if &filetype == 'xhtml' + let b:html_omni_flavor = 'xhtml10s' + else + let b:html_omni_flavor = 'html5' + endif + let i = 1 + let line = "" + while i < 10 && i < line("$") + let line = getline(i) + if line =~ '' + let b:html_omni_flavor = 'html40' + endif + if line =~ '\' + let b:html_omni_flavor .= 't' + elseif line =~ '\' + let b:html_omni_flavor .= 'f' + else + let b:html_omni_flavor .= 's' + endif + endif + endif +endfunction function! htmlcomplete#CompleteTags(findstart, base) if a:findstart @@ -162,11 +202,8 @@ function! htmlcomplete#CompleteTags(findstart, base) if exists("b:entitiescompl") unlet! b:entitiescompl - if !exists("b:html_doctype") - call htmlcomplete#CheckDoctype() - endif if !exists("b:html_omni") - "runtime! autoload/xml/xhtml10s.vim + call htmlcomplete#CheckDoctype() call htmlcomplete#LoadData() endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") @@ -464,11 +501,8 @@ function! htmlcomplete#CompleteTags(findstart, base) let entered_value = matchstr(attr, ".*=\\s*[\"']\\?\\zs.*") let values = [] " Load data {{{ - if !exists("b:html_doctype") - call htmlcomplete#CheckDoctype() - endif if !exists("b:html_omni") - "runtime! autoload/xml/xhtml10s.vim + call htmlcomplete#CheckDoctype() call htmlcomplete#LoadData() endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") @@ -547,10 +581,8 @@ function! htmlcomplete#CompleteTags(findstart, base) let sbase = matchstr(context, '.*\ze\s.*') " Load data {{{ - if !exists("b:html_doctype") - call htmlcomplete#CheckDoctype() - endif if !exists("b:html_omni") + call htmlcomplete#CheckDoctype() call htmlcomplete#LoadData() endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") @@ -653,11 +685,8 @@ function! htmlcomplete#CompleteTags(findstart, base) endif " }}} " Load data {{{ - if !exists("b:html_doctype") - call htmlcomplete#CheckDoctype() - endif if !exists("b:html_omni") - "runtime! autoload/xml/xhtml10s.vim + call htmlcomplete#CheckDoctype() call htmlcomplete#LoadData() endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") @@ -787,61 +816,8 @@ function! htmlcomplete#CheckDoctype() " {{{ else let old_flavor = '' endif - let i = 1 - while i < 10 && i < line("$") - let line = getline(i) - if line =~ ' 0 + execute "call Jump_" . a:function . "()" + let cnt = cnt - 1 + endwhile + let &foldenable = foldenable +endfunction + +function! s:Jump_Back() + call search('{', 'b') + keepjumps normal! w99[{ +endfunction + +function! s:Jump_Forward() + normal! j0 + call search('{', 'b') + keepjumps normal! w99[{% + call search('{') +endfunction + +" Run {{{1 + +function! rust#Run(bang, args) + if a:bang + let idx = index(a:args, '--') + if idx != -1 + let rustc_args = idx == 0 ? [] : a:args[:idx-1] + let args = a:args[idx+1:] + else + let rustc_args = a:args + let args = [] + endif + else + let rustc_args = [] + let args = a:args + endif + + let b:rust_last_rustc_args = rustc_args + let b:rust_last_args = args + + call s:WithPath(function("s:Run"), rustc_args, args) +endfunction + +function! s:Run(path, rustc_args, args) + try + let exepath = tempname() + if has('win32') + let exepath .= '.exe' + endif + + let rustc_args = [a:path, '-o', exepath] + a:rustc_args + + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let output = system(shellescape(rustc) . " " . join(map(rustc_args, 'shellescape(v:val)'))) + if output != '' + echohl WarningMsg + echo output + echohl None + endif + if !v:shell_error + exe '!' . shellescape(exepath) . " " . join(map(a:args, 'shellescape(v:val)')) + endif + finally + if exists("exepath") + silent! call delete(exepath) + endif + endtry +endfunction + +" Expand {{{1 + +function! rust#Expand(bang, args) + if a:bang && !empty(a:args) + let pretty = a:args[0] + let args = a:args[1:] + else + let pretty = "expanded" + let args = a:args + endif + call s:WithPath(function("s:Expand"), pretty, args) +endfunction + +function! s:Expand(path, pretty, args) + try + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let args = [a:path, '--pretty', a:pretty] + a:args + let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) + if v:shell_error + echohl WarningMsg + echo output + echohl None + else + new + silent put =output + 1 + d + setl filetype=rust + setl buftype=nofile + setl bufhidden=hide + setl noswapfile + endif + endtry +endfunction + +function! rust#CompleteExpand(lead, line, pos) + if a:line[: a:pos-1] =~ '^RustExpand!\s*\S*$' + " first argument and it has a ! + let list = ["normal", "expanded", "typed", "expanded,identified", "flowgraph="] + if !empty(a:lead) + call filter(list, "v:val[:len(a:lead)-1] == a:lead") + endif + return list + endif + + return glob(escape(a:lead, "*?[") . '*', 0, 1) +endfunction + +" Emit {{{1 + +function! rust#Emit(type, args) + call s:WithPath(function("s:Emit"), a:type, a:args) +endfunction + +function! s:Emit(path, type, args) + try + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let args = [a:path, '--emit', a:type, '-o', '-'] + a:args + let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) + if v:shell_error + echohl WarningMsg + echo output + echohl None + else + new + silent put =output + 1 + d + if a:type == "ir" + setl filetype=llvm + elseif a:type == "asm" + setl filetype=asm + endif + setl buftype=nofile + setl bufhidden=hide + setl noswapfile + endif + endtry +endfunction + +" Utility functions {{{1 + +function! s:WithPath(func, ...) + try + let save_write = &write + set write + let path = expand('%') + let pathisempty = empty(path) + if pathisempty || !save_write + " use a temporary file named 'unnamed.rs' inside a temporary + " directory. This produces better error messages + let tmpdir = tempname() + call mkdir(tmpdir) + + let save_cwd = getcwd() + silent exe 'lcd' tmpdir + + let path = 'unnamed.rs' + + let save_mod = &mod + set nomod + + silent exe 'keepalt write! ' . path + if pathisempty + silent keepalt 0file + endif + else + update + endif + + call call(a:func, [path] + a:000) + finally + if exists("save_mod") | let &mod = save_mod | endif + if exists("save_write") | let &write = save_write | endif + if exists("save_cwd") | silent exe 'lcd' save_cwd | endif + if exists("tmpdir") | silent call s:RmDir(tmpdir) | endif + endtry +endfunction + +function! rust#AppendCmdLine(text) + call setcmdpos(getcmdpos()) + let cmd = getcmdline() . a:text + return cmd +endfunction + +function! s:RmDir(path) + " sanity check; make sure it's not empty, /, or $HOME + if empty(a:path) + echoerr 'Attempted to delete empty path' + return 0 + elseif a:path == '/' || a:path == $HOME + echoerr 'Attempted to delete protected path: ' . a:path + return 0 + endif + silent exe "!rm -rf " . shellescape(a:path) +endfunction + +" }}}1 + +" vim: set noet sw=4 ts=4: diff --git a/autoload/xml/html5.vim b/autoload/xml/html5.vim index 01a1c74..4c99901 100644 --- a/autoload/xml/html5.vim +++ b/autoload/xml/html5.vim @@ -553,7 +553,7 @@ let g:xmldata_html5 = { \ ], \ 'input': [ \ [], - \ extend(copy(global_attributes), {'type': ['text', 'password', 'checkbox', 'radio', 'button', 'submit', 'reset', 'file', 'hidden', 'image', 'datetime', 'datetime-local', 'date', 'month', 'time', 'week', 'number', 'range', 'email', 'url', 'search', 'tel', 'coloe'], 'name': [], 'disabled': ['disabled', ''], 'form': [], 'maxlength': [], 'readonly': ['readonly', ''], 'size': [], 'value': [], 'autocomplete': ['on', 'off'], 'autofocus': ['autofocus', ''], 'list': [], 'pattern': [], 'required': ['required', ''], 'placeholder': [], 'checked': ['checked'], 'accept': [], 'multiple': ['multiple', ''], 'alt': [], 'src': [], 'height': [], 'width': [], 'min': [], 'max': [], 'step': [], 'formenctype': ['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain'], 'formmethod': ['get', 'post', 'put', 'delete'], 'formtarget': [], 'formnovalidate': ['formnovalidate', '']}) + \ extend(copy(global_attributes), {'type': ['text', 'password', 'checkbox', 'radio', 'button', 'submit', 'reset', 'file', 'hidden', 'image', 'datetime', 'datetime-local', 'date', 'month', 'time', 'week', 'number', 'range', 'email', 'url', 'search', 'tel', 'color'], 'name': [], 'disabled': ['disabled', ''], 'form': [], 'maxlength': [], 'readonly': ['readonly', ''], 'size': [], 'value': [], 'autocomplete': ['on', 'off'], 'autofocus': ['autofocus', ''], 'list': [], 'pattern': [], 'required': ['required', ''], 'placeholder': [], 'checked': ['checked'], 'accept': [], 'multiple': ['multiple', ''], 'alt': [], 'src': [], 'height': [], 'width': [], 'min': [], 'max': [], 'step': [], 'formenctype': ['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain'], 'formmethod': ['get', 'post', 'put', 'delete'], 'formtarget': [], 'formnovalidate': ['formnovalidate', '']}) \ ], \ 'ins': [ \ flow_elements, diff --git a/compiler/rake.vim b/compiler/rake.vim index 3bd9da0..8490f2a 100644 --- a/compiler/rake.vim +++ b/compiler/rake.vim @@ -27,7 +27,11 @@ CompilerSet errorformat= \%\\s%#[%f:%l:\ %#%m, \%\\s%#%f:%l:\ %#%m, \%\\s%#%f:%l:, - \%m\ [%f:%l]: + \%m\ [%f:%l]:, + \%+Erake\ aborted!, + \%+EDon't\ know\ how\ to\ build\ task\ %.%#, + \%+Einvalid\ option:%.%#, + \%+Irake\ %\\S%\\+%\\s%\\+#\ %.%# let &cpo = s:cpo_save unlet s:cpo_save diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 3e74c6f..d1cc2bf 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -31,6 +31,10 @@ autocmd BufNewFile,BufRead,StdinReadPost * \ if getline(1) =~ '^\(commit\|tree\|object\) \x\{40\}\>\|^tag \S\+$' | \ set ft=git | \ endif +autocmd BufNewFile,BufRead * + \ if getline(1) =~ '^From \x\{40\} Mon Sep 17 00:00:00 2001$' | + \ set filetype=gitsendemail | + \ endif let s:current_fileformats = '' let s:current_fileencodings = '' function! s:gofiletype_pre() @@ -99,6 +103,34 @@ if has("autocmd") endif au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/*,*/nginx/vhosts.d/*,nginx.conf if &ft == '' | setfiletype nginx | endif au BufRead,BufNewFile *.cl set filetype=opencl +function! s:DetectPerl6() + let line_no = 1 + let eof = line('$') + let in_pod = 0 + while line_no <= eof + let line = getline(line_no) + let line_no = line_no + 1 + if line =~ '^=\w' + let in_pod = 1 + elseif line =~ '^=\%(end\|cut\)' + let in_pod = 0 + elseif !in_pod + let line = substitute(line, '#.*', '', '') + if line =~ '^\s*$' + continue + endif + if line =~ '^\s*\%(use\s\+\)\=v6\%(\.\d\%(\.\d\)\=\)\=;' + set filetype=perl6 " we matched a 'use v6' declaration + elseif line =~ '^\s*\%(\%(my\|our\)\s\+\)\=\(module\|class\|role\|enum\|grammar\)' + set filetype=perl6 " we found a class, role, module, enum, or grammar declaration + endif + break " we either found what we needed, or we found a non-POD, non-comment, + " non-Perl 6 indicating line, so bail out + endif + endwhile +endfunction +autocmd BufReadPost *.pl,*.pm,*.t call s:DetectPerl6() +autocmd BufNew,BufRead *.nqp setf perl6 autocmd BufNewFile,BufRead *.proto setfiletype proto au! BufRead,BufNewFile *.pp setfiletype puppet function! s:setf(filetype) abort @@ -113,7 +145,7 @@ au BufNewFile,BufRead [rR]antfile,*.rant call s:setf('ruby') au BufNewFile,BufRead .irbrc,irbrc call s:setf('ruby') au BufNewFile,BufRead .pryrc call s:setf('ruby') au BufNewFile,BufRead *.ru call s:setf('ruby') -au BufNewFile,BufRead Capfile call s:setf('ruby') +au BufNewFile,BufRead Capfile,*.cap call s:setf('ruby') au BufNewFile,BufRead Gemfile call s:setf('ruby') au BufNewFile,BufRead Guardfile,.Guardfile call s:setf('ruby') au BufNewFile,BufRead Cheffile call s:setf('ruby') diff --git a/ftplugin/csv.vim b/ftplugin/csv.vim index b6414d9..9d8df12 100644 --- a/ftplugin/csv.vim +++ b/ftplugin/csv.vim @@ -160,7 +160,7 @@ fu! Init(startline, endline) "{{{3 " \ delf PrepareFolding | delf OutputFilters | " \ delf SortFilter | delf GetColumn | " \ delf RemoveLastItem | delf DisableFolding | - " \ delf GetSID | delf CheckHeaderLine | + " \ delf CheckHeaderLine | " \ delf AnalyzeColumn | delf Vertfold | " \ delf InitCSVFixedWidth | delf LocalCmd | " \ delf CommandDefinitions | delf NumberFormat | @@ -806,18 +806,18 @@ fu! 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! Sort(bang, line1, line2, colnr) range "{{{3 if !exists("b:csv_fixed_width_cols") let pat= '^' . GetColPat(col-1,1) . b:col else - let pat= '^' . GetColPat(col,0) + let pat= GetColPat(col,0) endif else let pat= '^' . 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! PrepareFolding(add, match) "{{{3 " for val in sort(values(b:csv_filter), 'SortFilter') " let @/ .= val.pat . (val.id == s:filter_count ? '' : '\&') " endfor - let sid = GetSID() " Fold settings: call LocalSettings('fold') " Don't put spaces between the arguments! - exe 'setl foldexpr=' . sid . '_FoldValue(v:lnum,b:csv_filter)' + exe 'setl foldexpr=' . 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! OutputFilters(bang) "{{{3 call Warn("No filters defined currently!") return else - let sid = GetSID() - exe 'setl foldexpr=' . sid . '_FoldValue(v:lnum,b:csv_filter)' + exe 'setl foldexpr=' . s:SID . '_FoldValue(v:lnum,b:csv_filter)' endif endif endfu @@ -1588,14 +1586,11 @@ fu! DisableFolding() "{{{3 endif endfu -fu! GetSID() "{{{3 - if v:version > 703 || v:version == 703 && has("patch032") - return maparg('W', "", "", 1).sid - else - "return substitute(maparg('W'), '\(\d\+\)_', '\1', '') - return matchstr(expand(''), '\zs\d\+\ze_GetSID$') - endif +fu! DetermineSID() + let s:SID = matchstr(expand(''), '\zs\d\+\ze_DetermineSID$') endfu +call s:DetermineSID() +delf s:DetermineSID fu! NumberFormat() "{{{3 let s:nr_format = [',', '.'] diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim index f52a1b2..b2f60fd 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 [ :exe jump('edit',v:count) - nnoremap ] :exe jump('edit',v:count) - nnoremap d :exe jump('split',v:count) - nnoremap :exe jump('split',v:count) - nnoremap [d :exe jump('pedit',v:count) - nnoremap ]d :exe jump('pedit',v:count) + cnoremap foldopen if &foldopen =~# 'tag'exe 'norm! zv'endif + nnoremap