diff options
author | Karl Berry <karl@freefriends.org> | 2020-04-27 21:17:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-04-27 21:17:13 +0000 |
commit | bf42995081d83e87bcfc31900f072921e3a95c41 (patch) | |
tree | e1b2b145be35174a19364111a99ba1b45c2f2dd6 /Master/texmf-dist/tex | |
parent | 597d59d1a34bc68a7d2b3e43012c15350df129be (diff) |
context-vim (27apr20)
git-svn-id: svn://tug.org/texlive/trunk@54913 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
3 files changed, 57 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/context/third/vim/2context.vim b/Master/texmf-dist/tex/context/third/vim/2context.vim index 9c72ba1bd19..c83a731c5c8 100644 --- a/Master/texmf-dist/tex/context/third/vim/2context.vim +++ b/Master/texmf-dist/tex/context/third/vim/2context.vim @@ -1,5 +1,5 @@ " Author : Aditya Mahajan <adityam [at] umich [dot] edu> -" 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/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv b/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv index 17019e14859..7c31c8f6a38 100644 --- a/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv +++ b/Master/texmf-dist/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/Master/texmf-dist/tex/context/third/vim/t-vim.tex b/Master/texmf-dist/tex/context/third/vim/t-vim.tex index 3cd83cdb2f8..eb0adbfe7b0 100644 --- a/Master/texmf-dist/tex/context/third/vim/t-vim.tex +++ b/Master/texmf-dist/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 <at> ieee <dot> 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, |