advanced autocomplete

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

advanced autocomplete

Mojca Miklavec

Hello,

ConTeXt, a TeX macro package, has a huge, however finite number of
commands. I would like to get some hints about the possibilities of
auto-completion.

Consider the following minimal example:

We have two commands \setupcolor and \setuplayout, an example usage
would be:

\setupcolor[My Color][red=.5,blue=.1,green=0]
\setuplayout
     [width=3cm,
      style=bold,
      grid=yes]

Is it feasible to write an auto-completion tool to:

1. autocomplete the commands like \setupcolor and \setuplayout
2. autocomplete options within a single command, for example to choose
only between width, style and grid when inside the first square brackets
of \setuplayout
3. to offer only yes/no after the grid= command in \setuplayout and only
regular/bold/italic/bolditalic after width= in \setuplayout?

There is a list of available commands (some 1000, some of them have
around 20 options), so once I would know a general scheme to support
autocompletion for one command, preparing support for the rest would be
trivial.

I know that syntax highlighting is pretty advanced in vim and that
writing a syntax-highlighter is doable for something like that (however
I'm not sure if vim would be fast enough to process so many regexps at
once).
I know that some people wrote Java plugins for example to support some
Java-specific behaviour (probably auto-complete as well). But how
advanced are the native auto-completion capabilities of vim? Does
support for the described auto-completion mean writing a complex plugin
or is there a simpler way?

Thank you very much,
        Mojca Miklavec
Reply | Threaded
Open this post in threaded view
|

Re: advanced autocomplete

Thomas-4-2
> \setupcolor[My Color][red=.5,blue=.1,green=0]
> \setuplayout
>     [width=3cm,
>      style=bold,
>      grid=yes]

<plug>
tSkeleton[1] can do this to some extent if you provide a map file.
Context-sensitive expansion is currently only implemented for
deplate/viki[2] mode though.
</plug>

This doesn't use vim's "native" auto completion. But maybe this is of
some use for you.

- thomas


[1] http://www.vim.org/scripts/script.php?script_id=1160
[2] http://www.vim.org/scripts/script.php?script_id=861