syntax/tex.vim and conceal support

250 views
Skip to first unread message

Charles Campbell

unread,
Jul 28, 2010, 9:55:22 AM7/28/10
to vim...@googlegroups.com
Hello,

I've put a new syntax/tex.vim on my website (and have given it to Bram
for inclusion in 7.3). You may try it out by getting it from
http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax and
clicking on tex.vim.gz . Of course you'll need a gunzip or similar tool
on Windows to decompress the file.

The new tex syntax file supports setting conceallevel to 2 with utf-8 by
showing appropriate glyphs for Greek in math, a few math symbols in
math, and a number of accented characters.

I personally have little call to use accents in my writing, so I may
well have missed some "favorites". If you'd like some accented
character that syntax/tex.vim is presently missing, please send me a
line or two of the form

syn match texAccent '\\c{c}' conceal cchar=�

where the '\\c{c}', for example, shows a Vim regex pattern matching the
LaTeX \c{c} which causes � to appear. To find the utf-8 glyphs, you may
wish to refer to http://www.utf8-chartable.de/unicode-utf8-table.pl .
You can find my email address at the 3rd line of vim73c/syntax/tex.vim .

Regards,
Chip Campbell

James Vega

unread,
Jul 28, 2010, 1:17:22 PM7/28/10
to vim...@googlegroups.com
On Wed, Jul 28, 2010 at 9:55 AM, Charles Campbell
<Charles.E...@nasa.gov> wrote:
> The new tex syntax file supports setting conceallevel to 2 with utf-8 by
> showing appropriate glyphs for Greek in math, a few math symbols in math,
> and a number of accented characters.

Why does the definition of the conceal syntax rely on &enc == 'utf-8'?
Removing those constraints and specifying the script is in utf-8
encoding (as in the attached patch) seems to work fine for me.

--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jame...@jamessan.com>

tex-enc.diff

Charles Campbell

unread,
Jul 28, 2010, 1:38:44 PM7/28/10
to vim...@googlegroups.com
James Vega wrote:
> On Wed, Jul 28, 2010 at 9:55 AM, Charles Campbell
> <Charles.E...@nasa.gov> wrote:
>
>> The new tex syntax file supports setting conceallevel to 2 with utf-8 by
>> showing appropriate glyphs for Greek in math, a few math symbols in math,
>> and a number of accented characters.
>>
> Why does the definition of the conceal syntax rely on&enc == 'utf-8'?

> Removing those constraints and specifying the script is in utf-8
> encoding (as in the attached patch) seems to work fine for me.
>
>
I'll put the

scriptencoding utf-8

into syntax/tex.vim, since the script is, in fact, written with utf-8.

However, the

if has("conceal") && &enc == "utf-8"

lines are still needed. With <enc.vimrc> as:

--------------------------------------------------
set nocp
syn on
set cole=3
--------------------------------------------------

and using

--------------------------------------------------
vi -u enc.vimrc -c ":e ++enc=latin abc.tex"
--------------------------------------------------

on the following tex file named <abc.tex>:

--------------------------------------------------
\documentclass[12pt]{article}
\pagestyle{empty}
\title{nothing}

