diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2014-07-29 13:03:49 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2014-07-29 13:03:49 +0200 | 
| commit | 5f1223fbc5285689db812236c9100329740a805b (patch) | |
| tree | 58bc6f11540011afb25826c96f65fa35f5687291 /autoload | |
| parent | a59f644d49ee029df48586a6c3c358858f1e6739 (diff) | |
| download | vim-polyglot-5f1223fbc5285689db812236c9100329740a805b.tar.gz vim-polyglot-5f1223fbc5285689db812236c9100329740a805b.zip | |
Major updatev1.9.2
Diffstat (limited to '')
| -rw-r--r-- | autoload/htmlcomplete.vim | 118 | ||||
| -rw-r--r-- | autoload/rust.vim | 225 | ||||
| -rw-r--r-- | autoload/xml/html5.vim | 2 | 
3 files changed, 273 insertions, 72 deletions
| diff --git a/autoload/htmlcomplete.vim b/autoload/htmlcomplete.vim index 8b4492e4..68a80384 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 =~ '<!DOCTYPE.*\<DTD ' +            break +        endif +        let i += 1 +    endwhile +    if line =~ '<!DOCTYPE.*\<DTD '  " doctype line found above +        if line =~ ' HTML 3\.2' +            let b:html_omni_flavor = 'html32' +        elseif line =~ ' XHTML 1\.1' +            let b:html_omni_flavor = 'xhtml11' +        else    " two-step detection with strict/frameset/transitional +            if line =~ ' XHTML 1\.0' +                let b:html_omni_flavor = 'xhtml10' +            elseif line =~ ' HTML 4\.01' +                let b:html_omni_flavor = 'html401' +            elseif line =~ ' HTML 4.0\>' +                let b:html_omni_flavor = 'html40' +            endif +            if line =~ '\<Transitional\>' +                let b:html_omni_flavor .= 't' +            elseif line =~ '\<Frameset\>' +                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 =~ '<!DOCTYPE.*\<DTD HTML 3\.2' -			let b:html_omni_flavor = 'html32' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Transitional' -			let b:html_omni_flavor = 'html40t' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Frameset' -			let b:html_omni_flavor = 'html40f' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0' -			let b:html_omni_flavor = 'html40s' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Transitional' -			let b:html_omni_flavor = 'html401t' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Frameset' -			let b:html_omni_flavor = 'html401f' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01' -			let b:html_omni_flavor = 'html401s' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Transitional' -			let b:html_omni_flavor = 'xhtml10t' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Frameset' -			let b:html_omni_flavor = 'xhtml10f' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Strict' -			let b:html_omni_flavor = 'xhtml10s' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.1' -			let b:html_omni_flavor = 'xhtml11' -			let b:html_doctype = 1 -			break -		elseif line =~ '<!DOCTYPE html' -			let b:html_omni_flavor = 'html5' -			let b:html_doctype = 1 -			break -		endif -		let i += 1 -	endwhile -	if !exists("b:html_doctype") +	call htmlcomplete#DetectOmniFlavor() +	if !exists('b:html_omni_flavor')  		return  	else  		" Tie g:xmldata with b:html_omni this way we need to sourca data file only diff --git a/autoload/rust.vim b/autoload/rust.vim new file mode 100644 index 00000000..c6b9b314 --- /dev/null +++ b/autoload/rust.vim @@ -0,0 +1,225 @@ +" Author: Kevin Ballard +" Description: Helper functions for Rust commands/mappings +" Last Modified: May 27, 2014 + +" Jump {{{1 + +function! rust#Jump(mode, function) range +	let cnt = v:count1 +	normal! m' +	if a:mode ==# 'v' +		norm! gv +	endif +	let foldenable = &foldenable +	set nofoldenable +	while cnt > 0 +		execute "call <SID>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 01a1c742..4c99901a 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, | 
