29885
|
1 *ft_context.txt* For Vim version 9.0. Last change: 2022 Aug 12
|
|
2
|
|
3 This is the documentation for the ConTeXt filetype plugin.
|
|
4
|
|
5 NOTE: the plugin requires +vim9script.
|
|
6
|
|
7 ==============================================================================
|
|
8 CONTENTS *context.vim* *ft-context*
|
|
9
|
|
10 1. Introduction |ft-context-intro|
|
|
11 2. Commands |ft-context-commands|
|
|
12 3. Settings |ft-context-settings|
|
|
13 4. Mappings |ft-context-mappings|
|
|
14
|
|
15 ==============================================================================
|
|
16 *ft-context-intro*
|
|
17 Introduction ~
|
|
18
|
|
19 ConTeXt, similarly to LaTeX, is a macro-based typesetting system built on TeX:
|
|
20 >
|
|
21 https://wiki.contextgarden.net
|
|
22 https://wiki.contextgarden.net/Vim
|
|
23 <
|
|
24 The ConTeXt plugin provides syntax highlighting, completion and support for
|
|
25 typesetting ConTeXt documents. The recommended way to typeset a document is to
|
|
26 use |:ConTeXt|. This will invoke the `mtxrun` script that is found in $PATH.
|
|
27
|
|
28 For more fine grained control over the command and its environment, you may
|
|
29 invoke `context.Typeset()` directly (or `context#Typeset()` from legacy Vim
|
|
30 script). For instance, if you have installed a version of ConTeXt in
|
|
31 `~/context`, you may define a function to use it (you may put the following
|
|
32 code in `~/.vim/after/ftplugin/context.vim`) similar to the following:
|
|
33 >
|
|
34 import autoload 'context.vim'
|
|
35
|
|
36 def MyConTeXt()
|
|
37 const env = {'PATH':
|
|
38 printf("%s/context/tex/texmf-<os>-<arch>/bin:%s", $HOME, $PATH)}
|
|
39 context.Typeset("%", env)
|
|
40 enddef
|
|
41 <
|
|
42 and perhaps use it with a mapping:
|
|
43 >
|
|
44 nnoremap <silent><buffer><leader>t <scriptcmd>MyConTeXt()<cr>
|
|
45 <
|
|
46 `context.Typeset()` accepts a third optional argument to specify a custom
|
|
47 typesetting command. Such argument must be a function that takes a path and
|
|
48 returns the command as a List. For example:
|
|
49 >
|
|
50 def ConTeXtCustomCommand(path: string): list<string>
|
|
51 return ['mtxrun', '--script', 'context', '--nonstopmode, path]
|
|
52 enddef
|
|
53
|
|
54 context.ConTeXtTypeset("%", v:none, ConTeXtCustomCommand)
|
|
55 <
|
|
56 Large projects are often organized as a root document and various chapter
|
|
57 files. When editing a chapter file, it is convenient to invoke |:ConTeXt|
|
|
58 directly on it, rather than having to switch to the root file. A "magic line"
|
|
59 can be added at the beginning of each chapter file, which specifies the
|
|
60 relative path to the root file. For instance:
|
|
61 >
|
|
62 % !TEX root = ../MyRoot.tex
|
|
63 <
|
|
64 Vim searches for the magic line in the first ten lines of the current buffer:
|
|
65 if it is found, the document specified by that line is typeset rather than the
|
|
66 one in the current buffer. The root document does not have to be opened in
|
|
67 Vim.
|
|
68
|
|
69 To extend completion and syntax highlighting, you may generate supporting
|
|
70 files using ConTeXt and add them to your configuration. If you configuration
|
|
71 resides in `~/.vim`, you may use these commands:
|
|
72 >
|
|
73 mkdir -p ~/.vim/syntax/shared
|
|
74 cd ~/.vim/syntax/shared
|
|
75 mtxrun --script interface --vim
|
|
76 <
|
|
77 The last command will create the following syntax files:
|
|
78
|
|
79 - `context-data-context.vim`;
|
|
80 - `context-data-interfaces.vim`;
|
|
81 - `context-data-metafun.vim`;
|
|
82 - `context-data-tex.vim`.
|
|
83
|
|
84 The same command can be used to update those syntax files.
|
|
85
|
|
86 *ft-context-commands*
|
|
87 Commands ~
|
|
88 *:ConTeXt*
|
|
89 Start a background |job| to typeset the document in the current buffer. The
|
|
90 command accepts an optional buffer's name, if you want to typeset a document
|
|
91 that is in a different buffer.
|
|
92
|
|
93 *:ConTeXtLog*
|
|
94 Edit the log file corresponding to the source in the current buffer.
|
|
95
|
|
96 *:ConTeXtJobsStatus*
|
|
97 Echo the number of jobs currently running in the background.
|
|
98
|
|
99 *:ConTeXtStopJobs*
|
|
100 Stop all the ConTeXt jobs currently running in the background.
|
|
101
|
|
102 *ft-context-settings*
|
|
103 Settings ~
|
|
104 *'b:context_ignore_makefile'*
|
|
105 *'g:context_ignore_makefile'*
|
|
106 `make` can be used to (synchronously) typeset a document. If a Makefile exists
|
|
107 and this option is not set, standard `make` is used. If this option is set,
|
|
108 `mtxrun` is invoked instead, even if a Makefile exists.
|
|
109 >
|
|
110 g:context_ignore_makefile = 0
|
|
111 <
|
|
112 NOTE: before using `make`, set the working directory of the buffer to the
|
|
113 directory of the file to be typeset.
|
|
114 *'b:context_include'*
|
|
115 *'g:context_include'*
|
|
116 Dictionary of filetype/GROUP pairs for which syntax highlighting should be
|
|
117 activated between \startGROUP and \stopGROUP. The default is to highlight XML
|
|
118 between `\startXML` and `\stopXML`.
|
|
119 >
|
|
120 g:context_include = {'xml': 'XML'}
|
|
121
|
|
122 NOTE: Lua and MetaPost are always highlighted within the respective blocks.
|
|
123
|
|
124 *'g:no_context_maps'*
|
|
125 When set, do not define any mappings.
|
|
126 >
|
|
127 g:no_context_maps = 0
|
|
128 <
|
|
129 *ft-context-mappings*
|
|
130 Mappings ~
|
|
131
|
|
132 tp "reflow TeX paragraph".
|
|
133
|
|
134 i$ "inside inline math block".
|
|
135
|
|
136 a$ "around inline math block".
|
|
137
|
|
138 ]] [count] start of sections forward.
|
|
139
|
|
140 [[ [count] start of sections backward.
|
|
141
|
|
142 ][ [count] end sections forward.
|
|
143
|
|
144 [] [count] end of sections backward.
|
|
145
|
|
146 ]} [count] end of blocks (\stop..., \setup...,
|
|
147 \define...) forward.
|
|
148
|
|
149 [{ [count] begin of blocks (\start..., \setup...,
|
|
150 \define...) backward.
|
|
151
|
|
152 vim:tw=78:sw=4:ts=8:noet:ft=help:norl:
|