blob: 11ddd3b796c86646753cf1a31da61fc2d7668912 [file] [log] [blame]
Christian Brabandtb4ddc6c2024-01-02 16:51:11 +01001*ft_mp.txt* For Vim version 9.1. Last change: 2022 Aug 12
Bram Moolenaar7dd54322022-08-26 18:01:12 +01002
3This is the documentation for the METAFONT and MetaPost filetype plugins.
4Unless otherwise specified, the commands, settings and mappings defined below
5apply equally to both filetypes.
6
7NOTE: the plugin requires +vim9script.
8
9==============================================================================
10CONTENTS *mp.vim* *ft-metapost*
11 *mf.vim* *ft-metafont*
12
131. Introduction |ft-metapost-intro|
142. Commands |ft-metapost-commands|
153. Settings |ft-metapost-settings|
164. Mappings |ft-metapost-mappings|
17
18==============================================================================
19 *ft-metapost-intro*
20 *ft-metafont-intro*
21Introduction ~
22This filetype plugin provides extensive support for editing METAFONT and
23MetaPost documents, including syntax coloring, indentation, and completion.
24
25Defining indentation rules for METAFONT and MetaPost code is tricky and
26somewhat subjective, because the syntax is quite liberal. The plugin uses some
27heuristics that work well most of the time, but in particular cases you may
28want to to override the automatic rules, so that the manually defined
29indentation is preserved by commands like `gg=G`.
30
31This can be achieved by appending `%>`, `%<`, `%=` or `%!` to a line to
32explicitly control the indentation of the next line. The `<` and `>` symbols
33may be repeated many times: for instance, `%>>` will cause the next line to be
34indented twice. Of course, `%<` means that the next line should be
35de-indented; `%=` sets the indentation of the next line to be equal to the
36indentation of the current line; and `%!` means that the indentation of the
37next line should not change from whatever it has been manually set.
38
39For example, this is the default indentation of a simple macro:
40>
41 def foo =
42 makepen(
43 subpath(T-n,t) of r
44 shifted .5down
45 --subpath(t,T) of r shifted .5up -- cycle
46 )
47 withcolor black
48 enddef
49<
50By adding the special comments, the indentation can be adjusted arbitrarily:
51>
52 def foo =
53 makepen(
54 subpath(T-n,t) of r %>
55 shifted .5down %>
56 --subpath(t,T) of r shifted .5up -- cycle %<<<
57 )
58 withcolor black
59 enddef
60<
61 *ft-metapost-commands*
62Commands ~
63 *:FixBeginfigs*
64Renumber beginfig() blocks in the current buffer so that the n-th figure has
65number n. MetaPost only.
66
67 *ft-metapost-settings*
68 *ft-metafont-settings*
69Settings ~
70 *'g:mf_other_macros'*
71Highlight some other basic macro names, e.g., from cmbase, logo, etc. This is
72set to 1 by default in METAFONT buffers, and it is set to 0 by default in
73MetaPost buffers.
74
75 *'g:mf_plain_macros'*
76Highlight keywords defined by plain.mf. This is set to 1 by default in
77METAFONT buffers, and it is set to 0 by default in MetaPost buffers.
78
79 *'g:mf_plain_modes'*
80Highlight keywords defined by modes.mf. This is set to 1 by default in
81METAFONT buffers, and it is set to 0 by default in MetaPost buffers.
82
83 *'g:mp_close_tag'*
84Define additional keywords that end indented blocks. For instance, if you
85define:
86>
Bram Moolenaarbe4e0162023-02-02 13:59:48 +000087 g:mp_close_tag = ['\<endfoo\>']
Bram Moolenaar7dd54322022-08-26 18:01:12 +010088<
89any line starting with `endfoo` will be de-indented compared to its previous
90line.
91>
92 g:mp_close_tag = []
93<
94 *'b:mp_metafun'*
95 *'g:mp_metafun'*
96If set to 1, highlight ConTeXt's MetaFun keywords. MetaPost only.
97>
98 g:mp_metafun = 0
99<
100 *'g:mp_mfplain_macros'*
101Highlight keywords defined by mfplain.mp. MetaPost only.
102>
103 g:mp_mfplain_macros = 1
104<
105 *'g:mp_open_tag'*
106Define additional keywords that start indented blocks. For instance, if you
107define:
108>
109 g:mp_open_tag = ['\<beginfoo\>']
110<
111the line following `beginfoo` will be indented.
112>
113 g:mp_open_tag = []
114<
115 *'g:mp_other_macros'*
116Highlight keywords defined by all base macro packages (boxes, rboxes, format,
117graph, marith, sarith, string, TEX). This option affects only MetaPost
118buffers.
119>
120 g:mp_other_macros = 1
121<
122 *'g:mp_plain_macros'*
123Highlight keywords defined by plain.mp. MetaPost only.
124>
125 g:mp_plain_macros = 1
126<
127 *'g:no_mp_maps'*
128 *'g:no_mf_maps'*
129When set, do not define any mapping in buffers with the corresponding
130filetype.
131>
132 g:no_mp_maps = 0
133 g:no_mf_maps = 0
134<
135 *ft-metapost-mappings*
136 *ft-metafont-mappings*
137Mappings ~
138
139]] [count] vardefs, macros or figures forward.
140
141[[ [count] vardefs, macros or figures backward.
142
143][ [count] end of vardefs, macros or figures forward.
144
145[] [count] end of vardefs, macros or figures backward.
146
147]} [count] end of blocks (fi, endfor, endgroup) forward.
148
149[{ [count] begin of blocks (if, for, begingroup) backward.
150
151 vim:tw=78:sw=4:ts=8:noet:ft=help:norl: