view runtime/doc/ft_mp.txt @ 33399:95db67c7b754 v9.0.1958

patch 9.0.1958: cannot complete option values Commit: https://github.com/vim/vim/commit/900894b09a95398dfc75599e9f0aa2ea25723384 Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Fri Sep 29 20:42:32 2023 +0200 patch 9.0.1958: cannot complete option values Problem: cannot complete option values Solution: Add completion functions for several options Add cmdline tab-completion for setting string options Add tab-completion for setting string options on the cmdline using `:set=` (along with `:set+=` and `:set-=`). The existing tab completion for setting options currently only works when nothing is typed yet, and it only fills in with the existing value, e.g. when the user does `:set diffopt=<Tab>` it will be completed to `set diffopt=internal,filler,closeoff` and nothing else. This isn't too useful as a user usually wants auto-complete to suggest all the possible values, such as 'iblank', or 'algorithm:patience'. For set= and set+=, this adds a new optional callback function for each option that can be invoked when doing completion. This allows for each option to have control over how completion works. For example, in 'diffopt', it will suggest the default enumeration, but if `algorithm:` is selected, it will further suggest different algorithm types like 'meyers' and 'patience'. When using set=, the existing option value will be filled in as the first choice to preserve the existing behavior. When using set+= this won't happen as it doesn't make sense. For flag list options (e.g. 'mouse' and 'guioptions'), completion will take into account existing typed values (and in the case of set+=, the existing option value) to make sure it doesn't suggest duplicates. For set-=, there is a new `ExpandSettingSubtract` function which will handle flag list and comma-separated options smartly, by only suggesting values that currently exist in the option. Note that Vim has some existing code that adds special handling for 'filetype', 'syntax', and misc dir options like 'backupdir'. This change preserves them as they already work, instead of converting to the new callback API for each option. closes: #13182 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Fri, 29 Sep 2023 20:45:04 +0200
parents cc751d944b7e
children 4635e43f2c6f
line wrap: on
line source

*ft_mp.txt*	For Vim version 9.0.  Last change: 2022 Aug 12

This is the documentation for the METAFONT and MetaPost filetype plugins.
Unless otherwise specified, the commands, settings and mappings defined below
apply equally to both filetypes.

NOTE: the plugin requires +vim9script.

==============================================================================
CONTENTS						*mp.vim* *ft-metapost*
							*mf.vim* *ft-metafont*

1. Introduction				|ft-metapost-intro|
2. Commands				|ft-metapost-commands|
3. Settings				|ft-metapost-settings|
4. Mappings				|ft-metapost-mappings|

==============================================================================
							*ft-metapost-intro*
							*ft-metafont-intro*
Introduction ~
This filetype plugin provides extensive support for editing METAFONT and
MetaPost documents, including syntax coloring, indentation, and completion.

Defining indentation rules for METAFONT and MetaPost code is tricky and
somewhat subjective, because the syntax is quite liberal. The plugin uses some
heuristics that work well most of the time, but in particular cases you may
want to to override the automatic rules, so that the manually defined
indentation is preserved by commands like `gg=G`.

This can be achieved by appending `%>`, `%<`, `%=` or `%!` to a line to
explicitly control the indentation of the next line. The `<` and `>` symbols
may be repeated many times: for instance, `%>>` will cause the next line to be
indented twice. Of course, `%<` means that the next line should be
de-indented; `%=` sets the indentation of the next line to be equal to the
indentation of the current line; and `%!` means that the indentation of the
next line should not change from whatever it has been manually set.

For example, this is the default indentation of a simple macro:
>
   def foo =
       makepen(
           subpath(T-n,t) of r
           shifted .5down
           --subpath(t,T) of r shifted .5up -- cycle
       )
       withcolor black
   enddef
<
By adding the special comments, the indentation can be adjusted arbitrarily:
>
   def foo =
       makepen(
           subpath(T-n,t) of r  %>
               shifted .5down   %>
                   --subpath(t,T) of r shifted .5up -- cycle   %<<<
       )
       withcolor black
   enddef
<
							*ft-metapost-commands*
Commands ~
					*:FixBeginfigs*
Renumber beginfig() blocks in the current buffer so that the n-th figure has
number n. MetaPost only.

							*ft-metapost-settings*
							*ft-metafont-settings*
Settings ~
					*'g:mf_other_macros'*
Highlight some other basic macro names, e.g., from cmbase, logo, etc. This is
set to 1 by default in METAFONT buffers, and it is set to 0 by default in
MetaPost buffers.

					*'g:mf_plain_macros'*
Highlight keywords defined by plain.mf. This is set to 1 by default in
METAFONT buffers, and it is set to 0 by default in MetaPost buffers.

					*'g:mf_plain_modes'*
Highlight keywords defined by modes.mf. This is set to 1 by default in
METAFONT buffers, and it is set to 0 by default in MetaPost buffers.

					*'g:mp_close_tag'*
Define additional keywords that end indented blocks. For instance, if you
define:
>
	g:mp_close_tag = ['\<endfoo\>']
<
any line starting with `endfoo` will be de-indented compared to its previous
line.
>
	g:mp_close_tag = []
<
					*'b:mp_metafun'*
					*'g:mp_metafun'*
If set to 1, highlight ConTeXt's MetaFun keywords. MetaPost only.
>
	g:mp_metafun = 0
<
					*'g:mp_mfplain_macros'*
Highlight keywords defined by mfplain.mp. MetaPost only.
>
	g:mp_mfplain_macros = 1
<
					*'g:mp_open_tag'*
Define additional keywords that start indented blocks. For instance, if you
define:
>
	g:mp_open_tag = ['\<beginfoo\>']
<
the line following `beginfoo` will be indented.
>
	g:mp_open_tag = []
<
					*'g:mp_other_macros'*
Highlight keywords defined by all base macro packages (boxes, rboxes, format,
graph, marith, sarith, string, TEX). This option affects only MetaPost
buffers.
>
	g:mp_other_macros = 1
<
					*'g:mp_plain_macros'*
Highlight keywords defined by plain.mp. MetaPost only.
>
	g:mp_plain_macros = 1
<
					*'g:no_mp_maps'*
					*'g:no_mf_maps'*
When set, do not define any mapping in buffers with the corresponding
filetype.
>
	g:no_mp_maps = 0
	g:no_mf_maps = 0
<
							*ft-metapost-mappings*
							*ft-metafont-mappings*
Mappings ~

]]			[count] vardefs, macros or figures forward.

[[			[count] vardefs, macros or figures backward.

][			[count] end of vardefs, macros or figures forward.

[]			[count] end of vardefs, macros or figures backward.

]}			[count] end of blocks (fi, endfor, endgroup) forward.

[{			[count] begin of blocks (if, for, begingroup) backward.

 vim:tw=78:sw=4:ts=8:noet:ft=help:norl: