From ae496a1c963576dfe63885afa818b2af745ed44a Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 27 Apr 2020 03:03:41 +0000 Subject: CTAN sync 202004270303 --- .../context-vim/tex/context/third/vim/2context.vim | 56 ++++++++++++++++++---- .../tex/context/third/vim/t-syntax-highlight.mkiv | 4 +- .../context-vim/tex/context/third/vim/t-vim.tex | 12 +++-- 3 files changed, 57 insertions(+), 15 deletions(-) (limited to 'macros/context/contrib/context-vim/tex/context/third') diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim b/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim index 9c72ba1bd1..c83a731c5c 100644 --- a/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim +++ b/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim @@ -1,5 +1,5 @@ " Author : Aditya Mahajan -" version : 2011.12.23 +" version : 2020.04.25 " license : Simplified BSD License " This script is part of the t-vim module for ConTeXt. It is based on 2html.vim. @@ -39,10 +39,22 @@ if !exists("highlight") endif " Set escapecomments -if !exists("escapecomments") - let escapecomments=0 +if exists("escapecomments") + let s:escapecomments=escapecomments " 0=off, 1=comments, 2=command +else + let s:escapecomments=0 endif +" Add a new syntax region to detect ConTeXt tags +if s:escapecomments==2 + syntax region vimtypingTEXcomment start="/BTEX" end="/ETEX" transparent oneline containedin=ALL contains=NONE + + " Find the id of /BTEX ... /ETEX syntax region + let s:texcommentid = hlID("vimtypingTEXcomment") +else + let s:texcommentid = -1 " Assuming that all ids are positive. Not documented +end + let s:strip = strlen( matchstr( getline(s:lstart), '^\s*' ) ) " Find the smallest leading white space @@ -74,6 +86,7 @@ let s:lnum = s:lstart while s:lnum <= s:lstop " Get the current line let s:line = getline(s:lnum) + let s:len = strlen(s:line) let s:new = '' @@ -81,28 +94,53 @@ while s:lnum <= s:lstop let s:col = s:strip + 1 while s:col <= s:len let s:startcol = s:col " The start column for processing text - let s:id = synID (s:lnum, s:col, 1) - let s:col = s:col + 1 + + " Check if the next transprarent syntax is "vimtypingTEXcomment". If not, + " find the next non-transparent syntax id. + let s:id = synID (s:lnum, s:col, 0) + if s:id == s:texcommentid + let s:texcomment = 1 + else + let s:texcomment = 0 + let s:id = synID (s:lnum, s:col, 1) + endif + let s:col = s:col + 1 " Speed loop (it's small - that's the trick) " Go along till we find a change in synID - while s:col <= s:len && s:id == synID(s:lnum, s:col, 1) + while s:col <= s:len + " If there is a "vimtypingTEXcomment" inside another syntax id, + " "vimtypingTEXcomment" should get preference + let s:nextid = synID(s:lnum, s:col, 0) + if !s:texcomment && s:nextid != s:texcommentid + let s:nextid = synID(s:lnum, s:col, 1) + endif + + if s:nextid != s:id + break + endif + let s:col = s:col + 1 endwhile " Output the text with the same synID, with class set to {s:id_name} let s:id = synIDtrans (s:id) let s:id_name = synIDattr (s:id, "name", "gui") - let s:temp = strpart(s:line, s:startcol - 1, s:col - s:startcol) + if s:texcomment + " Remove /BTEX and /ETEX which are 5 characters wide + let s:temp = strpart(s:line, s:startcol + 5 - 1, s:col - s:startcol - 5 - 5) + else + let s:temp = strpart(s:line, s:startcol - 1, s:col - s:startcol) + end " Remove line endings (on unix machines reading windows files) let s:temp = substitute(s:temp, '\r*$', '', '') " It might have happened that that one has been the last item in a row, so " we don't need to print in in that case if strlen(s:temp) > 0 " Change special TeX characters to escape sequences. - if !(escapecomments && s:id_name == "Comment") + if !(s:texcomment || (s:escapecomments == 1) && s:id_name == "Comment") let s:temp = escape( s:temp, '\{}') endif - if !empty(s:id_name) + if !(s:texcomment || empty(s:id_name)) let s:temp = '\SYN[' . s:id_name . ']{' . s:temp . '}' endif let s:new = s:new . s:temp diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv index 17019e1485..7c31c8f6a3 100644 --- a/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv +++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv @@ -87,13 +87,13 @@ \forgetall \usealignparameter\externalfilterparameter - \doifinset{\externalfilterparameter\c!option}{\v!packed} + \doifinset{\v!packed}{\externalfilterparameter\c!option} {\setupwhitespace[\v!none,\v!flexible]}% \doadaptleftskip{\externalfilterparameter\c!margin}% \setbreakpoints[compound]% Only works is `option=hyphenated` is set. - \doifnotinset{\externalfilterparameter\c!option}{\v!hyphenated} + \doifnotinset{\v!hyphenated}{\externalfilterparameter\c!option} {\language\minusone}% \def\obeyedline{\strut\par} diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex b/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex index 3cd83cdb2f..eb0adbfe7b 100644 --- a/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex +++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex @@ -1,6 +1,6 @@ %D \module %D [ file=t-vim, -%D version=2018.04.17, +%D version=2020.04.25, %D title=\CONTEXT\ User Module, %D subtitle=Vim syntax highlighting, %D author=Aditya Mahajan, @@ -9,7 +9,7 @@ %D email=adityam ieee org, %D license=Simplified BSD License] -\writestatus{loading}{Vim syntax highlighting (ver: 2018.04.17)} +\writestatus{loading}{Vim syntax highlighting (ver: 2020.04.25)} \startmodule [vim] \usemodule [filter] % loads module catcodes @@ -129,7 +129,7 @@ -c "let contextstartline=\externalfilterparameter\c!start \letterbar\space % let contextstopline=\externalfilterparameter\c!stop \letterbar\space % let strip=\getvalue{\vimtyping@id-\c!strip-\externalfilterparameter\c!strip}" % - -c "let escapecomments=\getvalue{\vimtyping@id-\c!escape-\externalfilterparameter\c!escape}" % + -c "let escapecomments=\getvalue{\vimtyping@id-\c!escape-\externalfilterparameter\c!escape}" -c "let highlight=[\externalfilterparameter\c!highlight]" % \vimrc_extras\space -c "source \vimtyping@script_name" % @@ -140,9 +140,14 @@ \setvalue{\vimtyping@id-\c!strip-\v!off}{0} \setvalue{\vimtyping@id-\c!strip-\v!on}{1} +\setvalue{\vimtyping@id-\c!escape-}{0} % Empty value + \setvalue{\vimtyping@id-\c!escape-\v!off}{0} \setvalue{\vimtyping@id-\c!escape-\v!on}{1} +\setvalue{\vimtyping@id-\c!escape-\v!comment}{1} +\setvalue{\vimtyping@id-\c!escape-\v!command}{2} + % Undocumented ... but useful if the user makes a mistake \setvalue{\vimtyping@id-\c!strip-\v!no}{0} @@ -151,7 +156,6 @@ \setvalue{\vimtyping@id-\c!escape-\v!no}{0} \setvalue{\vimtyping@id-\c!escape-\v!yes}{1} - \setupvimtyping [% \c!tab=4, % \c!start=1, -- cgit v1.2.3