From 5f1223fbc5285689db812236c9100329740a805b Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 29 Jul 2014 13:03:49 +0200 Subject: Major update --- autoload/htmlcomplete.vim | 118 ++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 71 deletions(-) (limited to 'autoload/htmlcomplete.vim') 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 =~ '' + 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 =~ '