summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-06-28 21:33:59 +0000
committerKarl Berry <karl@freefriends.org>2011-06-28 21:33:59 +0000
commit47938a882aac64c9cb55a98819fe3a107dc852c3 (patch)
tree9687bfe5ecadc19094fe0d6fcbfd2635c0bac4a2
parentc802db8128853e177e1ca863dd76c994599b28b6 (diff)
context-vim update per author
git-svn-id: svn://tug.org/texlive/trunk@23166 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/context/third/vim/vim.txt193
-rw-r--r--Master/texmf-dist/tex/context/third/vim/2context.vim51
-rw-r--r--Master/texmf-dist/tex/context/third/vim/t-syntax-groups.tex94
-rw-r--r--Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex230
-rw-r--r--Master/texmf-dist/tex/context/third/vim/t-vim.tex403
5 files changed, 669 insertions, 302 deletions
diff --git a/Master/texmf-dist/doc/context/third/vim/vim.txt b/Master/texmf-dist/doc/context/third/vim/vim.txt
index 349c9b39da8..153398011ce 100644
--- a/Master/texmf-dist/doc/context/third/vim/vim.txt
+++ b/Master/texmf-dist/doc/context/third/vim/vim.txt
@@ -11,10 +11,65 @@ 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
------------
-TODO:
+This module depends on the `t-filter` module. If you are using ConTeXt minimals,
+you can install the module using
+
+ first-setup.sh --extras="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
-----
@@ -75,16 +130,31 @@ The `t-vim` module simply defines the macros that are used by `2context.vim`.
Start and stop lines
--------------------
-The `\start<typing>` ... `\stop<typing>` environment and the `\type<typing>file`
+The `\start<vimtyping>` ... `\stop<vimtyping>` environment and the `\type<vimtyping>file`
macro take an optional argument that is used to set options.
-For example, if we only want to typeset lines 15 through 25 of a ruby file
-`rails_install.rb`, we can use:
+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
-------------
@@ -92,8 +162,8 @@ 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 the clutter, these temporary files can be written to a
-different directory, e.g.,
+temporary files. To avoid this clutter, write the temporary files to an a
+different directory using the `directory` key. For example,
\definevimtyping[...]
[directory=output/]
@@ -127,6 +197,110 @@ A particular color scheme may be chosen using the options:
The default color scheme is `pscolor`.
+Line numbering
+---------------
+
+To eanble 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
+-----------------------------------
+
+- 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`.
+
+Splitting lines
+---------------
+
+By default, long lines are not split. If you want to split long lines, set
+
+ \definevimtyping
+ [...]
+ [...
+ lines=split,
+ ...]
+
+The default value is `lines=fixed`.
+
+
A bit of a history
------------------
@@ -155,10 +329,3 @@ 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.
-
-TODO
-----
-
-- Line numbering
-- continue line numbering from previous environment
-- modify tabs and spaces
diff --git a/Master/texmf-dist/tex/context/third/vim/2context.vim b/Master/texmf-dist/tex/context/third/vim/2context.vim
index a90fc0719c4..0e29c46c5bf 100644
--- a/Master/texmf-dist/tex/context/third/vim/2context.vim
+++ b/Master/texmf-dist/tex/context/third/vim/2context.vim
@@ -3,53 +3,44 @@
" license : Simplified BSD License
" This script is part of the t-vim module for ConTeXt. It is based on 2html.vim.
-" It assumes that two buffers are open. The first buffer is the input buffer,
-" and the second buffer is the output buffer.
+" 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.
-" We move back and forth between the buffers,
-
-" Split and go to the last buffer
+" Split screen and go to the second buffer, ensure modifiable is set, and the
+" buffer is empty.
sblast
-
-" Make sure that the buffer is modifiable
set modifiable
-
-" ... and empty
%d
-" Loop over all lines in the original text.
-
+" Go to first buffer
wincmd p
-" Use contextstartline and contextstopline if they are set.
-
+" If contextstartline and contextstartline are set, use them.
if exists("contextstartline")
- let s:lnum = contextstartline
- if !(s:lnum >= 1 && s:lnum <= line("$"))
- let s:lnum = 1
- endif
+ let s:lnum = max([1, min([line("$"), contextstartline]) ])
else
let s:lnum = 1
endif
if exists("contextstopline")
- let s:end = contextstopline
- if !(s:end >= s:lnum && s:end <= line("$"))
- let s:end = line("$")
- elseif s:end < 0
- let s:end = line("$") - s:end
+ if contextstopline <= 0
+ let contextstopline = line("$") + contextstopline
endif
+ let s:end = min([line("$"), max([s:lnum, contextstopline]) ])
else
let s:end = line("$")
endif
let s:buffer_lnum = 1
+" Loop over all lines in the original text.
while s:lnum <= s:end
" Get the current line
let s:line = getline(s:lnum)
let s:len = strlen(s:line)
- let s:new = "\\NL{}"
+ let s:new = ''
" Loop over each character in the line
let s:col = 1
@@ -73,15 +64,11 @@ while s:lnum <= s:end
" we don't need to print in in that case
if strlen(s:temp) > 0
" Change special TeX characters to escape sequences.
-" The funny \type{||||||||||} and \type{$$$$$$$$$} characters should never
-" appear in {\em normal} \TEX\ file. As a side||effect, this script can not
-" pretty print itself.
- let s:temp = substitute( s:temp, '\\', '\\letterbackslash||||||||||$$$$$$$$$$', 'g')
- let s:temp = substitute( s:temp, '{', '\\letteropenbrace||||||||||$$$$$$$$$$', 'g')
- let s:temp = substitute( s:temp, '}', '\\letterclosebrace||||||||||$$$$$$$$$$', 'g')
- let s:temp = substitute( s:temp, '||||||||||' , '{' , 'g')
- let s:temp = substitute( s:temp, '\$\$\$\$\$\$\$\$\$\$' , '}' , 'g')
- let s:new = s:new . '\SYN[' . s:id_name . ']{' . s:temp . '}'
+ let s:temp = escape( s:temp, '\{}')
+ 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
diff --git a/Master/texmf-dist/tex/context/third/vim/t-syntax-groups.tex b/Master/texmf-dist/tex/context/third/vim/t-syntax-groups.tex
new file mode 100644
index 00000000000..ff24e81e4df
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/vim/t-syntax-groups.tex
@@ -0,0 +1,94 @@
+%D \module
+%D [ file=t-syntax-groups,
+%D version=2011.06.12,
+%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> umich <dot> edu,
+%D license=Simplified BSD License]
+
+\writestatus{loading}{ConTeXt User Module / Syntax Highlighting Support}
+
+% Colors are specified in hex; in MkII the hex mode needs to be activated.
+\doifmode\s!mkii
+ {\setupcolor[hex]}
+
+\startmodule [syntax-group]
+\usemodule [module-catcodes]
+
+\unprotectmodulecatcodes
+
+\def\colorscheme::name {}
+
+\def\syntaxgroup::id {syntaxgroup}
+\def\syntaxgroup::namespace {@@@@\colorscheme::name\syntaxgroup::id}
+\def\syntaxgroup::name {}
+
+\installparameterhandler \syntaxgroup::namespace \syntaxgroup::id
+
+\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 {##1}
+ \getparameters[\syntaxgroup::namespace##1]
+ [\c!color=,\c!style=,\c!command=,#2]
+ \doifsomething{\syntaxgroupparameter\c!color}
+ {
+ \expanded{\definecolor[\syntaxgroup::namespace-##1-color]
+ [\syntaxgroupparameter\c!color]}
+ \getparameters[\syntaxgroup::namespace##1][\c!color=\syntaxgroup::namespace-##1-color]
+ }
+ }
+ }{
+ \def\syntaxgroup::get_parameters##1%
+ {
+ \copyparameters[\syntaxgroup::namespace##1][\syntaxgroup::namespace#2]
+ [\c!color,\c!style,\c!command]
+ }
+ }
+
+ \processcommalist[#1]\syntaxgroup::get_parameters
+\stoptexdefinition
+
+\def\startcolorscheme%
+ {\dosingleargument\colorscheme::start}
+
+\starttexdefinition colorscheme::start [#1]
+ \pushmacro\colorscheme::name
+ \setcolorscheme{#1}
+ \getparameters[\syntaxgroup::namespace][\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{#1}%
+ \syntaxgroupparameter\c!command
+ {
+ \dostartattributes{\syntaxgroup::namespace #1}\c!style\c!color
+ #2
+ \dostopattributes
+ }
+ \endgroup
+\stoptexdefinition
+
+\def\currentsyntaxgroup {\syntaxgroup::name}
+
+\protectmodulecatcodes
+\stopmodule
diff --git a/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex b/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex
new file mode 100644
index 00000000000..35f24c656d7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex
@@ -0,0 +1,230 @@
+%D \module
+%D [ file=t-syntax-highlight,
+%D version=2011.06.14,
+%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> umich <dot> edu,
+%D license=Simplified BSD License]
+
+\writestatus{loading}{ConTeXt User Module / Code syntax highlighting}
+
+\startmodule [syntax-highlight]
+\usemodule [syntax-groups]
+\usemodule [filter]
+\usemodule [module-catcodes]
+
+\unprotectmodulecatcodes
+
+\startinterface all
+ \setinterfaceconstant {syntax} {syntax}
+\stopinterface
+
+%D Name space
+
+\def\syntaxhighlighting::id {syntaxhighlighting}
+\def\syntaxhighlighting::namespace {@@@@\syntaxhighlighting::id}
+\def\syntaxhighlighting::name {}
+
+\installparameterhandler \syntaxhighlighting::namespace \syntaxhighlighting::id
+\installsetuphandler \syntaxhighlighting::namespace \syntaxhighlighting::id
+
+\def\definesyntaxhighlighting
+ {\dodoubleargument\syntaxhighlighting::define}
+
+\starttexdefinition syntaxhighlighting::define [#1][#2]
+ \getparameters[\syntaxhighlighting::namespace#1][\s!parent=\syntaxhighlighting::namespace,#2]
+
+ \edef\syntaxhighlighting::name{#1}
+ \doifmode\s!mkiv{\setups{syntaxhighlighting::setup_line_number_mkiv}}
+
+ \defineexternalfilter[#1][\s!parent=\syntaxhighlighting::namespace#1]
+ \setvalue{type#1file}{\getvalue{process#1file}}
+
+\stoptexdefinition
+
+\startsetups syntaxhighlighting::setup
+
+ \edef\syntaxhighlighting::name{\currentexternalfilter}
+ \edef\colorscheme::name{\externalfilterparameter\c!alternative}
+
+ \let\SYN\syntaxgroup
+ \let\\\textbackslash
+ \let\{\textbraceleft
+ \let\}\textbraceright
+
+ \def\tab##1%
+ {\dorecurse{##1}{\space}}%
+
+ \doifmode\s!mkii{\setups{syntaxhighlighting::setup_line_number_mkii}}%
+
+ \doifinset{\externalfilterparameter\c!option}{\v!packed}
+ {\setupwhitespace[\v!none,\v!flexible]}%
+
+ \setcatcodetable\externalfilter::minimal_catcodes
+ \activatespacehandler{\syntaxhighlighting::namespace\externalfilterparameter\c!space}
+\stopsetups
+
+\startsetups syntaxhighlighting::setup_line_number_mkiv
+ \definelinenumbering [#1]
+
+ \setuplinenumbering
+ [\syntaxhighlighting::name]
+ [\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
+\doif{\externalfilterparameter\c!numbering}\v!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
+
+\startmode [\s!mkiv]
+\starttexdefinition syntaxhighlighting::read_command #1
+ \doifelse{\externalfilterparameter\c!numbering}\v!yes
+ {\startlinenumbering
+ [\syntaxhighlighting::name]
+ [\c!continue=\externalfilterparameter{\c!number\c!continue}]
+ \ReadFile{#1}
+ \stoplinenumbering}
+ {\ReadFile{#1}}
+\stoptexdefinition
+\stopmode
+
+\startmode [\s!mkii]
+\starttexdefinition syntaxhighlighting::read_command #1
+ \doifelse{\externalfilterparameter\c!numbering}\v!yes
+ {\doifelse{\externalfilterparameter{\c!number\c!continue}}\v!yes
+ {\startlinenumbering[\v!continue]}
+ {\startlinenumbering}
+ \syntaxhighlighting::read_command_aux{#1}
+ \stoplinenumbering}
+ {\syntaxhighlighting::read_command_aux{#1}}
+\stoptexdefinition
+
+\starttexdefinition syntaxhighlighting::read_command_aux #1
+ % In the filter module, style=something does not work in MkII.
+ % So, we explicitly add the global style before reading the file.
+ %
+ \dostartattributes{\syntaxhighlighting::namespace}\c!style\c!color
+ \dostartattributes{\syntaxhighlighting::namespace\syntaxhighlighting::name}\c!style\c!color
+ \ReadFile{#1}
+ \dostopattributes
+ \dostopattributes
+\stoptexdefinition
+\stopmode
+
+
+\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=\blank,
+ \c!after=\blank,
+ \c!style=\tttf,
+ \c!color=,
+ \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, % Could be a list
+ \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!number\c!command=,
+ \c!number\c!distance=0.5em,
+ \c!number\c!align=\v!flushright,
+ ]
+
+\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}}
+
+\protectmodulecatcodes
+
+\stopmodule
+
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 59daac5d5da..f2713a0af1b 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=2011.03.06,
+%D version=2011.06.14,
%D title=\CONTEXT\ User Module,
%D subtitle=Vim syntax highlighting,
%D author=Aditya Mahajan,
@@ -11,34 +11,21 @@
\writestatus{loading}{ConTeXt User Module / Vim syntax highlighting}
-\startmodule[vim]
-\usemodule[filter]
+\startmodule [vim]
+\usemodule [filter]
+\usemodule [syntax-highlight]
+\usemodule [syntax-groups]
+\usemodule [module-catcodes]
-% I use the experimental namespaces defined in t-filter.
-\pushcatcodetable
-\setcatcodetable\externalfiltermodulecatcodes
-
-% Colors are specified in hex; in MkII the hex mode needs to be activated.
-\doifmode\s!mkii
- {\setupcolor[hex]}
-
-\startinterface all
- \setinterfaceconstant {syntax} {syntax}
-\stopinterface
+\unprotectmodulecatcodes
\def\vimtyping::id {vimtyping}
\def\vimtyping::namespace {@@@@\vimtyping::id}
\def\vimtyping::name {}
-\def\vimalternative::id {vimalternative}
-\def\vimalternative::namespace {@@@@\vimalternative::id}
-\def\vimalternative::name {}
-
\installparameterhandler \vimtyping::namespace \vimtyping::id
\installsetuphandler \vimtyping::namespace \vimtyping::id
-
-
\def\definevimtyping
{\dodoubleargument\vimtyping::define}
@@ -46,81 +33,11 @@
\getparameters[\vimtyping::namespace#1][\s!parent=\vimtyping::namespace,#2]
\edef\vimtyping::name{#1}
- \doifmode\s!mkiv{\setups{vimtyping::setup_line_number_mkiv}}
-
- \defineexternalfilter[#1][\s!parent=\vimtyping::namespace#1]
- \setvalue{type#1file}{\getvalue{process#1file}}
+ \definesyntaxhighlighting[#1][\s!parent=\vimtyping::namespace#1]
\stoptexdefinition
-\startsetups vimtyping::setup
-
- \edef\vimtyping::name{\currentexternalfilter}
- \edef\vimalternative::name{\externalfilterparameter\c!alternative}
-
- \let\SYN\vimsyntax
- \def\NL{\strut}%
-
- \def\tab##1%
- {\dorecurse{##1}{\space}}%
-
- \doifmode\s!mkii{\setups{vimtyping::setup_line_number_mkii}}%
-
- \doifinset{\externalfilterparameter\c!option}{\v!packed}
- {\setupwhitespace[\v!none,\v!flexible]}%
-
- \setcatcodetable\externalfilter::write_catcodes
-\stopsetups
-
-\startsetups vimtyping::setup_line_number_mkiv
- \definelinenumbering [#1]
-
- \setuplinenumbering
- [\vimtyping::name]
- [\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\vimtyping::linenumber}
-
-\startsetups vimtyping::setup_line_number_mkii
-\doif{\externalfilterparameter\c!numbering}\v!yes
- {% setuplinenumbering resets \linenumber. So we save the value of linenumber and
- % revert it back.
- \vimtyping::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=\vimtyping::linenumber}
-\stopsetups
-
+% Mode to testing the dev version of 2context script.
\doifmodeelse{vimtest}
{\def\vimtyping::script_name{2context.vim}}
{\def\vimtyping::script_name{kpse:2context.vim}}
@@ -135,206 +52,178 @@
-c "syntax on" %
-c "set syntax=\externalfilterparameter\c!syntax" %
-c "let contextstartline=\externalfilterparameter\c!start" %
- -c "let contextstopline=\externalfilterparameter\c!stop" %
+ -c "let contextstopline=\externalfilterparameter\c!stop" %
-c "source \vimtyping::script_name" %
-c "qa" %
\externalfilterinputfile\space
\externalfilteroutputfile}
-\startmode [\s!mkiv]
-\starttexdefinition vimtyping::read_command #1
- \doifelse{\externalfilterparameter\c!numbering}\v!yes
- {\startlinenumbering
- [\vimtyping::name]
- [\c!continue=\externalfilterparameter{\c!number\c!continue}]
- \ReadFile{#1}
- \stoplinenumbering}
- {\ReadFile{#1}}
-\stoptexdefinition
-\stopmode
-
-\startmode [\s!mkii]
-\starttexdefinition vimtyping::read_command #1
- \doifelse{\externalfilterparameter\c!numbering}\v!yes
- {\doifelse{\externalfilterparameter{\c!number\c!continue}}\v!yes
- {\startlinenumbering[\v!continue]}
- {\startlinenumbering}
- \ReadFile{#1}
- \stoplinenumbering}
- {\ReadFile{#1}}
-\stoptexdefinition
-\stopmode
-
-\def\startvimalternative
- {\dosingleargument\vimalternative::start}
-
-\def\vimalternative::start[#1]%
- {\pushmacro\vimalternative::name
- \edef\vimalternative::name{#1}}
-
-\def\stopvimalternative
- {\popmacro\vimalternative::name}
-
-\def\setvimsyntax
- {\doquadrupleargument\vimalternative::set_syntax}
-
-\starttexdefinition vimalternative::set_syntax [#1][#2][#3][#4]
- % #1 = name
- % #2 = color
- % #3 = style
- % #4 = command
- \def\dodosetupvimsyntax##1%
- {\doifsomething{#2}
- % we check if color exists; otherwise ConTeXt gives a warning on stdout
- % which is very distracting
- {\definecolor[\vimalternative::namespace\vimalternative::name##1color_name] [#2]
- \getparameters[\vimalternative::namespace\vimalternative::name##1]
- [\c!color={\vimalternative::namespace\vimalternative::name##1color_name}]}
- \getparameters[\vimalternative::namespace\vimalternative::name##1]
- [\c!style=#3,
- \c!command=#4]}
- \processcommalist[#1]\dodosetupvimsyntax
-\stoptexdefinition
+\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!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!option=\v!packed, % Could be a list
+ \s!parent=\syntaxhighlighting::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!number\c!command=,
+ % \c!number\c!distance=0.5em,
+ % \c!number\c!align=\v!flushright,
+ ]
+\def\currentvimtyping {\vimtyping::name}
-\starttexdefinition vimsyntax [#1]#2
- % #1 = style
- % #2 = content
- \dostartattributes{\vimalternative::namespace\vimalternative::name Normal}\c!style\c!color\empty
- \dostartattributes{\vimalternative::namespace\vimalternative::name #1}\c!style\c!color\empty
- \getvalue{\vimalternative::namespace\vimalternative::name#1\c!command}{#2}
- \dostopattributes
- \dostopattributes
-\stoptexdefinition
+\startsetups[vim-minor-groups]
+ \definesyntaxgroup
+ [SpecialComment]
+ [Comment]
-% \startvimalternative[pscolor]
-%
-% \definesyntax
-% [Normal]
-% [color=\externalfilterparameter\c!color,
-% style=\tttf,
-% command=]
-%
-% \stopvimalternative
+ \definesyntaxgroup
+ [String,Character,Number,Boolean,Float]
+ [Constant]
-\startvimalternative[pscolor]
- \setvimsyntax [Normal] [\externalfilterparameter\c!color][\tttf]
+ \definesyntaxgroup
+ [Function]
+ [Identifier]
- \setvimsyntax
- [Constant,Character,Boolean,Float]
- [h=007068]
+ \definesyntaxgroup
+ [Condition,Repeat,Label,Operator,Keyword,Exception]
+ [Statement]
- \setvimsyntax [Number] [h=907000]
+ \definesyntaxgroup
+ [Include,Define,Macro,PreCondit]
+ [Preproc]
- \setvimsyntax
- [Identifier, Function]
- [h=a030a0]
+ \definesyntaxgroup
+ [StorateClass,Structure,Typedef]
+ [Type]
- \setvimsyntax
- [Statement,Conditional,Repeat,Label,Operator,Keyword,Exception]
- [h=2060a8]
+ \definesyntaxgroup
+ [SpecialChar,Delimiter,Debug]
+ [Special]
+\stopsetups
- \setvimsyntax
- [PreProc, Include, Define, Macro, PreCondit]
- [h=009030]
+\startcolorscheme[pscolor]
+ % Vim Preferred groups
+ \definesyntaxgroup
+ [Constant]
+ [\c!color={h=007068}]
- \setvimsyntax
- [Type,StorageClass, Structure, Typedef]
- [h=0850a0]
+ \definesyntaxgroup
+ [Identifier]
+ [\c!color={h=a030a0}]
- \setvimsyntax [Special] [h=907000]
- \setvimsyntax [SpecialKey][h=1050a0]
+ \definesyntaxgroup
+ [Statement]
+ [\c!color={h=2060a8}]
- \setvimsyntax
- [Tag, Delmiter]
+ \definesyntaxgroup
+ [PreProc]
+ [\c!color={h=009030}]
- \setvimsyntax
- [Comment, SpecialComment]
- [h=606000]
+ \definesyntaxgroup
+ [Type]
+ [\c!color={h=0850a0}]
- \setvimsyntax
- [Debug,Ignore]
+ \definesyntaxgroup
+ [Special]
+ [\c!color={h=907000}]
- \setvimsyntax [Todo] [h=e0e090]
- \setvimsyntax [Error] [h=c03000]
- \setvimsyntax [Underlined][h=6a5acd][][\underbar]
+ \definesyntaxgroup
+ [Comment]
+ [\c!color={h=606000}]
-\stopvimalternative
+ \definesyntaxgroup
+ [Ignore]
-%TODO
-% \setvimsyntax [id] [bg=, fc=, style=, command=] == \localframed[options]
-\startvimalternative[blackandwhite]
- \setvimsyntax [Normal] [\externalfilterparameter\c!color][\tttf]
+ \definesyntaxgroup
+ [Todo]
+ [\c!color={h=800000}]
- \setvimsyntax
- [Constant,Character,Boolean,Float,Number,Identifier,Function]
+ \definesyntaxgroup
+ [Error]
+ [\c!color={h=c03000}]
- \setvimsyntax
- [Statement,Conditional,Repeat,Label,Operator,Keyword,Exception]
- [][][\bold]
+ \definesyntaxgroup
+ [Underlined]
+ [\c!color={h=6a5acd},
+ \c!command=\underbar]
- \setvimsyntax
- [PreProc, Include, Define, Macro, PreCondit]
- [][][\bold]
+ \setups{vim-minor-groups}
- \setvimsyntax
- [Type,StorageClass, Structure, Typedef]
- [][][\bold]
+ \definesyntaxgroup
+ [Number]
+ [\c!color={h=907000}]
+\stopcolorscheme
- \setvimsyntax [Special, SpecialKey]
+\startcolorscheme[blackandwhite]
+ \definesyntaxgroup
+ [Constant]
- \setvimsyntax [Tag, Delmiter]
+ \definesyntaxgroup
+ [Identifier]
- \setvimsyntax
- [Comment, SpecialComment]
- [][][\italic]
+ \definesyntaxgroup
+ [Statement]
+ [\c!style=bold]
- \setvimsyntax
- [Debug,Ignore]
+ \definesyntaxgroup
+ [PreProc]
+ [\c!style=bold]
- \setvimsyntax [Todo] [][][\inframed]
- \setvimsyntax [Error] [][][\overstrike]
- \setvimsyntax [Underlined][][][\underbar]
+ \definesyntaxgroup
+ [Type]
+ [\c!style=bold]
-\stopvimalternative
+ \definesyntaxgroup
+ [Special]
-\setupvimtyping
- [\c!tab=4,
- \c!start=1,
- \c!stop=0,
- \c!syntax=context,
- \c!alternative=pscolor,
- \c!before=,
- \c!after=,
- \c!filtercommand=\vimtyping::filter_command,
- \c!continue=yes,
- \c!read=\v!yes,
- \c!readcommand=\vimtyping::read_command,
- \c!output=\externalfilterbasefile.vimout,
- \c!setups=vimtyping::setup,
- \c!option=\v!packed, % Could be a list
- \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=\tfx,
- \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,
- ]
+ \definesyntaxgroup
+ [Comment]
+ [\c!style=italic]
-\def\currentvimtyping {\vimtyping::name}
+ \definesyntaxgroup
+ [Ignore]
+
+ \definesyntaxgroup
+ [Todo]
+ [\c!command=\inframed]
+
+ \definesyntaxgroup
+ [Error]
+ [\c!command=\overstrike]
+
+ \definesyntaxgroup
+ [Underlined]
+ [\c!command=\underbar]
+
+ \setups{vim-minor-groups}
-\popcatcodetable
+\stopcolorscheme
+\protectmodulecatcodes
\stopmodule