summaryrefslogtreecommitdiff
path: root/macros/context/contrib/context-vim
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
Initial commit
Diffstat (limited to 'macros/context/contrib/context-vim')
-rw-r--r--macros/context/contrib/context-vim/VERSION1
-rw-r--r--macros/context/contrib/context-vim/doc/context/third/vim/vim.txt622
-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
7 files changed, 1847 insertions, 0 deletions
diff --git a/macros/context/contrib/context-vim/VERSION b/macros/context/contrib/context-vim/VERSION
new file mode 100644
index 0000000000..95c275e403
--- /dev/null
+++ b/macros/context/contrib/context-vim/VERSION
@@ -0,0 +1 @@
+2018.08.10
diff --git a/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt b/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt
new file mode 100644
index 0000000000..801d1fb34c
--- /dev/null
+++ b/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt
@@ -0,0 +1,622 @@
+The vim module
+==============
+
+This module highlights code snippets using vim as a syntax
+highlighter. Such a task may appear pointless at first glance. After all,
+ConTeXt provides excellent syntax highlighting features for TeX, Metapost, XML,
+and a few other languages. And in MkIV, you can specify the grammar to parse a
+language, and get syntax highlighting for a new language. But writing such
+grammars is difficult. More importantly, why reinvent the wheel? Most
+editors, and many other syntax highlighting programs, already syntax highlight
+many programming languages. Why not just leverage these external programs to
+generate syntax highlighting? This module does exactly that.
+
+Compatibility
+------------
+
+This module works with both MkII and MkIV.
+
+To get colors with MkII, use
+
+ \setupcolors[state=start]
+
+If avoid `--` and `---` to turn into `–` and `—` in MkII, use
+
+ \usetypescript [modern] [texnansi]
+ \setupbodyfont [modern]
+
+Both colors and no ligatures work out of the box in MkIV.
+
+
+Installation
+------------
+
+This module depends on the `t-filter` module. If you are using ConTeXt
+standalone, you can install the module using
+
+ first-setup.sh --modules="t-filter,t-vim"
+
+Depending on your TeX distribution, you may already have the module.
+To verify, check if
+
+ kpsewhich t-vim.tex
+
+returns a meaningful path. If not, you have to manually install the module.
+Download the latest version of the `filter` and `vim` modules from
+[http://github.com/adityam/filter/downloads](http://github.com/adityam/filter/downloads)
+and unzip them either `$TEXMFHOME` or `$TEXMFLOCAL`. Run
+
+ mktexlsr
+
+and
+
+ mtxrun --generate
+
+to refresh the TeX file database (for MkII and MkIV, respectively). If
+everything went well
+
+ kpsewhich t-vim
+
+will return the path where you stored the file.
+
+Unfortunately, that is not enough. For the module to work, TeX must be able to
+call an external program. This feature is a potential security risk and is
+disabled by default on most TeX distributions. To enable this feature, you must
+set
+
+ shell_escape=t
+
+in your `texmf.cnf` file. See this page
+[http://wiki.contextgarden.net/write18](http://wiki.contextgarden.net/write18)
+on the ConTeXt wiki for detailed instructions.
+
+
+Usage
+-----
+
+Suppose you want to syntax highlight Ruby. In particular, you want
+
+ \startRUBY
+ # Wow, my first ruby program
+ print("Hello World")
+ \stopRUBY
+
+to be printed with Ruby syntax highlighting. To get that, define
+
+ \definevimtyping [RUBY] [syntax=ruby]
+
+Yes, its that easy. To get syntax highlighting for a particular language, all
+you need to know what is its `filetype` in vim. If you don't know that, start
+vim and type `:help syntax.txt` and go through the list of supported languages to
+find the name of the language that you are interested in. (Oh, and in case you
+don't know how to quit vim, type `:qa!`.) Vim supports syntax
+highlighting for more than 500 programming languages; the `t-vim` module enables
+you to use any of them with just one `\definevimtyping`.
+
+The command
+
+ \definevimtyping [RUBY] [syntax=ruby]
+
+defines three things:
+
+1. An environment
+
+ \startRUBY
+ ...
+ \stopRUBY
+
+ The contents of this environment are processed by a vim script
+ (`2context.vim`) and the result is read back in ConTeXt.
+
+2. A macro
+
+ \inlineRUBY{...}
+
+ The contents of this environment are processed by a vim script
+ (`2context.vim`) and the result is read back in ConTeXt.
+
+3. A macro
+
+ \typeRUBYfile{...}
+
+ The argument of this macro must a file name or a url (urls work in MkIV
+ only). That file is processed by `2context.vim` and the result is read back
+ in ConTeXt. For controling how frequently a remote file is downloaded when
+ processing a url, see the _Processing remote files_ section of the
+ `t-filter` manual.
+
+In all the three cases, the `t-filter` module takes care of writing to external
+file, processing by `2context.vim`, and reading the contents back to ConTeXt.
+The `t-vim` module simply defines the macros that are used by `2context.vim`.
+
+
+Start and stop lines
+--------------------
+
+The `\start<vimtyping>` ... `\stop<vimtyping>` environment and the `\type<vimtyping>file`
+macro take an optional argument that is used to set options.
+
+For example, to typeset lines 15 through 25 of a ruby file
+`rails_install.rb`, use:
+
+ \typeRUBYfile[start=15,stop=25]{rails_install.rb}
+
+To exclude 10 lines from the end, set `stop=-10`.
+
+Changing tab skip
+-----------------
+
+By default, a literal tab (`0x09` or `^I`) character has a width of 8 spaces. For most
+cases, this is too excessive. To reduce the shift of a tab, use the `tab` key.
+For example:
+
+ \definevimtyping
+ [...]
+ [...
+ tab=4,
+ ...]
+
+changes the tab width to four spaces.
+
+Avoid clutter
+-------------
+
+Running an external file through vim is slow. So, `t-vim` reprocesses a snippet
+or a file only if its contents have changed. To check if the contents have
+changed, it writes each snippet to a different file and stores the md5 sum of
+that snippet. As a result, the working directory gets cluttered with lot of
+temporary files. To avoid this clutter, write the temporary files to a
+different directory using the `directory` key. For example,
+
+ \definevimtyping[...]
+ [directory=output/]
+
+ensures that all the temporary files are written to the `output` directory. See
+the section on _Output Directory_ in the documentation of `t-filter` module for
+more details.
+
+Before and after
+---------------
+
+Like most ConTeXt environments, `\definevimtyping` also accepts the `before` and
+`after` options. These can be used, for example, to enclose the output in a
+frame, etc.
+
+Changing the color scheme
+-------------------------
+
+This module provides two colorschemes
+
+- `pscolor` based on `ps_color` colorscheme for vim by Shi Zhu Pan.
+- `blackandwhite` based on `print_bw` colorscheme for vim by Mike Williams.
+
+A particular color scheme may be chosen using the options:
+
+ \definevimtyping
+ [...]
+ [...
+ alternative=pscolor,
+ ...]
+
+The default color scheme is `pscolor`.
+
+Line numbering
+---------------
+
+**Note**: Currently only works in MkIV. In principle, it should also
+work in MkII, but for some reasons it does not.
+
+To enable line numbering for a particular snippet, use:
+
+ \start<vimtyping>[numbering=yes]
+ ...
+ \stop<vimtyping>
+
+To enable line numbering for all code snippets, use:
+
+ \definevimtyping
+ [...]
+ [...
+ numbering=yes,
+ ...]
+
+If you want a particular snippet not to have line numbering, use
+
+ \start<vimtyping>[numbering=no]
+ ...
+ \stop<vimtyping>
+
+By default, numbering starts from one, all lines are numbered, numbering is
+reset at each snippet, and numbers are displayed on the left. All these defaults
+can be changed.
+
+Number of the first line
+------------------------
+
+By default, the numbering starts from one (that is, the first line is numbered
+`1`). If you want the first line to be numbered something else, say `15`, you
+need to set
+
+ \start<vimtyping>[numberstart=15]
+
+If you want the numbering to continue from where the previous snippet ended, use
+
+ \start<vimtyping>[numbercontinue=yes]
+
+By default, consecutive lines are numbered. If you want alternate lines to be
+numbered, use
+
+ \start<vimtyping>[numbertstep=2]
+
+If you want every fifth line to be numbered, use
+
+ \start<vimtyping>[numbertstep=5]
+
+Standard options for line numbering
+-----------------------------------
+
+**Note**: These options can only be set using `\definevimtyping[...][...]` or
+`\setupvimtyping[...][...]`. They do not work when used with
+`\start<vimtyping>`.
+
+- To change the color or style of the numbers, use the `numbercolor=...` and
+ `numberstyle=...` options. By default `numbercolor` is not set, while
+ `numberstyle` is set to `\ttx`.
+
+- To change the alignment of numbers, use the `numberalign=...` option. Default
+ value is `flushright`.
+
+- To change the width of the box in which the numbers are typeset, use
+ `numberwidth=...` option. Default value is `2em`.
+
+- To change the distance between the numbers and the rest of the code, use
+ `numberdistance=...` option. Default value is `0.5em`.
+
+- To change the conversion of numbers, use `numberconversion=...` option.
+ Default value is `numbers`.
+
+- Use `numberleft=...` and `numberright=...` options to typeset
+ something on the left and right of the number. By default, these options are
+ not set.
+
+- `numbercommand=...` is used to set a command for typesetting the number.
+
+- `numberlocation=...` is used to set the location of the numbers. Default value
+ is `left`. Change this to `right` if you want the numbers on the right.
+
+Spaces
+------
+
+By default, the space is invisible. If you want to make the space visible, set
+
+ \definevimtyping
+ [...]
+ [...
+ space=on,
+ ...]
+
+The default value is `space=off`.
+
+Removing leading spaces
+-----------------------
+
+If you are listing a code snippet inside another environment, it is common to
+indent the TeX code. For example:
+
+ \definevimtyping[C][syntax=C]
+ \definevimtyping[ruby][syntax=ruby]
+
+ \startitemize
+ \item A hello world example in C
+ \startC
+ #include<stdio.h>
+
+ int main()
+ {
+ printf("Hello World")
+ }
+ \stopC
+ \item A hello world example in ruby
+ \startruby
+ puts "Hello World"
+ \stopruby
+ \stopitemize
+
+By default, the leading whitespace is stripped so that the output is the same
+as
+
+ \startitemize
+ \item A hello world example in C
+ \startC
+ #include<stdio.h>
+
+ int main()
+ {
+ printf("Hello World")
+ }
+ \stopC
+ \item A hello world example in ruby
+ \startruby
+ puts "Hello World"
+ \stopruby
+ \stopitemize
+
+
+If you want to disable this, set
+
+ \definevimtyping
+ [...]
+ [...
+ strip=no,
+ ...]
+
+The default value of `strip` is ψ`yes`.
+
+Adding left margin
+------------------
+
+By default, a `<vimtyping>` environment resets the left skip to `0pt`, so each
+line is aligned to the left edge. Use the `margin` key to change the left skip
+of each line:
+
+ \definevimtyping
+ [...]
+ [...
+ margin=<dimen>,
+ ...]
+
+where `<dimen>` is a valid TeX dimension.
+
+
+
+
+Wrapping lines
+---------------
+
+By default, long lines are not wrapped. If your source code has long lines,
+there are two alternatives. First, you can allow the lines to break at spaces by
+setting
+
+ \definevimtyping
+ [...]
+ [...
+ lines=split,
+ ...]
+
+The default value is `lines=fixed`.
+
+Second, you can allow lines to break between _compound_ words, such as
+`long/path`, `long-path`, `long+path`, etc by setting
+
+ \definevimtyping
+ [...]
+ [...
+ option={packed,hyphenated},
+ ...]
+
+The default value of `option` is `packed`.
+
+Note that with both these alternatives do not hyphenate a word, merely break
+lines at spaces or at the boundary of compound words. If you really need to
+hyphenate words, use
+
+ \definevimtyping
+ [...]
+ [...
+ option={packed,hyphenated},
+ align=hyphenated,
+ ...]
+
+Note that you have to add **both** `option=hyphenated` and `align=hyphenated`.
+The default value of align is `nothypenated`.
+
+Highlighting lines
+------------------
+
+Sometimes you want to draw attention to a particular line (or set of lines). One
+way to do so it to highlight the lines by a background color. This can be done
+using:
+
+ \start<vimtyping>[highlight={<list>}]
+ ...
+ \stop<vimtyping>
+
+where `<list>` is a comma separated list. For example, if you want to highlight
+lines 1 and 5, you may use:
+
+ \start<vimtyping>[highlight={1,5}]
+ ...
+ \stop<vimtyping>
+
+This will highlight lines 1 and 5 with gray background color. To change the
+highlight color use
+
+ \definevimtyping
+ [...]
+ [...
+ highlightcolor=<color>,
+ ...]
+
+where `<color>` is any valid ConTeXt color.
+
+When you pass a comma list to `highlight`, the `2context.vim` script
+wraps **each** of those line around `\HGL{....}` macro. The `\HGL` is, in turn, set to the
+value of `highlightcommand` key. So, if you want to change the way highlighting
+works, change the `highlightcommand`:
+
+ \definevimtyping
+ [...]
+ [...
+ highlightcommand=<command>,
+ ...]
+
+where `<command>` is any valid ConTeXt command. The default value is
+`highlightcommand` is `\syntaxhighlightline`; in MkIV, `\syntaxhighlightline` is
+defined as a bar; in MkII, `\syntaxhighlightline` is defined as a text
+background. The bar mechanism is more efficient but both mechanisms behave
+differently. The text background starts from the left edge of the line, while
+the bar starts from the first non-blank character.
+
+Using TeX code in Comments
+--------------------------
+
+Sometimes one wants to use TeX code in comments, especially for math. To
+enable this use
+
+ \definevimtyping
+ [...]
+ [...
+ escape=on,
+ ]
+
+When `escape=on`, the `2context.vim` script passes the `Comment` syntax
+region (as identified by `vim`) verbatim to TeX. So, we may use TeX
+commands inside the comment region and they will be interpreted by TeX.
+For example
+
+ \definevimtyping[C][syntax=c, escape=on]
+
+ \startC
+ /* The following function computes the roots of \m{ax^2+bx+c=0}
+ * using the determinant \m{\Delta=\frac{-b\pm\sqrt{b^2-2ac}}{2a}}
+ */
+ double root (double a, double b, double c) {....}
+ \stopC
+
+**Note** that only `\ { }` have their usual meaning inside the `Comment`
+region when `escape=on` is set. Thus, to enter a math expression, use
+`\m{...}` instead of `$...$`. Moreover, spaces are active inside the
+math mode, so, as in the above example, avoid spaces in the math expressions.
+
+Tuning color schemes
+--------------------
+
+Some vim syntax files have optional features that are turned on or off using
+variables. To enable these optional features, you need to first create a `vimrc`
+file and then use it.
+
+To create a `vimrc` file, use
+
+ \startvimrc[name=...]
+ ...
+ \stopvimrc
+
+The `name=...` is necessary. To enable the settings in this `vimrc` file, use:
+
+ \definevimtyping
+ [...]
+ [...
+ vimrc=...,
+ ...]
+
+The value of `vimrc` key needs to be the same as the value of the `name`
+key in `\startvimrc`. You may set the `vimrc` file for a particular code snippet
+by
+
+ \start<vimtyping>[vimrc=....]
+ ..
+ \stop<vimtyping>
+
+
+To disable loading of `vimrc` file, use
+
+ \definevimtyping
+ [...]
+ [...
+ vimrc=none,
+ ...]
+
+
+The default is not to use any `vimrc` file.
+
+A `vimrc` file gets loaded before syntax highlighting is enabled. If you want to
+override the default syntax highlighting scheme, add the appropriate `syn ...`
+commands to a `vimrc` file, and source that using
+
+ \definevimtyping
+ [...]
+ [...
+ extras=<name of vimrc file>,
+ ...]
+
+For example, suppose you are using a C++ library that defines `uDouble` as a
+keyword, so you want to highlight it in your code. Use
+
+ \startvimrc[name=cpp_extras]
+ syn keyword Type uDouble
+ \stopvimrc
+
+ \definevimtyping
+ [cpp]
+ [
+ syntax=cpp,
+ extras=cpp_extras,
+ ]
+
+Messages and Tracing
+--------------------
+
+The vim module uses the filter module in the background. The filter module
+outputs some diagnostic information on the console output to indicate what is
+happening. For example, for each code snippet, you will see messages like
+
+ t-filter > command : vim -u NONE -e -s -C -n -c "set tabstop=4" -c "syntax on" -c "set syntax=scala" -c "let contextstartline=1" -c "let contextstopline=0" -c "source kpse:2context.vim" -c "qa" scala-temp-SCALA-0.tmp scala-temp-SCALA-0.vimout
+
+If, for some reason, the output file is not generated, or not found, a message
+similar to
+
+ t-filter > file matlab-temp-MATLAB-0.vimout cannot be found
+ t-filter > current filter : MATLAB
+ t-filter > base file : matlab-temp-MATLAB-0
+ t-filter > input file : matlab-temp-MATLAB-0.tmp
+ t-filter > output file : matlab-temp-MATLAB-0.vimout
+
+is displayed in the console. At the same time, the string
+
+ [[output file missing]]
+
+is displayed in the PDF output. This data, along with the filter command, is
+useful for debugging what whet wrong.
+
+Yes, on, whatever
+-----------------
+
+ConTeXt has two ways of indicating binary options:
+
+- `option=yes` and `option=no`
+- `option=on` and `option=off`
+
+The core commands freely switch between the two. In some cases, `option=yes` has
+a different meaning than `option=on`. To avoid confusion, I have made these
+synonyms. Thus, whenever the documentation says `option=yes`, you may use
+`option=on`. And vice-versa. One less thing to worry about!
+
+A bit of a history
+------------------
+
+Mojca Miklavec germinated the idea of using vim to get syntax highlighting.
+Below is her message to the ConTeXt mailing list (circa Sep 2005):
+
+> I am thinking of piping the code to vim, letting vim process it, and return
+> something like `highlight[Conditional]{if} \highlight[Delimiter]{(}
+> \highlight[Identifier]{!}`.
+>
+> One could modify the `2html.vim` file. Vim can already transform the highlighted
+> code to HTML, so ConTeXt should not be so difficult. Vim already has over 400
+> syntax file definitions, probably equivalent to some hundred thousand lines of
+> syntax definition in ConTexT. Well, I don't know (yet) how to do it, but if
+> someone on the last has more experience with vim, please feel free to
+> contribute.
+
+A few months later (circa Dec 2005), Nikolai Webull provided such a modification
+of `2html.vim` and called it `2context.vim`. That file was the foundation of
+`t-vim` module.
+
+About two years later (circa June 2008), Mojca and I (Aditya Mahajan) pickup up
+on this idea and released `t-vim`. Over the next few years, nothing much changed
+in the module, except a few minor bug fixes.
+
+Around June 2010, I decided to completely rewrite the module from scratch. The
+new version of `t-vim` relies on `t-filter` for all the bookkeeping. As a
+result, the module is smaller and more robust.
+
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
+