diff options
Diffstat (limited to 'runtime/syntax')
-rw-r--r-- | runtime/syntax/2html.vim | 663 | ||||
-rw-r--r-- | runtime/syntax/i3config.vim | 513 | ||||
-rw-r--r-- | runtime/syntax/masm.vim | 187 | ||||
-rw-r--r-- | runtime/syntax/mojo.vim | 316 | ||||
-rw-r--r-- | runtime/syntax/nasm.vim | 6 | ||||
-rw-r--r-- | runtime/syntax/rust.vim | 166 | ||||
-rw-r--r-- | runtime/syntax/scala.vim | 2 | ||||
-rw-r--r-- | runtime/syntax/swayconfig.vim | 196 |
8 files changed, 1403 insertions, 646 deletions
diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim index 9f43e91309..5fbdad90f3 100644 --- a/runtime/syntax/2html.vim +++ b/runtime/syntax/2html.vim @@ -1,6 +1,6 @@ " Vim syntax support file " Maintainer: Ben Fritz <fritzophrenic@gmail.com> -" Last Change: 2023 Jan 01 +" Last Change: 2023 Sep 05 " " Additional contributors: " @@ -32,9 +32,9 @@ let s:end=line('$') " Font if exists("g:html_font") if type(g:html_font) == type([]) - let s:htmlfont = "'". join(g:html_font,"','") . "', monospace" + let s:htmlfont = "'".. join(g:html_font,"','") .. "', monospace" else - let s:htmlfont = "'". g:html_font . "', monospace" + let s:htmlfont = "'".. g:html_font .. "', monospace" endif else let s:htmlfont = "monospace" @@ -221,8 +221,8 @@ else endif " Find out the background and foreground color for use later -let s:fgc = s:HtmlColor(synIDattr(hlID("Normal"), "fg#", s:whatterm)) -let s:bgc = s:HtmlColor(synIDattr(hlID("Normal"), "bg#", s:whatterm)) +let s:fgc = s:HtmlColor(synIDattr(hlID("Normal")->synIDtrans(), "fg#", s:whatterm)) +let s:bgc = s:HtmlColor(synIDattr(hlID("Normal")->synIDtrans(), "bg#", s:whatterm)) if s:fgc == "" let s:fgc = ( &background == "dark" ? "#ffffff" : "#000000" ) endif @@ -234,41 +234,43 @@ if !s:settings.use_css " Return opening HTML tag for given highlight id function! s:HtmlOpening(id, extra_attrs) let a = "" - if synIDattr(a:id, "inverse") + let translated_ID = synIDtrans(a:id) + if synIDattr(translated_ID, "inverse") " For inverse, we always must set both colors (and exchange them) - let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm)) - let a = a . '<span '.a:extra_attrs.'style="background-color: ' . ( x != "" ? x : s:fgc ) . '">' - let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm)) - let a = a . '<font color="' . ( x != "" ? x : s:bgc ) . '">' + let x = s:HtmlColor(synIDattr(translated_ID, "fg#", s:whatterm)) + let a = a .. '<span '..a:extra_attrs..'style="background-color: ' .. ( x != "" ? x : s:fgc ) .. '">' + let x = s:HtmlColor(synIDattr(translated_ID, "bg#", s:whatterm)) + let a = a .. '<font color="' .. ( x != "" ? x : s:bgc ) .. '">' else - let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm)) + let x = s:HtmlColor(synIDattr(translated_ID, "bg#", s:whatterm)) if x != "" - let a = a . '<span '.a:extra_attrs.'style="background-color: ' . x . '">' + let a = a .. '<span '..a:extra_attrs..'style="background-color: ' .. x .. '">' elseif !empty(a:extra_attrs) - let a = a . '<span '.a:extra_attrs.'>' + let a = a .. '<span '..a:extra_attrs..'>' endif - let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm)) - if x != "" | let a = a . '<font color="' . x . '">' | endif + let x = s:HtmlColor(synIDattr(translated_ID, "fg#", s:whatterm)) + if x != "" | let a = a .. '<font color="' .. x .. '">' | endif endif - if synIDattr(a:id, "bold") | let a = a . "<b>" | endif - if synIDattr(a:id, "italic") | let a = a . "<i>" | endif - if synIDattr(a:id, "underline") | let a = a . "<u>" | endif + if synIDattr(translated_ID, "bold") | let a = a .. "<b>" | endif + if synIDattr(translated_ID, "italic") | let a = a .. "<i>" | endif + if synIDattr(translated_ID, "underline") | let a = a .. "<u>" | endif return a endfun " Return closing HTML tag for given highlight id function! s:HtmlClosing(id, has_extra_attrs) let a = "" - if synIDattr(a:id, "underline") | let a = a . "</u>" | endif - if synIDattr(a:id, "italic") | let a = a . "</i>" | endif - if synIDattr(a:id, "bold") | let a = a . "</b>" | endif - if synIDattr(a:id, "inverse") - let a = a . '</font></span>' + let translated_ID = synIDtrans(a:id) + if synIDattr(translated_ID, "underline") | let a = a .. "</u>" | endif + if synIDattr(translated_ID, "italic") | let a = a .. "</i>" | endif + if synIDattr(translated_ID, "bold") | let a = a .. "</b>" | endif + if synIDattr(translated_ID, "inverse") + let a = a .. '</font></span>' else - let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm)) - if x != "" | let a = a . '</font>' | endif - let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm)) - if x != "" || a:has_extra_attrs | let a = a . '</span>' | endif + let x = s:HtmlColor(synIDattr(translated_ID, "fg#", s:whatterm)) + if x != "" | let a = a .. '</font>' | endif + let x = s:HtmlColor(synIDattr(translated_ID, "bg#", s:whatterm)) + if x != "" || a:has_extra_attrs | let a = a .. '</span>' | endif endif return a endfun @@ -286,84 +288,102 @@ if s:settings.use_css " save CSS to a list of rules to add to the output at the end of processing " first, get the style names we need - let wrapperfunc_lines = [ - \ 'function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, make_unselectable, unformatted)', - \ '', - \ ' let l:style_name = synIDattr(a:style_id, "name", s:whatterm)' - \ ] + let s:wrapperfunc_lines = [] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, make_unselectable, unformatted) + + let l:style_name = synIDattr(a:style_id, "name", s:whatterm) + ENDLET if &diff - let wrapperfunc_lines += [ - \ ' let l:diff_style_name = synIDattr(a:diff_style_id, "name", s:whatterm)'] - - " Add normal groups and diff groups to separate lists so we can order them to - " allow diff highlight to override normal highlight - - " if primary style IS a diff style, grab it from the diff cache instead - " (always succeeds because we pre-populate it) - let wrapperfunc_lines += [ - \ '', - \ ' if a:style_id == s:DIFF_D_ID || a:style_id == s:DIFF_A_ID ||'. - \ ' a:style_id == s:DIFF_C_ID || a:style_id == s:DIFF_T_ID', - \ ' let l:saved_style = get(s:diffstylelist,a:style_id)', - \ ' else' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + let l:diff_style_name = synIDattr(a:diff_style_id, "name", s:whatterm) + ENDLET + + " Add normal groups and diff groups to separate lists so we can order them to + " allow diff highlight to override normal highlight + + " if primary style IS a diff style, grab it from the diff cache instead + " (always succeeds because we pre-populate it) + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + + if a:style_id == s:DIFF_D_ID || a:style_id == s:DIFF_A_ID || a:style_id == s:DIFF_C_ID || a:style_id == s:DIFF_T_ID + let l:saved_style = get(s:diffstylelist,a:style_id) + else + ENDLET endif " get primary style info from cache or build it on the fly if not found - let wrapperfunc_lines += [ - \ ' let l:saved_style = get(s:stylelist,a:style_id)', - \ ' if type(l:saved_style) == type(0)', - \ ' unlet l:saved_style', - \ ' let l:saved_style = s:CSS1(a:style_id)', - \ ' if l:saved_style != ""', - \ ' let l:saved_style = "." . l:style_name . " { " . l:saved_style . "}"', - \ ' endif', - \ ' let s:stylelist[a:style_id]= l:saved_style', - \ ' endif' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + let l:saved_style = get(s:stylelist,a:style_id) + if type(l:saved_style) == type(0) + unlet l:saved_style + let l:saved_style = s:CSS1(a:style_id) + if l:saved_style != "" + let l:saved_style = "." .. l:style_name .. " { " .. l:saved_style .. "}" + endif + let s:stylelist[a:style_id] = l:saved_style + endif + ENDLET if &diff - let wrapperfunc_lines += [ ' endif' ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + endif + ENDLET endif +" Ignore this comment, just bypassing a highlighting issue: if " Build the wrapper tags around the text. It turns out that caching these " gives pretty much zero performance gain and adds a lot of logic. - let wrapperfunc_lines += [ - \ '', - \ ' if l:saved_style == "" && empty(a:extra_attrs)' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + + if l:saved_style == "" && empty(a:extra_attrs) + ENDLET if &diff - let wrapperfunc_lines += [ - \ ' if a:diff_style_id <= 0' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + if a:diff_style_id <= 0 + ENDLET endif " no surroundings if neither primary nor diff style has any info - let wrapperfunc_lines += [ - \ ' return a:text' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + return a:text + ENDLET if &diff " no primary style, but diff style - let wrapperfunc_lines += [ - \ ' else', - \ ' return "<span class=\"" .l:diff_style_name . "\">".a:text."</span>"', - \ ' endif' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + else + return '<span class="' ..l:diff_style_name .. '">'..a:text.."</span>" + endif + ENDLET endif + " Ignore this comment, just bypassing a highlighting issue: if + " open tag for non-empty primary style - let wrapperfunc_lines += [ - \ ' else'] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + else + ENDLET " non-empty primary style. handle either empty or non-empty diff style. " " separate the two classes by a space to apply them both if there is a diff " style name, unless the primary style is empty, then just use the diff style " name - let diffstyle = - \ (&diff ? '(a:diff_style_id <= 0 ? "" : " ". l:diff_style_name) .' - \ : "") + let s:diffstyle = + \ (&diff ? '(a:diff_style_id <= 0 ? "" : " " .. l:diff_style_name)..' + \ : '') if s:settings.prevent_copy == "" - let wrapperfunc_lines += [ - \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\">".a:text."</span>"' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim eval ENDLET + return "<span "..a:extra_attrs..'class="' .. l:style_name ..{s:diffstyle}'">'..a:text.."</span>" + ENDLET else " New method: use generated content in the CSS. The only thing needed here @@ -388,59 +408,76 @@ if s:settings.use_css " Note, if maxlength property needs to be added in the future, it will need " to use strchars(), because HTML specifies that the maxlength parameter " uses the number of unique codepoints for its limit. - let wrapperfunc_lines += [ - \ ' if a:make_unselectable', - \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\"' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim eval ENDLET + if a:make_unselectable + let return_span = "<span "..a:extra_attrs..'class="' .. l:style_name ..{s:diffstyle}'"' + ENDLET if s:settings.use_input_for_pc !=# 'all' - let wrapperfunc_lines[-1] .= ' " . "data-" . l:style_name . "-content=\"".a:text."\"' + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + let return_span ..= " data-" .. l:style_name .. '-content="'..a:text..'"' + ENDLET endif - let wrapperfunc_lines[-1] .= '>' + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + let return_span ..= '>' + ENDLET if s:settings.use_input_for_pc !=# 'none' - let wrapperfunc_lines[-1] .= - \ '<input'.s:unselInputType.' class=\"" . l:style_name .'.diffstyle.'"\"'. - \ ' value=\"".substitute(a:unformatted,''\s\+$'',"","")."\"'. - \ ' onselect=''this.blur(); return false;'''. - \ ' onmousedown=''this.blur(); return false;'''. - \ ' onclick=''this.blur(); return false;'''. - \ ' readonly=''readonly'''. - \ ' size=\"".strwidth(a:unformatted)."\"'. - \ (s:settings.use_xhtml ? '/' : '').'>' + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim eval ENDLET + let return_span ..= '<input'..s:unselInputType..' class="' .. l:style_name ..{s:diffstyle}'"' + let return_span ..= ' value="'..substitute(a:unformatted,'\s\+$',"","")..'"' + let return_span ..= " onselect='this.blur(); return false;'" + let return_span ..= " onmousedown='this.blur(); return false;'" + let return_span ..= " onclick='this.blur(); return false;'" + let return_span ..= " readonly='readonly'" + let return_span ..= ' size="'..strwidth(a:unformatted)..'"' + let return_span ..= (s:settings.use_xhtml ? '/>' : '>') + ENDLET endif - let wrapperfunc_lines[-1] .= '</span>"' - let wrapperfunc_lines += [ - \ ' else', - \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'. diffstyle .'"\">".a:text."</span>"' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim eval ENDLET + return return_span..'</span>' + else + return "<span "..a:extra_attrs..'class="' .. l:style_name .. {s:diffstyle}'">'..a:text.."</span>" + endif + ENDLET endif - let wrapperfunc_lines += [ - \ ' endif', - \ 'endfun' - \ ] + call add(s:wrapperfunc_lines, []) + let s:wrapperfunc_lines[-1] =<< trim ENDLET + endif + endfun + ENDLET else " Non-CSS method just needs the wrapper. " " Functions used to get opening/closing automatically return null strings if " no styles exist. if &diff - let wrapperfunc_lines = [ - \ 'function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, unusedarg, unusedarg2)', - \ ' return s:HtmlOpening(a:style_id, a:extra_attrs).(a:diff_style_id <= 0 ? "" :'. - \ 's:HtmlOpening(a:diff_style_id, "")).a:text.'. - \ '(a:diff_style_id <= 0 ? "" : s:HtmlClosing(a:diff_style_id, 0)).s:HtmlClosing(a:style_id, !empty(a:extra_attrs))', - \ 'endfun' - \ ] + let s:wrapperfunc_lines =<< trim ENDLET + function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, unusedarg, unusedarg2) + if a:diff_style_id <= 0 + let l:diff_opening = s:HtmlOpening(a:diff_style_id, "") + let l:diff_closing = s:HtmlClosing(a:diff_style_id, 0) + else + let l:diff_opening = "" + let l:diff_closing = "" + endif + return s:HtmlOpening(a:style_id, a:extra_attrs)..l:diff_opening..a:text..l:diff_closing..s:HtmlClosing(a:style_id, !empty(a:extra_attrs)) + endfun + ENDLET else - let wrapperfunc_lines = [ - \ 'function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, unusedarg, unusedarg2)', - \ ' return s:HtmlOpening(a:style_id, a:extra_attrs).a:text.s:HtmlClosing(a:style_id, !empty(a:extra_attrs))', - \ 'endfun' - \ ] + let s:wrapperfunc_lines =<< trim ENDLET + function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, unusedarg, unusedarg2) + return s:HtmlOpening(a:style_id, a:extra_attrs)..a:text..s:HtmlClosing(a:style_id, !empty(a:extra_attrs)) + endfun + ENDLET endif endif " create the function we built line by line above -exec join(wrapperfunc_lines, "\n") +exec join(flatten(s:wrapperfunc_lines), "\n") let s:diff_mode = &diff @@ -471,7 +508,7 @@ function! s:HtmlFormat(text, style_id, diff_style_id, extra_attrs, make_unselect " Replace double spaces, leading spaces, and trailing spaces if needed if ' ' != s:HtmlSpace - let formatted = substitute(formatted, ' ', s:HtmlSpace . s:HtmlSpace, 'g') + let formatted = substitute(formatted, ' ', s:HtmlSpace .. s:HtmlSpace, 'g') let formatted = substitute(formatted, '^ ', s:HtmlSpace, 'g') let formatted = substitute(formatted, ' \+$', s:HtmlSpace, 'g') endif @@ -487,7 +524,7 @@ if s:settings.prevent_copy =~# 'n' if s:settings.line_ids function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr) if a:lnr > 0 - return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'.(exists('g:html_diff_win_num') ? 'W'.g:html_diff_win_num : "").'L'.a:lnr.s:settings.id_suffix.'" ', 1) + return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'..(exists('g:html_diff_win_num') ? 'W'..g:html_diff_win_num : "")..'L'..a:lnr..s:settings.id_suffix..'" ', 1) else return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 1) endif @@ -503,14 +540,14 @@ if s:settings.prevent_copy =~# 'n' " always be non-zero, however we don't want to use the <input> because that " won't work as nice for empty text function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr) - return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'.(exists('g:html_diff_win_num') ? 'W'.g:html_diff_win_num : "").'L'.a:lnr.s:settings.id_suffix.'" ', 0) + return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'..(exists('g:html_diff_win_num') ? 'W'..g:html_diff_win_num : "")..'L'..a:lnr..s:settings.id_suffix..'" ', 0) endfun endif else if s:settings.line_ids function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr) if a:lnr > 0 - return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'.(exists('g:html_diff_win_num') ? 'W'.g:html_diff_win_num : "").'L'.a:lnr.s:settings.id_suffix.'" ', 0) + return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'..(exists('g:html_diff_win_num') ? 'W'..g:html_diff_win_num : "")..'L'..a:lnr..s:settings.id_suffix..'" ', 0) else return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 0) endif @@ -535,8 +572,8 @@ if s:settings.prevent_copy =~# 'f' " Simply space-pad to the desired width inside the generated content (note " that the FoldColumn definition includes a whitespace:pre rule) function! s:FoldColumn_build(char, len, numfill, char2, class, click) - return "<a href='#' class='".a:class."' onclick='".a:click."' data-FoldColumn-content='". - \ repeat(a:char, a:len).a:char2.repeat(' ', a:numfill). + return "<a href='#' class='"..a:class.."' onclick='"..a:click.."' data-FoldColumn-content='". + \ repeat(a:char, a:len)..a:char2..repeat(' ', a:numfill). \ "'></a>" endfun function! s:FoldColumn_fill() @@ -554,35 +591,38 @@ if s:settings.prevent_copy =~# 'f' " " Note, 'exec' commands do not recognize line continuations, so must " concatenate lines rather than continue them. - let build_fun_lines = [ - \ 'function! s:FoldColumn_build(char, len, numfill, char2, class, click)', - \ ' let l:input_open = "<input readonly=''readonly''".s:unselInputType.'. - \ ' " onselect=''this.blur(); return false;''".'. - \ ' " onmousedown=''this.blur(); ".a:click." return false;''".'. - \ ' " onclick=''return false;'' size=''".'. - \ ' string(a:len + (empty(a:char2) ? 0 : 1) + a:numfill) .'. - \ ' "'' "', - \ ' let l:common_attrs = "class=''FoldColumn'' value=''"', - \ ' let l:input_close = (s:settings.use_xhtml ? "'' />" : "''>")' - \ ] + let s:build_fun_lines = [] + call add(s:build_fun_lines, []) + let s:build_fun_lines[-1] =<< trim ENDLET + function! s:FoldColumn_build(char, len, numfill, char2, class, click) + let l:input_open = "<input readonly='readonly'"..s:unselInputType + let l:input_open ..= " onselect='this.blur(); return false;'" + let l:input_open ..= " onmousedown='this.blur(); "..a:click.." return false;'" + let l:input_open ..= " onclick='return false;' size='" + let l:input_open ..= string(a:len + (empty(a:char2) ? 0 : 1) + a:numfill) .. "' " + let l:common_attrs = "class='FoldColumn' value='" + let l:input_close = (s:settings.use_xhtml ? "' />" : "'>") + let l:return_span = "<span class='"..a:class.."'>" + let l:return_span ..= l:input_open..l:common_attrs..repeat(a:char, a:len)..(a:char2) + let l:return_span ..= l:input_close + ENDLET if s:settings.use_input_for_pc ==# 'fallback' - let build_fun_lines += [ - \ ' let l:gen_content_link ='. - \ ' "<a href=''#'' class=''FoldColumn'' onclick=''".a:click."'' data-FoldColumn-content=''".'. - \ ' repeat(a:char, a:len).a:char2.repeat('' '', a:numfill).'. - \ ' "''></a>"' - \ ] + call add(s:build_fun_lines, []) + let s:build_fun_lines[-1] =<< trim ENDLET + let l:return_span ..= "<a href='#' class='FoldColumn' onclick='"..a:click.."'" + let l:return_span ..= " data-FoldColumn-content='" + let l:return_span ..= repeat(a:char, a:len)..a:char2..repeat(' ', a:numfill) + let l:return_span ..= "'></a>" + ENDLET endif - let build_fun_lines += [ - \ ' return "<span class=''".a:class."''>".'. - \ ' l:input_open.l:common_attrs.repeat(a:char, a:len).(a:char2).'. - \ ' l:input_close.'. - \ (s:settings.use_input_for_pc ==# 'fallback' ? 'l:gen_content_link.' : ""). - \ ' "</span>"', - \ 'endfun' - \ ] + call add(s:build_fun_lines, []) + let s:build_fun_lines[-1] =<< trim ENDLET + let l:return_span ..= "</span>" + return l:return_span + endfun + ENDLET " create the function we built line by line above - exec join(build_fun_lines, "\n") + exec join(flatten(s:build_fun_lines), "\n") function! s:FoldColumn_fill() return s:FoldColumn_build(' ', s:foldcolumn, 0, '', 'FoldColumn', '') @@ -592,8 +632,8 @@ else " For normal fold columns, simply space-pad to the desired width (note that " the FoldColumn definition includes a whitespace:pre rule) function! s:FoldColumn_build(char, len, numfill, char2, class, click) - return "<a href='#' class='".a:class."' onclick='".a:click."'>". - \ repeat(a:char, a:len).a:char2.repeat(' ', a:numfill). + return "<a href='#' class='"..a:class.."' onclick='"..a:click.."'>". + \ repeat(a:char, a:len)..a:char2..repeat(' ', a:numfill). \ "</a>" endfun function! s:FoldColumn_fill() @@ -625,29 +665,30 @@ endif " Return CSS style describing given highlight id (can be empty) function! s:CSS1(id) let a = "" - if synIDattr(a:id, "inverse") + let translated_ID = synIDtrans(a:id) + if synIDattr(translated_ID, "inverse") " For inverse, we always must set both colors (and exchange them) - let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm)) - let a = a . "color: " . ( x != "" ? x : s:bgc ) . "; " - let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm)) - let a = a . "background-color: " . ( x != "" ? x : s:fgc ) . "; " + let x = s:HtmlColor(synIDattr(translated_ID, "bg#", s:whatterm)) + let a = a .. "color: " .. ( x != "" ? x : s:bgc ) .. "; " + let x = s:HtmlColor(synIDattr(translated_ID, "fg#", s:whatterm)) + let a = a .. "background-color: " .. ( x != "" ? x : s:fgc ) .. "; " else - let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm)) - if x != "" | let a = a . "color: " . x . "; " | endif - let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm)) + let x = s:HtmlColor(synIDattr(translated_ID, "fg#", s:whatterm)) + if x != "" | let a = a .. "color: " .. x .. "; " | endif + let x = s:HtmlColor(synIDattr(translated_ID, "bg#", s:whatterm)) if x != "" - let a = a . "background-color: " . x . "; " + let a = a .. "background-color: " .. x .. "; " " stupid hack because almost every browser seems to have at least one font " which shows 1px gaps between lines which have background - let a = a . "padding-bottom: 1px; " - elseif (a:id == s:FOLDED_ID || a:id == s:LINENR_ID || a:id == s:FOLD_C_ID) && !empty(s:settings.prevent_copy) + let a = a .. "padding-bottom: 1px; " + elseif (translated_ID == s:FOLDED_ID || translated_ID == s:LINENR_ID || translated_ID == s:FOLD_C_ID) && !empty(s:settings.prevent_copy) " input elements default to a different color than the rest of the page - let a = a . "background-color: " . s:bgc . "; " + let a = a .. "background-color: " .. s:bgc .. "; " endif endif - if synIDattr(a:id, "bold") | let a = a . "font-weight: bold; " | endif - if synIDattr(a:id, "italic") | let a = a . "font-style: italic; " | endif - if synIDattr(a:id, "underline") | let a = a . "text-decoration: underline; " | endif + if synIDattr(translated_ID, "bold") | let a = a .. "font-weight: bold; " | endif + if synIDattr(translated_ID, "italic") | let a = a .. "font-style: italic; " | endif + if synIDattr(translated_ID, "underline") | let a = a .. "text-decoration: underline; " | endif return a endfun @@ -720,7 +761,7 @@ if exists("g:loaded_2html_plugin") let s:pluginversion = g:loaded_2html_plugin else if !exists("g:unloaded_tohtml_plugin") - let s:main_plugin_path = expand("<sfile>:p:h:h")."/plugin/tohtml.vim" + let s:main_plugin_path = expand("<sfile>:p:h:h").."/plugin/tohtml.vim" if filereadable(s:main_plugin_path) let s:lines = readfile(s:main_plugin_path, "", 20) call filter(s:lines, 'v:val =~ "loaded_2html_plugin = "') @@ -743,12 +784,12 @@ let s:orgbufnr = winbufnr(0) let s:origwin_stl = &l:stl if expand("%") == "" if exists('g:html_diff_win_num') - exec 'new Untitled_win'.g:html_diff_win_num.'.'.(s:settings.use_xhtml ? 'x' : '').'html' + exec 'new Untitled_win'..g:html_diff_win_num..'.'.(s:settings.use_xhtml ? 'xhtml' : 'html') else - exec 'new Untitled.'.(s:settings.use_xhtml ? 'x' : '').'html' + exec 'new Untitled.'..(s:settings.use_xhtml ? 'xhtml' : 'html') endif else - exec 'new %.'.(s:settings.use_xhtml ? 'x' : '').'html' + exec 'new %.'..(s:settings.use_xhtml ? 'xhtml' : 'html') endif " Resize the new window to very small in order to make it draw faster @@ -795,7 +836,7 @@ let s:lines = [] if s:settings.use_xhtml if s:settings.encoding != "" - call add(s:lines, "<?xml version=\"1.0\" encoding=\"" . s:settings.encoding . "\"?>") + call add(s:lines, "<?xml version=\"1.0\" encoding=\"" .. s:settings.encoding .. "\"?>") else call add(s:lines, "<?xml version=\"1.0\"?>") endif @@ -808,9 +849,9 @@ let s:HtmlSpace = ' ' let s:LeadingSpace = ' ' let s:HtmlEndline = '' if s:settings.no_pre - let s:HtmlEndline = '<br' . s:tag_close + let s:HtmlEndline = '<br' .. s:tag_close let s:LeadingSpace = s:settings.use_xhtml ? ' ' : ' ' - let s:HtmlSpace = '\' . s:LeadingSpace + let s:HtmlSpace = '\' .. s:LeadingSpace endif " HTML header, with the title and generator ;-). Left free space for the CSS, @@ -823,30 +864,30 @@ if !s:settings.no_doc " contained in XML information (to avoid haggling over content type) if s:settings.encoding != "" && !s:settings.use_xhtml if s:html5 - call add(s:lines, '<meta charset="' . s:settings.encoding . '"' . s:tag_close) + call add(s:lines, '<meta charset="' .. s:settings.encoding .. '"' .. s:tag_close) else - call add(s:lines, "<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:settings.encoding . '"' . s:tag_close) + call add(s:lines, "<meta http-equiv=\"content-type\" content=\"text/html; charset=" .. s:settings.encoding .. '"' .. s:tag_close) endif endif call extend(s:lines, [ - \ ("<title>".expand("%:p:~")."</title>"), - \ ("<meta name=\"Generator\" content=\"Vim/".v:version/100.".".v:version%100.'"'.s:tag_close), - \ ("<meta name=\"plugin-version\" content=\"".s:pluginversion.'"'.s:tag_close) + \ ("<title>"..expand("%:p:~").."</title>"), + \ ("<meta name=\"Generator\" content=\"Vim/"..v:version/100.."."..v:version%100..'"'..s:tag_close), + \ ("<meta name=\"plugin-version\" content=\""..s:pluginversion..'"'..s:tag_close) \ ]) - call add(s:lines, '<meta name="syntax" content="'.s:current_syntax.'"'.s:tag_close) - call add(s:lines, '<meta name="settings" content="'. - \ join(filter(keys(s:settings),'s:settings[v:val]'),','). - \ ',prevent_copy='.s:settings.prevent_copy. - \ ',use_input_for_pc='.s:settings.use_input_for_pc. - \ '"'.s:tag_close) - call add(s:lines, '<meta name="colorscheme" content="'. + call add(s:lines, '<meta name="syntax" content="'..s:current_syntax..'"'..s:tag_close) + call add(s:lines, '<meta name="settings" content="'.. + \ join(filter(keys(s:settings),'s:settings[v:val]'),',').. + \ ',prevent_copy='..s:settings.prevent_copy.. + \ ',use_input_for_pc='..s:settings.use_input_for_pc.. + \ '"'..s:tag_close) + call add(s:lines, '<meta name="colorscheme" content="'.. \ (exists('g:colors_name') \ ? g:colors_name - \ : 'none'). '"'.s:tag_close) + \ : 'none').. '"'..s:tag_close) if s:settings.use_css call extend(s:lines, [ - \ "<style" . (s:html5 ? "" : " type=\"text/css\"") . ">", + \ "<style" .. (s:html5 ? "" : " type=\"text/css\"") .. ">", \ s:settings.use_xhtml ? "" : "<!--"]) let s:ieonly = [] if s:settings.dynamic_folds @@ -921,7 +962,7 @@ if !s:settings.no_doc if s:uses_script call extend(s:lines, [ \ "", - \ "<script" . (s:html5 ? "" : " type='text/javascript'") . ">", + \ "<script" .. (s:html5 ? "" : " type='text/javascript'") .. ">", \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"]) endif @@ -968,7 +1009,7 @@ if !s:settings.no_doc \ "", \ " /* navigate upwards in the DOM tree to open all folds containing the line */", \ " var node = lineElem;", - \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')", + \ " while (node && node.id != 'vimCodeElement"..s:settings.id_suffix.."')", \ " {", \ " if (node.className == 'closed-fold')", \ " {", @@ -1003,7 +1044,7 @@ if !s:settings.no_doc endif call extend(s:lines, ["</head>", - \ "<body".(s:settings.line_ids ? " onload='JumpToLine();'" : "").">"]) + \ "<body"..(s:settings.line_ids ? " onload='JumpToLine();'" : "")..">"]) endif if s:settings.no_pre @@ -1015,20 +1056,20 @@ else call extend(s:lines, ["<pre id='vimCodeElement" .. s:settings.id_suffix .. "'>"]) endif -exe s:orgwin . "wincmd w" +exe s:orgwin .. "wincmd w" " caches of style data " initialize to include line numbers if using them if s:settings.number_lines - let s:stylelist = { s:LINENR_ID : ".LineNr { " . s:CSS1( s:LINENR_ID ) . "}" } + let s:stylelist = { s:LINENR_ID : ".LineNr { " .. s:CSS1( s:LINENR_ID ) .. "}" } else let s:stylelist = {} endif let s:diffstylelist = { - \ s:DIFF_A_ID : ".DiffAdd { " . s:CSS1( s:DIFF_A_ID ) . "}", - \ s:DIFF_C_ID : ".DiffChange { " . s:CSS1( s:DIFF_C_ID ) . "}", - \ s:DIFF_D_ID : ".DiffDelete { " . s:CSS1( s:DIFF_D_ID ) . "}", - \ s:DIFF_T_ID : ".DiffText { " . s:CSS1( s:DIFF_T_ID ) . "}" + \ s:DIFF_A_ID : ".DiffAdd { " .. s:CSS1( s:DIFF_A_ID ) .. "}", + \ s:DIFF_C_ID : ".DiffChange { " .. s:CSS1( s:DIFF_C_ID ) .. "}", + \ s:DIFF_D_ID : ".DiffDelete { " .. s:CSS1( s:DIFF_D_ID ) .. "}", + \ s:DIFF_T_ID : ".DiffText { " .. s:CSS1( s:DIFF_T_ID ) .. "}" \ } " set up progress bar in the status line @@ -1046,17 +1087,17 @@ if !s:settings.no_progress \ g:colors_name != s:last_colors_name let s:last_colors_name = exists("g:colors_name") ? g:colors_name : "none" - let l:diffatr = synIDattr(hlID("DiffDelete"), "reverse", s:whatterm) ? "fg#" : "bg#" - let l:stlatr = synIDattr(hlID("StatusLine"), "reverse", s:whatterm) ? "fg#" : "bg#" + let l:diffatr = synIDattr(hlID("DiffDelete")->synIDtrans(), "reverse", s:whatterm) ? "fg#" : "bg#" + let l:stlatr = synIDattr(hlID("StatusLine")->synIDtrans(), "reverse", s:whatterm) ? "fg#" : "bg#" - let l:progbar_color = synIDattr(hlID("DiffDelete"), l:diffatr, s:whatterm) - let l:stl_color = synIDattr(hlID("StatusLine"), l:stlatr, s:whatterm) + let l:progbar_color = synIDattr(hlID("DiffDelete")->synIDtrans(), l:diffatr, s:whatterm) + let l:stl_color = synIDattr(hlID("StatusLine")->synIDtrans(), l:stlatr, s:whatterm) if "" == l:progbar_color - let l:progbar_color = synIDattr(hlID("DiffDelete"), "reverse", s:whatterm) ? s:fgc : s:bgc + let l:progbar_color = synIDattr(hlID("DiffDelete")->synIDtrans(), "reverse", s:whatterm) ? s:fgc : s:bgc endif if "" == l:stl_color - let l:stl_color = synIDattr(hlID("StatusLine"), "reverse", s:whatterm) ? s:fgc : s:bgc + let l:stl_color = synIDattr(hlID("StatusLine")->synIDtrans(), "reverse", s:whatterm) ? s:fgc : s:bgc endif if l:progbar_color == l:stl_color @@ -1086,13 +1127,13 @@ if !s:settings.no_progress endif echomsg "diff detected progbar color set to" l:progbar_color endif - exe "hi TOhtmlProgress_auto" s:whatterm."bg=".l:progbar_color + exe "hi TOhtmlProgress_auto" s:whatterm.."bg="..l:progbar_color endif endfun func! s:ProgressBar(title, max_value, winnr) let pgb=copy(s:progressbar) - let pgb.title = a:title.' ' + let pgb.title = a:title..' ' let pgb.max_value = a:max_value let pgb.winnr = a:winnr let pgb.cur_value = 0 @@ -1194,6 +1235,66 @@ if !s:settings.no_progress call s:SetProgbarColor() endif +let s:build_fun_lines = [] +call add(s:build_fun_lines, []) +let s:build_fun_lines[-1] =<< trim ENDLET + func! s:Add_diff_fill(lnum) + let l:filler = diff_filler(a:lnum) + if l:filler > 0 + let l:to_insert = l:filler + while l:to_insert > 0 + let l:new = repeat(s:difffillchar, 3) + + if l:to_insert > 2 && l:to_insert < l:filler && !s:settings.whole_filler + let l:new = l:new .. " " .. l:filler .. " inserted lines " + let l:to_insert = 2 + endif +ENDLET +call add(s:build_fun_lines, []) +if !s:settings.no_pre + let s:build_fun_lines[-1] =<< trim ENDLET + " HTML line wrapping is off--go ahead and fill to the margin + " TODO: what about when CSS wrapping is turned on? + let l:new = l:new .. repeat(s:difffillchar, &columns - strlen(l:new) - s:margin) + ENDLET +else + let s:build_fun_lines[-1] =<< trim ENDLET + let l:new = l:new .. repeat(s:difffillchar, 3) + ENDLET +endif +call add(s:build_fun_lines, []) +let s:build_fun_lines[-1] =<< trim ENDLET + let l:new = s:HtmlFormat_d(l:new, s:DIFF_D_ID, 0) +ENDLET +if s:settings.number_lines + call add(s:build_fun_lines, []) + let s:build_fun_lines[-1] =<< trim ENDLET + " Indent if line numbering is on. Indent gets style of line number + " column. + let l:new = s:HtmlFormat_n(repeat(' ', s:margin), s:LINENR_ID, 0, 0) .. l:new + ENDLET +endif +if s:settings.dynamic_folds && !s:settings.no_foldcolumn + call add(s:build_fun_lines, []) + let s:build_fun_lines[-1] =<< trim ENDLET + if s:foldcolumn > 0 + " Indent for foldcolumn if there is one. Assume it's empty, there should + " not be a fold for deleted lines in diff mode. + let l:new = s:FoldColumn_fill() .. l:new + endif + ENDLET +endif +" Ignore this comment, just bypassing a highlighting issue: if +call add(s:build_fun_lines, []) +let s:build_fun_lines[-1] =<< trim ENDLET + call add(s:lines, l:new..s:HtmlEndline) + let l:to_insert = l:to_insert - 1 + endwhile + endif + endfun +ENDLET +exec join(flatten(s:build_fun_lines), "\n") + " First do some preprocessing for dynamic folding. Do this for the entire file " so we don't accidentally start within a closed fold or something. let s:allfolds = [] @@ -1220,7 +1321,7 @@ if s:settings.dynamic_folds let s:newfold = {'firstline': s:lnum, 'lastline': foldclosedend(s:lnum), 'level': s:level,'type': "closed-fold"} call add(s:allfolds, s:newfold) " open the fold so we can find any contained folds - execute s:lnum."foldopen" + execute s:lnum.."foldopen" else if !s:settings.no_progress call s:pgb.incr() @@ -1252,7 +1353,7 @@ if s:settings.dynamic_folds call add(s:allfolds, s:newfold) endif " open the fold so we can find any contained folds - execute s:lnum."foldopen" + execute s:lnum.."foldopen" else if !s:settings.no_progress call s:pgb.incr() @@ -1339,7 +1440,7 @@ if s:settings.dynamic_folds " Note that only when a start and an end line is specified will a fold " containing the current range ever be removed. while leveladjust > 0 - exe g:html_start_line."foldopen" + exe g:html_start_line.."foldopen" let leveladjust -= 1 endwhile endif @@ -1399,47 +1500,11 @@ endif while s:lnum <= s:end " If there are filler lines for diff mode, show these above the line. - let s:filler = diff_filler(s:lnum) - if s:filler > 0 - let s:n = s:filler - while s:n > 0 - let s:new = repeat(s:difffillchar, 3) - - if s:n > 2 && s:n < s:filler && !s:settings.whole_filler - let s:new = s:new . " " . s:filler . " inserted lines " - let s:n = 2 - endif - - if !s:settings.no_pre - " HTML line wrapping is off--go ahead and fill to the margin - " TODO: what about when CSS wrapping is turned on? - let s:new = s:new . repeat(s:difffillchar, &columns - strlen(s:new) - s:margin) - else - let s:new = s:new . repeat(s:difffillchar, 3) - endif - - let s:new = s:HtmlFormat_d(s:new, s:DIFF_D_ID, 0) - if s:settings.number_lines - " Indent if line numbering is on. Indent gets style of line number - " column. - let s:new = s:HtmlFormat_n(repeat(' ', s:margin), s:LINENR_ID, 0, 0) . s:new - endif - if s:settings.dynamic_folds && !s:settings.no_foldcolumn && s:foldcolumn > 0 - " Indent for foldcolumn if there is one. Assume it's empty, there should - " not be a fold for deleted lines in diff mode. - let s:new = s:FoldColumn_fill() . s:new - endif - call add(s:lines, s:new.s:HtmlEndline) - - let s:n = s:n - 1 - endwhile - unlet s:n - endif - unlet s:filler + call s:Add_diff_fill(s:lnum) " Start the line with the line number. if s:settings.number_lines - let s:numcol = repeat(' ', s:margin - 1 - strlen(s:lnum)) . s:lnum . ' ' + let s:numcol = repeat(' ', s:margin - 1 - strlen(s:lnum)) .. s:lnum .. ' ' endif let s:new = "" @@ -1450,11 +1515,11 @@ while s:lnum <= s:end let s:new = foldtextresult(s:lnum) if !s:settings.no_pre " HTML line wrapping is off--go ahead and fill to the margin - let s:new = s:new . repeat(s:foldfillchar, &columns - strlen(s:new)) + let s:new = s:new .. repeat(s:foldfillchar, &columns - strlen(s:new)) endif " put numcol in a separate group for sake of unselectable text - let s:new = (s:settings.number_lines ? s:HtmlFormat_n(s:numcol, s:FOLDED_ID, 0, s:lnum): "") . s:HtmlFormat_t(s:new, s:FOLDED_ID, 0) + let s:new = (s:settings.number_lines ? s:HtmlFormat_n(s:numcol, s:FOLDED_ID, 0, s:lnum): "") .. s:HtmlFormat_t(s:new, s:FOLDED_ID, 0) " Skip to the end of the fold let s:new_lnum = foldclosedend(s:lnum) @@ -1475,7 +1540,7 @@ while s:lnum <= s:end if s:settings.dynamic_folds " First insert a closing for any open folds that end on this line while !empty(s:foldstack) && get(s:foldstack,0).lastline == s:lnum-1 - let s:new = s:new."</span></span>" + let s:new = s:new.."</span></span>" call remove(s:foldstack, 0) endwhile @@ -1483,9 +1548,9 @@ while s:lnum <= s:end let s:firstfold = 1 while !empty(s:allfolds) && get(s:allfolds,0).firstline == s:lnum let s:foldId = s:foldId + 1 - let s:new .= "<span id='" - let s:new .= (exists('g:html_diff_win_num') ? "win".g:html_diff_win_num : "") - let s:new .= "fold".s:foldId.s:settings.id_suffix."' class='".s:allfolds[0].type."'>" + let s:new ..= "<span id='" + let s:new ..= (exists('g:html_diff_win_num') ? "win"..g:html_diff_win_num : "") + let s:new ..= "fold"..s:foldId..s:settings.id_suffix.."' class='"..s:allfolds[0].type.."'>" " Unless disabled, add a fold column for the opening line of a fold. @@ -1496,20 +1561,20 @@ while s:lnum <= s:end if !s:settings.no_foldcolumn " add fold column that can open the new fold if s:allfolds[0].level > 1 && s:firstfold - let s:new = s:new . s:FoldColumn_build('|', s:allfolds[0].level - 1, 0, "", - \ 'toggle-open FoldColumn','javascript:toggleFold("fold'.s:foldstack[0].id.s:settings.id_suffix.'");') + let s:new = s:new .. s:FoldColumn_build('|', s:allfolds[0].level - 1, 0, "", + \ 'toggle-open FoldColumn','javascript:toggleFold("fold'..s:foldstack[0].id..s:settings.id_suffix..'");') endif " add the filler spaces separately from the '+' char so that it can be " shown/hidden separately during a hover unfold - let s:new = s:new . s:FoldColumn_build("+", 1, 0, "", - \ 'toggle-open FoldColumn', 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");') + let s:new = s:new .. s:FoldColumn_build("+", 1, 0, "", + \ 'toggle-open FoldColumn', 'javascript:toggleFold("fold'..s:foldId..s:settings.id_suffix..'");') " If this is not the last fold we're opening on this line, we need " to keep the filler spaces hidden if the fold is opened by mouse " hover. If it is the last fold to open in the line, we shouldn't hide " them, so don't apply the toggle-filler class. - let s:new = s:new . s:FoldColumn_build(" ", 1, s:foldcolumn - s:allfolds[0].level - 1, "", - \ 'toggle-open FoldColumn'. (get(s:allfolds, 1, {'firstline': 0}).firstline == s:lnum ?" toggle-filler" :""), - \ 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");') + let s:new = s:new .. s:FoldColumn_build(" ", 1, s:foldcolumn - s:allfolds[0].level - 1, "", + \ 'toggle-open FoldColumn'.. (get(s:allfolds, 1, {'firstline': 0}).firstline == s:lnum ?" toggle-filler" :""), + \ 'javascript:toggleFold("fold'..s:foldId..s:settings.id_suffix..'");') " add fold column that can close the new fold " only add extra blank space if we aren't opening another fold on the @@ -1522,12 +1587,12 @@ while s:lnum <= s:end if s:firstfold " the first fold in a line has '|' characters from folds opened in " previous lines, before the '-' for this fold - let s:new .= s:FoldColumn_build('|', s:allfolds[0].level - 1, s:extra_space, '-', - \ 'toggle-closed FoldColumn', 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");') + let s:new ..= s:FoldColumn_build('|', s:allfolds[0].level - 1, s:extra_space, '-', + \ 'toggle-closed FoldColumn', 'javascript:toggleFold("fold'..s:foldId..s:settings.id_suffix..'");') else " any subsequent folds in the line only add a single '-' - let s:new = s:new . s:FoldColumn_build("-", 1, s:extra_space, "", - \ 'toggle-closed FoldColumn', 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");') + let s:new = s:new .. s:FoldColumn_build("-", 1, s:extra_space, "", + \ 'toggle-closed FoldColumn', 'javascript:toggleFold("fold'..s:foldId..s:settings.id_suffix..'");') endif let s:firstfold = 0 endif @@ -1535,12 +1600,12 @@ while s:lnum <= s:end " Add fold text, moving the span ending to the next line so collapsing " of folds works correctly. " Put numcol in a separate group for sake of unselectable text. - let s:new = s:new . (s:settings.number_lines ? s:HtmlFormat_n(s:numcol, s:FOLDED_ID, 0, 0) : "") . substitute(s:HtmlFormat_t(foldtextresult(s:lnum), s:FOLDED_ID, 0), '</span>', s:HtmlEndline.'\n\0', '') - let s:new = s:new . "<span class='fulltext'>" + let s:new = s:new .. (s:settings.number_lines ? s:HtmlFormat_n(s:numcol, s:FOLDED_ID, 0, 0) : "") .. substitute(s:HtmlFormat_t(foldtextresult(s:lnum), s:FOLDED_ID, 0), '</span>', s:HtmlEndline..'\n\0', '') + let s:new = s:new .. "<span class='fulltext'>" " open the fold now that we have the fold text to allow retrieval of " fold text for subsequent folds - execute s:lnum."foldopen" + execute s:lnum.."foldopen" call insert(s:foldstack, remove(s:allfolds,0)) let s:foldstack[0].id = s:foldId endwhile @@ -1555,13 +1620,13 @@ while s:lnum <= s:end " add the empty foldcolumn for unfolded lines if there is a fold " column at all if s:foldcolumn > 0 - let s:new = s:new . s:FoldColumn_fill() + let s:new = s:new .. s:FoldColumn_fill() endif else " add the fold column for folds not on the opening line if get(s:foldstack, 0).firstline < s:lnum - let s:new = s:new . s:FoldColumn_build('|', s:foldstack[0].level, s:foldcolumn - s:foldstack[0].level, "", - \ 'FoldColumn', 'javascript:toggleFold("fold'.s:foldstack[0].id.s:settings.id_suffix.'");') + let s:new = s:new .. s:FoldColumn_build('|', s:foldstack[0].level, s:foldcolumn - s:foldstack[0].level, "", + \ 'FoldColumn', 'javascript:toggleFold("fold'..s:foldstack[0].id..s:settings.id_suffix..'");') endif endif endif @@ -1569,9 +1634,9 @@ while s:lnum <= s:end " Now continue with the unfolded line text if s:settings.number_lines - let s:new = s:new . s:HtmlFormat_n(s:numcol, s:LINENR_ID, 0, s:lnum) + let s:new = s:new .. s:HtmlFormat_n(s:numcol, s:LINENR_ID, 0, s:lnum) elseif s:settings.line_ids - let s:new = s:new . s:HtmlFormat_n("", s:LINENR_ID, 0, s:lnum) + let s:new = s:new .. s:HtmlFormat_n("", s:LINENR_ID, 0, s:lnum) endif " Get the diff attribute, if any. @@ -1611,7 +1676,7 @@ while s:lnum <= s:end if s:len < &columns && !s:settings.no_pre " Add spaces at the end of the raw text line to extend the changed " line to the full width. - let s:line = s:line . repeat(' ', &columns - virtcol([s:lnum, s:len]) - s:margin) + let s:line = s:line .. repeat(' ', &columns - virtcol([s:lnum, s:len]) - s:margin) let s:len = &columns endif else @@ -1649,11 +1714,11 @@ while s:lnum <= s:end " if the found tab is the first character in the text being " processed, we need to get the character prior to the text, " given by startcol. - let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:offset) . 'c') + let s:prevc = matchstr(s:line, '.\%' .. (s:startcol + s:offset) .. 'c') else " Otherwise, the byte index of the tab into s:expandedtab is " given by s:idx. - let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c') + let s:prevc = matchstr(s:expandedtab, '.\%' .. (s:idx + 1) .. 'c') endif let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)]) @@ -1689,12 +1754,12 @@ while s:lnum <= s:end " Output the text with the same synID, with class set to the highlight ID " name, unless it has been concealed completely. if strlen(s:expandedtab) > 0 - let s:new = s:new . s:HtmlFormat(s:expandedtab, s:id, s:diff_id, "", 0) + let s:new = s:new .. s:HtmlFormat(s:expandedtab, s:id, s:diff_id, "", 0) endif endwhile endif - call extend(s:lines, split(s:new.s:HtmlEndline, '\n', 1)) + call extend(s:lines, split(s:new..s:HtmlEndline, '\n', 1)) if !s:settings.no_progress && s:pgb.needs_redraw redrawstatus let s:pgb.needs_redraw = 0 @@ -1706,17 +1771,21 @@ while s:lnum <= s:end endif endwhile +" Diff filler is returned based on what needs inserting *before* the given line. +" So to get diff filler at the end of the buffer, we need to use last line + 1 +call s:Add_diff_fill(s:end+1) + if s:settings.dynamic_folds " finish off any open folds while !empty(s:foldstack) - let s:lines[-1].="</span></span>" + let s:lines[-1]..="</span></span>" call remove(s:foldstack, 0) endwhile " add fold column to the style list if not already there let s:id = s:FOLD_C_ID if !has_key(s:stylelist, s:id) - let s:stylelist[s:id] = '.FoldColumn { ' . s:CSS1(s:id) . '}' + let s:stylelist[s:id] = '.FoldColumn { ' .. s:CSS1(s:id) .. '}' endif endif @@ -1734,7 +1803,7 @@ if !s:settings.no_doc call extend(s:lines, ["</body>", "</html>"]) endif -exe s:newwin . "wincmd w" +exe s:newwin .. "wincmd w" call setline(1, s:lines) unlet s:lines @@ -1757,17 +1826,17 @@ if s:settings.use_css && !s:settings.no_doc " Normal/global attributes if s:settings.no_pre - call append('.', "body { color: " . s:fgc . "; background-color: " . s:bgc . "; font-family: ". s:htmlfont ."; }") + call append('.', "body { color: " .. s:fgc .. "; background-color: " .. s:bgc .. "; font-family: ".. s:htmlfont .."; }") + else - call append('.', "pre { " . s:whitespace . "font-family: ". s:htmlfont ."; color: " . s:fgc . "; background-color: " . s:bgc . "; }") + call append('.', "pre { " .. s:whitespace .. "font-family: ".. s:htmlfont .."; color: " .. s:fgc .. "; background-color: " .. s:bgc .. "; }") + yank put execute "normal! ^cwbody\e" " body should not have the wrap formatting, only the pre section if s:whitespace != '' - exec 's#'.s:whitespace + exec 's#'..s:whitespace endif endif " fix browser inconsistencies (sometimes within the same browser) of different @@ -1778,13 +1847,13 @@ if s:settings.use_css && !s:settings.no_doc " like normal text if !empty(s:settings.prevent_copy) if s:settings.use_input_for_pc !=# "none" - call append('.', 'input { border: none; margin: 0; padding: 0; font-family: '.s:htmlfont.'; }') + call append('.', 'input { border: none; margin: 0; padding: 0; font-family: '..s:htmlfont..'; }') + " ch units for browsers which support them, em units for a somewhat " reasonable fallback. for w in range(1, 20, 1) call append('.', [ - \ "input[size='".w."'] { width: ".w."em; width: ".w."ch; }" + \ "input[size='"..w.."'] { width: "..w.."em; width: "..w.."ch; }" \ ]) + endfor @@ -1828,14 +1897,15 @@ if s:settings.use_css && !s:settings.no_doc endif for s:style_name in s:unselectable_styles call append('.', [ - \ ' .'.s:style_name.' { user-select: none; }', - \ ' [data-'.s:style_name.'-content]::before { content: attr(data-'.s:style_name.'-content); }', - \ ' [data-'.s:style_name.'-content]::before { padding-bottom: 1px; display: inline-block; /* match the 1-px padding of standard items with background */ }', - \ ' span[data-'.s:style_name.'-content]::before { cursor: default; }', + \ ' .'..s:style_name..' { user-select: none; }', + \ ' [data-'..s:style_name..'-content]::before { content: attr(data-'..s:style_name..'-content); }', + \ ' [data-'..s:style_name..'-content]::before { padding-bottom: 1px; display: inline-block; /* match the 1-px padding of standard items with background */ }', + \ ' span[data-'..s:style_name..'-content]::before { cursor: default; }', \ ]) +4 endfor if s:settings.use_input_for_pc !=# 'none' + " Note, the extra '}' is to match the "@supports" above call append('.', [ \ ' input { display: none; }', \ '}' @@ -1851,12 +1921,12 @@ if s:settings.use_css && !s:settings.no_doc " Make the cursor show active fold columns as active areas, and empty fold " columns as not interactive. call append('.', ['input.FoldColumn { cursor: pointer; }', - \ 'input.FoldColumn[value="'.repeat(' ', s:foldcolumn).'"] { cursor: default; }' + \ 'input.FoldColumn[value="'..repeat(' ', s:foldcolumn)..'"] { cursor: default; }' \ ]) +2 if s:settings.use_input_for_pc !=# 'all' call append('.', [ - \ 'a[data-FoldColumn-content="'.repeat(' ', s:foldcolumn).'"] { cursor: default; }' + \ 'a[data-FoldColumn-content="'..repeat(' ', s:foldcolumn)..'"] { cursor: default; }' \ ]) +1 end @@ -1884,7 +1954,7 @@ endif if !s:settings.use_css && !s:settings.no_doc " For Netscape 4, set <body> attributes too, though, strictly speaking, it's " incorrect. - execute '%s:<body\([^>]*\):<body bgcolor="' . s:bgc . '" text="' . s:fgc . '"\1>\r<font face="'. s:htmlfont .'"' + execute '%s:<body\([^>]*\):<body bgcolor="' .. s:bgc .. '" text="' .. s:fgc .. '"\1>\r<font face="'.. s:htmlfont ..'"' endif " Gather attributes for all other classes. Do diff first so that normal @@ -1935,7 +2005,7 @@ let @/ = s:old_search let &more = s:old_more " switch to original window to restore those settings -exe s:orgwin . "wincmd w" +exe s:orgwin .. "wincmd w" if !s:settings.expand_tabs let &l:isprint = s:old_isprint @@ -1945,7 +2015,7 @@ let &l:et = s:old_et let &l:scrollbind = s:old_bind " and back to the new window again to end there -exe s:newwin . "wincmd w" +exe s:newwin .. "wincmd w" let &l:stl = s:newwin_stl exec 'resize' s:old_winheight @@ -1982,10 +2052,13 @@ if !v:profiling delfunc s:progressbar.incr unlet s:pgb s:progressbar endif + + delfunc s:Add_diff_fill endif -unlet! s:new_lnum s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace +unlet! s:new_lnum s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace s:diffstyle unlet! s:LeadingSpace s:HtmlEndline s:firstfold s:numcol s:foldcolumn +unlet! s:wrapperfunc_lines s:build_fun_lines unlet s:foldstack s:allfolds s:foldId s:settings let &cpo = s:cpo_sav diff --git a/runtime/syntax/i3config.vim b/runtime/syntax/i3config.vim index caef244ce5..8bc2a6e03c 100644 --- a/runtime/syntax/i3config.vim +++ b/runtime/syntax/i3config.vim @@ -2,8 +2,9 @@ " Language: i3 config file " Original Author: Mohamed Boughaba <mohamed dot bgb at gmail dot com> " Maintainer: Quentin Hibon (github user hiqua) -" Version: 0.4 -" Last Change: 2022 Jun 05 +" Version: 0.4.22 +" Reference version (JosefLitos/i3config.vim): 4.22 +" Last Change: 2023-09-12 " References: " http://i3wm.org/docs/userguide.html#configuring @@ -18,247 +19,329 @@ endif scriptencoding utf-8 " Error -syn match i3ConfigError /.*/ +syn match i3ConfigError /.\+/ " Todo syn keyword i3ConfigTodo TODO FIXME XXX contained -" Comment -" Comments are started with a # and can only be used at the beginning of a line +" Helper type definitions +syn match i3ConfigSeparator /[,;]/ contained +syn match i3ConfigParen /[{}]/ contained +syn keyword i3ConfigBoolean yes no enabled disabled on off true false contained +syn region i3ConfigString start=/\W\@<="/ skip=/\\"/ end=/"/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend +syn region i3ConfigString start=/\W\@<='/ end=/'/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend +syn match i3ConfigColor /#\w\{3,8}/ contained +syn match i3ConfigNumber /[a-zA-Z_$-]\@<!-\?\d\+\w\@!/ contained + +" 4.1 Include directive +syn keyword i3ConfigIncludeKeyword include contained +syn match i3ConfigIncludeCommand /`[^`]*`/ contained contains=i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper,i3ConfigShCommand +syn match i3ConfigInclude /^include .*$/ contains=i3ConfigIncludeKeyword,i3ConfigString,i3ConfigVariable,i3ConfigIncludeCommand + +" 4.2 Comments syn match i3ConfigComment /^\s*#.*$/ contains=i3ConfigTodo -" Font -" A FreeType font description is composed by: -" a font family, a style, a weight, a variant, a stretch and a size. -syn match i3ConfigFontSeparator /,/ contained -syn match i3ConfigFontSeparator /:/ contained +" 4.3 Fonts syn keyword i3ConfigFontKeyword font contained -syn match i3ConfigFontNamespace /\w\+:/ contained contains=i3ConfigFontSeparator -syn match i3ConfigFontContent /-\?\w\+\(-\+\|\s\+\|,\)/ contained contains=i3ConfigFontNamespace,i3ConfigFontSeparator,i3ConfigFontKeyword +syn match i3ConfigColonOperator /:/ contained +syn match i3ConfigFontNamespace /\w\+:/ contained contains=i3ConfigColonOperator syn match i3ConfigFontSize /\s\=\d\+\(px\)\?\s\?$/ contained -syn match i3ConfigFont /^\s*font\s\+.*$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace -syn match i3ConfigFont /^\s*font\s\+.*\(\\\_.*\)\?$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace -syn match i3ConfigFont /^\s*font\s\+.*\(\\\_.*\)\?[^\\]\+$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace -syn match i3ConfigFont /^\s*font\s\+\(\(.*\\\_.*\)\|\(.*[^\\]\+$\)\)/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace - -" variables -syn match i3ConfigString /\(['"]\)\(.\{-}\)\1/ contained -syn match i3ConfigColor /#\w\{6}/ contained -syn match i3ConfigVariableModifier /+/ contained -syn match i3ConfigVariableAndModifier /+\w\+/ contained contains=i3ConfigVariableModifier -syn match i3ConfigVariable /\$\w\+\(\(-\w\+\)\+\)\?\(\s\|+\)\?/ contains=i3ConfigVariableModifier,i3ConfigVariableAndModifier -syn keyword i3ConfigInitializeKeyword set contained -syn match i3ConfigInitialize /^\s*set\s\+.*$/ contains=i3ConfigVariable,i3ConfigInitializeKeyword,i3ConfigColor,i3ConfigString - -" Include -syn keyword i3ConfigIncludeKeyword include contained -syn match i3ConfigInclude /^\s*include\s\+.*$/ contains=i3ConfigIncludeKeyword,i3ConfigString,i3ConfigVariable - -" Gaps -syn keyword i3ConfigGapStyleKeyword inner outer horizontal vertical top right bottom left current all set plus minus toggle up down contained -syn match i3ConfigGapStyle /^\s*\(gaps\)\s\+\(inner\|outer\|horizontal\|vertical\|left\|top\|right\|bottom\)\(\s\+\(current\|all\)\)\?\(\s\+\(set\|plus\|minus\|toggle\)\)\?\(\s\+\(-\?\d\+\|\$.*\)\)$/ contains=i3ConfigGapStyleKeyword,i3ConfigNumber,i3ConfigVariable -syn keyword i3ConfigSmartGapKeyword on inverse_outer off contained -syn match i3ConfigSmartGap /^\s*smart_gaps\s\+\(on\|inverse_outer\|off\)\s\?$/ contains=i3ConfigSmartGapKeyword -syn keyword i3ConfigSmartBorderKeyword on no_gaps contained -syn match i3ConfigSmartBorder /^\s*smart_borders\s\+\(on\|no_gaps\)\s\?$/ contains=i3ConfigSmartBorderKeyword - -" Keyboard bindings -syn keyword i3ConfigAction toggle fullscreen restart key import kill shrink grow contained -syn keyword i3ConfigAction focus move grow height width split layout resize restore reload mute unmute exit mode workspace container to contained -syn match i3ConfigModifier /\w\++\w\+\(\(+\w\+\)\+\)\?/ contained contains=i3ConfigVariableModifier -syn match i3ConfigNumber /\s\d\+/ contained -syn match i3ConfigUnit /\sp\(pt\|x\)/ contained -syn match i3ConfigUnitOr /\sor/ contained -syn keyword i3ConfigBindKeyword bindsym bindcode exec gaps border contained -syn match i3ConfigBindArgument /--\w\+\(\(-\w\+\)\+\)\?\s/ contained -syn match i3ConfigBind /^\s*\(bindsym\|bindcode\)\s\+.*$/ contains=i3ConfigVariable,i3ConfigBindKeyword,i3ConfigVariableAndModifier,i3ConfigNumber,i3ConfigUnit,i3ConfigUnitOr,i3ConfigBindArgument,i3ConfigModifier,i3ConfigAction,i3ConfigString,i3ConfigGapStyleKeyword,i3ConfigBorderStyleKeyword - -" Floating +syn region i3ConfigFont start=/^\s*font / skip=/\\$/ end=/$/ contains=i3ConfigFontKeyword,i3ConfigFontNamespace,i3ConfigFontSize,i3ConfigSeparator keepend + +" 4.4-4.5 Keyboard/Mouse bindings +syn keyword i3ConfigBindKeyword bindsym bindcode contained +syn match i3ConfigBindArgument /--\(release\|border\|whole-window\|exclude-titlebar\)/ contained +syn match i3ConfigBindModifier /+/ contained +syn match i3ConfigBindModkey /Ctrl\|Shift\|Mod[1-5]/ contained +syn match i3ConfigBindCombo /[$a-zA-Z0-9_+]\+ / contained contains=i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey +syn match i3ConfigBindComboLine /bind\(sym\|code\)\( --[a-z-]\+\)* [$a-zA-Z0-9_+]\+ / contained contains=i3ConfigBindKeyword,i3ConfigBindArgument,i3ConfigBindCombo +syn region i3ConfigBind start=/^\s*bind\(sym\|code\) / skip=/\\$/ end=/$/ contains=i3ConfigBindComboLine,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean keepend + +" 4.6 Binding modes +syn region i3ConfigKeyword start=/^mode\( --pango_markup\)\? \([^'" {]\+\|'[^']\+'\|".\+"\)\s\+{$/ end=/^\s*}$/ contains=i3ConfigShParam,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigNumber,i3ConfigParen,i3ConfigVariable fold keepend extend + +" 4.7 Floating modifier +syn match i3ConfigKeyword /^floating_modifier [$a-zA-Z0-9+]\+$/ contains=i3ConfigVariable,i3ConfigBindModkey + +" 4.8 Floating window size syn keyword i3ConfigSizeSpecial x contained -syn match i3ConfigNegativeSize /-/ contained -syn match i3ConfigSize /-\?\d\+\s\?x\s\?-\?\d\+/ contained contains=i3ConfigSizeSpecial,i3ConfigNumber,i3ConfigNegativeSize -syn match i3ConfigFloatingModifier /^\s*floating_modifier\s\+\$\w\+\d\?/ contains=i3ConfigVariable -syn match i3ConfigFloating /^\s*floating_\(maximum\|minimum\)_size\s\+-\?\d\+\s\?x\s\?-\?\d\+/ contains=i3ConfigSize - -" Orientation -syn keyword i3ConfigOrientationKeyword vertical horizontal auto contained -syn match i3ConfigOrientation /^\s*default_orientation\s\+\(vertical\|horizontal\|auto\)\s\?$/ contains=i3ConfigOrientationKeyword - -" Layout -syn keyword i3ConfigLayoutKeyword default stacking tabbed contained -syn match i3ConfigLayout /^\s*workspace_layout\s\+\(default\|stacking\|tabbed\)\s\?$/ contains=i3ConfigLayoutKeyword - -" Border style -syn keyword i3ConfigBorderStyleKeyword none normal pixel contained -syn match i3ConfigBorderStyle /^\s*\(new_window\|new_float\|default_border\|default_floating_border\)\s\+\(none\|\(normal\|pixel\)\(\s\+\d\+\)\?\(\s\+\$\w\+\(\(-\w\+\)\+\)\?\(\s\|+\)\?\)\?\)\s\?$/ contains=i3ConfigBorderStyleKeyword,i3ConfigNumber,i3ConfigVariable - -" Hide borders and edges -syn keyword i3ConfigEdgeKeyword none vertical horizontal both smart smart_no_gaps contained -syn match i3ConfigEdge /^\s*hide_edge_borders\s\+\(none\|vertical\|horizontal\|both\|smart\|smart_no_gaps\)\s\?$/ contains=i3ConfigEdgeKeyword - -" Arbitrary commands for specific windows (for_window) -syn keyword i3ConfigCommandKeyword for_window contained -syn region i3ConfigWindowStringSpecial start=+"+ skip=+\\"+ end=+"+ contained contains=i3ConfigString -syn region i3ConfigWindowCommandSpecial start="\[" end="\]" contained contains=i3ConfigWindowStringSpacial,i3ConfigString -syn match i3ConfigArbitraryCommand /^\s*for_window\s\+.*$/ contains=i3ConfigWindowCommandSpecial,i3ConfigCommandKeyword,i3ConfigBorderStyleKeyword,i3ConfigLayoutKeyword,i3ConfigOrientationKeyword,Size,i3ConfigNumber - -" Disable focus open opening -syn keyword i3ConfigNoFocusKeyword no_focus contained -syn match i3ConfigDisableFocus /^\s*no_focus\s\+.*$/ contains=i3ConfigWindowCommandSpecial,i3ConfigNoFocusKeyword - -" Move client to specific workspace automatically -syn keyword i3ConfigAssignKeyword assign contained -syn match i3ConfigAssignSpecial /→/ contained -syn match i3ConfigAssign /^\s*assign\s\+.*$/ contains=i3ConfigAssignKeyword,i3ConfigWindowCommandSpecial,i3ConfigAssignSpecial +syn match i3ConfigSize / -\?\d\+ x -\?\d\+/ contained contains=i3ConfigSizeSpecial,i3ConfigNumber +syn match i3ConfigKeyword /^floating_\(maximum\|minimum\)_size .*$/ contains=i3ConfigSize -" X resources -syn keyword i3ConfigResourceKeyword set_from_resource contained -syn match i3ConfigResource /^\s*set_from_resource\s\+.*$/ contains=i3ConfigResourceKeyword,i3ConfigWindowCommandSpecial,i3ConfigColor,i3ConfigVariable +" 4.9 Orientation +syn keyword i3ConfigOrientationOpts vertical horizontal auto contained +syn match i3ConfigKeyword /^default_orientation \w*$/ contains=i3ConfigOrientationOpts -" Auto start applications -syn keyword i3ConfigExecKeyword exec exec_always contained -syn match i3ConfigNoStartupId /--no-startup-id/ contained " We are not using i3ConfigBindArgument as only no-startup-id is supported here -syn match i3ConfigExec /^\s*exec\(_always\)\?\s\+.*$/ contains=i3ConfigExecKeyword,i3ConfigNoStartupId,i3ConfigString +" 4.10 Layout mode +syn keyword i3ConfigWorkspaceLayoutOpts default stacking tabbed contained +syn match i3ConfigKeyword /^workspace_layout \w*$/ contains=i3ConfigWorkspaceLayoutOpts -" Automatically putting workspaces on specific screens -syn keyword i3ConfigWorkspaceKeyword workspace contained -syn keyword i3ConfigOutput output contained -syn match i3ConfigWorkspace /^\s*workspace\s\+.*$/ contains=i3ConfigWorkspaceKeyword,i3ConfigNumber,i3ConfigString,i3ConfigOutput +" 4.11 Title alignment +syn keyword i3ConfigTitleAlignOpts left center right contained +syn match i3ConfigKeyword /^title_align .*$/ contains=i3ConfigTitleAlignOpts -" Changing colors -syn keyword i3ConfigClientColorKeyword client focused focused_inactive unfocused urgent placeholder background contained -syn match i3ConfigClientColor /^\s*client.\w\+\s\+.*$/ contains=i3ConfigClientColorKeyword,i3ConfigColor,i3ConfigVariable +" 4.12 Border style +syn keyword i3ConfigBorderOpts none normal pixel contained +syn match i3ConfigKeyword /^default\(_floating\)\?_border .*$/ contains=i3ConfigBorderOpts,i3ConfigNumber,i3ConfigVariable -syn keyword i3ConfigTitleAlignKeyword left center right contained -syn match i3ConfigTitleAlign /^\s*title_align\s\+.*$/ contains=i3ConfigTitleAlignKeyword +" 4.13 Hide edge borders +syn keyword i3ConfigEdgeOpts none vertical horizontal both smart smart_no_gaps contained +syn match i3ConfigKeyword /^hide_edge_borders \w\+$/ contains=i3ConfigEdgeOpts -" Interprocess communication -syn match i3ConfigInterprocessKeyword /ipc-socket/ contained -syn match i3ConfigInterprocess /^\s*ipc-socket\s\+.*$/ contains=i3ConfigInterprocessKeyword +" 4.14 Smart Borders +syn keyword i3ConfigSmartBorderOpts no_gaps contained +syn match i3ConfigKeyword /^smart_borders \(on\|off\|no_gaps\)$/ contains=i3ConfigSmartBorderOpts,i3ConfigBoolean -" Mouse warping -syn keyword i3ConfigMouseWarpingKeyword mouse_warping contained -syn keyword i3ConfigMouseWarpingType output none contained -syn match i3ConfigMouseWarping /^\s*mouse_warping\s\+\(output\|none\)\s\?$/ contains=i3ConfigMouseWarpingKeyword,i3ConfigMouseWarpingType +" 4.15 Arbitrary commands +syn keyword i3ConfigForWindowKeyword for_window contained +syn region i3ConfigForWindow start=/^for_window / end=/$/ contains=i3ConfigForWindowKeyword,i3ConfigCriteria keepend -" Focus follows mouse -syn keyword i3ConfigFocusFollowsMouseKeyword focus_follows_mouse contained -syn keyword i3ConfigFocusFollowsMouseType yes no contained -syn match i3ConfigFocusFollowsMouse /^\s*focus_follows_mouse\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusFollowsMouseKeyword,i3ConfigFocusFollowsMouseType +" 4.16 No opening focus +syn match i3ConfigKeyword /^no_focus .*$/ contains=i3ConfigCondition -" Popups during fullscreen mode -syn keyword i3ConfigPopupOnFullscreenKeyword popup_during_fullscreen contained -syn keyword i3ConfigPopuponFullscreenType smart ignore leave_fullscreen contained -syn match i3ConfigPopupOnFullscreen /^\s*popup_during_fullscreen\s\+\w\+\s\?$/ contains=i3ConfigPopupOnFullscreenKeyword,i3ConfigPopupOnFullscreenType +" 4.17 Variables +syn match i3ConfigVariable /\$[A-Z0-9a-z_:|[\]-]\+/ +syn keyword i3ConfigSetKeyword set contained +syn match i3ConfigSet /^set \$.*$/ contains=i3ConfigVariable,i3ConfigSetKeyword,i3ConfigColor,i3ConfigString,i3ConfigNoStartupId,i3ConfigNumber,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper -" Focus wrapping -syn keyword i3ConfigFocusWrappingKeyword force_focus_wrapping focus_wrapping contained -syn keyword i3ConfigFocusWrappingType yes no contained -syn match i3ConfigFocusWrapping /^\s*\(force_\)\?focus_wrapping\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigFocusWrappingKeyword +" 4.18 X resources +syn keyword i3ConfigResourceKeyword set_from_resource contained +syn match i3ConfigResource /^set_from_resource\s\+.*$/ contains=i3ConfigResourceKeyword,i3ConfigCondition,i3ConfigColor,i3ConfigVariable,i3ConfigString,i3ConfigNumber + +" 4.19 Assign clients to workspaces +syn keyword i3ConfigAssignKeyword assign contained +syn match i3ConfigAssignSpecial /→/ contained +syn match i3ConfigAssign /^assign .*$/ contains=i3ConfigAssignKeyword,i3ConfigAssignSpecial,i3ConfigCondition,i3ConfigVariable,i3ConfigString,i3ConfigNumber + +" 4.20 Executing shell commands +syn keyword i3ConfigExecKeyword exec contained +syn keyword i3ConfigExecAlwaysKeyword exec_always contained +syn match i3ConfigShCmdDelim /\$(/ contained +syn region i3ConfigShCommand start=/\$(/ end=/)/ contained contains=i3ConfigShCmdDelim,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigString,i3ConfigNumber,i3ConfigVariable keepend extend +syn match i3ConfigShDelim /[[\]{}();`]\+/ contained +syn match i3ConfigShOper /[<>&|+=~^*!.?]\+/ contained +syn match i3ConfigShParam /\<-[a-zA-Z0-9_-]\+\>/ contained containedin=i3ConfigVar +syn region i3ConfigExec start=/^\s*exec\(_always\)\?\( --no-startup-id\)\? [^{]/ skip=/\\$/ end=/$/ contains=i3ConfigExecKeyword,i3ConfigExecAlwaysKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigExecAction keepend + +" 4.21 Workspaces per output +syn keyword i3ConfigWorkspaceKeyword workspace contained +syn keyword i3ConfigWorkspaceOutput output contained +syn keyword i3ConfigWorkspaceDir prev next back_and_forth contained +syn region i3ConfigWorkspaceLine start=/^workspace / skip=/\\$/ end=/$/ contains=i3ConfigWorkspaceKeyword,i3ConfigNumber,i3ConfigString,i3ConfigGaps,i3ConfigWorkspaceOutput,i3ConfigVariable,i3ConfigBoolean,i3ConfigSeparator keepend -" Forcing Xinerama -syn keyword i3ConfigForceXineramaKeyword force_xinerama contained -syn match i3ConfigForceXinerama /^\s*force_xinerama\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigForceXineramaKeyword +" 4.22 Changing colors +syn match i3ConfigDotOperator /\./ contained +syn keyword i3ConfigClientOpts focused focused_inactive unfocused urgent placeholder background contained +syn match i3ConfigKeyword /^client\..*$/ contains=i3ConfigDotOperator,i3ConfigClientOpts,i3ConfigColor,i3ConfigVariable -" Automatic back-and-forth when switching to the current workspace -syn keyword i3ConfigAutomaticSwitchKeyword workspace_auto_back_and_forth contained -syn match i3ConfigAutomaticSwitch /^\s*workspace_auto_back_and_forth\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigAutomaticSwitchKeyword +" 4.23 Interprocess communication +syn match i3ConfigIpcKeyword /ipc-socket/ contained +syn match i3ConfigIpc /^ipc-socket .*$/ contains=i3ConfigIpcKeyword -" Delay urgency hint -syn keyword i3ConfigTimeUnit ms contained -syn keyword i3ConfigDelayUrgencyKeyword force_display_urgency_hint contained -syn match i3ConfigDelayUrgency /^\s*force_display_urgency_hint\s\+\d\+\s\+ms\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigDelayUrgencyKeyword,i3ConfigNumber,i3ConfigTimeUnit +" 4.24 Focus follows mouse +syn keyword i3ConfigFocusFollowsMouseOpts always contained +syn match i3ConfigFocusFollowsMouse /^focus_follows_mouse \(yes\|no\|always\)$/ contains=i3ConfigBoolean,i3ConfigFocusFollowsMouseOpts -" Focus on window activation -syn keyword i3ConfigFocusOnActivationKeyword focus_on_window_activation contained -syn keyword i3ConfigFocusOnActivationType smart urgent focus none contained -syn match i3ConfigFocusOnActivation /^\s*focus_on_window_activation\s\+\(smart\|urgent\|focus\|none\)\s\?$/ contains=i3ConfigFocusOnActivationKeyword,i3ConfigFocusOnActivationType +" 4.25 Mouse warping +syn keyword i3ConfigMouseWarpingOpts output container none contained +syn match i3ConfigMouseWarping /^mouse_warping \w*$/ contains=i3ConfigMouseWarpingOpts -" Automatic back-and-forth when switching to the current workspace -syn keyword i3ConfigDrawingMarksKeyword show_marks contained -syn match i3ConfigDrawingMarks /^\s*show_marks\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigDrawingMarksKeyword +" 4.26 Popups while fullscreen +syn keyword i3ConfigPopupFullscreenOpts smart ignore leave_fullscreen contained +syn match i3ConfigPopupFullscreen /^popup_during_fullscreen \w*$/ contains=i3ConfigPopupFullscreenOpts -" Group mode/bar -syn keyword i3ConfigBlockKeyword mode bar colors i3bar_command status_command position exec mode hidden_state modifier id position output background statusline tray_output tray_padding separator separator_symbol workspace_min_width workspace_buttons strip_workspace_numbers binding_mode_indicator focused_workspace active_workspace inactive_workspace urgent_workspace binding_mode contained -syn region i3ConfigBlock start=+^\s*[^#]*s\?{$+ end=+^\s*[^#]*}$+ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable transparent keepend extend +" 4.27 Focus wrapping +syn keyword i3ConfigFocusWrappingOpts force workspace contained +syn match i3ConfigFocusWrapping /^focus_wrapping \(yes\|no\|force\|workspace\)$/ contains=i3ConfigBoolean,i3ConfigFocusWrappingOpts -" Line continuation -syn region i3ConfigLineCont start=/^.*\\$/ end=/^.*$/ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable transparent keepend extend +" 4.28 Forcing Xinerama +syn match i3ConfigForceXinerama /^force_xinerama \(yes\|no\)$/ contains=i3ConfigBoolean + +" 4.29 Automatic workspace back-and-forth +syn match i3ConfigAutomaticSwitch /^workspace_auto_back_and_forth \(yes\|no\)$/ contains=i3ConfigBoolean + +" 4.30 Delay urgency hint +syn keyword i3ConfigTimeUnit ms contained +syn match i3ConfigDelayUrgency /^force_display_urgency_hint \d\+ ms$/ contains=i3ConfigBoolean,i3ConfigNumber,i3ConfigTimeUnit + +" 4.31 Focus on window activation +syn keyword i3ConfigFocusOnActivationOpts smart urgent focus none contained +syn match i3ConfigFocusOnActivation /^focus_on_window_activation .*$/ contains=i3ConfigFocusOnActivationKeyword + +" 4.32 Show marks in title +syn match i3ConfigShowMarks /^show_marks \(yes\|no\)$/ contains=i3ConfigBoolean + +" 4.34 Tiling drag +syn keyword i3ConfigTilingDragOpts modifier titlebar contained +syn match i3ConfigTilingDrag /^tiling_drag\( off\|\( modifier\| titlebar\)\{1,2\}\)$/ contains=i3ConfigTilingOpts,i3ConfigBoolean + +" 4.35 Gaps +syn keyword i3ConfigGapsOpts inner outer horizontal vertical left right top bottom current all set plus minus toggle contained +syn region i3ConfigGaps start=/gaps/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigGapsOpts,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend +syn match i3ConfigGapStyleLine /^gaps .*$/ contains=i3ConfigGaps +syn keyword i3ConfigSmartGapOpts inverse_outer contained +syn match i3ConfigSmartGap /^smart_gaps \(on\|off\|inverse_outer\)$/ contains=i3ConfigSmartGapOpts,i3ConfigBoolean + +" 5 Configuring bar +syn match i3ConfigBarModifier /^\s\+modifier [^ ]\+$/ contained contains=i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey +syn keyword i3ConfigBarOpts bar i3bar_command status_command mode hidden_state id position output tray_output tray_padding font separator_symbol workspace_buttons workspace_min_width strip_workspace_numbers strip_workspace_name binding_mode_indicator padding contained +syn region i3ConfigBarBlock start=/^bar {$/ end=/^}$/ contains=i3ConfigBarOpts,i3ConfigBarModifier,i3ConfigBind,i3ConfigString,i3ConfigComment,i3ConfigFont,i3ConfigBoolean,i3ConfigNumber,i3ConfigParen,i3ConfigColor,i3ConfigVariable,i3ConfigColorsBlock fold keepend extend + +" 5.16 Color block +syn match i3ConfigColorsOpts /\(focused_\)\?\(background\|statusline\|separator\)\|\(focused\|active\|inactive\|urgent\)_workspace\|binding_mode/ contained +syn region i3ConfigColorsBlock start=/^\s\+colors {$/ end=/^\s\+}$/ contained contains=i3ConfigColorsOpts,i3ConfigColor,i3ConfigVariable,i3ConfigComment,i3ConfigParen fold keepend extend + +" 6.0 Criteria-based commands +syn match i3ConfigConditionProp /\w\+\(-\w\+\)*/ contained +syn match i3ConfigConditionText /[^[ ]\+=/ contained contains=i3ConfigConditionProp,i3ConfigShOper +syn keyword i3ConfigConditionFocused __focused__ contained +syn region i3ConfigCondition start=/\[/ end=/\]/ contained contains=i3ConfigConditionText,i3ConfigShDelim,i3ConfigNumber,i3ConfigString,i3ConfigConditionFocused keepend extend +syn region i3ConfigCriteria start=/\[/ skip=/\\$/ end=/\(;\|$\)/ contained contains=i3ConfigCondition,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigBoolean,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend + +" 6.1 Actions through shell +syn match i3ConfigExecActionKeyword /i3-msg/ contained +syn region i3ConfigExecAction start=/[a-z3-]\+msg '/ skip=/\\$\| '/ end=/'/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend +syn region i3ConfigExecAction start=/[a-z3-]\+msg "/ skip=/\\$\| "/ end=/"/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend +syn region i3ConfigExecAction start=/[a-z3-]\+msg\( ['"-]\)\@!/ skip=/\\$/ end=/\([&|;})'"]\|$\)/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend +" 6.1 Executing applications (4.20) +syn region i3ConfigAction start=/exec/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigExecKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigSeparator keepend + +" 6.3 Manipulating layout +syn keyword i3ConfigLayoutKeyword layout contained +syn keyword i3ConfigLayoutOpts default tabbed stacking splitv splith toggle split all contained +syn region i3ConfigAction start=/layout/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigLayoutKeyword,i3ConfigLayoutOpts,i3ConfigSeparator keepend + +" 6.4 Focusing containers +syn keyword i3ConfigFocusKeyword focus contained +syn keyword i3ConfigFocusOpts left right up down parent child next prev sibling floating tiling mode_toggle contained +syn keyword i3ConfigFocusOutputOpts left right down up current primary nonprimary next prev contained +syn region i3ConfigFocusOutput start=/ output / skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMoveType,i3ConfigWorkspaceOutput,i3ConfigFocusOutputOpts,i3ConfigString,i3ConfigNumber,i3ConfigSeparator keepend +syn match i3ConfigFocusOutputLine /^focus output .*$/ contains=i3ConfigFocusKeyword,i3ConfigFocusOutput +syn region i3ConfigAction start=/focus/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigFocusKeyword,i3ConfigFocusOpts,i3ConfigFocusOutput,i3ConfigString,i3ConfigSeparator keepend + +" 6.8 Focusing workspaces (4.21) +syn region i3ConfigAction start=/workspace / skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigWorkspaceKeyword,i3ConfigWorkspaceDir,i3ConfigNumber,i3ConfigString,i3ConfigGaps,i3ConfigWorkspaceOutput,i3ConfigVariable,i3ConfigBoolean,i3ConfigSeparator keepend + +" 6.9-6.11 Moving containers +syn keyword i3ConfigMoveKeyword move contained +syn keyword i3ConfigMoveDir left right down up position absolute center to contained +syn keyword i3ConfigMoveType window container workspace output mark mouse scratchpad contained +syn match i3ConfigUnit / px\| ppt/ contained +syn region i3ConfigAction start=/move/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMoveKeyword,i3ConfigMoveDir,i3ConfigMoveType,i3ConfigWorkspaceDir,i3ConfigUnit,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend + +" 6.12 Resizing containers/windows +syn keyword i3ConfigResizeKeyword resize contained +syn keyword i3ConfigResizeOpts grow shrink up down left right set width height or contained +syn region i3ConfigAction start=/resize/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigResizeKeyword,i3ConfigResizeOpts,i3ConfigNumber,i3ConfigUnit,i3ConfigSeparator keepend + +" 6.14 VIM-like marks +syn keyword i3ConfigMarkKeyword mark contained +syn match i3ConfigMark /mark\( --\(add\|replace\)\( --toggle\)\?\)\?/ contained contains=i3ConfigMarkKeyword +syn region i3ConfigAction start=/\<mark/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMark,i3ConfigNumber,i3ConfigString,i3ConfigSeparator keepend + +" 6.24 Changing gaps (4.35) +syn region i3ConfigAction start=/gaps/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigGaps keepend + +" Commands useable in keybinds +syn keyword i3ConfigActionKeyword mode append_layout kill open fullscreen sticky split floating swap rename unmark show_marks title_window_icon title_format border restart reload exit scratchpad nop bar contained +syn keyword i3ConfigOption enable disable toggle key restore current horizontal vertical auto none normal pixel show container with id con_id contained " Define the highlighting. hi def link i3ConfigError Error hi def link i3ConfigTodo Todo -hi def link i3ConfigComment Comment -hi def link i3ConfigFontContent Type -hi def link i3ConfigFocusOnActivationType Type -hi def link i3ConfigPopupOnFullscreenType Type -hi def link i3ConfigOrientationKeyword Type -hi def link i3ConfigMouseWarpingType Type -hi def link i3ConfigFocusFollowsMouseType Type -hi def link i3ConfigGapStyleKeyword Type -hi def link i3ConfigTitleAlignKeyword Type -hi def link i3ConfigSmartGapKeyword Type -hi def link i3ConfigSmartBorderKeyword Type -hi def link i3ConfigLayoutKeyword Type -hi def link i3ConfigBorderStyleKeyword Type -hi def link i3ConfigEdgeKeyword Type -hi def link i3ConfigAction Type -hi def link i3ConfigCommand Type -hi def link i3ConfigOutput Type -hi def link i3ConfigWindowCommandSpecial Type -hi def link i3ConfigFocusWrappingType Type -hi def link i3ConfigUnitOr Type -hi def link i3ConfigFontSize Constant +hi def link i3ConfigKeyword Keyword +hi def link i3ConfigCommand Statement +hi def link i3ConfigOperator Operator +hi def link i3ConfigSeparator i3ConfigOperator +hi def link i3ConfigParen Delimiter +hi def link i3ConfigBoolean Boolean +hi def link i3ConfigString String hi def link i3ConfigColor Constant -hi def link i3ConfigNumber Constant -hi def link i3ConfigUnit Constant -hi def link i3ConfigVariableAndModifier Constant -hi def link i3ConfigTimeUnit Constant -hi def link i3ConfigModifier Constant -hi def link i3ConfigString Constant -hi def link i3ConfigNegativeSize Constant -hi def link i3ConfigInclude Constant -hi def link i3ConfigFontSeparator Special -hi def link i3ConfigVariableModifier Special -hi def link i3ConfigSizeSpecial Special -hi def link i3ConfigWindowSpecial Special -hi def link i3ConfigAssignSpecial Special -hi def link i3ConfigFontNamespace PreProc -hi def link i3ConfigBindArgument PreProc -hi def link i3ConfigNoStartupId PreProc -hi def link i3ConfigIncludeKeyword Identifier -hi def link i3ConfigFontKeyword Identifier -hi def link i3ConfigBindKeyword Identifier -hi def link i3ConfigOrientation Identifier -hi def link i3ConfigGapStyle Identifier -hi def link i3ConfigTitleAlign Identifier -hi def link i3ConfigSmartGap Identifier -hi def link i3ConfigSmartBorder Identifier -hi def link i3ConfigLayout Identifier -hi def link i3ConfigBorderStyle Identifier -hi def link i3ConfigEdge Identifier -hi def link i3ConfigFloating Identifier -hi def link i3ConfigFloatingModifier Identifier -hi def link i3ConfigCommandKeyword Identifier -hi def link i3ConfigNoFocusKeyword Identifier -hi def link i3ConfigInitializeKeyword Identifier -hi def link i3ConfigAssignKeyword Identifier -hi def link i3ConfigResourceKeyword Identifier -hi def link i3ConfigExecKeyword Identifier -hi def link i3ConfigWorkspaceKeyword Identifier -hi def link i3ConfigClientColorKeyword Identifier -hi def link i3ConfigInterprocessKeyword Identifier -hi def link i3ConfigMouseWarpingKeyword Identifier -hi def link i3ConfigFocusFollowsMouseKeyword Identifier -hi def link i3ConfigPopupOnFullscreenKeyword Identifier -hi def link i3ConfigFocusWrappingKeyword Identifier -hi def link i3ConfigForceXineramaKeyword Identifier -hi def link i3ConfigAutomaticSwitchKeyword Identifier -hi def link i3ConfigDelayUrgencyKeyword Identifier -hi def link i3ConfigFocusOnActivationKeyword Identifier -hi def link i3ConfigDrawingMarksKeyword Identifier -hi def link i3ConfigBlockKeyword Identifier -hi def link i3ConfigVariable Statement -hi def link i3ConfigArbitraryCommand Type - -let b:current_syntax = "i3config" +hi def link i3ConfigNumber Number +hi def link i3ConfigIncludeKeyword i3ConfigKeyword +hi def link i3ConfigInclude i3ConfigString +hi def link i3ConfigComment Comment +hi def link i3ConfigFontKeyword i3ConfigKeyword +hi def link i3ConfigColonOperator i3ConfigOperator +hi def link i3ConfigFontNamespace i3ConfigOption +hi def link i3ConfigFontSize i3ConfigNumber +hi def link i3ConfigFont i3ConfigString +hi def link i3ConfigBindKeyword i3ConfigKeyword +hi def link i3ConfigBindArgument i3ConfigShParam +hi def link i3ConfigBindModifier i3ConfigOperator +hi def link i3ConfigBindModkey Special +hi def link i3ConfigBindCombo SpecialChar +hi def link i3ConfigSizeSpecial i3ConfigOperator +hi def link i3ConfigOrientationOpts i3ConfigOption +hi def link i3ConfigWorkspaceLayoutOpts i3ConfigOption +hi def link i3ConfigTitleAlignOpts i3ConfigOption +hi def link i3ConfigBorderOpts i3ConfigOption +hi def link i3ConfigEdgeOpts i3ConfigOption +hi def link i3ConfigSmartBorderOpts i3ConfigOption +hi def link i3ConfigForWindowKeyword i3ConfigKeyword +hi def link i3ConfigVariable Variable +hi def link i3ConfigSetKeyword i3ConfigKeyword +hi def link i3ConfigResourceKeyword i3ConfigKeyword +hi def link i3ConfigResource i3ConfigString +hi def link i3ConfigAssignKeyword i3ConfigKeyword +hi def link i3ConfigAssignSpecial i3ConfigOption +hi def link i3ConfigExecKeyword i3ConfigCommand +hi def link i3ConfigExecAlwaysKeyword i3ConfigKeyword +hi def link i3ConfigShParam PreProc +hi def link i3ConfigShDelim Delimiter +hi def link i3ConfigShOper Operator +hi def link i3ConfigShCmdDelim i3ConfigShDelim +hi def link i3ConfigShCommand Normal +hi def link i3ConfigWorkspaceKeyword i3ConfigCommand +hi def link i3ConfigWorkspaceOutput i3ConfigOption +hi def link i3ConfigWorkspaceDir i3ConfigOption +hi def link i3ConfigDotOperator i3ConfigOperator +hi def link i3ConfigClientOpts i3ConfigOption +hi def link i3ConfigIpcKeyword i3ConfigKeyword +hi def link i3ConfigIpc i3ConfigString +hi def link i3ConfigFocusFollowsMouseOpts i3ConfigOption +hi def link i3ConfigFocusFollowsMouse i3ConfigKeyword +hi def link i3ConfigMouseWarpingOpts i3ConfigOption +hi def link i3ConfigMouseWarping i3ConfigKeyword +hi def link i3ConfigPopupFullscreenOpts i3ConfigOption +hi def link i3ConfigPopupFullscreen i3ConfigKeyword +hi def link i3ConfigFocusWrappingOpts i3ConfigOption +hi def link i3ConfigFocusWrapping i3ConfigKeyword +hi def link i3ConfigForceXinerama i3ConfigKeyword +hi def link i3ConfigAutomaticSwitch i3ConfigKeyword +hi def link i3ConfigTimeUnit i3ConfigNumber +hi def link i3ConfigDelayUrgency i3ConfigKeyword +hi def link i3ConfigFocusOnActivationOpts i3ConfigOption +hi def link i3ConfigFocusOnActivation i3ConfigKeyword +hi def link i3ConfigShowMarks i3ConfigCommand +hi def link i3ConfigTilingDragOpts i3ConfigOption +hi def link i3ConfigTilingDrag i3ConfigKeyword +hi def link i3ConfigGapsOpts i3ConfigOption +hi def link i3ConfigGaps i3ConfigCommand +hi def link i3ConfigSmartGapOpts i3ConfigOption +hi def link i3ConfigSmartGap i3ConfigKeyword +hi def link i3ConfigBarModifier i3ConfigKeyword +hi def link i3ConfigBarOpts i3ConfigKeyword +hi def link i3ConfigColorsOpts i3ConfigOption +hi def link i3ConfigColors i3ConfigKeyword +hi def link i3ConfigConditionProp i3ConfigShParam +hi def link i3ConfigConditionFocused Constant +hi def link i3ConfigExecActionKeyword i3ConfigShCommand +hi def link i3ConfigExecAction i3ConfigString +hi def link i3ConfigLayoutKeyword i3ConfigCommand +hi def link i3ConfigLayoutOpts i3ConfigOption +hi def link i3ConfigFocusKeyword i3ConfigCommand +hi def link i3ConfigFocusOpts i3ConfigOption +hi def link i3ConfigFocusOutputOpts i3ConfigOption +hi def link i3ConfigMoveKeyword i3ConfigCommand +hi def link i3ConfigMoveDir i3ConfigOption +hi def link i3ConfigMoveType i3ConfigOption +hi def link i3ConfigUnit i3ConfigNumber +hi def link i3ConfigResizeKeyword i3ConfigCommand +hi def link i3ConfigResizeOpts i3ConfigOption +hi def link i3ConfigMarkKeyword i3ConfigCommand +hi def link i3ConfigMark i3ConfigShParam +hi def link i3ConfigActionKeyword i3ConfigCommand +hi def link i3ConfigOption Type + +let b:current_syntax = "i3config"
\ No newline at end of file diff --git a/runtime/syntax/masm.vim b/runtime/syntax/masm.vim index 3be0fd45d1..85e457106d 100644 --- a/runtime/syntax/masm.vim +++ b/runtime/syntax/masm.vim @@ -2,7 +2,7 @@ " Language: Microsoft Macro Assembler (80x86) " Orig Author: Rob Brady <robb@datatone.com> " Maintainer: Wu Yongwei <wuyongwei@gmail.com> -" Last Change: 2022-04-24 20:07:04 +0800 +" Last Change: 2023-09-09 20:48:26 +0800 " Quit when a syntax file was already loaded if exists("b:current_syntax") @@ -194,8 +194,8 @@ syn keyword masmRegister R8W R9W R10W R11W R12W R13W R14W R15W syn keyword masmRegister R8B R9B R10B R11B R12B R13B R14B R15B " SSE/AVX registers -syn match masmRegister "\(X\|Y\)MM[0-9]\>" -syn match masmRegister "\(X\|Y\)MM1[0-5]\>" +syn match masmRegister "\(X\|Y\|Z\)MM[12]\?[0-9]\>" +syn match masmRegister "\(X\|Y\|Z\)MM3[01]\>" " Instruction prefixes syn keyword masmOpcode LOCK REP REPE REPNE REPNZ REPZ @@ -338,11 +338,192 @@ syn keyword masmOpcode VINSERTF128 VEXTRACTF128 VMASKMOVPS VMASKMOVPD syn keyword masmOpcode VPERMILPS VPERMILPD VPERM2F128 syn keyword masmOpcode VZEROALL VZEROUPPER +" AVX-2 (Haswell and later) +syn keyword masmOpcode VPBROADCASTB VPBROADCASTW VPBROADCASTD +syn keyword masmOpcode VPBROADCASTQ VBROADCASTI128 +syn keyword masmOpcode VINSERTI128 VEXTRACTI128 +syn keyword masmOpcode VGATHERDPD VGATHERQPD VGATHERDPS VGATHERQPS +syn keyword masmOpcode VPGATHERDD VPGATHERDQ VPGATHERQD VPGATHERQQ +syn keyword masmOpcode VPMASKMOVD VPMASKMOVQ +syn keyword masmOpcode PERMPS VPERMD VPERMPD VPERMQ VPERM2I128 +syn keyword masmOpcode VPBLENDD VPSLLVD VPSLLVQ VPSRLVD VPSRLVQ +syn keyword masmOpcode VPSRAVD + +" AVX-512 (Knights Landing/Skylake-X and later) +syn keyword masmOpcode KAND KANDN KMOV KUNPCK KNOT KOR KORTEST +syn keyword masmOpcode KSHIFTL KSHIFTR KXNOR KXOR KADD KTEST +syn keyword masmOpcode VBLENDMPD VBLENDMPS +syn keyword masmOpcode VPBLENDMD VPBLENDMQ VPBLENDMB VPBLENDMW +syn keyword masmOpcode VPCMPD VPCMPUD VPCMPQ VPCMPUQ +syn keyword masmOpcode VPCMPB VPCMPUB VPCMPW VPCMPUW +syn keyword masmOpcode VPTESTMD VPTESTMQ VPTESTNMD VPTESTNMQ +syn keyword masmOpcode VPTESTMB VPTESTMW VPTESTNMB VPTESTNMW +syn keyword masmOpcode VCOMPRESSPD VCOMPRESSPS VPCOMPRESSD VPCOMPRESSQ +syn keyword masmOpcode VEXPANDPD VEXPANDPS VPEXPANDD VPEXPANDQ +syn keyword masmOpcode VPERMB VPERMW VPERMT2B VPERMT2W VPERMI2PD +syn keyword masmOpcode VPERMI2PS VPERMI2D VPERMI2Q VPERMI2B VPERMI2W +syn keyword masmOpcode VPERMT2PS VPERMT2PD VPERMT2D VPERMT2Q +syn keyword masmOpcode VSHUFF32x4 VSHUFF64x2 VSHUFI32x4 VSHUFI64x2 +syn keyword masmOpcode VPMULTISHIFTQB VPTERNLOGD VPTERNLOGQ +syn keyword masmOpcode VPMOVQD VPMOVSQD VPMOVUSQD VPMOVQW VPMOVSQW +syn keyword masmOpcode VPMOVUSQW VPMOVQB VPMOVSQB VPMOVUSQB VPMOVDW +syn keyword masmOpcode VPMOVSDW VPMOVUSDW VPMOVDB VPMOVSDB VPMOVUSDB +syn keyword masmOpcode VPMOVWB VPMOVSWB VPMOVUSWB +syn keyword masmOpcode VCVTPS2UDQ VCVTPD2UDQ VCVTTPS2UDQ VCVTTPD2UDQ +syn keyword masmOpcode VCVTSS2USI VCVTSD2USI VCVTTSS2USI VCVTTSD2USI +syn keyword masmOpcode VCVTPS2QQ VCVTPD2QQ VCVTPS2UQQ VCVTPD2UQQ +syn keyword masmOpcode VCVTTPS2QQ VCVTTPD2QQ VCVTTPS2UQQ VCVTTPD2UQQ +syn keyword masmOpcode VCVTUDQ2PS VCVTUDQ2PD VCVTUSI2PS VCVTUSI2PD +syn keyword masmOpcode VCVTUSI2SD VCVTUSI2SS VCVTUQQ2PS VCVTUQQ2PD +syn keyword masmOpcode VCVTQQ2PD VCVTQQ2PS VGETEXPPD +syn keyword masmOpcode VGETEXPPS VGETEXPSD VGETEXPSS +syn keyword masmOpcode VGETMANTPD VGETMANTPS VGETMANTSD VGETMANTSS +syn keyword masmOpcode VFIXUPIMMPD VFIXUPIMMPS VFIXUPIMMSD VFIXUPIMMSS +syn keyword masmOpcode VRCP14PD VRCP14PS VRCP14SD VRCP14SS +syn keyword masmOpcode VRNDSCALEPS VRNDSCALEPD VRNDSCALESS VRNDSCALESD +syn keyword masmOpcode VRSQRT14PD VRSQRT14PS VRSQRT14SD VRSQRT14SS +syn keyword masmOpcode VSCALEFPS VSCALEFPD VSCALEFSS VSCALEFSD +syn keyword masmOpcode VBROADCASTI32X2 VBROADCASTI32X4 VBROADCASTI32X8 +syn keyword masmOpcode VBROADCASTI64X2 VBROADCASTI64X4 +syn keyword masmOpcode VALIGND VALIGNQ VDBPSADBW VPABSQ VPMAXSQ +syn keyword masmOpcode VPMAXUQ VPMINSQ VPMINUQ VPROLD VPROLVD VPROLQ +syn keyword masmOpcode VPROLVQ VPRORD VPRORVD VPRORQ VPRORVQ +syn keyword masmOpcode VPSCATTERDD VPSCATTERDQ VPSCATTERQD VPSCATTERQQ +syn keyword masmOpcode VSCATTERDPS VSCATTERDPD VSCATTERQPS VSCATTERQPD +syn keyword masmOpcode VPCONFLICTD VPCONFLICTQ VPLZCNTD VPLZCNTQ +syn keyword masmOpcode VPBROADCASTMB2Q VPBROADCASTMW2D +syn keyword masmOpcode VEXP2PD VEXP2PS +syn keyword masmOpcode VRCP28PD VRCP28PS VRCP28SD VRCP28SS +syn keyword masmOpcode VRSQRT28PD VRSQRT28PS VRSQRT28SD VRSQRT28SS +syn keyword masmOpcode VGATHERPF0DPS VGATHERPF0QPS VGATHERPF0DPD +syn keyword masmOpcode VGATHERPF0QPD VGATHERPF1DPS VGATHERPF1QPS +syn keyword masmOpcode VGATHERPF1DPD VGATHERPF1QPD VSCATTERPF0DPS +syn keyword masmOpcode VSCATTERPF0QPS VSCATTERPF0DPD VSCATTERPF0QPD +syn keyword masmOpcode VSCATTERPF1DPS VSCATTERPF1QPS VSCATTERPF1DPD +syn keyword masmOpcode VSCATTERPF1QPD +syn keyword masmOpcode V4FMADDPS V4FMADDSS V4FNMADDPS V4FNMADDSS +syn keyword masmOpcode VP4DPWSSD VP4DPWSSDS +syn keyword masmOpcode VFPCLASSPS VFPCLASSPD VFPCLASSSS VFPCLASSSD +syn keyword masmOpcode VRANGEPS VRANGEPD VRANGESS VRANGESD +syn keyword masmOpcode VREDUCEPS VREDUCEPD VREDUCESS VREDUCESD +syn keyword masmOpcode VPMOVM2D VPMOVM2Q VPMOVM2B VPMOVM2W VPMOVD2M +syn keyword masmOpcode VPMOVQ2M VPMOVB2M VPMOVW2M VPMULLQ +syn keyword masmOpcode VPCOMPRESSB VPCOMPRESSW VPEXPANDB VPEXPANDW +syn keyword masmOpcode VPSHLD VPSHLDV VPSHRD VPSHRDV +syn keyword masmOpcode VPDPBUSD VPDPBUSDS VPDPWSSD VPDPWSSDS +syn keyword masmOpcode VPMADD52LUQ VPMADD52HUQ +syn keyword masmOpcode VPOPCNTD VPOPCNTQ VPOPCNTB VPOPCNTW +syn keyword masmOpcode VPSHUFBITQMB VP2INTERSECTD VP2INTERSECTQ +syn keyword masmOpcode VGF2P8AFFINEINVQB VGF2P8AFFINEQB +syn keyword masmOpcode VGF2P8MULB VPCLMULQDQ +syn keyword masmOpcode VAESDEC VAESDECLAST VAESENC VAESENCLAST +syn keyword masmOpcode VCVTNE2PS2BF16 VCVTNEPS2BF16 VDPBF16PS +syn keyword masmOpcode VADDPH VADDSH VSUBPH VSUBSH VMULPH VMULSH +syn keyword masmOpcode VDIVPH VDIVSH VSQRTPH VSQRTSH +syn keyword masmOpcode VFMADD132PH VFMADD213PH VFMADD231PH +syn keyword masmOpcode VFMADD132SH VFMADD213SH VFMADD231SH +syn keyword masmOpcode VFNMADD132PH VFNMADD213PH VFNMADD231PH +syn keyword masmOpcode VFNMADD132SH VFNMADD213SH VFNMADD231SH +syn keyword masmOpcode VFMSUB132PH VFMSUB213PH VFMSUB231PH +syn keyword masmOpcode VFMSUB132SH VFMSUB213SH VFMSUB231SH +syn keyword masmOpcode VFNMSUB132PH VFNMSUB213PH VFNMSUB231PH +syn keyword masmOpcode VFNMSUB132SH VFNMSUB213SH VFNMSUB231SH +syn keyword masmOpcode VFMADDSUB132PH VFMADDSUB213PH VFMADDSUB231PH +syn keyword masmOpcode VFMSUBADD132PH VFMSUBADD213PH VFMSUBADD231PH +syn keyword masmOpcode VREDUCEPH VREDUCESH VRNDSCALEPH VRNDSCALESH +syn keyword masmOpcode VSCALEFPH VSCALEFSH VFMULCPH VFMULCSH VFCMULCPH +syn keyword masmOpcode VFCMULCSH VFMADDCPH VFMADDCSH VFCMADDCPH +syn keyword masmOpcode VFCMADDCSH VRCPPH VRCPSH VRSQRTPH VRSQRTSH +syn keyword masmOpcode VCMPPH VCMPSH VCOMISH VUCOMISH VMAXPH VMAXSH +syn keyword masmOpcode VMINPH VMINSH VFPCLASSPH VFPCLASSSH +syn keyword masmOpcode VCVTW2PH VCVTUW2PH VCVTDQ2PH VCVTUDQ2PH +syn keyword masmOpcode VCVTQQ2PH VCVTUQQ2PH VCVTPS2PHX VCVTPD2PH +syn keyword masmOpcode VCVTSI2SH VCVTUSI2SH VCVTSS2SH VCVTSD2SH +syn keyword masmOpcode VCVTPH2W VCVTTPH2W VCVTPH2UW VCVTTPH2UW +syn keyword masmOpcode VCVTPH2DQ VCVTTPH2DQ VCVTPH2UDQ VCVTTPH2UDQ +syn keyword masmOpcode VCVTPH2QQ VCVTTPH2QQ VCVTPH2UQQ VCVTTPH2UQQ +syn keyword masmOpcode VCVTPH2PSX VCVTPH2PD VCVTSH2SI VCVTTSH2SI +syn keyword masmOpcode VCVTSH2USI VCVTTSH2USI VCVTSH2SS VCVTSH2SD +syn keyword masmOpcode VGETEXPPH VGETEXPSH VGETMANTPH VGETMANTSH +syn keyword masmOpcode VMOVSH VMOVW VADDPD VADDPS VADDSD VADDSS +syn keyword masmOpcode VANDPD VANDPS VANDNPD VANDNPS +syn keyword masmOpcode VCMPPD VCMPPS VCMPSD VCMPSS +syn keyword masmOpcode VCOMISD VCOMISS VDIVPD VDIVPS VDIVSD VDIVSS +syn keyword masmOpcode VCVTDQ2PD VCVTDQ2PS VCVTPD2DQ VCVTPD2PS +syn keyword masmOpcode VCVTPH2PS VCVTPS2PH VCVTPS2DQ VCVTPS2PD +syn keyword masmOpcode VCVTSD2SI VCVTSD2SS VCVTSI2SD VCVTSI2SS +syn keyword masmOpcode VCVTSS2SD VCVTSS2SI VCVTTPD2DQ VCVTTPS2DQ +syn keyword masmOpcode VCVTTSD2SI VCVTTSS2SI VMAXPD VMAXPS +syn keyword masmOpcode VMAXSD VMAXSS VMINPD VMINPS VMINSD VMINSS +syn keyword masmOpcode VMOVAPD VMOVAPS VMOVD VMOVQ VMOVDDUP +syn keyword masmOpcode VMOVHLPS VMOVHPD VMOVHPS VMOVLHPS VMOVLPD +syn keyword masmOpcode VMOVLPS VMOVNTDQA VMOVNTDQ VMOVNTPD VMOVNTPS +syn keyword masmOpcode VMOVSD VMOVSHDUP VMOVSLDUP VMOVSS VMOVUPD +syn keyword masmOpcode VMOVUPS VMOVDQA32 VMOVDQA64 VMOVDQU8 +syn keyword masmOpcode VMOVDQU16 VMOVDQU32 VMOVDQU64 VMULPD VMULPS +syn keyword masmOpcode VMULSD VMULSS VORPD VORPS VSQRTPD VSQRTPS +syn keyword masmOpcode VSQRTSD VSQRTSS VSUBPD VSUBPS VSUBSD VSUBSS +syn keyword masmOpcode VUCOMISD VUCOMISS VUNPCKHPD VUNPCKHPS VUNPCKLPD +syn keyword masmOpcode VUNPCKLPS VXORPD VXORPS VEXTRACTPS VINSERTPS +syn keyword masmOpcode VPEXTRB VPEXTRW VPEXTRD VPEXTRQ VPINSRB VPINSRW +syn keyword masmOpcode VPINSRD VPINSRQ VPACKSSWB VPACKSSDW VPACKUSDW +syn keyword masmOpcode VPACKUSWB VPADDB VPADDW VPADDD VPADDQ VPADDSB +syn keyword masmOpcode VPADDSW VPADDUSB VPADDUSW VPANDD VPANDQ VPANDND +syn keyword masmOpcode VPANDNQ VPAVGB VPAVGW VPCMPEQB VPCMPEQW +syn keyword masmOpcode VPCMPEQD VPCMPEQQ VPCMPGTB VPCMPGTW VPCMPGTD +syn keyword masmOpcode VPCMPGTQ VPMAXSB VPMAXSW VPMAXSD VPMAXSQ +syn keyword masmOpcode VPMAXUB VPMAXUW VPMAXUD VPMAXUQ VPMINSB VPMINSW +syn keyword masmOpcode VPMINSD VPMINSQ VPMINUB VPMINUW VPMINUD VPMINUQ +syn keyword masmOpcode VPMOVSXBW VPMOVSXBD VPMOVSXBQ VPMOVSXWD +syn keyword masmOpcode VPMOVSXWQ VPMOVSXDQ VPMOVZXBW VPMOVZXBD +syn keyword masmOpcode VPMOVZXBQ VPMOVZXWD VPMOVZXWQ VPMOVZXDQ VPMULDQ +syn keyword masmOpcode VPMULUDQ VPMULHRSW VPMULHUW VPMULHW VPMULLD +syn keyword masmOpcode VPMULLQ VPMULLW VPORD VPORQ VPSUBB VPSUBW +syn keyword masmOpcode VPSUBD VPSUBQ VPSUBSB VPSUBSW VPSUBUSB VPSUBUSW +syn keyword masmOpcode VPUNPCKHBW VPUNPCKHWD VPUNPCKHDQ VPUNPCKHQDQ +syn keyword masmOpcode VPUNPCKLBW VPUNPCKLWD VPUNPCKLDQ VPUNPCKLQDQ +syn keyword masmOpcode VPXORD VPXORQ VPSADBW VPSHUFB VPSHUFHW VPSHUFLW +syn keyword masmOpcode VPSHUFD VPSLLDQ VPSLLW VPSLLD VPSLLQ VPSRAW +syn keyword masmOpcode VPSRAD VPSRAQ VPSRLDQ VPSRLW VPSRLD VPSRLQ +syn keyword masmOpcode VPSLLVW VPSRLVW VPSHUFPD VPSHUFPS VEXTRACTF32X4 +syn keyword masmOpcode VEXTRACTF64X2 VEXTRACTF32X8 VEXTRACTF64X4 +syn keyword masmOpcode VEXTRACTI32X4 VEXTRACTI64X2 VEXTRACTI32X8 +syn keyword masmOpcode VEXTRACTI64X4 VINSERTF32x4 VINSERTF64X2 +syn keyword masmOpcode VINSERTF32X8 VINSERTF64x4 VINSERTI32X4 +syn keyword masmOpcode VINSERTI64X2 VINSERTI32X8 VINSERTI64X4 +syn keyword masmOpcode VPABSB VPABSW VPABSD VPABSQ VPALIGNR +syn keyword masmOpcode VPMADDUBSW VPMADDWD +syn keyword masmOpcode VFMADD132PD VFMADD213PD VFMADD231PD +syn keyword masmOpcode VFMADD132PS VFMADD213PS VFMADD231PS +syn keyword masmOpcode VFMADD132SD VFMADD213SD VFMADD231SD +syn keyword masmOpcode VFMADD132SS VFMADD213SS VFMADD231SS +syn keyword masmOpcode VFMADDSUB132PD VFMADDSUB213PD VFMADDSUB231PD +syn keyword masmOpcode VFMADDSUB132PS VFMADDSUB213PS VFMADDSUB231PS +syn keyword masmOpcode VFMSUBADD132PD VFMSUBADD213PD VFMSUBADD231PD +syn keyword masmOpcode VFMSUBADD132PS VFMSUBADD213PS VFMSUBADD231PS +syn keyword masmOpcode VFMSUB132PD VFMSUB213PD VFMSUB231PD +syn keyword masmOpcode VFMSUB132PS VFMSUB213PS VFMSUB231PS +syn keyword masmOpcode VFMSUB132SD VFMSUB213SD VFMSUB231SD +syn keyword masmOpcode VFMSUB132SS VFMSUB213SS VFMSUB231SS +syn keyword masmOpcode VFNMADD132PD VFNMADD213PD VFNMADD231PD +syn keyword masmOpcode VFNMADD132PS VFNMADD213PS VFNMADD231PS +syn keyword masmOpcode VFNMADD132SD VFNMADD213SD VFNMADD231SD +syn keyword masmOpcode VFNMADD132SS VFNMADD213SS VFNMADD231SS +syn keyword masmOpcode VFNMSUB132PD VFNMSUB213PD VFNMSUB231PD +syn keyword masmOpcode VFNMSUB132PS VFNMSUB213PS VFNMSUB231PS +syn keyword masmOpcode VFNMSUB132SD VFNMSUB213SD VFNMSUB231SD +syn keyword masmOpcode VFNMSUB132SS VFNMSUB213SS VFNMSUB231SS +syn keyword masmOpcode VPSRAVW VPSRAVQ + " Other opcodes in Pentium and later processors syn keyword masmOpcode CMPXCHG8B CPUID UD2 syn keyword masmOpcode RSM RDMSR WRMSR RDPMC RDTSC SYSENTER SYSEXIT syn match masmOpcode "CMOV\(P[EO]\|\(N\?\([ABGL]E\?\|[CEOPSZ]\)\)\)\>" +" Not really used by MASM, but useful for viewing GCC-generated assembly code +" in Intel syntax +syn match masmHexadecimal "[-+]\?0[Xx]\x*" +syn keyword masmOpcode MOVABS " The default highlighting hi def link masmLabel PreProc diff --git a/runtime/syntax/mojo.vim b/runtime/syntax/mojo.vim new file mode 100644 index 0000000000..b7dae24a15 --- /dev/null +++ b/runtime/syntax/mojo.vim @@ -0,0 +1,316 @@ +" Vim syntax file +" Language: Mojo +" Maintainer: Mahmoud Abduljawad <me@mahmoudajawad.com> +" Last Change: 2023 Sep 09 +" Credits: Mahmoud Abduljawad <me@mahmoudajawad.com> +" Neil Schemenauer <nas@python.ca> +" Dmitry Vasiliev +" +" This is based on Vim Python highlighting +" +" - introduced highlighting of doctests +" - updated keywords, built-ins, and exceptions +" - corrected regular expressions for +" +" * functions +" * decorators +" * strings +" * escapes +" * numbers +" * space error +" +" - corrected synchronization +" - more highlighting is ON by default, except +" - space error highlighting is OFF by default +" +" Optional highlighting can be controlled using these variables. +" +" let mojo_no_builtin_highlight = 1 +" let mojo_no_doctest_code_highlight = 1 +" let mojo_no_doctest_highlight = 1 +" let mojo_no_exception_highlight = 1 +" let mojo_no_number_highlight = 1 +" let mojo_space_error_highlight = 1 +" +" All the options above can be switched on together. +" +" let mojo_highlight_all = 1 +" +" The use of Python 2 compatible syntax highlighting can be enforced. +" The straddling code (Python 2 and 3 compatible), up to Python 3.5, +" will be also supported. +" +" let mojo_use_python2_syntax = 1 +" +" This option will exclude all modern Python 3.6 or higher features. +" + +" quit when a syntax file was already loaded. +if exists("b:current_syntax") + finish +endif + +" We need nocompatible mode in order to continue lines with backslashes. +" Original setting will be restored. +let s:cpo_save = &cpo +set cpo&vim + +if exists("mojo_no_doctest_highlight") + let mojo_no_doctest_code_highlight = 1 +endif + +if exists("mojo_highlight_all") + if exists("mojo_no_builtin_highlight") + unlet mojo_no_builtin_highlight + endif + if exists("mojo_no_doctest_code_highlight") + unlet mojo_no_doctest_code_highlight + endif + if exists("mojo_no_doctest_highlight") + unlet mojo_no_doctest_highlight + endif + if exists("mojo_no_exception_highlight") + unlet mojo_no_exception_highlight + endif + if exists("mojo_no_number_highlight") + unlet mojo_no_number_highlight + endif + let mojo_space_error_highlight = 1 +endif + +" These keywords are based on Python syntax highlight, and adds to it struct, +" fn, alias, var, let +" +syn keyword mojoStatement False None True +syn keyword mojoStatement as assert break continue del global +syn keyword mojoStatement lambda nonlocal pass return with yield +syn keyword mojoStatement class def nextgroup=mojoFunction skipwhite +syn keyword mojoStatement struct fn nextgroup=mojoFunction skipwhite +syn keyword mojoStatement alias var let +syn keyword mojoConditional elif else if +syn keyword mojoRepeat for while +syn keyword mojoOperator and in is not or +syn keyword mojoException except finally raise try +syn keyword mojoInclude from import +syn keyword mojoAsync async await + +" Soft keywords +" These keywords do not mean anything unless used in the right context. +" See https://docs.python.org/3/reference/lexical_analysis.html#soft-keywords +" for more on this. +syn match mojoConditional "^\s*\zscase\%(\s\+.*:.*$\)\@=" +syn match mojoConditional "^\s*\zsmatch\%(\s\+.*:\s*\%(#.*\)\=$\)\@=" + +" Decorators +" A dot must be allowed because of @MyClass.myfunc decorators. +syn match mojoDecorator "@" display contained +syn match mojoDecoratorName "@\s*\h\%(\w\|\.\)*" display contains=pythonDecorator + +" Python 3.5 introduced the use of the same symbol for matrix multiplication: +" https://www.python.org/dev/peps/pep-0465/. We now have to exclude the +" symbol from highlighting when used in that context. +" Single line multiplication. +syn match mojoMatrixMultiply + \ "\%(\w\|[])]\)\s*@" + \ contains=ALLBUT,mojoDecoratorName,mojoDecorator,mojoFunction,mojoDoctestValue + \ transparent +" Multiplication continued on the next line after backslash. +syn match mojoMatrixMultiply + \ "[^\\]\\\s*\n\%(\s*\.\.\.\s\)\=\s\+@" + \ contains=ALLBUT,mojoDecoratorName,mojoDecorator,mojoFunction,mojoDoctestValue + \ transparent +" Multiplication in a parenthesized expression over multiple lines with @ at +" the start of each continued line; very similar to decorators and complex. +syn match mojoMatrixMultiply + \ "^\s*\%(\%(>>>\|\.\.\.\)\s\+\)\=\zs\%(\h\|\%(\h\|[[(]\).\{-}\%(\w\|[])]\)\)\s*\n\%(\s*\.\.\.\s\)\=\s\+@\%(.\{-}\n\%(\s*\.\.\.\s\)\=\s\+@\)*" + \ contains=ALLBUT,mojoDecoratorName,mojoDecorator,mojoFunction,mojoDoctestValue + \ transparent + +syn match mojoFunction "\h\w*" display contained + +syn match mojoComment "#.*$" contains=mojoTodo,@Spell +syn keyword mojoTodo FIXME NOTE NOTES TODO XXX contained + +" Triple-quoted strings can contain doctests. +syn region mojoString matchgroup=mojoQuotes + \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" + \ contains=mojoEscape,@Spell +syn region mojoString matchgroup=mojoTripleQuotes + \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend + \ contains=mojoEscape,mojoSpaceError,mojoDoctest,@Spell +syn region mojoRawString matchgroup=mojoQuotes + \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" + \ contains=@Spell +syn region mojoRawString matchgroup=pythonTripleQuotes + \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend + \ contains=pythonSpaceError,mojoDoctest,@Spell + +syn match mojoEscape +\\[abfnrtv'"\\]+ contained +syn match mojoEscape "\\\o\{1,3}" contained +syn match mojoEscape "\\x\x\{2}" contained +syn match mojoEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained +" Python allows case-insensitive Unicode IDs: http://www.unicode.org/charts/ +syn match mojoEscape "\\N{\a\+\%(\s\a\+\)*}" contained +syn match mojoEscape "\\$" + +" It is very important to understand all details before changing the +" regular expressions below or their order. +" The word boundaries are *not* the floating-point number boundaries +" because of a possible leading or trailing decimal point. +" The expressions below ensure that all valid number literals are +" highlighted, and invalid number literals are not. For example, +" +" - a decimal point in '4.' at the end of a line is highlighted, +" - a second dot in 1.0.0 is not highlighted, +" - 08 is not highlighted, +" - 08e0 or 08j are highlighted, +" +" and so on, as specified in the 'Python Language Reference'. +" https://docs.python.org/reference/lexical_analysis.html#numeric-literals +if !exists("mojo_no_number_highlight") + " numbers (including complex) + syn match mojoNumber "\<0[oO]\%(_\=\o\)\+\>" + syn match mojoNumber "\<0[xX]\%(_\=\x\)\+\>" + syn match mojoNumber "\<0[bB]\%(_\=[01]\)\+\>" + syn match mojoNumber "\<\%([1-9]\%(_\=\d\)*\|0\+\%(_\=0\)*\)\>" + syn match mojoNumber "\<\d\%(_\=\d\)*[jJ]\>" + syn match mojoNumber "\<\d\%(_\=\d\)*[eE][+-]\=\d\%(_\=\d\)*[jJ]\=\>" + syn match mojoNumber + \ "\<\d\%(_\=\d\)*\.\%([eE][+-]\=\d\%(_\=\d\)*\)\=[jJ]\=\%(\W\|$\)\@=" + syn match mojoNumber + \ "\%(^\|\W\)\zs\%(\d\%(_\=\d\)*\)\=\.\d\%(_\=\d\)*\%([eE][+-]\=\d\%(_\=\d\)*\)\=[jJ]\=\>" +endif + +" The built-ins are added in the same order of appearance in Mojo stdlib docs +" https://docs.modular.com/mojo/lib.html +" +if !exists("mojo_no_builtin_highlight") + " Built-in functions + syn keyword mojoBuiltin slice constrained debug_assert put_new_line print + syn keyword mojoBuiltin print_no_newline len range rebind element_type + syn keyword mojoBuiltin ord chr atol isdigit index address string + " Built-in types + syn keyword mojoType Byte ListLiteral CoroutineContext Coroutine DType + syn keyword mojoType dtype type invalid bool int8 si8 unit8 ui8 int16 + syn keyword mojoType si16 unit16 ui16 int32 si32 uint32 ui32 int64 + syn keyword mojoType si64 uint64 ui64 bfloat16 bf16 float16 f16 float32 + syn keyword mojoType f32 float64 f64 Error FloatLiteral Int Attr SIMD + syn keyword mojoType Int8 UInt8 Int16 UInt16 Int32 UInt32 Int64 UInt64 + syn keyword mojoType Float16 Float32 Float64 element_type _65x13_type + syn keyword mojoType String StringLiteral StringRef Tuple AnyType + syn keyword mojoType NoneType None Lifetime + " avoid highlighting attributes as builtins + syn match mojoAttribute /\.\h\w*/hs=s+1 + \ contains=ALLBUT,mojoBuiltin,mojoFunction,mojoAsync + \ transparent +endif + +" From the 'Python Library Reference' class hierarchy at the bottom. +" http://docs.python.org/library/exceptions.html +if !exists("mojo_no_exception_highlight") + " builtin base exceptions (used mostly as base classes for other exceptions) + syn keyword mojoExceptions BaseException Exception + syn keyword mojoExceptions ArithmeticError BufferError LookupError + " builtin exceptions (actually raised) + syn keyword mojoExceptions AssertionError AttributeError EOFError + syn keyword mojoExceptions FloatingPointError GeneratorExit ImportError + syn keyword mojoExceptions IndentationError IndexError KeyError + syn keyword mojoExceptions KeyboardInterrupt MemoryError + syn keyword mojoExceptions ModuleNotFoundError NameError + syn keyword mojoExceptions NotImplementedError OSError OverflowError + syn keyword mojoExceptions RecursionError ReferenceError RuntimeError + syn keyword mojoExceptions StopAsyncIteration StopIteration SyntaxError + syn keyword mojoExceptions SystemError SystemExit TabError TypeError + syn keyword mojoExceptions UnboundLocalError UnicodeDecodeError + syn keyword mojoExceptions UnicodeEncodeError UnicodeError + syn keyword mojoExceptions UnicodeTranslateError ValueError + syn keyword mojoExceptions ZeroDivisionError + " builtin exception aliases for OSError + syn keyword mojoExceptions EnvironmentError IOError WindowsError + " builtin OS exceptions in Python 3 + syn keyword mojoExceptions BlockingIOError BrokenPipeError + syn keyword mojoExceptions ChildProcessError ConnectionAbortedError + syn keyword mojoExceptions ConnectionError ConnectionRefusedError + syn keyword mojoExceptions ConnectionResetError FileExistsError + syn keyword mojoExceptions FileNotFoundError InterruptedError + syn keyword mojoExceptions IsADirectoryError NotADirectoryError + syn keyword mojoExceptions PermissionError ProcessLookupError TimeoutError + " builtin warnings + syn keyword mojoExceptions BytesWarning DeprecationWarning FutureWarning + syn keyword mojoExceptions ImportWarning PendingDeprecationWarning + syn keyword mojoExceptions ResourceWarning RuntimeWarning + syn keyword mojoExceptions SyntaxWarning UnicodeWarning + syn keyword mojoExceptions UserWarning Warning +endif + +if exists("mojo_space_error_highlight") + " trailing whitespace + syn match mojoSpaceError display excludenl "\s\+$" + " mixed tabs and spaces + syn match mojoSpaceError display " \+\t" + syn match mojoSpaceError display "\t\+ " +endif + +" Do not spell doctests inside strings. +" Notice that the end of a string, either ''', or """, will end the contained +" doctest too. Thus, we do *not* need to have it as an end pattern. +if !exists("mojo_no_doctest_highlight") + if !exists("mojo_no_doctest_code_highlight") + syn region mojoDoctest + \ start="^\s*>>>\s" end="^\s*$" + \ contained contains=ALLBUT,mojoDoctest,mojoFunction,@Spell + syn region mojoDoctestValue + \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$" + \ contained + else + syn region mojoDoctest + \ start="^\s*>>>" end="^\s*$" + \ contained contains=@NoSpell + endif +endif + +" Sync at the beginning of class, function, or method definition. +syn sync match mojoSync grouphere NONE "^\%(def\|class\)\s\+\h\w*\s*[(:]" + +" The default highlight links. Can be overridden later. +hi def link mojoStatement Statement +hi def link mojoConditional Conditional +hi def link mojoRepeat Repeat +hi def link mojoOperator Operator +hi def link mojoException Exception +hi def link mojoInclude Include +hi def link mojoAsync Statement +hi def link mojoDecorator Define +hi def link mojoDecoratorName Function +hi def link mojoFunction Function +hi def link mojoComment Comment +hi def link mojoTodo Todo +hi def link mojoString String +hi def link mojoRawString String +hi def link mojoQuotes String +hi def link mojoTripleQuotes mojoQuotes +hi def link mojoEscape Special +if !exists("mojo_no_number_highlight") + hi def link mojoNumber Number +endif +if !exists("mojo_no_builtin_highlight") + hi def link mojoBuiltin Function + hi def link mojoType Type +endif +if !exists("mojo_no_exception_highlight") + hi def link mojoExceptions Structure +endif +if exists("mojo_space_error_highlight") + hi def link mojoSpaceError Error +endif +if !exists("mojo_no_doctest_highlight") + hi def link mojoDoctest Special + hi def link mojoDoctestValue Define +endif + +let b:current_syntax = "mojo" + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2 ts=8 noet: diff --git a/runtime/syntax/nasm.vim b/runtime/syntax/nasm.vim index 0eb82fad10..e1dfc1db12 100644 --- a/runtime/syntax/nasm.vim +++ b/runtime/syntax/nasm.vim @@ -8,7 +8,7 @@ " Peter Stanhope <dev.rptr@gmail.com> (Add missing 64-bit mode registers) " Frédéric Hamel <rederic.hamel123@gmail.com> (F16c support, partial AVX " support, other) -" Last Change: 2022 May 3 +" Last Change: 2023 Sep 7 " NASM Home: http://www.nasm.us/ @@ -250,12 +250,12 @@ syn match nasmSegRegister "\<[C-GS]S\>" syn match nasmSpcRegister "\<E\=IP\>" syn match nasmFpuRegister "\<ST\o\>" syn match nasmMmxRegister "\<MM\o\>" -syn match nasmSseRegister "\<XMM\o\>" +syn match nasmAvxRegister "\<[XYZ]MM\d\{1,2}\>" syn match nasmCtrlRegister "\<CR\o\>" syn match nasmDebugRegister "\<DR\o\>" syn match nasmTestRegister "\<TR\o\>" syn match nasmRegisterError "\<\(CR[15-9]\|DR[4-58-9]\|TR[0-28-9]\)\>" -syn match nasmRegisterError "\<X\=MM[8-9]\>" +syn match nasmRegisterError "\<[XYZ]MM\(3[2-9]\|[04-9]\d\)\>" syn match nasmRegisterError "\<ST\((\d)\|[8-9]\>\)" syn match nasmRegisterError "\<E\([A-D][HL]\|[C-GS]S\)\>" " Memory reference operand (address): diff --git a/runtime/syntax/rust.vim b/runtime/syntax/rust.vim index 57343301e0..55d3f14dc2 100644 --- a/runtime/syntax/rust.vim +++ b/runtime/syntax/rust.vim @@ -3,44 +3,57 @@ " Maintainer: Patrick Walton <pcwalton@mozilla.com> " Maintainer: Ben Blum <bblum@cs.cmu.edu> " Maintainer: Chris Morgan <me@chrismorgan.info> -" Last Change: Feb 24, 2016 +" Last Change: 2023-09-11 " For bugs, patches and license go to https://github.com/rust-lang/rust.vim if version < 600 - syntax clear + syntax clear elseif exists("b:current_syntax") - finish + finish endif " Syntax definitions {{{1 " Basic keywords {{{2 syn keyword rustConditional match if else -syn keyword rustRepeat for loop while +syn keyword rustRepeat loop while +" `:syn match` must be used to prioritize highlighting `for` keyword. +syn match rustRepeat /\<for\>/ +" Highlight `for` keyword in `impl ... for ... {}` statement. This line must +" be put after previous `syn match` line to overwrite it. +syn match rustKeyword /\%(\<impl\>.\+\)\@<=\<for\>/ +syn keyword rustRepeat in syn keyword rustTypedef type nextgroup=rustIdentifier skipwhite skipempty syn keyword rustStructure struct enum nextgroup=rustIdentifier skipwhite skipempty syn keyword rustUnion union nextgroup=rustIdentifier skipwhite skipempty contained syn match rustUnionContextual /\<union\_s\+\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*/ transparent contains=rustUnion syn keyword rustOperator as +syn keyword rustExistential existential nextgroup=rustTypedef skipwhite skipempty contained +syn match rustExistentialContextual /\<existential\_s\+type/ transparent contains=rustExistential,rustTypedef syn match rustAssert "\<assert\(\w\)*!" contained syn match rustPanic "\<panic\(\w\)*!" contained +syn match rustAsync "\<async\%(\s\|\n\)\@=" syn keyword rustKeyword break -syn keyword rustKeyword box nextgroup=rustBoxPlacement skipwhite skipempty +syn keyword rustKeyword box syn keyword rustKeyword continue +syn keyword rustKeyword crate syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite skipempty syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite skipempty -syn keyword rustKeyword in impl let +syn keyword rustKeyword impl let +syn keyword rustKeyword macro syn keyword rustKeyword pub nextgroup=rustPubScope skipwhite skipempty syn keyword rustKeyword return +syn keyword rustKeyword yield syn keyword rustSuper super -syn keyword rustKeyword unsafe where +syn keyword rustKeyword where +syn keyword rustUnsafeKeyword unsafe syn keyword rustKeyword use nextgroup=rustModPath skipwhite skipempty " FIXME: Scoped impl's name is also fallen in this category syn keyword rustKeyword mod trait nextgroup=rustIdentifier skipwhite skipempty syn keyword rustStorage move mut ref static const -syn match rustDefault /\<default\ze\_s\+\(impl\|fn\|type\|const\)\>/ - -syn keyword rustInvalidBareKeyword crate +syn match rustDefault /\<default\ze\_s\+\(impl\|fn\|type\|const\)\>/ +syn keyword rustAwait await +syn match rustKeyword /\<try\>!\@!/ display syn keyword rustPubScopeCrate crate contained syn match rustPubScopeDelim /[()]/ contained @@ -52,22 +65,14 @@ syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifie syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained - -syn region rustBoxPlacement matchgroup=rustBoxPlacementParens start="(" end=")" contains=TOP contained -" Ideally we'd have syntax rules set up to match arbitrary expressions. Since -" we don't, we'll just define temporary contained rules to handle balancing -" delimiters. -syn region rustBoxPlacementBalance start="(" end=")" containedin=rustBoxPlacement transparent -syn region rustBoxPlacementBalance start="\[" end="\]" containedin=rustBoxPlacement transparent -" {} are handled by rustFoldBraces - -syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end=")" contains=TOP nextgroup=rustMacroRepeatCount -syn match rustMacroRepeatCount ".\?[*+]" contained +syn match rustFuncName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained + +syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP syn match rustMacroVariable "$\w\+" +syn match rustRawIdent "\<r#\h\w*" contains=NONE " Reserved (but not yet used) keywords {{{2 -syn keyword rustReservedKeyword alignof become do offsetof priv pure sizeof typeof unsized yield abstract virtual final override macro +syn keyword rustReservedKeyword become do priv typeof unsized abstract virtual final override " Built-in types {{{2 syn keyword rustType isize usize char bool u8 u16 u32 u64 u128 f32 @@ -138,18 +143,37 @@ syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustPanic syn match rustEscapeError display contained /\\./ syn match rustEscape display contained /\\\([nrt0\\'"]\|x\x\{2}\)/ -syn match rustEscapeUnicode display contained /\\u{\x\{1,6}}/ +syn match rustEscapeUnicode display contained /\\u{\%(\x_*\)\{1,6}}/ syn match rustStringContinuation display contained /\\\n\s*/ -syn region rustString start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeError,rustStringContinuation -syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustStringContinuation,@Spell -syn region rustString start='b\?r\z(#*\)"' end='"\z1' contains=@Spell - -syn region rustAttribute start="#!\?\[" end="\]" contains=rustString,rustDerive,rustCommentLine,rustCommentBlock,rustCommentLineDocError,rustCommentBlockDocError +syn region rustString matchgroup=rustStringDelimiter start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeError,rustStringContinuation +syn region rustString matchgroup=rustStringDelimiter start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustStringContinuation,@Spell +syn region rustString matchgroup=rustStringDelimiter start='b\?r\z(#*\)"' end='"\z1' contains=@Spell + +" Match attributes with either arbitrary syntax or special highlighting for +" derives. We still highlight strings and comments inside of the attribute. +syn region rustAttribute start="#!\?\[" end="\]" contains=@rustAttributeContents,rustAttributeParenthesizedParens,rustAttributeParenthesizedCurly,rustAttributeParenthesizedBrackets,rustDerive +syn region rustAttributeParenthesizedParens matchgroup=rustAttribute start="\w\%(\w\)*("rs=e end=")"re=s transparent contained contains=rustAttributeBalancedParens,@rustAttributeContents +syn region rustAttributeParenthesizedCurly matchgroup=rustAttribute start="\w\%(\w\)*{"rs=e end="}"re=s transparent contained contains=rustAttributeBalancedCurly,@rustAttributeContents +syn region rustAttributeParenthesizedBrackets matchgroup=rustAttribute start="\w\%(\w\)*\["rs=e end="\]"re=s transparent contained contains=rustAttributeBalancedBrackets,@rustAttributeContents +syn region rustAttributeBalancedParens matchgroup=rustAttribute start="("rs=e end=")"re=s transparent contained contains=rustAttributeBalancedParens,@rustAttributeContents +syn region rustAttributeBalancedCurly matchgroup=rustAttribute start="{"rs=e end="}"re=s transparent contained contains=rustAttributeBalancedCurly,@rustAttributeContents +syn region rustAttributeBalancedBrackets matchgroup=rustAttribute start="\["rs=e end="\]"re=s transparent contained contains=rustAttributeBalancedBrackets,@rustAttributeContents +syn cluster rustAttributeContents contains=rustString,rustCommentLine,rustCommentBlock,rustCommentLineDocError,rustCommentBlockDocError syn region rustDerive start="derive(" end=")" contained contains=rustDeriveTrait " This list comes from src/libsyntax/ext/deriving/mod.rs " Some are deprecated (Encodable, Decodable) or to be removed after a new snapshot (Show). syn keyword rustDeriveTrait contained Clone Hash RustcEncodable RustcDecodable Encodable Decodable PartialEq Eq PartialOrd Ord Rand Show Debug Default FromPrimitive Send Sync Copy +" dyn keyword: It's only a keyword when used inside a type expression, so +" we make effort here to highlight it only when Rust identifiers follow it +" (not minding the case of pre-2018 Rust where a path starting with :: can +" follow). +" +" This is so that uses of dyn variable names such as in 'let &dyn = &2' +" and 'let dyn = 2' will not get highlighted as a keyword. +syn match rustKeyword "\<dyn\ze\_s\+\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)" contains=rustDynKeyword +syn keyword rustDynKeyword dyn contained + " Number literals syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\=" syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\=" @@ -168,29 +192,31 @@ syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)" " For the benefit of delimitMate -syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u{\x\{1,6}}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime -syn region rustGenericRegion display start=/<\%('\|[^[cntrl:][:space:][:punct:]]\)\@=')\S\@=/ end=/>/ contains=rustGenericLifetimeCandidate +syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u{\%(\x_*\)\{1,6}}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime +syn region rustGenericRegion display start=/<\%('\|[^[:cntrl:][:space:][:punct:]]\)\@=')\S\@=/ end=/>/ contains=rustGenericLifetimeCandidate syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime "rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" syn match rustLabel display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*:" +syn match rustLabel display "\%(\<\%(break\|continue\)\s*\)\@<=\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" syn match rustCharacterInvalid display contained /b\?'\zs[\n\r\t']\ze'/ " The groups negated here add up to 0-255 but nothing else (they do not seem to go beyond ASCII). syn match rustCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:graph:][:alnum:][:space:]]\ze'/ syn match rustCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=rustEscape,rustEscapeError,rustCharacterInvalid,rustCharacterInvalidUnicode -syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u{\x\{1,6}}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid +syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u{\%(\x_*\)\{1,6}}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid syn match rustShebang /\%^#![^[].*/ syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell syn region rustCommentLineDocError start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell contained syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell -syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell +syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,rustCommentBlockDocRustCode,@Spell syn region rustCommentBlockDocError matchgroup=rustCommentBlockDocError start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNestError,@Spell contained syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent syn region rustCommentBlockDocNestError matchgroup=rustCommentBlockDocError start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNestError,@Spell contained transparent + " FIXME: this is a really ugly and not fully correct implementation. Most " importantly, a case like ``/* */*`` should have the final ``*`` not being in " a comment, but in practice at present it leaves comments open two levels @@ -203,13 +229,67 @@ syn region rustCommentBlockDocNestError matchgroup=rustCommentBlockDocError star " then you must deal with cases like ``/*/**/*/``. And don't try making it " worse with ``\%(/\@<!\*\)\@<!``, either... -syn keyword rustTodo contained TODO FIXME XXX NB NOTE +syn keyword rustTodo contained TODO FIXME XXX NB NOTE SAFETY + +" asm! macro {{{2 +syn region rustAsmMacro matchgroup=rustMacro start="\<asm!\s*(" end=")" contains=rustAsmDirSpec,rustAsmSym,rustAsmConst,rustAsmOptionsGroup,rustComment.*,rustString.* + +" Clobbered registers +syn keyword rustAsmDirSpec in out lateout inout inlateout contained nextgroup=rustAsmReg skipwhite skipempty +syn region rustAsmReg start="(" end=")" contained contains=rustString + +" Symbol operands +syn keyword rustAsmSym sym contained nextgroup=rustAsmSymPath skipwhite skipempty +syn region rustAsmSymPath start="\S" end=",\|)"me=s-1 contained contains=rustComment.*,rustIdentifier + +" Const +syn region rustAsmConstBalancedParens start="("ms=s+1 end=")" contained contains=@rustAsmConstExpr +syn cluster rustAsmConstExpr contains=rustComment.*,rust.*Number,rustString,rustAsmConstBalancedParens +syn region rustAsmConst start="const" end=",\|)"me=s-1 contained contains=rustStorage,@rustAsmConstExpr + +" Options +syn region rustAsmOptionsGroup start="options\s*(" end=")" contained contains=rustAsmOptions,rustAsmOptionsKey +syn keyword rustAsmOptionsKey options contained +syn keyword rustAsmOptions pure nomem readonly preserves_flags noreturn nostack att_syntax contained " Folding rules {{{2 " Trivial folding rules to begin with. " FIXME: use the AST to make really good folding syn region rustFoldBraces start="{" end="}" transparent fold +if !exists("b:current_syntax_embed") + let b:current_syntax_embed = 1 + syntax include @RustCodeInComment <sfile>:p:h/rust.vim + unlet b:current_syntax_embed + + " Currently regions marked as ```<some-other-syntax> will not get + " highlighted at all. In the future, we can do as vim-markdown does and + " highlight with the other syntax. But for now, let's make sure we find + " the closing block marker, because the rules below won't catch it. + syn region rustCommentLinesDocNonRustCode matchgroup=rustCommentDocCodeFence start='^\z(\s*//[!/]\s*```\).\+$' end='^\z1$' keepend contains=rustCommentLineDoc + + " We borrow the rules from rust’s src/librustdoc/html/markdown.rs, so that + " we only highlight as Rust what it would perceive as Rust (almost; it’s + " possible to trick it if you try hard, and indented code blocks aren’t + " supported because Markdown is a menace to parse and only mad dogs and + " Englishmen would try to handle that case correctly in this syntax file). + syn region rustCommentLinesDocRustCode matchgroup=rustCommentDocCodeFence start='^\z(\s*//[!/]\s*```\)[^A-Za-z0-9_-]*\%(\%(should_panic\|no_run\|ignore\|allow_fail\|rust\|test_harness\|compile_fail\|E\d\{4}\|edition201[58]\)\%([^A-Za-z0-9_-]\+\|$\)\)*$' end='^\z1$' keepend contains=@RustCodeInComment,rustCommentLineDocLeader + syn region rustCommentBlockDocRustCode matchgroup=rustCommentDocCodeFence start='^\z(\%(\s*\*\)\?\s*```\)[^A-Za-z0-9_-]*\%(\%(should_panic\|no_run\|ignore\|allow_fail\|rust\|test_harness\|compile_fail\|E\d\{4}\|edition201[58]\)\%([^A-Za-z0-9_-]\+\|$\)\)*$' end='^\z1$' keepend contains=@RustCodeInComment,rustCommentBlockDocStar + " Strictly, this may or may not be correct; this code, for example, would + " mishighlight: + " + " /** + " ```rust + " println!("{}", 1 + " * 1); + " ``` + " */ + " + " … but I don’t care. Balance of probability, and all that. + syn match rustCommentBlockDocStar /^\s*\*\s\?/ contained + syn match rustCommentLineDocLeader "^\s*//\%(//\@!\|!\)" contained +endif + " Default highlighting {{{1 hi def link rustDecNumber rustNumber hi def link rustHexNumber rustNumber @@ -219,7 +299,6 @@ hi def link rustIdentifierPrime rustIdentifier hi def link rustTrait rustType hi def link rustDeriveTrait rustTrait -hi def link rustMacroRepeatCount rustMacroRepeatDelimiters hi def link rustMacroRepeatDelimiters Macro hi def link rustMacroVariable Define hi def link rustSigil StorageClass @@ -228,6 +307,7 @@ hi def link rustEscapeUnicode rustEscape hi def link rustEscapeError Error hi def link rustStringContinuation Special hi def link rustString String +hi def link rustStringDelimiter String hi def link rustCharacterInvalid Error hi def link rustCharacterInvalidUnicode rustCharacterInvalid hi def link rustCharacter Character @@ -241,12 +321,15 @@ hi def link rustFloat Float hi def link rustArrowCharacter rustOperator hi def link rustOperator Operator hi def link rustKeyword Keyword +hi def link rustDynKeyword rustKeyword hi def link rustTypedef Keyword " More precise is Typedef, but it doesn't feel right for Rust hi def link rustStructure Keyword " More precise is Structure hi def link rustUnion rustStructure +hi def link rustExistential rustKeyword hi def link rustPubScopeDelim Delimiter hi def link rustPubScopeCrate rustKeyword hi def link rustSuper rustKeyword +hi def link rustUnsafeKeyword Exception hi def link rustReservedKeyword Error hi def link rustRepeat Conditional hi def link rustConditional Conditional @@ -260,10 +343,13 @@ hi def link rustFuncCall Function hi def link rustShebang Comment hi def link rustCommentLine Comment hi def link rustCommentLineDoc SpecialComment +hi def link rustCommentLineDocLeader rustCommentLineDoc hi def link rustCommentLineDocError Error hi def link rustCommentBlock rustCommentLine hi def link rustCommentBlockDoc rustCommentLineDoc +hi def link rustCommentBlockDocStar rustCommentBlockDoc hi def link rustCommentBlockDocError Error +hi def link rustCommentDocCodeFence rustCommentLineDoc hi def link rustAssert PreCondit hi def link rustPanic PreCondit hi def link rustMacro Macro @@ -276,11 +362,15 @@ hi def link rustStorage StorageClass hi def link rustObsoleteStorage Error hi def link rustLifetime Special hi def link rustLabel Label -hi def link rustInvalidBareKeyword Error hi def link rustExternCrate rustKeyword hi def link rustObsoleteExternMod Error -hi def link rustBoxPlacementParens Delimiter hi def link rustQuestionMark Special +hi def link rustAsync rustKeyword +hi def link rustAwait rustKeyword +hi def link rustAsmDirSpec rustKeyword +hi def link rustAsmSym rustKeyword +hi def link rustAsmOptions rustKeyword +hi def link rustAsmOptionsKey rustAttribute " Other Suggestions: " hi rustAttribute ctermfg=cyan @@ -293,3 +383,5 @@ syn sync minlines=200 syn sync maxlines=500 let b:current_syntax = "rust" + +" vim: set et sw=4 sts=4 ts=8: diff --git a/runtime/syntax/scala.vim b/runtime/syntax/scala.vim index c08e60e55a..cc098ce017 100644 --- a/runtime/syntax/scala.vim +++ b/runtime/syntax/scala.vim @@ -180,7 +180,7 @@ hi def link scalaNumber Number syn region scalaRoundBrackets start="(" end=")" skipwhite contained contains=scalaTypeDeclaration,scalaSquareBrackets,scalaRoundBrackets -syn region scalaSquareBrackets matchgroup=scalaSquareBracketsBrackets start="\[" end="\]" skipwhite nextgroup=scalaTypeExtension contains=scalaTypeDeclaration,scalaSquareBrackets,scalaTypeOperator,scalaTypeAnnotationParameter +syn region scalaSquareBrackets matchgroup=scalaSquareBracketsBrackets start="\[" end="\]" skipwhite nextgroup=scalaTypeExtension contains=scalaTypeDeclaration,scalaSquareBrackets,scalaTypeOperator,scalaTypeAnnotationParameter,scalaString syn match scalaTypeOperator /[-+=:<>]\+/ contained syn match scalaTypeAnnotationParameter /@\<[`_A-Za-z0-9$]\+\>/ contained hi def link scalaSquareBracketsBrackets Type diff --git a/runtime/syntax/swayconfig.vim b/runtime/syntax/swayconfig.vim index 6b36210252..290e8cc1ac 100644 --- a/runtime/syntax/swayconfig.vim +++ b/runtime/syntax/swayconfig.vim @@ -1,10 +1,10 @@ " Vim syntax file " Language: sway window manager config -" Original Author: James Eapen <james.eapen@vai.org> +" Original Author: Josef Litos " Maintainer: James Eapen <james.eapen@vai.org> -" Version: 0.2.1 -" Reference version (jamespeapen/swayconfig.vim): 0.12.1 -" Last Change: 2023 Mar 20 +" Version: 0.2.2 +" Reference version (JosefLitos/i3config.vim): 1.8.1 +" Last Change: 2023-09-12 " References: " http://i3wm.org/docs/userguide.html#configuring @@ -19,98 +19,110 @@ endif runtime! syntax/i3config.vim -scriptencoding utf-8 +" i3 extensions +syn match i3ConfigSet /^\s*set \$\w\+ .*$/ contains=i3ConfigVariable,i3ConfigSetKeyword,i3ConfigColor,i3ConfigString,i3ConfigNoStartupId,i3ConfigNumber,swayConfigOutputCommand,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper -" Error -"syn match swayConfigError /.*/ +syn keyword i3ConfigActionKeyword opacity contained -" binding syn keyword swayConfigBindKeyword bindswitch bindgesture contained -syn match swayConfigBind /^\s*\(bindswitch\)\s\+.*$/ contains=i3ConfigVariable,i3ConfigBindKeyword,swayConfigBindKeyword,i3ConfigVariableAndModifier,i3ConfigNumber,i3ConfigUnit,i3ConfigUnitOr,i3ConfigBindArgument,i3ConfigModifier,i3ConfigAction,i3ConfigString,i3ConfigGapStyleKeyword,i3ConfigBorderStyleKeyword - -" bindgestures -syn keyword swayConfigBindGestureCommand swipe pinch hold contained -syn keyword swayConfigBindGestureDirection up down left right next prev contained -syn keyword swayConfigBindGesturePinchDirection inward outward clockwise counterclockwise contained -syn match swayConfigBindGestureHold /^\s*\(bindgesture\)\s\+hold\(:[1-5]\)\?\s\+.*$/ contains=swayConfigBindKeyword,swayConfigBindGestureCommand,swayConfigBindGestureDirection,i3ConfigWorkspaceKeyword,i3ConfigAction -syn match swayConfigBindGestureSwipe /^\s*\(bindgesture\)\s\+swipe\(:[3-5]\)\?:\(up\|down\|left\|right\)\s\+.*$/ contains=swayConfigBindKeyword,swayConfigBindGestureCommand,swayConfigBindGestureDirection,i3ConfigWorkspaceKeyword,i3ConfigAction -syn match swayConfigBindGesturePinch /^\s*\(bindgesture\)\s\+pinch\(:[2-5]\)\?:\(up\|down\|left\|right\|inward\|outward\|clockwise\|counterclockwise\)\(+\(up\|down\|left\|right\|inward\|outward\|clockwise\|counterclockwise\)\)\?.*$/ contains=swayConfigBindKeyword,swayConfigBindGestureCommand,swayConfigBindGestureDirection,swayConfigBindGesturePinchDirection,i3ConfigWorkspaceKeyword,i3ConfigAction - -" floating -syn keyword swayConfigFloatingKeyword floating contained -syn match swayConfigFloating /^\s*floating\s\+\(enable\|disable\|toggle\)\s*$/ contains=swayConfigFloatingKeyword - -syn clear i3ConfigFloatingModifier -syn keyword swayConfigFloatingModifier floating_modifier contained -syn match swayConfigFloatingMouseAction /^\s\?.*floating_modifier\s\S\+\s\?\(normal\|inverted\|none\)\?$/ contains=swayConfigFloatingModifier,i3ConfigVariable - -" Gaps -syn clear i3ConfigSmartBorderKeyword -syn clear i3ConfigSmartBorder -syn keyword swayConfigSmartBorderKeyword on no_gaps off contained -syn match swayConfigSmartBorder /^\s*smart_borders\s\+\(on\|no_gaps\|off\)\s\?$/ contains=swayConfigSmartBorderKeyword - -" Changing colors -syn keyword swayConfigClientColorKeyword focused_tab_title contained -syn match swayConfigClientColor /^\s*client.\w\+\s\+.*$/ contains=i3ConfigClientColorKeyword,i3ConfigColor,i3ConfigVariable,i3ConfigClientColorKeyword,swayConfigClientColorKeyword - -" Input config -syn keyword swayConfigInputKeyword input contained -syn match swayConfigInput /^\s*input\s\+.*$/ contains=swayConfigInputKeyword +syn match i3ConfigBindArgument /--\(locked\|to-code\|no-repeat\|input-device=[:0-9a-zA-Z_/-]\+\|no-warn\)/ contained +syn region i3ConfigBind start=/^\s*bind\(switch\|gesture\) / skip=/\\$/ end=/$/ contains=swayConfigBindKeyword,swayConfigBindswitch,swayConfigBindswitchArgument,swayConfigBindgesture,swayConfigBindgestureArgument,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean keepend + +syn match swayConfigBindBlockHeader /^\s*bind\(sym\|code\) .*{$/ contained contains=i3ConfigBindKeyword,i3ConfigBindArgument,i3ConfigParen +syn match swayConfigBindBlockCombo /^\s\+\(--[a-z-]\+ \)*[$a-zA-Z0-9_+]\+ [a-z[]\@=/ contained contains=i3ConfigBindArgument,i3ConfigBindCombo +syn region i3ConfigBind start=/^\s*bind\(sym\|code\) .*{$/ end=/^\s*}$/ contains=swayConfigBindBlockHeader,swayConfigBindBlockCombo,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean,i3ConfigComment,i3ConfigParen fold keepend extend + +syn keyword i3ConfigClientOpts focused_tab_title contained + +syn region swayConfigExecBlock start=/exec\(_always\)\? {/ end=/^}$/ contains=i3ConfigExecKeyword,i3ConfigExecAlwaysKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigComment fold keepend extend + +syn keyword swayConfigFloatingModifierOpts normal inverse contained +syn match i3ConfigKeyword /^floating_modifier [$a-zA-Z0-9+]\+ \(normal\|inverse\)$/ contains=i3ConfigVariable,i3ConfigBindModkey,swayConfigFloatingModifierOpts + +syn match i3ConfigEdge /^hide_edge_borders\( --i3\)\? \(none\|vertical\|horizontal\|both\|smart\|smart_no_gaps\)\s\?$/ contains=i3ConfigEdgeKeyword,i3ConfigShParam + +syn keyword i3ConfigBarBlockKeyword swaybar_command gaps height pango_markup status_edge_padding status_padding wrap_scroll tray_bindcode tray_bindsym icon_theme contained + +syn keyword i3ConfigExecActionKeyword swaymsg contained -" Seat config +" Sway-only options +" Xwayland +syn keyword swayConfigXOpt enable disable force contained +syn match i3ConfigKeyword /^xwayland .*$/ contains=swayConfigXOpt + +" Bindswitch +syn match swayConfigBindswitchArgument /--\(locked\|no-warn\|reload\)/ contained +syn keyword swayConfigBindswitchType lid tablet contained +syn keyword swayConfigBindswitchState toggle contained +syn match swayConfigBindswitch /\(lid\|tablet\):\(on\|off\|toggle\) / contained contains=swayConfigBindswitchType,i3ConfigColonOperator,swayConfigBindswitchState,i3ConfigBoolean +syn region i3ConfigBind start=/^\s*bindswitch\s\+.*{$/ end=/^\s*}$/ contains=swayConfigBindKeyword,swayConfigBindswitch,swayConfigBindswitchArgument,i3ConfigNumber,i3ConfigVariable,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigSeparator,i3ConfigString,i3ConfigCriteria,swayConfigOutputCommand,i3ConfigBoolean,i3ConfigComment,i3ConfigParen fold keepend extend + +" Bindgesture +syn match swayConfigBindgestureArgument /--\(exact\|input-device=[:0-9a-zA-Z_/-]\+\|no-warn\)/ contained +syn keyword swayConfigBindgestureType hold swipe pinch contained +syn keyword swayConfigBindgestureDir up down left right inward outward clockwise counterclockwise contained +syn match swayConfigBindgesture /\(hold\(:[1-5]\)\?\|swipe\(:[3-5]\)\?\(:up\|:down\|:left\|:right\)\?\|pinch\(:[2-5]\)\?:\(+\?\(inward\|outward\|clockwise\|counterclockwise\|up\|down\|left\|right\)\)\+\) / contained contains=i3ConfigNumber,swayConfigBindgestureType,i3ConfigColonOperator,swayConfigBindgestureDir,i3ConfigBindModifier +syn region i3ConfigBind start=/^\s*bindgesture\s\+.*{$/ end=/^\s*}$/ contains=swayConfigBindKeyword,swayConfigBindgesture,swayConfigBindgestureArgument,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean,i3ConfigParen fold keepend extend + +" Titlebar commands +syn match i3ConfigKeyword /^titlebar_border_thickness \(\d\+\|\$\S\+\)$/ contains=i3ConfigNumber,i3ConfigVariable +syn match i3ConfigKeyword /^titlebar_padding \(\d\+\|\$\S\+\)\( \d\+\)\?$/ contains=i3ConfigNumber,i3ConfigVariable + +syn match swayConfigDeviceOps /[*,:;]/ contained + +" Output monitors +syn keyword swayConfigOutputKeyword output contained +syn keyword swayConfigOutputOpts mode resolution res modeline position pos scale scale_filter subpixel background bg transform disable enable power dpms max_render_time adaptive_sync render_bit_depth contained +syn keyword swayConfigOutputOptVals linear nearest smart rgb bgr vrgb vbgr none normal flipped fill stretch fit center tile solid_color clockwise anticlockwise toggle contained +syn match swayConfigOutputFPS /@[0-9.]\+Hz/ contained +syn match swayConfigOutputMode / [0-9]\+x[0-9]\+\(@[0-9.]\+Hz\)\?/ contained contains=swayConfigOutputFPS,i3ConfigNumber +syn region i3ConfigAction start=/output/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps keepend +syn region swayConfigOutput start=/^output/ skip=/\\$/ end=/$/ contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps keepend +syn region swayConfigOutput start=/^output .* {$/ end=/}$/ contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps,i3ConfigParen keepend extend + +" Input devices +syn keyword swayConfigInputKeyword input contained +syn keyword swayConfigInputOpts xkb_layout xkb_variant xkb_rules xkb_switch_layout xkb_numlock xkb_file xkb_capslock xkb_model repeat_delay repeat_rate map_to_output map_to_region map_from_region tool_mode accel_profile dwt dwtp drag_lock drag click_method middle_emulation tap events calibration_matrix natural_scroll left_handed pointer_accel scroll_button scroll_factor scroll_method tap_button_map contained +syn keyword swayConfigInputOptVals absolute relative adaptive flat none button_areas clickfinger toggle two_finger edge on_button_down lrm lmr contained +syn match swayConfigColonPairVal /:[0-9a-z_-]\+/ contained contains=i3ConfigColonOperator +syn match swayConfigColonPair /[a-z]\+:[0-9a-z_-]\+/ contained contains=swayConfigColonPairVal +syn match swayConfigInputXkbOpts /xkb_options \([a-z]\+:[0-9a-z_-]\+,\?\)\+/ contained contains=swayConfigColonPair,swayConfigDeviceOps +syn region i3ConfigAction start=/input/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigInputKeyword,swayConfigColonPair,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigBoolean,swayConfigDeviceOps keepend +syn region i3ConfigInput start=/^input/ skip=/\\$/ end=/$/ contains=swayConfigInputKeyword,swayConfigColonPair,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigBoolean,swayConfigDeviceOps keepend +syn region i3ConfigInput start=/^input .* {/ end=/}$/ contains=swayConfigInputKeyword,swayConfigColonPair,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigBoolean,swayConfigDeviceOps,i3ConfigParen keepend extend + +" Seat syn keyword swayConfigSeatKeyword seat contained -syn match swayConfigSeat /^\s*seat\s\+.*$/ contains=swayConfigSeatKeyword - -" set display outputs -syn match swayConfigOutput /^\s*output\s\+.*$/ contains=i3ConfigOutput - -" set display focus -syn keyword swayConfigFocusKeyword focus contained -syn keyword swayConfigFocusType output contained -syn match swayConfigFocus /^\s*focus\soutput\s.*$/ contains=swayConfigFocusKeyword,swayConfigFocusType - -" mouse warping -syn keyword swayConfigMouseWarpingType container contained -syn match swayConfigMouseWarping /^\s*mouse_warping\s\+\(output\|container\|none\)\s\?$/ contains=i3ConfigMouseWarpingKeyword,i3ConfigMouseWarpingType,swayConfigMouseWarpingType - -" focus follows mouse -syn clear i3ConfigFocusFollowsMouseType -syn clear i3ConfigFocusFollowsMouse - -syn keyword swayConfigFocusFollowsMouseType yes no always contained -syn match swayConfigFocusFollowsMouse /^\s*focus_follows_mouse\s\+\(yes\|no\|always\)\s\?$/ contains=i3ConfigFocusFollowsMouseKeyword,swayConfigFocusFollowsMouseType - - -" xwayland -syn keyword swayConfigXwaylandKeyword xwayland contained -syn match swayConfigXwaylandModifier /^\s*xwayland\s\+\(enable\|disable\|force\)\s\?$/ contains=swayConfigXwaylandKeyword - -" Group mode/bar -syn clear i3ConfigBlock -syn region swayConfigBlock start=+.*s\?{$+ end=+^}$+ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigInitializeKeyword,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable,swayConfigInputKeyword,swayConfigSeatKeyword,i3ConfigOutput transparent keepend extend - -"hi def link swayConfigError Error -hi def link i3ConfigFloating Error -hi def link swayConfigFloating Type -hi def link swayConfigFloatingMouseAction Type -hi def link swayConfigFocusKeyword Type -hi def link swayConfigSmartBorderKeyword Type -hi def link swayConfigInputKeyword Type -hi def link swayConfigSeatKeyword Type -hi def link swayConfigMouseWarpingType Type -hi def link swayConfigFocusFollowsMouseType Type -hi def link swayConfigBindGestureCommand Identifier -hi def link swayConfigBindGestureDirection Constant -hi def link swayConfigBindGesturePinchDirection Constant -hi def link swayConfigBindKeyword Identifier -hi def link swayConfigClientColorKeyword Identifier -hi def link swayConfigFloatingKeyword Identifier -hi def link swayConfigFloatingModifier Identifier -hi def link swayConfigFocusType Identifier -hi def link swayConfigSmartBorder Identifier -hi def link swayConfigXwaylandKeyword Identifier -hi def link swayConfigXwaylandModifier Type -hi def link swayConfigBindGesture PreProc +syn keyword swayConfigSeatOpts attach cursor fallback hide_cursor idle_inhibit idle_wake keyboard_grouping shortcuts_inhibitor pointer_constraint xcursor_theme contained +syn match swayConfigSeatOptVals /when-typing/ contained +syn keyword swayConfigSeatOptVals move set press release none smart activate deactivate toggle escape enable disable contained +syn region i3ConfigAction start=/seat/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps keepend +syn region swayConfigSeat start=/seat/ skip=/\\$/ end=/$/ contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps keepend +syn region swayConfigSeat start=/seat .* {$/ end=/}$/ contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps,i3ConfigParen keepend extend + +" Define the highlighting. +hi def link swayConfigFloatingModifierOpts i3ConfigOption +hi def link swayConfigBindKeyword i3ConfigBindKeyword +hi def link swayConfigXOpt i3ConfigOption +hi def link swayConfigBindswitchArgument i3ConfigBindArgument +hi def link swayConfigBindswitchType i3ConfigMoveType +hi def link swayConfigBindswitchState i3ConfigMoveDir +hi def link swayConfigBindgestureArgument i3ConfigBindArgument +hi def link swayConfigBindgestureType i3ConfigMoveType +hi def link swayConfigBindgestureDir i3ConfigMoveDir +hi def link swayConfigDeviceOps i3ConfigOperator +hi def link swayConfigOutputKeyword i3ConfigCommand +hi def link swayConfigOutputOptVals i3ConfigOption +hi def link swayConfigOutputOpts i3ConfigOption +hi def link swayConfigOutputFPS Constant +hi def link swayConfigInputKeyword i3ConfigCommand +hi def link swayConfigInputOptVals i3ConfigShParam +hi def link swayConfigInputOpts i3ConfigOption +hi def link swayConfigInputXkbOpts i3ConfigOption +hi def link swayConfigColonPairVal i3ConfigString +hi def link swayConfigColonPair i3ConfigShParam +hi def link swayConfigSeatKeyword i3ConfigCommand +hi def link swayConfigSeatOptVals i3ConfigOption +hi def link swayConfigSeatOpts i3ConfigOption let b:current_syntax = "swayconfig" |