\begin{document}
\begin{equation}
\delta^0\\
\alpha\alpha = x^{a0123456789zABabTUW} \\
\beta\delta^3\\
y= z^{1.5}\\
\phi= x_{\chi}\\
x_1 + x_2 \\
\end{equation}
\`{a} \`{e} \`{i} \`{o} \`{u} \`{y} \`{A} \`{E} \`{I} \`{O} \`{U} \`{Y}
\'{a} \'{e} \'{i} \'{o} \'{u} \'{y} \'{A} \'{E} \'{I} \'{O} \'{U} \'{Y}
\^{a} \^{e} \^{i} \^{o} \^{u} \^{y} \^{A} \^{E} \^{I} \^{O} \^{U} \^{Y}
\~{a} \~{e} \~{i} \~{o} \~{u} \~{y} \~{A} \~{E} \~{I} \~{O} \~{U} \~{Y}
\~{a} \~{e} \~{i} \~{o} \~{u} \~{y} \~{A} \~{E} \~{I} \~{O} \~{U} \~{Y}
\r{a} \r{A}
\v{a} \v{e} \v{i} \v{o} \v{u} \v{A} \v{E} \v{I} \v{O} \v{U}
\aa \AA \k{a} \k{A} \c{C} \~{n} \~{N} \o \O \H{o} \H{O} \c{r} \AE
\ae \oe \OE \ss
\end{document}
Check if $x$
% vim: cole=2
--------------------------------------------------

shows rather unpleasant behavior otherwise.

Regards,
Chip Campbell

James Vega

unread,
Jul 28, 2010, 2:30:17 PM7/28/10
to vim...@googlegroups.com
On Wed, Jul 28, 2010 at 1:38 PM, Charles Campbell
<Charles.E...@nasa.gov> wrote:
> However, the
>
>  if has("conceal") && &enc == "utf-8"
>
> lines are still needed.  With <enc.vimrc> as:
>
> --------------------------------------------------
> set nocp
> syn on
> set cole=3
> --------------------------------------------------
>
> and using
>
> --------------------------------------------------
> vi -u enc.vimrc -c ":e ++enc=latin abc.tex"
> --------------------------------------------------

The '++enc=latin1' solely changes what &fenc is. Since the actual
contents of the file are all ASCII, this doesn't actually change
anything. If you meant that you're running in a UTF-8 locale (like
en_US.UTF-8) and you ran:

env LC_ALL=en_US.ISO8859-1 vi -u enc.vimrc abc.tex

then you're right, but only because your terminal is expecting UTF-8
bytes and you've told Vim (tangentially) to send latin1 bytes to the
terminal.

"set tenc=utf-8" will cause Vim to display all the glyphs which exist in
both UTF-8 and latin1 correctly and the others using the an upside-down
question mark (for me) instead of the "unknown character" glyph. This
sounds like maybe the conceal feature is relying on &enc instead of
&tenc for determining whether the concealed characters should be
displayed, which would be a bug IMO.

bjorn.winckler

unread,
Aug 2, 2010, 7:39:25 AM8/2/10
to Charles Campbell, vim...@googlegroups.com
On Jul 28, 3:55 pm, Charles Campbell wrote:
>
> I've put a new syntax/tex.vim on my website (and have given it to Bram
> for inclusion in 7.3).  You may try it out by getting it fromhttp://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntaxand
> clicking ontex.vim.gz .  Of course you'll need a gunzip or similar tool

> on Windows to decompress the file.
>
> The newtexsyntax file supports setting conceallevel to 2 with utf-8 by

> showing appropriate glyphs for Greek in math, a few math symbols in
> math, and a number of accented characters.
>
> I personally have little call to use accents in my writing, so I may
> well have missed some "favorites".  If you'd like some accented
> character that syntax/tex.vim is presently missing, please send me a
> line or two of the form
>
>    syn match texAccent    '\\c{c}'    conceal cchar=
>
> where the '\\c{c}', for example, shows a Vim regex pattern matching the
> LaTeX \c{c} which causes to appear.  To find the utf-8 glyphs, you may
> wish to refer tohttp://www.utf8-chartable.de/unicode-utf8-table.pl.  
> You can find my email address at the 3rd line of  vim73c/syntax/tex.vim .

Hi Chip (and vim_dev),

I really like the idea of using conceal in the tex syntax file but it
still needs some work (I'm basing my comments on the version of
tex.vim that was included in the Sun 1 Aug changeset).

Try the following:

$\eps_b \geq \rho^{-\sigma b}$

- Super/subscripts look weird. The \sigma is typeset as superscript
"s i g m a" (each letter is a superscript). As it stands I'd rather
have no super/subscripts at all than this weird behavior. (In fact, I
dislike the super/subscripts anyway because they become so tiny that
they are hard to read unless you set your 'gfn' size to something
enormous.)

- Super/subscripts work inconsistently. Note that the "_b" after
"\eps" is not turned into a subscript. As far as I understand some
letters are not available as subscripts? Again, I'd rather have no
subscripts at all than to have some letters turn into subscripts but
not others.

- $, { and } are turned into "-". Why?

- I can think of a few more things to conceal (off the top of my
head): \infty, \in, \subset (and variants), \cup, \cap, \wedge, \vee,
the list goes forever on (it may be helpful to take a look at "short-
math-guide.pdf" by Michael Downes)


Anyway, I am grateful for the work you've put into this but there is
definitely room for improvement (my apologies for not simply sending
you a patch but I really should get back to writing that
article... ;-).


Björn

Reply all
Reply to author
Forward
0 new messages