diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2016-12-20 20:57:20 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2016-12-20 20:57:20 +0100 |
commit | e404a658b1647fad396a954776eda0bdabf8353c (patch) | |
tree | fcdab0e324fd72015ba656e43bd8f8c243030c14 /autoload | |
parent | 74652b465d7eff97070001317a4ea5557717378d (diff) | |
download | vim-polyglot-e404a658b1647fad396a954776eda0bdabf8353c.tar.gz vim-polyglot-e404a658b1647fad396a954776eda0bdabf8353c.zip |
Update
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/dart.vim | 24 | ||||
-rw-r--r-- | autoload/elixir/indent.vim | 212 | ||||
-rw-r--r-- | autoload/elixir/util.vim | 56 | ||||
-rw-r--r-- | autoload/htmlcomplete.vim | 1404 | ||||
-rw-r--r-- | autoload/rubycomplete.vim | 2 | ||||
-rw-r--r-- | autoload/rustfmt.vim | 43 | ||||
-rw-r--r-- | autoload/xml/html5.vim | 22 |
7 files changed, 1030 insertions, 733 deletions
diff --git a/autoload/dart.vim b/autoload/dart.vim index 65380926..df341b48 100644 --- a/autoload/dart.vim +++ b/autoload/dart.vim @@ -20,18 +20,20 @@ endfunction function! dart#fmt(q_args) abort if executable('dartfmt') - let path = expand('%:p:gs:\:/:') - if filereadable(path) - let joined_lines = system(printf('dartfmt %s %s', a:q_args, shellescape(path))) - if 0 == v:shell_error - silent % delete _ - silent put=joined_lines - silent 1 delete _ - else - call s:cexpr('line %l\, column %c of %f: %m', joined_lines) - endif + let buffer_content = join(getline(1, '$'), "\n") + let joined_lines = system(printf('dartfmt %s', a:q_args), buffer_content) + if 0 == v:shell_error + let win_view = winsaveview() + silent % delete _ + silent put=joined_lines + silent 1 delete _ + call winrestview(win_view) else - call s:error(printf('cannot read a file: "%s"', path)) + let errors = split(joined_lines, "\n")[2:] + let file_path = expand('%') + call map(errors, 'file_path.":".v:val') + let error_format = '%A%f:line %l\, column %c of stdin: %m,%C%.%#' + call s:cexpr(error_format, join(errors, "\n")) endif else call s:error('cannot execute binary file: dartfmt') diff --git a/autoload/elixir/indent.vim b/autoload/elixir/indent.vim new file mode 100644 index 00000000..8e0c609c --- /dev/null +++ b/autoload/elixir/indent.vim @@ -0,0 +1,212 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 + +let s:NO_COLON_BEFORE = ':\@<!' +let s:NO_COLON_AFTER = ':\@!' +let s:ENDING_SYMBOLS = '\]\|}\|)' +let s:STARTING_SYMBOLS = '\[\|{\|(' +let s:ARROW = '->' +let s:END_WITH_ARROW = s:ARROW.'$' +let s:SKIP_SYNTAX = '\%(Comment\|String\)$' +let s:BLOCK_SKIP = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '".s:SKIP_SYNTAX."'" +let s:DEF = '^\s*def' +let s:FN = '\<fn\>' +let s:MULTILINE_FN = s:FN.'\%(.*end\)\@!' +let s:BLOCK_START = '\%(\<do\>\|'.s:FN.'\)\>' +let s:MULTILINE_BLOCK = '\%(\<do\>'.s:NO_COLON_AFTER.'\|'.s:MULTILINE_FN.'\)' +let s:BLOCK_MIDDLE = '\<\%(else\|match\|elsif\|catch\|after\|rescue\)\>' +let s:BLOCK_END = 'end' +let s:STARTS_WITH_PIPELINE = '^\s*|>.*$' +let s:ENDING_WITH_ASSIGNMENT = '=\s*$' +let s:INDENT_KEYWORDS = s:NO_COLON_BEFORE.'\%('.s:MULTILINE_BLOCK.'\|'.s:BLOCK_MIDDLE.'\)' +let s:DEINDENT_KEYWORDS = '^\s*\<\%('.s:BLOCK_END.'\|'.s:BLOCK_MIDDLE.'\)\>' +let s:PAIR_START = '\<\%('.s:NO_COLON_BEFORE.s:BLOCK_START.'\)\>'.s:NO_COLON_AFTER +let s:PAIR_MIDDLE = '^\s*\%('.s:BLOCK_MIDDLE.'\)\>'.s:NO_COLON_AFTER.'\zs' +let s:PAIR_END = '\<\%('.s:NO_COLON_BEFORE.s:BLOCK_END.'\)\>\zs' + +function! s:pending_parenthesis(line) + if a:line.last.text !~ s:ARROW + return elixir#util#count_indentable_symbol_diff(a:line.last, '(', '\%(end\s*\)\@<!)') + end +endfunction + +function! s:pending_square_brackets(line) + if a:line.last.text !~ s:ARROW + return elixir#util#count_indentable_symbol_diff(a:line.last, '[', ']') + end +endfunction + +function! s:pending_brackets(line) + if a:line.last.text !~ s:ARROW + return elixir#util#count_indentable_symbol_diff(a:line.last, '{', '}') + end +endfunction + +function! elixir#indent#deindent_case_arrow(ind, line) + if get(b:old_ind, 'arrow', 0) > 0 + \ && (a:line.current.text =~ s:ARROW + \ || a:line.current.text =~ s:BLOCK_END) + let ind = b:old_ind.arrow + let b:old_ind.arrow = 0 + return ind + else + return a:ind + end +endfunction + +function! elixir#indent#deindent_ending_symbols(ind, line) + if a:line.current.text =~ '^\s*\('.s:ENDING_SYMBOLS.'\)' + return a:ind - &sw + else + return a:ind + end +endfunction + +function! elixir#indent#deindent_keywords(ind, line) + if a:line.current.text =~ s:DEINDENT_KEYWORDS + let bslnum = searchpair( + \ s:PAIR_START, + \ s:PAIR_MIDDLE, + \ s:PAIR_END, + \ 'nbW', + \ s:BLOCK_SKIP + \ ) + + return indent(bslnum) + else + return a:ind + end +endfunction + +function! elixir#indent#deindent_opened_symbols(ind, line) + let s:opened_symbol = + \ s:pending_parenthesis(a:line) + \ + s:pending_square_brackets(a:line) + \ + s:pending_brackets(a:line) + + if s:opened_symbol < 0 + let ind = get(b:old_ind, 'symbol', a:ind + (s:opened_symbol * &sw)) + let ind = float2nr(ceil(floor(ind)/&sw)*&sw) + return ind <= 0 ? 0 : ind + else + return a:ind + end +endfunction + +function! elixir#indent#indent_after_pipeline(ind, line) + if a:line.last.text =~ s:STARTS_WITH_PIPELINE + if empty(substitute(a:line.current.text, ' ', '', 'g')) + \ || a:line.current.text =~ s:STARTS_WITH_PIPELINE + return indent(a:line.last.num) + elseif a:line.last.text !~ s:INDENT_KEYWORDS + let ind = b:old_ind.pipeline + let b:old_ind.pipeline = 0 + return ind + end + end + + return a:ind +endfunction + +function! elixir#indent#indent_assignment(ind, line) + if a:line.last.text =~ s:ENDING_WITH_ASSIGNMENT + let b:old_ind.pipeline = indent(a:line.last.num) " FIXME: side effect + return a:ind + &sw + else + return a:ind + end +endfunction + +function! elixir#indent#indent_brackets(ind, line) + if s:pending_brackets(a:line) > 0 + return a:ind + &sw + else + return a:ind + end +endfunction + +function! elixir#indent#indent_case_arrow(ind, line) + if a:line.last.text =~ s:END_WITH_ARROW && a:line.last.text !~ '\<fn\>' + let b:old_ind.arrow = a:ind + return a:ind + &sw + else + return a:ind + end +endfunction + +function! elixir#indent#indent_ending_symbols(ind, line) + if a:line.last.text =~ '^\s*\('.s:ENDING_SYMBOLS.'\)\s*$' + return a:ind + &sw + else + return a:ind + end +endfunction + +function! elixir#indent#indent_keywords(ind, line) + if a:line.last.text =~ s:INDENT_KEYWORDS + return a:ind + &sw + else + return a:ind + end +endfunction + +function! elixir#indent#indent_parenthesis(ind, line) + if s:pending_parenthesis(a:line) > 0 + \ && a:line.last.text !~ s:DEF + \ && a:line.last.text !~ s:END_WITH_ARROW + let b:old_ind.symbol = a:ind + return matchend(a:line.last.text, '(') + else + return a:ind + end +endfunction + +function! elixir#indent#indent_pipeline_assignment(ind, line) + if a:line.current.text =~ s:STARTS_WITH_PIPELINE + \ && a:line.last.text =~ '^[^=]\+=.\+$' + let b:old_ind.pipeline = indent(a:line.last.num) + " if line starts with pipeline + " and last line is an attribution + " indents pipeline in same level as attribution + return match(a:line.last.text, '=\s*\zs[^ ]') + else + return a:ind + end +endfunction + +function! elixir#indent#indent_pipeline_continuation(ind, line) + if a:line.last.text =~ s:STARTS_WITH_PIPELINE + \ && a:line.current.text =~ s:STARTS_WITH_PIPELINE + return indent(a:line.last.num) + else + return a:ind + end +endfunction + +function! elixir#indent#indent_square_brackets(ind, line) + if s:pending_square_brackets(a:line) > 0 + if a:line.last.text =~ '[\s*$' + return a:ind + &sw + else + " if start symbol is followed by a character, indent based on the + " whitespace after the symbol, otherwise use the default shiftwidth + " Avoid negative indentation index + return matchend(a:line.last.text, '[\s*') + end + else + return a:ind + end +endfunction + +function! elixir#indent#deindent_case_arrow(ind, line) + if get(b:old_ind, 'arrow', 0) > 0 + \ && (a:line.current.text =~ s:ARROW + \ || a:line.current.text =~ s:BLOCK_END) + let ind = b:old_ind.arrow + let b:old_ind.arrow = 0 + return ind + else + return a:ind + end +endfunction + +endif diff --git a/autoload/elixir/util.vim b/autoload/elixir/util.vim new file mode 100644 index 00000000..3139d779 --- /dev/null +++ b/autoload/elixir/util.vim @@ -0,0 +1,56 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 + +let s:SKIP_SYNTAX = '\%(Comment\|String\)$' +let s:BLOCK_SKIP = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '".s:SKIP_SYNTAX."'" + +function! elixir#util#is_indentable_at(line, col) + if a:col == -1 " skip synID lookup for not found match + return 1 + end + " TODO: Remove these 2 lines + " I don't know why, but for the test on spec/indent/lists_spec.rb:24. + " Vim is making some mess on parsing the syntax of 'end', it is being + " recognized as 'elixirString' when should be recognized as 'elixirBlock'. + call synID(a:line, a:col, 1) + " This forces vim to sync the syntax. Using fromstart is very slow on files + " over 1k lines + syntax sync minlines=20 maxlines=150 + + return synIDattr(synID(a:line, a:col, 1), "name") + \ !~ s:SKIP_SYNTAX +endfunction + +function! elixir#util#is_indentable_match(line, pattern) + return elixir#util#is_indentable_at(a:line.num, match(a:line.text, a:pattern)) +endfunction + +function! elixir#util#count_indentable_symbol_diff(line, open, close) + if elixir#util#is_indentable_match(a:line, a:open) + \ && elixir#util#is_indentable_match(a:line, a:close) + return + \ s:match_count(a:line.text, a:open) + \ - s:match_count(a:line.text, a:close) + else + return 0 + end +endfunction + +function! s:match_count(string, pattern) + let size = strlen(a:string) + let index = 0 + let counter = 0 + + while index < size + let index = match(a:string, a:pattern, index) + if index >= 0 + let index += 1 + let counter +=1 + else + break + end + endwhile + + return counter +endfunction + +endif diff --git a/autoload/htmlcomplete.vim b/autoload/htmlcomplete.vim index f58793a2..fc9a4b5a 100644 --- a/autoload/htmlcomplete.vim +++ b/autoload/htmlcomplete.vim @@ -1,12 +1,12 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 " Vim completion script -" Language: HTML and XHTML -" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) -" Last Change: 2006 Oct 19 +" Language: HTML and XHTML +" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) +" Last Change: 2006 Oct 19 " Modified: othree <othree@gmail.com> " Changes: Add HTML5, WAI-ARIA support -" Last Change: 2010 Sep 25 +" Last Change: 2016 Oct 11 if !exists('g:aria_attributes_complete') let g:aria_attributes_complete = 1 @@ -16,42 +16,42 @@ endif " 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' + 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 - 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 + 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) @@ -59,491 +59,493 @@ function! htmlcomplete#CompleteTags(findstart, base) " locate the start of the word let line = getline('.') let start = col('.') - 1 - let curline = line('.') - let compl_begin = col('.') - 2 + let curline = line('.') + let compl_begin = col('.') - 2 while start >= 0 && line[start - 1] =~ '\(\k\|[!:.-]\)' - let start -= 1 + let start -= 1 endwhile - " Handling of entities {{{ - if start >= 0 && line[start - 1] =~ '&' - let b:entitiescompl = 1 - let b:compl_context = '' - return start - endif - " }}} - " Handling of <style> tag {{{ - let stylestart = searchpair('<style\>', '', '<\/style\>', "bnW") - let styleend = searchpair('<style\>', '', '<\/style\>', "nW") - if stylestart != 0 && styleend != 0 - if stylestart <= curline && styleend >= curline - let start = col('.') - 1 - let b:csscompl = 1 - while start >= 0 && line[start - 1] =~ '\(\k\|-\)' - let start -= 1 - endwhile - endif - endif - " }}} - " Handling of <script> tag {{{ - let scriptstart = searchpair('<script\>', '', '<\/script\>', "bnW") - let scriptend = searchpair('<script\>', '', '<\/script\>', "nW") - if scriptstart != 0 && scriptend != 0 - if scriptstart <= curline && scriptend >= curline - let start = col('.') - 1 - let b:jscompl = 1 - let b:jsrange = [scriptstart, scriptend] - while start >= 0 && line[start - 1] =~ '\k' - let start -= 1 - endwhile - " We are inside of <script> tag. But we should also get contents - " of all linked external files and (secondary, less probably) other <script> tags - " This logic could possible be done in separate function - may be - " reused in events scripting (also with option could be reused for - " CSS - let b:js_extfiles = [] - let l = line('.') - let c = col('.') - call cursor(1,1) - while search('<\@<=script\>', 'W') && line('.') <= l - if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment' - let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1') - if filereadable(sname) - let b:js_extfiles += readfile(sname) - endif - endif - endwhile - call cursor(1,1) - let js_scripttags = [] - while search('<script\>', 'W') && line('.') < l - if matchstr(getline('.'), '<script[^>]*src') == '' - let js_scripttag = getline(line('.'), search('</script>', 'W')) - let js_scripttags += js_scripttag - endif - endwhile - let b:js_extfiles += js_scripttags - call cursor(l,c) - unlet! l c - endif - endif - " }}} - if !exists("b:csscompl") && !exists("b:jscompl") - let b:compl_context = getline('.')[0:(compl_begin)] - if b:compl_context !~ '<[^>]*$' - " Look like we may have broken tag. Check previous lines. - let i = 1 - while 1 - let context_line = getline(curline-i) - if context_line =~ '<[^>]*$' - " Yep, this is this line - let context_lines = getline(curline-i, curline-1) + [b:compl_context] - let b:compl_context = join(context_lines, ' ') - break - elseif context_line =~ '>[^<]*$' || i == curline - " We are in normal tag line, no need for completion at all - " OR reached first line without tag at all - let b:compl_context = '' - break - endif - let i += 1 - endwhile - " Make sure we don't have counter - unlet! i - endif - let b:compl_context = matchstr(b:compl_context, '.*\zs<.*') - - " Return proper start for on-events. Without that beginning of - " completion will be badly reported - if b:compl_context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$' - let start = col('.') - 1 - while start >= 0 && line[start - 1] =~ '\k' - let start -= 1 - endwhile - endif - " If b:compl_context begins with <? we are inside of PHP code. It - " wasn't closed so PHP completion passed it to HTML - if &filetype =~? 'php' && b:compl_context =~ '^<?' - let b:phpcompl = 1 - let start = col('.') - 1 - while start >= 0 && line[start - 1] =~ '[a-zA-Z_0-9\x7f-\xff$]' - let start -= 1 - endwhile - endif - else - let b:compl_context = getline('.')[0:compl_begin] - endif + " Handling of entities {{{ + if start >= 0 && line[start - 1] =~ '&' + let b:entitiescompl = 1 + let b:compl_context = '' + return start + endif + " }}} + " Handling of <style> tag {{{ + let stylestart = searchpair('<style\>', '', '<\/style\>', "bnW") + let styleend = searchpair('<style\>', '', '<\/style\>', "nW") + if stylestart != 0 && styleend != 0 + if stylestart <= curline && styleend >= curline + let start = col('.') - 1 + let b:csscompl = 1 + while start >= 0 && line[start - 1] =~ '\(\k\|-\)' + let start -= 1 + endwhile + endif + endif + " }}} + " Handling of <script> tag {{{ + let scriptstart = searchpair('<script\>', '', '<\/script\>', "bnW") + let scriptend = searchpair('<script\>', '', '<\/script\>', "nW") + if scriptstart != 0 && scriptend != 0 + if scriptstart <= curline && scriptend >= curline + let start = col('.') - 1 + let b:jscompl = 1 + let b:jsrange = [scriptstart, scriptend] + while start >= 0 && line[start - 1] =~ '\k' + let start -= 1 + endwhile + " We are inside of <script> tag. But we should also get contents + " of all linked external files and (secondary, less probably) other <script> tags + " This logic could possible be done in separate function - may be + " reused in events scripting (also with option could be reused for + " CSS + let b:js_extfiles = [] + let l = line('.') + let c = col('.') + call cursor(1,1) + while search('<\@<=script\>', 'W') && line('.') <= l + if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment' + let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1') + if filereadable(sname) + let b:js_extfiles += readfile(sname) + endif + endif + endwhile + call cursor(1,1) + let js_scripttags = [] + while search('<script\>', 'W') && line('.') < l + if matchstr(getline('.'), '<script[^>]*src') == '' + let js_scripttag = getline(line('.'), search('</script>', 'W')) + let js_scripttags += js_scripttag + endif + endwhile + let b:js_extfiles += js_scripttags + call cursor(l,c) + unlet! l c + endif + endif + " }}} + if !exists("b:csscompl") && !exists("b:jscompl") + let b:compl_context = getline('.')[0:(compl_begin)] + if b:compl_context !~ '<[^>]*$' + " Look like we may have broken tag. Check previous lines. + let i = 1 + while 1 + let context_line = getline(curline-i) + if context_line =~ '<[^>]*$' + " Yep, this is this line + let context_lines = getline(curline-i, curline-1) + [b:compl_context] + let b:compl_context = join(context_lines, ' ') + break + elseif context_line =~ '>[^<]*$' || i == curline + " We are in normal tag line, no need for completion at all + " OR reached first line without tag at all + let b:compl_context = '' + break + endif + let i += 1 + endwhile + " Make sure we don't have counter + unlet! i + endif + let b:compl_context = matchstr(b:compl_context, '.*\zs<.*') + + " Return proper start for on-events. Without that beginning of + " completion will be badly reported + if b:compl_context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$' + let start = col('.') - 1 + while start >= 0 && line[start - 1] =~ '\k' + let start -= 1 + endwhile + endif + " If b:compl_context begins with <? we are inside of PHP code. It + " wasn't closed so PHP completion passed it to HTML + if &filetype =~? 'php' && b:compl_context =~ '^<?' + let b:phpcompl = 1 + let start = col('.') - 1 + while start >= 0 && line[start - 1] =~ '[a-zA-Z_0-9\x7f-\xff$]' + let start -= 1 + endwhile + endif + else + let b:compl_context = getline('.')[0:compl_begin] + endif return start else - " Initialize base return lists + " Initialize base return lists let res = [] let res2 = [] - " a:base is very short - we need context - let context = b:compl_context - " Check if we should do CSS completion inside of <style> tag - " or JS completion inside of <script> tag or PHP completion in case of <? - " tag AND &ft==php - if exists("b:csscompl") - unlet! b:csscompl - let context = b:compl_context - unlet! b:compl_context - return csscomplete#CompleteCSS(0, context) - elseif exists("b:jscompl") - unlet! b:jscompl - return javascriptcomplete#CompleteJS(0, a:base) - elseif exists("b:phpcompl") - unlet! b:phpcompl - let context = b:compl_context - return phpcomplete#CompletePHP(0, a:base) - else - if len(b:compl_context) == 0 && !exists("b:entitiescompl") - return [] - endif - let context = matchstr(b:compl_context, '.\zs.*') - endif - unlet! b:compl_context - " Entities completion {{{ - if exists("b:entitiescompl") - unlet! b:entitiescompl - - if !exists("b:html_omni") - call htmlcomplete#CheckDoctype() - call htmlcomplete#LoadData() - endif + " a:base is very short - we need context + let context = b:compl_context + " Check if we should do CSS completion inside of <style> tag + " or JS completion inside of <script> tag or PHP completion in case of <? + " tag AND &ft==php + if exists("b:csscompl") + unlet! b:csscompl + let context = b:compl_context + unlet! b:compl_context + return csscomplete#CompleteCSS(0, context) + elseif exists("b:jscompl") + unlet! b:jscompl + return javascriptcomplete#CompleteJS(0, a:base) + elseif exists("b:phpcompl") + unlet! b:phpcompl + let context = b:compl_context + return phpcomplete#CompletePHP(0, a:base) + else + if len(b:compl_context) == 0 && !exists("b:entitiescompl") + return [] + endif + let context = matchstr(b:compl_context, '.\zs.*') + endif + unlet! b:compl_context + " Entities completion {{{ + if exists("b:entitiescompl") + unlet! b:entitiescompl + + if !exists("b:html_omni") + call htmlcomplete#CheckDoctype() + call htmlcomplete#LoadData() + endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") call htmlcomplete#LoadAria() endif let entities = b:html_omni['vimxmlentities'] - if len(a:base) == 1 - for m in entities - if m =~ '^'.a:base - call add(res, m.';') - endif - endfor - return res - else - for m in entities - if m =~? '^'.a:base - call add(res, m.';') - elseif m =~? a:base - call add(res2, m.';') - endif - endfor - - return res + res2 - endif - - - endif - " }}} - if context =~ '>' - " Generally if context contains > it means we are outside of tag and - " should abandon action - with one exception: <style> span { bo - if context =~ 'style[^>]\{-}>[^<]\{-}$' - return csscomplete#CompleteCSS(0, context) - elseif context =~ 'script[^>]\{-}>[^<]\{-}$' - let b:jsrange = [line('.'), search('<\/script\>', 'nW')] - return javascriptcomplete#CompleteJS(0, context) - else - return [] - endif - endif - - " If context contains > it means we are already outside of tag and we - " should abandon action - " If context contains white space it is attribute. - " It can be also value of attribute. - " We have to get first word to offer proper completions - if context == '' - let tag = '' - else - let tag = split(context)[0] - " Detect if tag is uppercase to return in proper case, - " we need to make it lowercase for processing - if tag =~ '^\u*$' - let uppercase_tag = 1 - let tag = tolower(tag) - else - let uppercase_tag = 0 - endif - endif - " Get last word, it should be attr name - let attr = matchstr(context, '\S\+="[^"]*$') + if len(a:base) == 1 + for m in entities + if m =~ '^'.a:base + call add(res, m.';') + endif + endfor + return res + else + for m in entities + if m =~? '^'.a:base + call add(res, m.';') + elseif m =~? a:base + call add(res2, m.';') + endif + endfor + + return res + res2 + endif + + + endif + " }}} + if context =~ '>' + " Generally if context contains > it means we are outside of tag and + " should abandon action - with one exception: <style> span { bo + if context =~ 'style[^>]\{-}>[^<]\{-}$' + return csscomplete#CompleteCSS(0, context) + elseif context =~ 'script[^>]\{-}>[^<]\{-}$' + let b:jsrange = [line('.'), search('<\/script\>', 'nW')] + return javascriptcomplete#CompleteJS(0, context) + else + return [] + endif + endif + + " If context contains > it means we are already outside of tag and we + " should abandon action + " If context contains white space it is attribute. + " It can be also value of attribute. + " We have to get first word to offer proper completions + if context == '' + let tag = '' + else + let tag = split(context)[0] + " Detect if tag is uppercase to return in proper case, + " we need to make it lowercase for processing + if tag =~ '^\u*$' + let uppercase_tag = 1 + let tag = tolower(tag) + else + let uppercase_tag = 0 + endif + endif + " Get last word, it should be attr name + let attr = matchstr(context, '\S\+="[^"]*$') if attr == '' let attr = matchstr(context, '.*\s\zs.*') endif - " Possible situations where any prediction would be difficult: - " 1. Events attributes - if context =~ '\s' - " Sort out style, class, and on* cases - if context =~? "\\s\\(on[a-z]+\\|id\\|style\\|class\\)\\s*=\\s*[\"']" - " Id, class completion {{{ - if context =~? "\\(id\\|class\\)\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" - if context =~? "class\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" - let search_for = "class" - elseif context =~? "id\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" - let search_for = "id" - endif - " Handle class name completion - " 1. Find lines of <link stylesheet> - " 1a. Check file for @import - " 2. Extract filename(s?) of stylesheet, - call cursor(1,1) - let head = getline(search('<head\>'), search('<\/head>')) - let headjoined = join(copy(head), ' ') - if headjoined =~ '<style' - " Remove possibly confusing CSS operators - let stylehead = substitute(headjoined, '+>\*[,', ' ', 'g') - if search_for == 'class' - let styleheadlines = split(stylehead) - let headclasslines = filter(copy(styleheadlines), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'") - else - let stylesheet = split(headjoined, '[{}]') - " Get all lines which fit id syntax - let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'") - " Filter out possible color definitions - call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'") - " Filter out complex border definitions - call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'") - let templines = join(classlines, ' ') - let headclasslines = split(templines) - call filter(headclasslines, "v:val =~ '#[a-zA-Z0-9_-]\\+'") - endif - let internal = 1 - else - let internal = 0 - endif - let styletable = [] - let secimportfiles = [] - let filestable = filter(copy(head), "v:val =~ '\\(@import\\|link.*stylesheet\\)'") - for line in filestable - if line =~ "@import" - let styletable += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")] - elseif line =~ "<link" - let styletable += [matchstr(line, "href\\s*=\\s*[\"']\\zs\\f\\+\\ze")] - endif - endfor - for file in styletable - if filereadable(file) - let stylesheet = readfile(file) - let secimport = filter(copy(stylesheet), "v:val =~ '@import'") - if len(secimport) > 0 - for line in secimport - let secfile = matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze") - let secfile = fnamemodify(file, ":p:h").'/'.secfile - let secimportfiles += [secfile] - endfor - endif - endif - endfor - let cssfiles = styletable + secimportfiles - let classes = [] - for file in cssfiles - if filereadable(file) - let stylesheet = readfile(file) - let stylefile = join(stylesheet, ' ') - let stylefile = substitute(stylefile, '+>\*[,', ' ', 'g') - if search_for == 'class' - let stylesheet = split(stylefile) - let classlines = filter(copy(stylesheet), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'") - else - let stylesheet = split(stylefile, '[{}]') - " Get all lines which fit id syntax - let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'") - " Filter out possible color definitions - call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'") - " Filter out complex border definitions - call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'") - let templines = join(classlines, ' ') - let stylelines = split(templines) - let classlines = filter(stylelines, "v:val =~ '#[a-zA-Z0-9_-]\\+'") - - endif + " Possible situations where any prediction would be difficult: + " 1. Events attributes + if context =~ '\s' + " Sort out style, class, and on* cases + if context =~? "\\(id\\|class\\)\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" + \ || context =~? "style\\s*=\\s*[\"'][^\"']*$" + \ || context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$' + " Id, class completion {{{ + if context =~? "\\(id\\|class\\)\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" + if context =~? "class\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" + let search_for = "class" + elseif context =~? "id\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" + let search_for = "id" + endif + " Handle class name completion + " 1. Find lines of <link stylesheet> + " 1a. Check file for @import + " 2. Extract filename(s?) of stylesheet, + call cursor(1,1) + let head = getline(search('<head\>'), search('<\/head>')) + let headjoined = join(copy(head), ' ') + if headjoined =~ '<style' + " Remove possibly confusing CSS operators + let stylehead = substitute(headjoined, '+>\*[,', ' ', 'g') + if search_for == 'class' + let styleheadlines = split(stylehead) + let headclasslines = filter(copy(styleheadlines), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'") + else + let stylesheet = split(headjoined, '[{}]') + " Get all lines which fit id syntax + let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'") + " Filter out possible color definitions + call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'") + " Filter out complex border definitions + call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'") + let templines = join(classlines, ' ') + let headclasslines = split(templines) + call filter(headclasslines, "v:val =~ '#[a-zA-Z0-9_-]\\+'") + endif + let internal = 1 + else + let internal = 0 + endif + let styletable = [] + let secimportfiles = [] + let filestable = filter(copy(head), "v:val =~ '\\(@import\\|link.*stylesheet\\)'") + for line in filestable + if line =~ "@import" + let styletable += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")] + elseif line =~ "<link" + let styletable += [matchstr(line, "href\\s*=\\s*[\"']\\zs\\f\\+\\ze")] + endif + endfor + for file in styletable + if filereadable(file) + let stylesheet = readfile(file) + let secimport = filter(copy(stylesheet), "v:val =~ '@import'") + if len(secimport) > 0 + for line in secimport + let secfile = matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze") + let secfile = fnamemodify(file, ":p:h").'/'.secfile + let secimportfiles += [secfile] + endfor + endif + endif + endfor + let cssfiles = styletable + secimportfiles + let classes = [] + for file in cssfiles + if filereadable(file) + let stylesheet = readfile(file) + let stylefile = join(stylesheet, ' ') + let stylefile = substitute(stylefile, '+>\*[,', ' ', 'g') + if search_for == 'class' + let stylesheet = split(stylefile) + let classlines = filter(copy(stylesheet), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'") + else + let stylesheet = split(stylefile, '[{}]') + " Get all lines which fit id syntax + let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'") + " Filter out possible color definitions + call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'") + " Filter out complex border definitions + call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'") + let templines = join(classlines, ' ') + let stylelines = split(templines) + let classlines = filter(stylelines, "v:val =~ '#[a-zA-Z0-9_-]\\+'") + + endif " We gathered classes definitions from all external files let classes += classlines - endif - endfor - if internal == 1 - let classes += headclasslines - endif - - if search_for == 'class' - let elements = {} - for element in classes - if element =~ '^\.' - let class = matchstr(element, '^\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze') - let class = substitute(class, ':.*', '', '') - if has_key(elements, 'common') - let elements['common'] .= ' '.class - else - let elements['common'] = class - endif - else - let class = matchstr(element, '[a-zA-Z1-6]*\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze') - let tagname = tolower(matchstr(element, '[a-zA-Z1-6]*\ze.')) - if tagname != '' - if has_key(elements, tagname) - let elements[tagname] .= ' '.class - else - let elements[tagname] = class - endif - endif - endif - endfor - - if has_key(elements, tag) && has_key(elements, 'common') - let values = split(elements[tag]." ".elements['common']) - elseif has_key(elements, tag) && !has_key(elements, 'common') - let values = split(elements[tag]) - elseif !has_key(elements, tag) && has_key(elements, 'common') - let values = split(elements['common']) - else - return [] - endif - - elseif search_for == 'id' - " Find used IDs - " 1. Catch whole file - let filelines = getline(1, line('$')) - " 2. Find lines with possible id - let used_id_lines = filter(filelines, 'v:val =~ "id\\s*=\\s*[\"''][a-zA-Z0-9_-]\\+"') - " 3a. Join all filtered lines - let id_string = join(used_id_lines, ' ') - " 3b. And split them to be sure each id is in separate item - let id_list = split(id_string, 'id\s*=\s*') - " 4. Extract id values - let used_id = map(id_list, 'matchstr(v:val, "[\"'']\\zs[a-zA-Z0-9_-]\\+\\ze")') - let joined_used_id = ','.join(used_id, ',').',' - - let allvalues = map(classes, 'matchstr(v:val, ".*#\\zs[a-zA-Z0-9_-]\\+")') - - let values = [] - - for element in classes - if joined_used_id !~ ','.element.',' - let values += [element] - endif - - endfor - - endif - - " We need special version of sbase - let classbase = matchstr(context, ".*[\"']") - let classquote = matchstr(classbase, '.$') - - let entered_class = matchstr(attr, ".*=\\s*[\"']\\zs.*") - - for m in sort(values) - if m =~? '^'.entered_class - call add(res, m . classquote) - elseif m =~? entered_class - call add(res2, m . classquote) - endif - endfor - - return res + res2 - - elseif context =~? "style\\s*=\\s*[\"'][^\"']*$" - return csscomplete#CompleteCSS(0, context) - - endif - " }}} - " Complete on-events {{{ - if context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$' - " We have to: - " 1. Find external files - let b:js_extfiles = [] - let l = line('.') - let c = col('.') - call cursor(1,1) - while search('<\@<=script\>', 'W') && line('.') <= l - if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment' - let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1') - if filereadable(sname) - let b:js_extfiles += readfile(sname) - endif - endif - endwhile - " 2. Find at least one <script> tag - call cursor(1,1) - let js_scripttags = [] - while search('<script\>', 'W') && line('.') < l - if matchstr(getline('.'), '<script[^>]*src') == '' - let js_scripttag = getline(line('.'), search('</script>', 'W')) - let js_scripttags += js_scripttag - endif - endwhile - let b:js_extfiles += js_scripttags - - " 3. Proper call for javascriptcomplete#CompleteJS - call cursor(l,c) - let js_context = matchstr(a:base, '\k\+$') - let js_shortcontext = substitute(a:base, js_context.'$', '', '') - let b:compl_context = context - let b:jsrange = [l, l] - unlet! l c - return javascriptcomplete#CompleteJS(0, js_context) - - endif - - " }}} - let stripbase = matchstr(context, ".*\\(on[a-zA-Z]*\\|style\\|class\\)\\s*=\\s*[\"']\\zs.*") - " Now we have context stripped from all chars up to style/class. - " It may fail with some strange style value combinations. - if stripbase !~ "[\"']" - return [] - endif - endif - " Value of attribute completion {{{ - " If attr contains =\s*[\"'] we catched value of attribute - if attr =~ "=\s*[\"']" || attr =~ "=\s*$" - " Let do attribute specific completion - let attrname = matchstr(attr, '.*\ze\s*=') - let entered_value = matchstr(attr, ".*=\\s*[\"']\\?\\zs.*") - let values = [] - " Load data {{{ - if !exists("b:html_omni") - call htmlcomplete#CheckDoctype() - call htmlcomplete#LoadData() - endif + endif + endfor + if internal == 1 + let classes += headclasslines + endif + + if search_for == 'class' + let elements = {} + for element in classes + if element =~ '^\.' + let class = matchstr(element, '^\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze') + let class = substitute(class, ':.*', '', '') + if has_key(elements, 'common') + let elements['common'] .= ' '.class + else + let elements['common'] = class + endif + else + let class = matchstr(element, '[a-zA-Z1-6]*\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze') + let tagname = tolower(matchstr(element, '[a-zA-Z1-6]*\ze.')) + if tagname != '' + if has_key(elements, tagname) + let elements[tagname] .= ' '.class + else + let elements[tagname] = class + endif + endif + endif + endfor + + if has_key(elements, tag) && has_key(elements, 'common') + let values = split(elements[tag]." ".elements['common']) + elseif has_key(elements, tag) && !has_key(elements, 'common') + let values = split(elements[tag]) + elseif !has_key(elements, tag) && has_key(elements, 'common') + let values = split(elements['common']) + else + return [] + endif + + elseif search_for == 'id' + " Find used IDs + " 1. Catch whole file + let filelines = getline(1, line('$')) + " 2. Find lines with possible id + let used_id_lines = filter(filelines, 'v:val =~ "id\\s*=\\s*[\"''][a-zA-Z0-9_-]\\+"') + " 3a. Join all filtered lines + let id_string = join(used_id_lines, ' ') + " 3b. And split them to be sure each id is in separate item + let id_list = split(id_string, 'id\s*=\s*') + " 4. Extract id values + let used_id = map(id_list, 'matchstr(v:val, "[\"'']\\zs[a-zA-Z0-9_-]\\+\\ze")') + let joined_used_id = ','.join(used_id, ',').',' + + let allvalues = map(classes, 'matchstr(v:val, ".*#\\zs[a-zA-Z0-9_-]\\+")') + + let values = [] + + for element in classes + if joined_used_id !~ ','.element.',' + let values += [element] + endif + + endfor + + endif + + " We need special version of sbase + let classbase = matchstr(context, ".*[\"']") + let classquote = matchstr(classbase, '.$') + + let entered_class = matchstr(attr, ".*=\\s*[\"']\\zs.*") + + for m in sort(values) + if m =~? '^'.entered_class + call add(res, m . classquote) + elseif m =~? entered_class + call add(res2, m . classquote) + endif + endfor + + return res + res2 + + elseif context =~? "style\\s*=\\s*[\"'][^\"']*$" + return csscomplete#CompleteCSS(0, context) + + endif + " }}} + " Complete on-events {{{ + if context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$' + " We have to: + " 1. Find external files + let b:js_extfiles = [] + let l = line('.') + let c = col('.') + call cursor(1,1) + while search('<\@<=script\>', 'W') && line('.') <= l + if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment' + let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1') + if filereadable(sname) + let b:js_extfiles += readfile(sname) + endif + endif + endwhile + " 2. Find at least one <script> tag + call cursor(1,1) + let js_scripttags = [] + while search('<script\>', 'W') && line('.') < l + if matchstr(getline('.'), '<script[^>]*src') == '' + let js_scripttag = getline(line('.'), search('</script>', 'W')) + let js_scripttags += js_scripttag + endif + endwhile + let b:js_extfiles += js_scripttags + + " 3. Proper call for javascriptcomplete#CompleteJS + call cursor(l,c) + let js_context = matchstr(a:base, '\k\+$') + let js_shortcontext = substitute(a:base, js_context.'$', '', '') + let b:compl_context = context + let b:jsrange = [l, l] + unlet! l c + return javascriptcomplete#CompleteJS(0, js_context) + + endif + + " }}} + let stripbase = matchstr(context, ".*\\(on[a-zA-Z]*\\|style\\|class\\)\\s*=\\s*[\"']\\zs.*") + " Now we have context stripped from all chars up to style/class. + " It may fail with some strange style value combinations. + if stripbase !~ "[\"']" + return [] + endif + endif + " Value of attribute completion {{{ + " If attr contains =\s*[\"'] we catched value of attribute + if attr =~ "=\s*[\"']" || attr =~ "=\s*$" + " Let do attribute specific completion + let attrname = matchstr(attr, '.*\ze\s*=') + let entered_value = matchstr(attr, ".*=\\s*[\"']\\?\\zs.*") + let values = [] + " Load data {{{ + if !exists("b:html_omni") + call htmlcomplete#CheckDoctype() + call htmlcomplete#LoadData() + endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") call htmlcomplete#LoadAria() endif - " }}} - if attrname == 'href' - " Now we are looking for local anchors defined by name or id - if entered_value =~ '^#' - let file = join(getline(1, line('$')), ' ') - " Split it be sure there will be one id/name element in - " item, it will be also first word [a-zA-Z0-9_-] in element - let oneelement = split(file, "\\(meta \\)\\@<!\\(name\\|id\\)\\s*=\\s*[\"']") - for i in oneelement - let values += ['#'.matchstr(i, "^[a-zA-Z][a-zA-Z0-9%_-]*")] - endfor - endif - else - if has_key(b:html_omni, tag) && has_key(b:html_omni[tag][1], attrname) - let values = b:html_omni[tag][1][attrname] + " }}} + if attrname == 'href' + " Now we are looking for local anchors defined by name or id + if entered_value =~ '^#' + let file = join(getline(1, line('$')), ' ') + " Split it be sure there will be one id/name element in + " item, it will be also first word [a-zA-Z0-9_-] in element + let oneelement = split(file, "\\(meta \\)\\@<!\\(name\\|id\\)\\s*=\\s*[\"']") + for i in oneelement + let values += ['#'.matchstr(i, "^[a-zA-Z][a-zA-Z0-9%_-]*")] + endfor + endif + else + if has_key(b:html_omni, tag) && has_key(b:html_omni[tag][1], attrname) + let values = b:html_omni[tag][1][attrname] elseif attrname =~ '^aria-' && exists("b:aria_omni") && has_key(b:aria_omni['aria_attributes'], attrname) - let values = b:aria_omni['aria_attributes'][attrname] - else - return [] - endif - endif - - if len(values) == 0 - return [] + let values = b:aria_omni['aria_attributes'][attrname] + else + return [] + endif + endif + + if len(values) == 0 + return [] endif - " We need special version of sbase - let attrbase = matchstr(context, ".*[\"']") - let attrquote = matchstr(attrbase, '.$') - if attrquote !~ "['\"]" - let attrquoteopen = '"' + " We need special version of sbase + let attrbase = matchstr(context, ".*[\"']") + let attrquote = matchstr(attrbase, '.$') + if attrquote !~ "['\"]" + let attrquoteopen = '"' let attrquote = '"' - else - let attrquoteopen = '' + else + let attrquoteopen = '' endif " Multi value attributes don't need ending quote let info = '' @@ -563,39 +565,39 @@ function! htmlcomplete#CompleteTags(findstart, base) let entered_value = split(entered_value)[-1] endif endif - for m in values - " This if is needed to not offer all completions as-is - " alphabetically but sort them. Those beginning with entered - " part will be as first choices - if m =~ '^'.entered_value - call add(res, attrquoteopen . m . attrquote) - elseif m =~ entered_value - call add(res2, attrquoteopen . m . attrquote) - endif - endfor - - return res + res2 - - endif - " }}} - " Attribute completion {{{ - " Shorten context to not include last word - let sbase = matchstr(context, '.*\ze\s.*') - - " Load data {{{ - if !exists("b:html_omni") - call htmlcomplete#CheckDoctype() - call htmlcomplete#LoadData() - endif + for m in values + " This if is needed to not offer all completions as-is + " alphabetically but sort them. Those beginning with entered + " part will be as first choices + if m =~ '^'.entered_value + call add(res, attrquoteopen . m . attrquote) + elseif m =~ entered_value + call add(res2, attrquoteopen . m . attrquote) + endif + endfor + + return res + res2 + + endif + " }}} + " Attribute completion {{{ + " Shorten context to not include last word + let sbase = matchstr(context, '.*\ze\s.*') + + " Load data {{{ + if !exists("b:html_omni") + call htmlcomplete#CheckDoctype() + call htmlcomplete#LoadData() + endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") call htmlcomplete#LoadAria() endif - " }}} + " }}} - if has_key(b:html_omni, tag) - let attrs = keys(b:html_omni[tag][1]) - else - return [] + if has_key(b:html_omni, tag) + let attrs = keys(b:html_omni[tag][1]) + else + return [] endif if exists("b:aria_omni") let roles = [] @@ -617,28 +619,28 @@ function! htmlcomplete#CompleteTags(findstart, base) endfor endif - for m in sort(attrs) - if m =~ '^'.attr - call add(res, m) - elseif m =~ attr - call add(res2, m) - endif - endfor - "let menu = res + res2 - let menu = res - if has_key(b:html_omni, 'vimxmlattrinfo') || (exists("b:aria_omni") && has_key(b:aria_omni, 'vimariaattrinfo')) - let final_menu = [] - for i in range(len(menu)) - let item = menu[i] - if has_key(b:html_omni['vimxmlattrinfo'], item) - let m_menu = b:html_omni['vimxmlattrinfo'][item][0] - let m_info = b:html_omni['vimxmlattrinfo'][item][1] + for m in sort(attrs) + if m =~ '^'.attr + call add(res, m) + elseif m =~ attr + call add(res2, m) + endif + endfor + "let menu = res + res2 + let menu = res + if has_key(b:html_omni, 'vimxmlattrinfo') || (exists("b:aria_omni") && has_key(b:aria_omni, 'vimariaattrinfo')) + let final_menu = [] + for i in range(len(menu)) + let item = menu[i] + if has_key(b:html_omni['vimxmlattrinfo'], item) + let m_menu = b:html_omni['vimxmlattrinfo'][item][0] + let m_info = b:html_omni['vimxmlattrinfo'][item][1] elseif exists("b:aria_omni") && has_key(b:aria_omni['vimariaattrinfo'], item) - let m_menu = b:aria_omni['vimariaattrinfo'][item][0] - let m_info = b:aria_omni['vimariaattrinfo'][item][1] + let m_menu = b:aria_omni['vimariaattrinfo'][item][0] + let m_info = b:aria_omni['vimariaattrinfo'][item][1] else - let m_menu = '' - let m_info = '' + let m_menu = '' + let m_info = '' endif if item =~ '^aria-' && exists("b:aria_omni") if len(b:aria_omni['aria_attributes'][item]) > 0 && b:aria_omni['aria_attributes'][item][0] =~ '^\(BOOL\|'.item.'\)$' @@ -655,128 +657,128 @@ function! htmlcomplete#CompleteTags(findstart, base) let item .= '="' endif endif - let final_menu += [{'word':item, 'menu':m_menu, 'info':m_info}] - endfor - else - let final_menu = [] - for i in range(len(menu)) - let item = menu[i] - if len(b:html_omni[tag][1][item]) > 0 && b:html_omni[tag][1][item][0] =~ '^\(BOOL\|'.item.'\)$' - let item = item - else - let item .= '="' - endif - let final_menu += [item] - endfor - return final_menu - - endif - return final_menu - - endif - " }}} - " Close tag {{{ - let b:unaryTagsStack = "area base br col command embed hr img input keygen link meta param source track wbr" - if context =~ '^\/' - if context =~ '^\/.' - return [] - else - let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack") - return [opentag.">"] - endif - endif - " }}} - " Load data {{{ - if !exists("b:html_omni") - call htmlcomplete#CheckDoctype() - call htmlcomplete#LoadData() - endif + let final_menu += [{'word':item, 'menu':m_menu, 'info':m_info}] + endfor + else + let final_menu = [] + for i in range(len(menu)) + let item = menu[i] + if len(b:html_omni[tag][1][item]) > 0 && b:html_omni[tag][1][item][0] =~ '^\(BOOL\|'.item.'\)$' + let item = item + else + let item .= '="' + endif + let final_menu += [item] + endfor + return final_menu + + endif + return final_menu + + endif + " }}} + " Close tag {{{ + let b:unaryTagsStack = "area base br col command embed hr img input keygen link meta param source track wbr" + if context =~ '^\/' + if context =~ '^\/.' + return [] + else + let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack") + return [opentag.">"] + endif + endif + " }}} + " Load data {{{ + if !exists("b:html_omni") + call htmlcomplete#CheckDoctype() + call htmlcomplete#LoadData() + endif if g:aria_attributes_complete == 1 && !exists("b:aria_omni") call htmlcomplete#LoadAria() endif - " }}} - " Tag completion {{{ - " Deal with tag completion. - let opentag = tolower(xmlcomplete#GetLastOpenTag("b:unaryTagsStack")) - " MM: TODO: GLOT works always the same but with some weird situation it - " behaves as intended in HTML but screws in PHP - if opentag == '' || &filetype == 'php' && !has_key(b:html_omni, opentag) - " Hack for sometimes failing GetLastOpenTag. - " As far as I tested fail isn't GLOT fault but problem - " of invalid document - not properly closed tags and other mish-mash. - " Also when document is empty. Return list of *all* tags. - let tags = keys(b:html_omni) - call filter(tags, 'v:val !~ "^vimxml"') - else - if has_key(b:html_omni, opentag) - let tags = b:html_omni[opentag][0] - else - return [] - endif - endif - " }}} - - if exists("uppercase_tag") && uppercase_tag == 1 - let context = tolower(context) - endif - " Handle XML keywords: DOCTYPE - if opentag == '' - let tags = [ - \ '!DOCTYPE html>', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', - \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/1999/xhtml">' - \ ] + sort(tags) - endif - - "for m in sort(tags) - for m in tags - if m =~ '^'.context - call add(res, m) - elseif m =~ context - call add(res2, m) - endif - endfor - let menu = res + res2 - if has_key(b:html_omni, 'vimxmltaginfo') - let final_menu = [] - for i in range(len(menu)) - let item = menu[i] - if has_key(b:html_omni['vimxmltaginfo'], item) - let m_menu = b:html_omni['vimxmltaginfo'][item][0] - let m_info = b:html_omni['vimxmltaginfo'][item][1] - else - let m_menu = '' - let m_info = '' - endif - if &filetype == 'html' && exists("uppercase_tag") && uppercase_tag == 1 && item !~ 'DOCTYPE' - let item = toupper(item) - endif - if item =~ 'DOCTYPE' + " }}} + " Tag completion {{{ + " Deal with tag completion. + let opentag = tolower(xmlcomplete#GetLastOpenTag("b:unaryTagsStack")) + " MM: TODO: GLOT works always the same but with some weird situation it + " behaves as intended in HTML but screws in PHP + if opentag == '' || &filetype == 'php' && !has_key(b:html_omni, opentag) + " Hack for sometimes failing GetLastOpenTag. + " As far as I tested fail isn't GLOT fault but problem + " of invalid document - not properly closed tags and other mish-mash. + " Also when document is empty. Return list of *all* tags. + let tags = keys(b:html_omni) + call filter(tags, 'v:val !~ "^vimxml"') + else + if has_key(b:html_omni, opentag) + let tags = b:html_omni[opentag][0] + else + return [] + endif + endif + " }}} + + if exists("uppercase_tag") && uppercase_tag == 1 + let context = tolower(context) + endif + " Handle XML keywords: DOCTYPE + if opentag == '' + let tags = [ + \ '!DOCTYPE html>', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', + \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/1999/xhtml">' + \ ] + sort(tags) + endif + + "for m in sort(tags) + for m in tags + if m =~ '^'.context + call add(res, m) + elseif m =~ context + call add(res2, m) + endif + endfor + let menu = res + res2 + if has_key(b:html_omni, 'vimxmltaginfo') + let final_menu = [] + for i in range(len(menu)) + let item = menu[i] + if has_key(b:html_omni['vimxmltaginfo'], item) + let m_menu = b:html_omni['vimxmltaginfo'][item][0] + let m_info = b:html_omni['vimxmltaginfo'][item][1] + else + let m_menu = '' + let m_info = '' + endif + if &filetype == 'html' && exists("uppercase_tag") && uppercase_tag == 1 && item !~ 'DOCTYPE' + let item = toupper(item) + endif + if item =~ 'DOCTYPE' if item =~ 'DTD' let abbr = 'DOCTYPE '.matchstr(item, 'DTD \zsX\?HTML .\{-}\ze\/\/') else let abbr = 'DOCTYPE HTML 5' endif - else - let abbr = item - endif - let final_menu += [{'abbr':abbr, 'word':item, 'menu':m_menu, 'info':m_info}] - endfor - else - let final_menu = menu - endif - return final_menu - - " }}} + else + let abbr = item + endif + let final_menu += [{'abbr':abbr, 'word':item, 'menu':m_menu, 'info':m_info}] + endfor + else + let final_menu = menu + endif + return final_menu + + " }}} endif endfunction @@ -794,48 +796,48 @@ function! htmlcomplete#LoadAria() " {{{ endfunction " }}} function! htmlcomplete#LoadData() " {{{ - if !exists("b:html_omni_flavor") - if &filetype == 'html' - let b:html_omni_flavor = 'html5' - else - let b:html_omni_flavor = 'html5' - endif - endif - " With that if we still have bloated memory but create new buffer - " variables only by linking to existing g:variable, not sourcing whole - " file. - if exists('g:xmldata_'.b:html_omni_flavor) - exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor - else - exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim' - exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor - endif + if !exists("b:html_omni_flavor") + if &filetype == 'html' + let b:html_omni_flavor = 'html5' + else + let b:html_omni_flavor = 'html5' + endif + endif + " With that if we still have bloated memory but create new buffer + " variables only by linking to existing g:variable, not sourcing whole + " file. + if exists('g:xmldata_'.b:html_omni_flavor) + exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor + else + exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim' + exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor + endif endfunction " }}} function! htmlcomplete#CheckDoctype() " {{{ - if exists('b:html_omni_flavor') - let old_flavor = b:html_omni_flavor - else - let old_flavor = '' - endif - 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 - " once, not every time per buffer. - if old_flavor == b:html_omni_flavor - return - else - if exists('g:xmldata_'.b:html_omni_flavor) - exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor - else - exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim' - exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor - endif - return - endif - endif + if exists('b:html_omni_flavor') + let old_flavor = b:html_omni_flavor + else + let old_flavor = '' + endif + 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 + " once, not every time per buffer. + if old_flavor == b:html_omni_flavor + return + else + if exists('g:xmldata_'.b:html_omni_flavor) + exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor + else + exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim' + exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor + endif + return + endif + endif endfunction " }}} " vim:set foldmethod=marker: diff --git a/autoload/rubycomplete.vim b/autoload/rubycomplete.vim index 9dd5d8c4..973be8ef 100644 --- a/autoload/rubycomplete.vim +++ b/autoload/rubycomplete.vim @@ -198,7 +198,7 @@ function! rubycomplete#Complete(findstart, base) if c =~ '\w' continue elseif ! c =~ '\.' - idx = -1 + let idx = -1 break else break diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim index 4cb91d60..a43c07cc 100644 --- a/autoload/rustfmt.vim +++ b/autoload/rustfmt.vim @@ -22,17 +22,20 @@ endif let s:got_fmt_error = 0 -function! rustfmt#Format() - let l:curw = winsaveview() - let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt" - call writefile(getline(1, '$'), l:tmpname) +function! s:RustfmtCommandRange(filename, line1, line2) + let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]} + return printf("%s %s --write-mode=overwrite --file-lines '[%s]'", g:rustfmt_command, g:rustfmt_options, json_encode(l:arg)) +endfunction - let command = g:rustfmt_command . " --write-mode=overwrite " +function! s:RustfmtCommand(filename) + return g:rustfmt_command . " --write-mode=overwrite " . g:rustfmt_options . " " . shellescape(a:filename) +endfunction +function! s:RunRustfmt(command, curw, tmpname) if exists("*systemlist") - let out = systemlist(command . g:rustfmt_options . " " . shellescape(l:tmpname)) + let out = systemlist(a:command) else - let out = split(system(command . g:rustfmt_options . " " . shellescape(l:tmpname)), '\r\?\n') + let out = split(system(a:command), '\r\?\n') endif if v:shell_error == 0 || v:shell_error == 3 @@ -40,7 +43,7 @@ function! rustfmt#Format() try | silent undojoin | catch | endtry " Replace current file with temp file, then reload buffer - call rename(l:tmpname, expand('%')) + call rename(a:tmpname, expand('%')) silent edit! let &syntax = &syntax @@ -78,10 +81,30 @@ function! rustfmt#Format() let s:got_fmt_error = 1 lwindow " We didn't use the temp file, so clean up - call delete(l:tmpname) + call delete(a:tmpname) endif - call winrestview(l:curw) + call winrestview(a:curw) +endfunction + +function! rustfmt#FormatRange(line1, line2) + let l:curw = winsaveview() + let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt" + call writefile(getline(1, '$'), l:tmpname) + + let command = s:RustfmtCommandRange(l:tmpname, a:line1, a:line2) + + call s:RunRustfmt(command, l:curw, l:tmpname) +endfunction + +function! rustfmt#Format() + let l:curw = winsaveview() + let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt" + call writefile(getline(1, '$'), l:tmpname) + + let command = s:RustfmtCommand(l:tmpname) + + call s:RunRustfmt(command, l:curw, l:tmpname) endfunction endif diff --git a/autoload/xml/html5.vim b/autoload/xml/html5.vim index b422b2ca..cf60cd63 100644 --- a/autoload/xml/html5.vim +++ b/autoload/xml/html5.vim @@ -62,6 +62,8 @@ let charset = [ \ 'windows-1256', 'windows-1257', 'windows-1258', 'TIS-620', ] " }}} +let autofill_tokens = ['on', 'off', 'name', 'honorific-prefix', 'given-name', 'additional-name', 'family-name', 'honorific-suffix', 'nickname', 'username', 'new-password', 'current-password', 'organization-title', 'organization', 'street-address', 'address-line1', 'address-line2', 'address-line3', 'address-level4', 'address-level3', 'address-level2', 'address-level1', 'country', 'country-name', 'postal-code', 'cc-name', 'cc-given-name', 'cc-additional-name', 'cc-family-name', 'cc-number', 'cc-exp', 'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-type', 'transaction-currency', 'transaction-amount', 'language', 'bday', 'bday-day', 'bday-month', 'bday-year', 'sex', 'url', 'photo'] + " Attributes_and_Settings: {{{ 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']} @@ -80,7 +82,7 @@ let attributes_value = { \ 'action': ['URL', ''], \ 'alt': ['Text', ''], \ 'async': ['Bool', ''], - \ 'autocomplete': ['on/off', ''], + \ 'autocomplete': ['*Token', ''], \ 'autofocus': ['Bool', ''], \ 'autoplay': ['Bool', ''], \ 'border': ['1', ''], @@ -347,7 +349,7 @@ let g:xmldata_html5 = { \ 'vimxmlroot': ['html', 'head', 'body'] + flow_elements, \ 'a': [ \ filter(copy(flow_elements), "!(v:val =~ '". abutton_dec ."')"), - \ extend(copy(global_attributes), {'name': [], 'href': [], 'target': [], 'rel': linktypes, 'hreflang': lang_tag, 'media': [], 'type': []}) + \ extend(copy(global_attributes), {'name': [], 'href': [], 'target': [], 'rel': linktypes, 'hreflang': lang_tag, 'media': [], 'type': [], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url']}) \ ], \ 'abbr': [ \ phrasing_elements, @@ -359,7 +361,7 @@ let g:xmldata_html5 = { \ ], \ 'area': [ \ [], - \ extend(copy(global_attributes), {'alt': [], 'href': [], 'target': [], 'rel': linktypes, 'media': [], 'hreflang': lang_tag, 'type': [], 'shape': ['rect', 'circle', 'poly', 'default'], 'coords': []}) + \ extend(copy(global_attributes), {'alt': [], 'href': [], 'target': [], 'rel': linktypes, 'media': [], 'hreflang': lang_tag, 'type': [], 'shape': ['rect', 'circle', 'poly', 'default'], 'coords': [], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url']}) \ ], \ 'article': [ \ flow_elements + ['style'], @@ -495,7 +497,7 @@ let g:xmldata_html5 = { \ ], \ 'form': [ \ flow_elements, - \ extend(copy(global_attributes), {'name': [], 'action': [], 'enctype': ['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain'], 'method': ['get', 'post', 'put', 'delete'], 'target': [], 'novalidate': ['novalidate', ''], 'accept-charset': charset, 'autocomplete': ['on', 'off']}) + \ extend(copy(global_attributes), {'name': [], 'action': [], 'enctype': ['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain'], 'method': ['get', 'post', 'put', 'delete'], 'target': [], 'novalidate': ['novalidate', ''], 'accept-charset': charset, 'autocomplete': autofill_tokens}) \ ], \ 'h1': [ \ phrasing_elements, @@ -547,15 +549,15 @@ let g:xmldata_html5 = { \ ], \ 'iframe': [ \ [], - \ extend(copy(global_attributes), {'src': [], 'srcdoc': [], 'name': [], 'width': [], 'height': [], 'sandbox': ['allow-same-origin', 'allow-forms', 'allow-scripts'], 'seamless': ['seamless', '']}) + \ extend(copy(global_attributes), {'src': [], 'srcdoc': [], 'name': [], 'width': [], 'height': [], 'sandbox': ['allow-same-origin', 'allow-forms', 'allow-scripts'], 'seamless': ['seamless', ''], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url']}) \ ], \ 'img': [ \ [], - \ extend(copy(global_attributes), {'src': [], 'alt': [], 'height': [], 'width': [], 'usemap': [], 'ismap': ['ismap', '']}) + \ extend(copy(global_attributes), {'src': [], 'alt': [], 'height': [], 'width': [], 'usemap': [], 'ismap': ['ismap', ''], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url']}) \ ], \ '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', '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', '']}) + \ 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': autofill_tokens, '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, @@ -583,7 +585,7 @@ let g:xmldata_html5 = { \ ], \ 'link': [ \ [], - \ extend(copy(global_attributes), {'href': [], 'rel': linkreltypes, 'hreflang': lang_tag, 'media': [], 'type': [], 'sizes': ['any']}) + \ extend(copy(global_attributes), {'href': [], 'rel': linkreltypes, 'hreflang': lang_tag, 'media': [], 'type': [], 'sizes': ['any'], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url']}) \ ], \ 'main': [ \ flow_elements + ['style'], @@ -691,7 +693,7 @@ let g:xmldata_html5 = { \ ], \ 'script': [ \ [], - \ extend(copy(global_attributes), {'src': [], 'defer': ['defer', ''], 'async': ['async', ''], 'type': [], 'charset': charset}) + \ extend(copy(global_attributes), {'src': [], 'defer': ['defer', ''], 'async': ['async', ''], 'type': [], 'charset': charset, 'nonce': []}) \ ], \ 'section': [ \ flow_elements + ['style'], @@ -723,7 +725,7 @@ let g:xmldata_html5 = { \ ], \ 'style': [ \ [], - \ extend(copy(global_attributes), {'type': [], 'media': [], 'scoped': ['scoped', '']}) + \ extend(copy(global_attributes), {'type': [], 'media': [], 'scoped': ['scoped', ''], 'nonce': []}) \ ], \ 'sub': [ \ phrasing_elements, |