summaryrefslogtreecommitdiff
path: root/macros/context/contrib/context-vim/tex/context/third
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/context/contrib/context-vim/tex/context/third
Initial commit
Diffstat (limited to 'macros/context/contrib/context-vim/tex/context/third')
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/2context.vim153
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-groups.tex130
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkii257
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv245
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex439
5 files changed, 1224 insertions, 0 deletions
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
new file mode 100644
index 0000000000..9c72ba1bd1
--- /dev/null
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim
@@ -0,0 +1,153 @@
+" Author : Aditya Mahajan <adityam [at] umich [dot] edu>
+" version : 2011.12.23
+" license : Simplified BSD License
+
+" This script is part of the t-vim module for ConTeXt. It is based on 2html.vim.
+" Since this script is called by the t-vim module, we assume that Two buffers
+" are open. The first buffer is the input buffer, and the second buffer is the
+" output buffer. The script parses content line-by-line from the first buffer
+" and pastes the modified result on the second buffer.
+
+" Split screen and go to the second buffer, ensure modifiable is set, and the
+" buffer is empty.
+sblast
+set modifiable
+%d
+
+" Go to first buffer
+wincmd p
+
+" If contextstartline and contextstartline are set, use them.
+if exists("contextstartline")
+ let s:lstart = max([1, min([line("$"), contextstartline]) ])
+else
+ let s:lstart = 1
+endif
+
+if exists("contextstopline")
+ if contextstopline <= 0
+ let contextstopline = line("$") + contextstopline
+ endif
+ let s:lstop = min([line("$"), max([s:lstart, contextstopline]) ])
+else
+ let s:lstop = line("$")
+endif
+
+" Set highlight
+if !exists("highlight")
+ let highlight=[]
+endif
+
+" Set escapecomments
+if !exists("escapecomments")
+ let escapecomments=0
+endif
+
+let s:strip = strlen( matchstr( getline(s:lstart), '^\s*' ) )
+
+" Find the smallest leading white space
+if exists("strip") && strip && (s:strip != 0)
+ echo "Calculating amount of leading whitespace"
+ for s:lnum in range(s:lstart, s:lstop)
+ let s:line = getline(s:lnum)
+ if (match(s:line, '^\s*$')) == -1 " line is not empty
+ let s:space = matchstr(s:line, '^\s*')
+ let s:len = strlen(s:space)
+ " echo s:len
+ let s:strip = min([s:strip, s:len])
+ if s:strip == 0
+ break
+ end
+ end
+ endfor
+ " echo "Strip amount:" . s:strip
+else
+ let s:strip = 0
+endif
+
+let s:lines = []
+
+" Loop over all lines in the original text.
+let s:buffer_lnum = 1
+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 = ''
+
+" Loop over each character in the line
+ 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
+" 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)
+ 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)
+" 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")
+ let s:temp = escape( s:temp, '\{}')
+ endif
+ if !empty(s:id_name)
+ let s:temp = '\SYN[' . s:id_name . ']{' . s:temp . '}'
+ endif
+ let s:new = s:new . s:temp
+ endif
+
+" Why will we ever enter this loop
+" if s:col > s:len
+" break
+" endif
+ endwhile
+
+" Expand tabs
+ let s:pad = 0
+ let s:start = 0
+ let s:idx = stridx(s:line, "\t")
+ while s:idx >= 0
+ let s:i = &ts - ((s:start + s:pad + s:idx) % &ts)
+" let s:new = substitute(s:new, '\t', strpart(s:expandedtab, 0, s:i), '')
+ let s:new = substitute(s:new, '\t', '\\tab{' . s:i . '}', '')
+ let s:pad = s:pad + s:i - 1
+ let s:start = s:start + s:idx + 1
+ let s:idx = stridx(strpart(s:line, s:start), "\t")
+ endwhile
+
+" Remove leading whitespace
+" let s:new = substitute(s:new, '^\s\{' . s:strip . '\}', "", "")
+
+" Highlight line, if needed.
+ if (index(highlight, s:lnum) != -1)
+ let s:new = '\HGL{' . s:new . '}'
+ endif
+
+ " Add begin and end line markers
+ let s:new = "\\SYNBOL{}" . s:new . "\\SYNEOL{}"
+
+ call add(s:lines, s:new)
+
+" Increment line numbers
+ let s:lnum = s:lnum + 1
+ let s:buffer_lnum = s:buffer_lnum + 1
+endwhile
+
+" Go to previous buffer
+wincmd p
+echo s:lines
+call setline(1,s:lines)
+unlet s:lines
+write
diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-groups.tex b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-groups.tex
new file mode 100644
index 0000000000..db526bf77e
--- /dev/null
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-groups.tex
@@ -0,0 +1,130 @@
+%D \module
+%D [ file=t-syntax-groups,
+%D version=2012.05.06,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Syntax highlighting support,
+%D author=Aditya Mahajan,
+%D date=\currentdate,
+%D copyright=Aditya Mahajan,
+%D email=adityam <at> ieee <dot> org,
+%D license=Simplified BSD License]
+
+\writestatus{loading}{Syntax highlighting groups (ver: 2012.05.06)}
+
+\startmodule [syntax-group]
+\usemodule [module-catcodes]
+
+\unprotectmodulecatcodes
+
+% Colors are specified in hex; in MkII the hex mode needs to be activated.
+\doifmode\s!mkii
+ {\setupcolor[hex]}
+
+
+\def\colorscheme@name {}
+
+\def\syntaxgroup@id {syntaxgroup}
+\def\syntaxgroup@namespace {@@@@\syntaxgroup@id}
+\def\syntaxgroup@name {}
+
+\edef\t!syntaxgroup {\syntaxgroup@id}
+
+
+\installparameterhandler \syntaxgroup@namespace \syntaxgroup@id
+\installsetuphandler \syntaxgroup@namespace \syntaxgroup@id
+\doifmode{\s!mkiv}
+ {\installstyleandcolorhandler \syntaxgroup@namespace \syntaxgroup@id}
+
+\def\m!syntaxgroup{t-syntax-group}
+
+\def\definesyntaxgroup
+ {\dodoubleargument\syntaxgroup@define}
+
+\starttexdefinition syntaxgroup@define [#1][#2]
+ % #1 list name
+ % #2 options
+ \doifassignmentelse{#2}
+ {
+ \def\syntaxgroup@get_parameters##1%
+ {
+ \edef\syntaxgroup@name {\colorscheme@name##1}
+ \setupsyntaxgroup[\syntaxgroup@name]
+ [\s!parent=\syntaxgroup@namespace,\c!color=,\c!style=,\c!command=,#2]
+ \doifsomething{\syntaxgroupparameter\c!color}
+ {
+ \expanded{\definecolor[\syntaxgroup@namespace-##1-color]
+ [\syntaxgroupparameter\c!color]}
+ \setupsyntaxgroup[\syntaxgroup@name][\s!parent=\syntaxgroup@namespace,\c!color=\syntaxgroup@namespace-##1-color]
+ }
+ }
+ }{
+ \def\syntaxgroup@get_parameters##1%
+ {
+ \edef\syntaxgroup@name {\colorscheme@name##1}
+ \expanded{\setupsyntaxgroup[\syntaxgroup@name]
+ [\c!color=\namedsyntaxgroupparameter{\colorscheme@name#2}\c!color,
+ \c!style=\namedsyntaxgroupparameter{\colorscheme@name#2}\c!style,
+ \c!command=\namedsyntaxgroupparameter{\colorscheme@name#2}\c!command,
+ ]}
+
+ % In MkII, \expanded messes up the definition of \currentsyntaxgroup
+ \def\currentsyntaxgroup {\syntaxgroup@name}
+ }
+ }
+
+ \processcommalist[#1]\syntaxgroup@get_parameters
+\stoptexdefinition
+
+\def\startcolorscheme%
+ {\dosingleargument\colorscheme@start}
+
+\starttexdefinition colorscheme@start [#1]
+ \pushmacro\colorscheme@name
+ \setcolorscheme{#1}
+ %\setupsyntaxgroup[\c!color=,\c!style=,\c!command=]
+\stoptexdefinition
+
+\def\stopcolorscheme
+ {\popmacro\colorscheme@name}
+
+\def\setcolorscheme#1%
+ {\edef\colorscheme@name{#1}}
+
+\starttexdefinition syntaxgroup [#1]#2
+ % #1 = style
+ % #2 = content
+ \begingroup
+ \edef\syntaxgroup@name{\colorscheme@name#1}%
+ \syntaxgroupparameter\c!before
+ \iftracesyntaxgroups
+ \syntaxgroup@show_values
+ \fi
+ \doifmode{\s!mkiv}{\dostarttagged\t!syntaxgroup{#1}}
+ \syntaxgroupparameter\c!command
+ {
+ \externalfilter@attributes_start\syntaxgroup@id\c!style\c!color
+ #2
+ \externalfilter@attributes_stop
+ }
+ \doifmode{\s!mkiv}{\dostoptagged}
+ \syntaxgroupparameter\c!after
+ \endgroup
+\stoptexdefinition
+
+%D Tracing macros
+
+\newif\iftracesyntaxgroups
+\let\tracesyntaxgroups\tracesyntaxgroupstrue
+
+\def\currentsyntaxgroup {\syntaxgroup@name}
+
+\starttexdefinition syntaxgroup@show_values
+ \writestatus\m!syntaxgroup{color scheme : \colorscheme@name}
+ \writestatus\m!syntaxgroup{current group: \syntaxgroup@name}
+ \writestatus\m!syntaxgroup{command : \syntaxgroupparameter\c!command}
+ \writestatus\m!syntaxgroup{style : \syntaxgroupparameter\c!style}
+ \writestatus\m!syntaxgroup{color : \syntaxgroupparameter\c!color}
+\stoptexdefinition
+
+\protectmodulecatcodes
+\stopmodule
diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkii b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkii
new file mode 100644
index 0000000000..c50f3654d7
--- /dev/null
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkii
@@ -0,0 +1,257 @@
+%D \module
+%D [ file=t-syntax-highlight,
+%D version=2013.04.15,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Code syntax highlighting,
+%D author=Aditya Mahajan,
+%D date=\currentdate,
+%D copyright=Aditya Mahajan,
+%D email=adityam <at> ieee <dot> org,
+%D license=Simplified BSD License]
+
+\writestatus{loading}{Code syntax highlighting (ver: 2013.04.15)}
+
+\startmodule [syntax-highlight]
+\usemodule [syntax-groups]
+\usemodule [filter] % loads module-catcodes
+
+\unprotectmodulecatcodes
+
+\startinterface all
+ \setinterfaceconstant {syntax} {syntax}
+ \setinterfaceconstant {highlight} {highlight}
+ \setinterfaceconstant {highlightcolor} {highlightcolor}
+\stopinterface
+
+%D Name space
+
+\def\syntaxhighlighting@id {syntaxhighlighting}
+\def\syntaxhighlighting@namespace {@@@@\syntaxhighlighting@id}
+\def\syntaxhighlighting@name {}
+
+\edef\t!syntaxhighlighting {\syntaxhighlighting@id}
+
+\installparameterhandler \syntaxhighlighting@namespace \syntaxhighlighting@id
+\installsetuphandler \syntaxhighlighting@namespace \syntaxhighlighting@id
+
+%D Helper macro
+
+\def\syntaxhighlighting@yes{\v!yes,\v!on}
+
+\def\definesyntaxhighlighting
+ {\dodoubleargument\syntaxhighlighting@define}
+
+\starttexdefinition syntaxhighlighting@define [#1][#2]
+ \setupsyntaxhighlighting[#1][\s!parent=\syntaxhighlighting@namespace,#2]
+
+ \edef\syntaxhighlighting@name{#1}
+ \defineexternalfilter[#1][\s!parent=\syntaxhighlighting@namespace#1]
+
+ \doifmode\s!mkiv{\setups{syntaxhighlighting@setup_line_number_mkiv}}
+
+ \setvalue{type#1file}{\getvalue{process#1file}}
+
+\stoptexdefinition
+
+\startsetups syntaxhighlighting@setup
+
+ \edef\syntaxhighlighting@name{\currentexternalfilter}
+ \edef\colorscheme@name{\externalfilterparameter\c!alternative}
+
+ \let\SYN\syntaxgroup
+ \edef\HGL{\externalfilterparameter{\c!highlight\c!command}}
+ \let\\\textbackslash
+ \let\{\textbraceleft
+ \let\}\textbraceright
+ \let\SYNBOL\donothing
+ \let\SYNEOL\donothing
+
+ \def\tab##1%
+ {\dorecurse{##1}{\obeyedspace}}%
+
+ \setups{syntaxhighlighting@setup_line_number_mkii}%
+
+ \forgetall
+ \doifinset{\externalfilterparameter\c!option}{\v!packed}
+ {\setupwhitespace[\v!none,\v!flexible]}%
+
+ \doifnotinset{\externalfilterparameter\c!option}{\v!hyphenated}
+ {\language\minusone}%
+
+ \setcatcodetable\externalfilter@minimal_catcodes
+ \expandafter\def\activeendoflinetoken{\strut\par}
+ \activatespacehandler{\syntaxhighlighting@namespace\externalfilterparameter\c!space}
+ \raggedright
+\stopsetups
+
+\startsetups syntaxhighlighting@setup_line_number_mkiv
+\definelinenumbering [#1]
+
+\setuplinenumbering
+ [#1]
+ [\c!conversion=\externalfilterparameter\c!numberconversion,
+ \c!start=\externalfilterparameter{\c!number\c!start},
+ \c!step=\externalfilterparameter{\c!number\c!step},
+ \c!method=\externalfilterparameter{\c!number\c!method},
+ \c!location=\externalfilterparameter{\c!number\c!location},
+ \c!style=\externalfilterparameter\c!numberstyle,
+ \c!color=\externalfilterparameter\c!numbercolor,
+ \c!width=\externalfilterparameter{\c!number\c!width},
+ \c!left=\externalfilterparameter{\c!number\c!left},
+ \c!right=\externalfilterparameter{\c!number\c!right},
+ \c!command=\externalfilterparameter\c!numbercommand,
+ \c!distance=\externalfilterparameter{\c!number\c!distance},
+ \c!align=\externalfilterparameter{\c!number\c!align},
+ ]
+\stopsetups
+
+\doifmode\s!mkii
+ {\newcount\syntaxhighlighting@linenumber}
+
+\startsetups syntaxhighlighting@setup_line_number_mkii
+\doifinset{\externalfilterparameter\c!numbering}\syntaxhighlighting@yes
+ {% setuplinenumbering resets \linenumber. So we save the value of linenumber and
+ % revert it back.
+ \syntaxhighlighting@linenumber=\linenumber
+
+ \setuplinenumbering
+ [\c!conversion=\externalfilterparameter\c!numberconversion,
+ \c!start=\externalfilterparameter{\c!number\c!start},
+ \c!step=\externalfilterparameter{\c!number\c!step},
+ \c!method=\externalfilterparameter{\c!number\c!method},
+ \c!location=\externalfilterparameter{\c!number\c!location},
+ \c!style=\externalfilterparameter\c!numberstyle,
+ \c!color=\externalfilterparameter\c!numbercolor,
+ \c!width=\externalfilterparameter{\c!number\c!width},
+ \c!left=\externalfilterparameter{\c!number\c!left},
+ \c!right=\externalfilterparameter{\c!number\c!right},
+ \c!command=\externalfilterparameter\c!numbercommand,
+ \c!distance=\externalfilterparameter{\c!number\c!distance},
+ \c!align=\externalfilterparameter{\c!number\c!align},
+ ]
+
+ \linenumber=\syntaxhighlighting@linenumber}
+\stopsetups
+
+\starttexdefinition syntaxhighlighting@read_command #1
+ \syntaxhighlighting@linenumbering_start
+ \ReadFile{#1}
+ \syntaxhighlighting@linenumbering_stop
+\stoptexdefinition
+
+
+\starttexdefinition syntaxhighlighting@linenumbering_stop
+ \dostoptagged
+ \doifinset{\externalfilterparameter\c!numbering}\syntaxhighlighting@yes
+ {\stoplinenumbering}
+\stoptexdefinition
+
+\starttexdefinition syntaxhighlighting@linenumbering_start
+ \doifinset{\externalfilterparameter\c!numbering}\syntaxhighlighting@yes
+ {\doifelse{\externalfilterparameter{\c!number\c!continue}}\syntaxhighlighting@yes
+ {\startlinenumbering[\v!continue]}
+ {\startlinenumbering}}
+\stoptexdefinition
+\starttexdefinition syntaxhighlighting@linenumbering_stop
+ \doifinset{\externalfilterparameter\c!numbering}\syntaxhighlighting@yes
+ {\stoplinenumbering}
+\stoptexdefinition
+
+
+\setupsyntaxhighlighting
+ [\c!tab=4,
+ \c!space=\v!off,
+ \c!lines=\v!split,
+ \c!start=1,
+ \c!stop=0,
+ % \c!syntax=context,
+ \c!alternative=pscolor,
+ \c!before=,
+ \c!after=,
+ \c!spacebefore=\v!none,
+ \c!spaceafter=\v!none,
+ \c!location=\v!paragraph,
+ \c!style=\tttf,
+ \c!color=,
+ \c!align={\v!flushleft,\v!nothyphenated}, %Does not work due to \forgetall
+ \c!filtercommand=echo, % placeholder
+ \c!continue=yes,
+ \c!read=\v!yes,
+ \c!readcommand=\syntaxhighlighting@read_command,
+ \c!output=\externalfilterinputfile, % placeholder
+ \c!setups=syntaxhighlighting@setup,
+ \c!option=\v!packed, % \v!hyphenated
+ \s!parent=\externalfilter@namespace,
+ % Numbering options
+ \c!numbering=\v!no,
+ \c!number\c!start=1,
+ \c!number\c!step=1,
+ \c!number\c!continue=\v!no,
+ \c!numberconversion=\v!numbers,
+ \c!number\c!method=\v!first,
+ \c!number\c!location=\v!left,
+ \c!numberstyle=\ttx,
+ \c!numbercolor=,
+ \c!number\c!width=2em,
+ \c!number\c!left=,
+ \c!number\c!right=,
+ \c!numbercommand=,
+ \c!number\c!distance=0.5em,
+ \c!number\c!align=\v!flushright,
+ %Highlight options
+ \c!highlight=,
+ \c!highlightcolor=lightgray,
+ \c!highlight\c!command=\syntaxhighlightline,
+ ]
+
+\def\currentsyntaxhighlighting {\syntaxhighlighting@name}
+
+% Space handler
+%
+% The space handing code for MkII and MkIV is not consistent. So, we provide our
+% own versions.
+
+\setvalue{\syntaxhighlighting@namespace @\c!lines @\v!split}{\hskip}
+\setvalue {\syntaxhighlighting@namespace @\c!lines @\v!fixed}{\dontleavehmode\kern}
+
+% default
+\setvalue{\syntaxhighlighting@namespace @\c!lines @}{\hskip}
+
+\def\syntaxhighlighting@split%
+ {\getvalue{\syntaxhighlighting@namespace @\c!lines @\externalfilterparameter\c!lines}}
+
+% Visible space
+\installspacehandler {\syntaxhighlighting@namespace\v!on}
+ {\obeyspaces
+ \unexpanded\def\obeyedspace
+ {\syntaxhighlighting@split\zeropoint\relax
+ \hbox{\normalcontrolspace}%
+ \syntaxhighlighting@split\zeropoint\relax}}%
+
+% Invisible space
+\installspacehandler {\syntaxhighlighting@namespace\v!off}
+ {\obeyspaces
+ \unexpanded\def\obeyedspace
+ {\syntaxhighlighting@split\interwordspace\relax}}
+
+% Default
+\installspacehandler {\syntaxhighlighting@namespace}
+ {\activatespacehandler {\syntaxhighlighting@namespace\v!off}}
+
+% Line highlighting
+
+\definetextbackground[syntaxhighlightline]
+ [\c!location=\v!text,
+ %% location=paragraph causes a spurious line break
+ \c!alternative=0,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=\externalfilterparameter\c!highlightcolor,
+ \c!before=,
+ \c!after=,
+ ]
+
+
+\protectmodulecatcodes
+
+\stopmodule
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
new file mode 100644
index 0000000000..17019e1485
--- /dev/null
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv
@@ -0,0 +1,245 @@
+%D \module
+%D [ file=t-syntax-highlight,
+%D version=2018.08.10,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Code syntax highlighting,
+%D author=Aditya Mahajan,
+%D date=\currentdate,
+%D copyright=Aditya Mahajan,
+%D email=adityam <at> ieee <dot> org,
+%D license=Simplified BSD License]
+
+\writestatus{loading}{Code syntax highlighting (ver: 2018.08.10)}
+
+\startmodule [syntax-highlight]
+\usemodule [syntax-groups]
+\usemodule [filter] % loads module-catcodes
+
+\unprotect
+
+\startinterface all
+ \setinterfaceconstant {syntax} {syntax}
+ \setinterfaceconstant {highlight} {highlight}
+ \setinterfaceconstant {highlightcolor} {highlightcolor}
+\stopinterface
+
+%D Name space
+
+\definenamespace
+ [syntaxhighlighting]
+ [\c!type=module,
+ \c!name=syntaxhighlighting,
+ \c!command=\v!yes,
+ setup=\v!list,
+ \c!style=\v!no,
+ \s!parent=syntaxhighlighting]
+
+\appendtoks
+ \defineexternalfilter[\currentsyntaxhighlighting]
+ [\s!parent=\????syntaxhighlighting\currentexternalfilter,\c!taglabel=\vimtyping@id]%
+ \normalexpanded{\definelinenumbering [\currentsyntaxhighlighting]}%
+ \setevalue{type\currentsyntaxhighlighting file}{\getvalue{process\currentsyntaxhighlighting file}}%
+\to\everydefinesyntaxhighlighting
+
+\appendtoks
+ % \externalfitlterparameter does not work, so it is better to use
+ % \syntaxhighlighting parameter.
+ \normalexpanded{\setuplinenumbering[\currentsyntaxhighlighting]
+ [
+ \c!method=\syntaxhighlightingparameter{\c!number\c!method},
+ \c!conversion=\syntaxhighlightingparameter\c!numberconversion,
+ \c!location=\syntaxhighlightingparameter{\c!number\c!location},
+ \c!style=\syntaxhighlightingparameter\c!numberstyle,
+ \c!color=\syntaxhighlightingparameter\c!numbercolor,
+ \c!width=\syntaxhighlightingparameter{\c!number\c!width},
+ \c!left=\syntaxhighlightingparameter{\c!number\c!left},
+ \c!right=\syntaxhighlightingparameter{\c!number\c!right},
+ \c!command=\syntaxhighlightingparameter\c!numbercommand,
+ \c!distance=\syntaxhighlightingparameter{\c!number\c!distance},
+ \c!align=\syntaxhighlightingparameter{\c!number\c!align},
+ ]}%
+\to\everysetupsyntaxhighlighting
+
+\def\syntaxhighlighting@id {syntaxhighlighting}
+\edef\t!syntaxhighlighting {\syntaxhighlighting@id}
+
+%D Helper macro
+
+\def\syntaxhighlighting@yes{\v!yes,\v!on}
+
+\startsetups syntaxhighlighting@setup
+
+ \edef\currentsyntaxhighlighting{\currentexternalfilter}
+ \edef\colorscheme@name{\externalfilterparameter\c!alternative}
+
+ \let\SYN\syntaxgroup
+ \edef\HGL{\externalfilterparameter{\c!highlight\c!command}}
+ \let\\\textbackslash
+ \let\{\textbraceleft
+ \let\}\textbraceright
+ \let\SYNBOL\donothing
+ \let\SYNEOL\donothing
+
+ \setupbar[syntaxhighlightline][color=\externalfilterparameter\c!highlightcolor]
+
+ \def\tab##1%
+ {\dorecurse{##1}{\obeyedspace}}%
+
+ \forgetall
+ \usealignparameter\externalfilterparameter
+ \doifinset{\externalfilterparameter\c!option}{\v!packed}
+ {\setupwhitespace[\v!none,\v!flexible]}%
+
+ \doadaptleftskip{\externalfilterparameter\c!margin}%
+
+ \setbreakpoints[compound]% Only works is `option=hyphenated` is set.
+ \doifnotinset{\externalfilterparameter\c!option}{\v!hyphenated}
+ {\language\minusone}%
+
+ \def\obeyedline{\strut\par}
+ \setcatcodetable\externalfilter@minimal_catcodes%
+ \letcharcode\endoflineasciicode\obeyedline
+ \letcharcode\spaceasciicode\obeyedspace
+ \activatespacehandler{\????syntaxhighlighting\externalfilterparameter\c!space}
+ \raggedright
+\stopsetups
+
+\starttexdefinition syntaxhighlighting@read_command #1
+ \syntaxhighlighting@linenumbering_start
+ \ReadFile{#1}
+ \syntaxhighlighting@linenumbering_stop
+\stoptexdefinition
+
+\starttexdefinition syntaxhighlighting@linenumbering_start
+ \doifinset{\externalfilterparameter\c!numbering}\syntaxhighlighting@yes
+ {\let\SYNBOL=\syntaxhighlighting_begin_number_lines
+ \let\SYNEOL=\syntaxhighlighting_end_number_lines
+ \startlinenumbering
+ [\currentsyntaxhighlighting]
+ [
+ \c!method=\v!type,
+ \c!start=\externalfilterparameter{\c!number\c!start},
+ \c!step=\externalfilterparameter{\c!number\c!step},
+ \c!continue=\externalfilterparameter{\c!number\c!continue},
+ ]}
+ \dostarttagged\t!syntaxhighlighting\colorscheme@name
+\stoptexdefinition
+
+\starttexdefinition syntaxhighlighting@linenumbering_stop
+ \dostoptagged
+ \doifinset{\externalfilterparameter\c!numbering}\syntaxhighlighting@yes
+ {\stoplinenumbering}
+\stoptexdefinition
+
+\newcount\nofsyntaxhighlightinglines
+
+\starttexdefinition syntaxhighlighting_begin_number_lines
+ \global\advance\nofsyntaxhighlightinglines\plusone
+ \attribute\verbatimlineattribute\nofsyntaxhighlightinglines
+\stoptexdefinition
+
+\starttexdefinition syntaxhighlighting_end_number_lines
+ \attribute\verbatimlineattribute\attributeunsetvalue
+\stoptexdefinition
+
+
+\setupsyntaxhighlighting
+ [\c!tab=4,
+ \c!space=\v!off,
+ \c!lines=\v!fixed,
+ \c!margin=\zeropoint,
+ \c!start=1,
+ \c!stop=0,
+ % \c!syntax=context,
+ \c!alternative=pscolor,
+ \c!before=,
+ \c!after=,
+ \c!spacebefore=\v!none,
+ \c!spaceafter=\v!none,
+ \c!location=\v!paragraph,
+ \c!style=\tttf,
+ \c!color=,
+ \c!align={\v!flushleft,\v!nothyphenated},
+ \c!filtercommand=echo, % placeholder
+ \c!continue=yes,
+ \c!read=\v!yes,
+ \c!readcommand=\syntaxhighlighting@read_command,
+ \c!output=\externalfilterinputfile, % placeholder
+ \c!setups=syntaxhighlighting@setup,
+ \c!option=\v!packed, % \v!hyphenated
+ \s!parent=\????externalfilter,
+ % Numbering options
+ \c!numbering=\v!no,
+ \c!number\c!start=1,
+ \c!number\c!step=1,
+ \c!number\c!continue=\v!no,
+ \c!numberconversion=\v!numbers,
+ \c!number\c!method=\v!type,
+ \c!number\c!location=\v!left,
+ \c!numberstyle=\ttx,
+ \c!numbercolor=,
+ \c!number\c!width=2em,
+ \c!number\c!left=,
+ \c!number\c!right=,
+ \c!numbercommand=,
+ \c!number\c!distance=0.5em,
+ \c!number\c!align=\v!flushright,
+ %Highlight options
+ \c!highlight=,
+ \c!highlightcolor=lightgray,
+ \c!highlight\c!command=\syntaxhighlightline,
+ ]
+
+% Space handler
+%
+% The space handing code for MkII and MkIV is not consistent. So, we provide our
+% own versions.
+
+\setvalue{\????syntaxhighlighting::\c!lines::\v!split}{\hskip}
+\setvalue{\????syntaxhighlighting::\c!lines::\v!fixed}{\dontleavehmode\kern}
+
+% default
+\setvalue{\????syntaxhighlighting::\c!lines::}{\dontleavehmode\kern}
+
+\def\syntaxhighlighting@split%
+ {\getvalue{\????syntaxhighlighting::\c!lines::\externalfilterparameter\c!lines}}
+
+% Visible space
+\installspacemethod {\????syntaxhighlighting\v!on}
+ {\unexpanded\def\obeyedspace
+ {\mathortext\normalspace
+ {\syntaxhighlighting@split\zeropoint\relax
+ \hbox{\normalcontrolspace}%
+ \syntaxhighlighting@split\zeropoint\relax}}%
+ \letcharcode\spaceasciicode\obeyedspace}
+
+% Invisible space
+\installspacemethod {\????syntaxhighlighting\v!off}
+ {\unexpanded\def\obeyedspace
+ {\mathortext\normalspace
+ {\syntaxhighlighting@split\interwordspace\relax}}%
+ \letcharcode\spaceasciicode\obeyedspace}
+
+% Default
+\installspacemethod {\????syntaxhighlighting}
+ {\activatespacehandler {\????syntaxhighlighting\v!off}}
+
+% Line highlighting
+
+\definebar[syntaxhighlightline]
+ [\c!order=\v!background,
+ \c!rulethickness=2.5,
+ \c!method=0,
+ \c!offset=1.375,
+ \c!continue=\v!yes,
+ \c!color=\externalfilterparameter\c!highlightcolor,
+ ]
+
+% For backward compatibility
+\def\syntaxhighlighting@namespace {\????syntaxhighlighting}
+\def\syntaxhighlighting@name {\currentsyntaxhighlighting}
+
+\protect
+
+\stopmodule
+
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
new file mode 100644
index 0000000000..3cd83cdb2f
--- /dev/null
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex
@@ -0,0 +1,439 @@
+%D \module
+%D [ file=t-vim,
+%D version=2018.04.17,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Vim syntax highlighting,
+%D author=Aditya Mahajan,
+%D date=\currentdate,
+%D copyright=Aditya Mahajan,
+%D email=adityam <at> ieee <dot> org,
+%D license=Simplified BSD License]
+
+\writestatus{loading}{Vim syntax highlighting (ver: 2018.04.17)}
+
+\startmodule [vim]
+\usemodule [filter] % loads module catcodes
+\usemodule [syntax-highlight] % loads syntax-groups and filter module
+
+\startinterface all
+ \setinterfaceconstant {vimrc} {vimrc}
+\stopinterface
+
+\unprotectmodulecatcodes
+
+\def\vimtyping@id {vimtyping}
+\def\vimtyping@namespace {@@@@\vimtyping@id}
+\def\vimtyping@name {}
+
+\def\vimrc@id {vimrc}
+
+\installparameterhandler \vimtyping@namespace \vimtyping@id
+\installsetuphandler \vimtyping@namespace \vimtyping@id
+
+\def\definevimtyping
+ {\dodoubleargument\vimtyping@define}
+
+\starttexdefinition vimtyping@define [#1][#2]
+ \setupvimtyping[#1][\s!parent=\vimtyping@namespace,#2]
+
+ \definesyntaxhighlighting[#1][\s!parent=\vimtyping@namespace#1]
+ \setupsyntaxhighlighting [#1][#2]
+
+
+ \setvalue{\e!start raw#1}{\bgroup\obeylines\dodoubleargument\vimtyping@start_raw[#1]}
+ \setvalue{\e!stop raw#1}{\vimtyping@stop_raw}
+ \setvalue{inlineraw#1}{\dodoubleargument\vimtyping@inline_raw[#1]}
+\stoptexdefinition
+
+\starttexdefinition vimtyping@start_raw [#1][#2]
+ % #1 = filter
+ % #2 = options
+ \egroup %\bgroup in \start#1
+
+ \edef\vimtyping@name{#1}
+ \edef\externalfilter@name{#1}
+ \edef\currentexternalfilter{#1}
+
+ \begingroup % to keep assignments local
+ \setupvimtyping[#1][\c!name=,#2]
+
+ \externalfilterparameter\c!before
+
+ \externalfilter@attributes_start \externalfilter@id \c!style \c!color
+ \syntaxhighlighting@linenumbering_start
+ \processcommacommand[\externalfilterparameter\c!setups]\directsetup
+ \gobbleoneargument % For some reason the next argument is \type{^M}
+\stoptexdefinition
+
+\starttexdefinition vimtyping@stop_raw
+ % The last argument of the environment is \type{^M},
+ % so we explicitly backup one line.
+ \nobreak
+ \vskip-\dimexpr\lineheight+\parskip\relax
+ \nobreak
+
+ \removeunwantedspaces
+ \syntaxhighlighting@linenumbering_stop
+ \externalfilter@attributes_stop
+ \externalfilterparameter\c!after
+ \endgroup
+
+\stoptexdefinition
+
+\starttexdefinition vimtyping@inline_raw [#1][#2]
+ % #1 = filter
+ % #2 = options
+
+ \edef\vimtyping@name{#1}
+ \edef\externalfilter@name{#1}
+ \edef\currentexternalfilter{#1}
+
+ \begingroup % to keep assignments local
+ \setupvimtyping[#1][\c!name=,\c!location=\v!text,#2]
+
+ \externalfilter@attributes_start \externalfilter@id \c!style \c!color
+ % We assume that the setups set minimal_catcodes
+ \processcommacommand[\externalfilterparameter\c!setups]\directsetup
+
+ \vimtyping@inline_raw_indeed
+\stoptexdefinition
+
+\starttexdefinition vimtyping@inline_raw_indeed #1
+ #1
+ \externalfilter@attributes_stop
+ \endgroup
+\stoptexdefinition
+
+% Mode to testing the dev version of 2context script.
+\doifmodeelse{vim-dev}
+ {\def\vimtyping@script_name{2context.vim}}
+ {\doifmodeelse\s!mkiv
+ {\ctxlua{context.setvalue("vimtyping@script_name",resolvers.resolve("full:2context.vim"))}}
+ {\def\vimtyping@script_name{kpse:2context.vim}}}
+
+\def\vimtyping@filter_command
+ {vim -u \vimrc_filename\space % read global config file
+ % --startuptime log
+ % -V3log
+ -X % dont connect to X server
+ -i NONE % dont use viminfo file
+ --noplugin % dont load plugins
+ -e % run in ex mode
+ -s % silent
+ -C % set compatible
+ -n % no swap file
+ -c "syntax manual" % don't load filetype detection
+ -c "set syntax=\externalfilterparameter\c!syntax" %
+ -c "set tabstop=\externalfilterparameter\c!tab" %
+ % vim only accepts 10 -c commands, so we combine a few let statements
+ -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 highlight=[\externalfilterparameter\c!highlight]" %
+ \vimrc_extras\space
+ -c "source \vimtyping@script_name" %
+ -c "qa" %
+ \externalfilterinputfile\space
+ \externalfilteroutputfile}
+
+\setvalue{\vimtyping@id-\c!strip-\v!off}{0}
+\setvalue{\vimtyping@id-\c!strip-\v!on}{1}
+
+\setvalue{\vimtyping@id-\c!escape-\v!off}{0}
+\setvalue{\vimtyping@id-\c!escape-\v!on}{1}
+
+
+% Undocumented ... but useful if the user makes a mistake
+\setvalue{\vimtyping@id-\c!strip-\v!no}{0}
+\setvalue{\vimtyping@id-\c!strip-\v!yes}{1}
+
+\setvalue{\vimtyping@id-\c!escape-\v!no}{0}
+\setvalue{\vimtyping@id-\c!escape-\v!yes}{1}
+
+
+\setupvimtyping
+ [% \c!tab=4,
+ % \c!start=1,
+ % \c!stop=0,
+ % \c!syntax=context,
+ % \c!alternative=pscolor,
+ % \c!before=,
+ % \c!after=,
+ % \c!style=\tttf,
+ % \c!color=,
+ \c!strip=\v!yes,
+ \c!escape=\v!off,
+ % \c!highlight=,
+ % \c!highlightcolor=lightgray,
+ \c!filtercommand=\vimtyping@filter_command,
+ % \c!continue=yes,
+ % \c!read=\v!yes,
+ % \c!readcommand=\syntaxhighlighting@read_command,
+ \c!output=\externalfilterbasefile.vimout,
+ %\c!setups=syntaxhighlighting@setup,
+ \c!filter\c!setups=vimrc@setup,
+ % \c!option=\v!packed, % Could be a list
+ \s!parent=\syntaxhighlighting@namespace,
+ \c!vimrc=,
+ % % Numbering options
+ % \c!numbering=\v!no,
+ % \c!number\c!start=1,
+ % \c!number\c!step=1,
+ % \c!number\c!continue=\v!no,
+ % \c!numberconversion=\v!numbers,
+ % \c!number\c!method=\v!first,
+ % \c!number\c!location=\v!left,
+ % \c!numberstyle=\ttx,
+ % \c!numbercolor=,
+ % \c!number\c!width=2em,
+ % \c!number\c!left=,
+ % \c!number\c!right=,
+ % \c!number\c!command=,
+ % \c!number\c!distance=0.5em,
+ % \c!number\c!align=\v!flushright,
+ ]
+
+\def\currentvimtyping {\vimtyping@name}
+
+\defineexternalfilter
+ [\vimrc@id]
+ [\c!continue=\v!no,
+ \c!read=\v!no,
+ \c!purge=\v!no,
+ \c!filtercommand=\empty]
+
+\def\vimrcfile_name{NONE}
+\def\vimrc_extras{}
+
+\startsetups vimrc@setup
+ \doifelsenothing{\externalfilterparameter\c!vimrc}
+ {\def\vimrc_filename{NONE}}
+ {\begingroup
+ \expanded{\setupexternalfilter[\vimrc@id][\c!name=\externalfilterparameter\c!vimrc]}
+
+ \edef\externalfilter@name{\vimrc@id}
+ \edef\currentexternalfilter{\vimrc@id}
+
+ \externalfilter@set_filenames
+
+ \global\xdef\vimrc_filename{\externalfilter@input_file}
+ \endgroup
+ }
+
+ \doifelsenothing{\externalfilterparameter\c!extras}
+ {\def\vimrc_extras{}}
+ {\begingroup
+ \expanded{\setupexternalfilter[\vimrc@id][\c!name=\externalfilterparameter\c!extras]}
+
+ \edef\externalfilter@name{\vimrc@id}
+ \edef\currentexternalfilter{\vimrc@id}
+
+ \externalfilter@set_filenames
+
+ \global\xdef\vimrc_extras{-c "source \externalfilter@input_file"}
+ \endgroup
+ }
+\stopsetups
+
+\defineframed[vimtodoframed]
+ [
+ \c!location=\v!low,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=vimtodoyellow,
+ ]
+
+\definecolor[vimtodoyellow]
+ [h={E0E090}]
+
+\startsetups[vim-minor-groups]
+ \definesyntaxgroup
+ [SpecialComment]
+ [Comment]
+
+ \definesyntaxgroup
+ [String,Character,Number,Boolean,Float]
+ [Constant]
+
+ \definesyntaxgroup
+ [Function]
+ [Identifier]
+
+ \definesyntaxgroup
+ [Condition,Repeat,Label,Operator,Keyword,Exception]
+ [Statement]
+
+ \definesyntaxgroup
+ [Include,Define,Macro,PreCondit]
+ [Preproc]
+
+ \definesyntaxgroup
+ [StorageClass,Structure,Typedef]
+ [Type]
+
+ \definesyntaxgroup
+ [SpecialChar,Delimiter,Debug]
+ [Special]
+\stopsetups
+
+\startcolorscheme[pscolor]
+ % Vim Preferred groups
+ \definesyntaxgroup
+ [Constant]
+ [\c!color={h=007068}]
+
+ \definesyntaxgroup
+ [Identifier]
+ [\c!color={h=a030a0}]
+
+ \definesyntaxgroup
+ [Statement]
+ [\c!color={h=2060a8}]
+
+ \definesyntaxgroup
+ [PreProc]
+ [\c!color={h=009030}]
+
+ \definesyntaxgroup
+ [Type]
+ [\c!color={h=0850a0}]
+
+ \definesyntaxgroup
+ [Special]
+ [\c!color={h=907000}]
+
+ \definesyntaxgroup
+ [Comment]
+ [\c!color={h=606000}]
+
+ \definesyntaxgroup
+ [Ignore]
+
+ \definesyntaxgroup
+ [Todo]
+ [\c!color={h=800000},
+ \c!command=\vimtodoframed]
+
+
+ \definesyntaxgroup
+ [Error]
+ [\c!color={h=c03000}]
+
+ \definesyntaxgroup
+ [Underlined]
+ [\c!color={h=6a5acd},
+ \c!command=\underbar]
+
+ \definesyntaxgroup
+ [Todo]
+ [\c!color={h=800000},
+ \c!command=\vimtodoframed]
+
+ \setups{vim-minor-groups}
+
+ \definesyntaxgroup
+ [Number]
+ [\c!color={h=907000}]
+\stopcolorscheme
+
+\startcolorscheme[blackandwhite]
+ \definesyntaxgroup
+ [Constant]
+
+ \definesyntaxgroup
+ [Identifier]
+
+ \definesyntaxgroup
+ [Statement]
+ [\c!style=bold]
+
+ \definesyntaxgroup
+ [PreProc]
+ [\c!style=bold]
+
+ \definesyntaxgroup
+ [Type]
+ [\c!style=bold]
+
+ \definesyntaxgroup
+ [Special]
+
+ \definesyntaxgroup
+ [Comment]
+ [\c!style=italic]
+
+ \definesyntaxgroup
+ [Ignore]
+
+ \definesyntaxgroup
+ [Todo]
+ [\c!command=\inframed]
+
+ \definesyntaxgroup
+ [Error]
+ [\c!command=\overstrike]
+
+ \definesyntaxgroup
+ [Underlined]
+ [\c!command=\underbar]
+
+ \setups{vim-minor-groups}
+
+\stopcolorscheme
+
+\startcolorscheme[kate]
+ % Temporary definition... will change
+ % . kw dsKeyword
+ % . dt dsDataType
+ % . dv dsDecVal
+ % . bn dsBaseN
+ % . fl dsFloat
+ % . ch dsChar
+ % . st dsString
+ % . co dsComment
+ % . ot dsOthers
+ % . al dsAlert
+ % . fu dsFunction
+ % . re dsRegionMarker
+ % . er dsError
+ \definesyntaxgroup
+ [kw]
+ [\c!color={h=007020}, \c!style=bold]
+
+ \definesyntaxgroup
+ [dt]
+ [\c!color={h=902000}]
+
+ \definesyntaxgroup
+ [dv, bn, fl]
+ [\c!color={h=40a070}]
+
+ \definesyntaxgroup
+ [ch, st]
+ [\c!color={h=4070a0}]
+
+ \definesyntaxgroup
+ [co]
+ [\c!color={h=60a0b0}, \c!style=italic]
+
+ \definesyntaxgroup
+ [ot]
+ [\c!color={h=007020}]
+
+ \definesyntaxgroup
+ [al, er]
+ [\c!color=red, \c!style=bold]
+
+ \definesyntaxgroup
+ [fu]
+ [\c!color={h=06287e}]
+
+ \definesyntaxgroup
+ [re]
+
+\stopcolorscheme
+\protectmodulecatcodes
+
+\stopmodule
+