syntax/vo_base.vim

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

syntax/vo_base.vim

Stefan Schmiedl
Now that I've switched my gentoo box to UTF-8, an old problem raised
it's head again. Syntax coloring failed for the heading "Übersicht"
starting with an umlaut.

Instead of working (don't tell my wife), I tried an old recipe:
  Throw out stuff until it works.

Welllll, with some help from the online docs (:help syntax, :help
regex), I came up with the following (complete file attached):


syn match outlTags '_tag_\w*' contained

syntax region BT1 start=/\z(^:\)/           skip=/\z1/ end=/\_$\z1\@!/ contains=outlTags
syntax region BT2 start=/\z(^\(\t\)\{1}:\)/ skip=/\z1/ end=/\_$\z1\@!/ contains=outlTags
...
syntax region PT1 start=/\z(^;\)/           skip=/\z1/ end=/\_$\z1\@!/ contains=outlTags
syntax region PT2 start=/\z(^\(\t\)\{1};\)/ skip=/\z1/ end=/\_$\z1\@!/ contains=outlTags
...
... TAi UTi UBi ...
...
syntax region OL1 start=/^[^\t:;<>|]/           end=/$/ contains=outlTags
syntax region OL2 start=/^\t[^\t:;<>|]/         end=/$/ contains=outlTags
syntax region OL3 start=/^\(\t\)\{2}[^\t:;<>|]/ end=/$/ contains=outlTags


The "strange stuff" explained:
\z( \) is like \( \), but only useful in exactly the situation above :-)
\_$    denotes the end of a line, but can appear anywhere in a pattern
\@!    requires the preceding item *not* to match.

So the syntax classes skip over their leaders and end, when the pattern
in front of the line changes. Also I only need to contain only the
"inline" element outlTags (spell checking is for wusses;-).

Oh, and btw, "Übersicht" is colored as it's supposed to be.

If you like living dangerous, replace ~/.vim/syntax/vo_base.vim with the
attached file. If you like playing it safe, make a backup copy first.
I'd appreciate it, if you could compare this syntax file's behaviour to
the original.

s.
--
Stefan Schmiedl
+-------------------------------+----------------------------------------+
|Approximity GmbH               | EDV-Beratung Schmiedl                  |
|http://www.approximity.com     | Am Bräuweiher 4, 93499 Zandt, Germany  |
|mailto:[hidden email]  | Tel. (09944) 3068-98, Fax -97          |
+-------------------------------+----------------------------------------+

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner

vo_base.vim (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: syntax/vo_base.vim

Noel Henson
On Saturday 03 September 2005 03:32 pm, Stefan Schmiedl wrote:

> Now that I've switched my gentoo box to UTF-8, an old problem raised
> it's head again. Syntax coloring failed for the heading "Übersicht"
> starting with an umlaut.
>
> Instead of working (don't tell my wife), I tried an old recipe:
>   Throw out stuff until it works.
>
> Welllll, with some help from the online docs (:help syntax, :help
> regex), I came up with the following (complete file attached):
>

I wonder why it raised it's head? Didn't we have that fixed? Did the UTF-8
install use an older version of VO?

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: syntax/vo_base.vim

Stefan Schmiedl
Noel Henson (04.09. 06:06):

>
> I wonder why it raised it's head? Didn't we have that fixed? Did the UTF-8
> install use an older version of VO?

current release, of course. Maybe there's something in vim with
[^...] and UTF that's wrong. But I'm not fussy about that, as
long as I get it working :-)

s.
_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: syntax/vo_base.vim

Matej Cepl-2
In reply to this post by Noel Henson
Noel Henson wrote:
> I wonder why it raised it's head? Didn't we have that fixed? Did the UTF-8
> install use an older version of VO?

Just to confirm, that I saw this bug as well (and I was the reporter
reporting this to ignorant-ASCII-only-American Noel last time :-)), but
then I was distracted from reporting by Kate and KJS. So just to confirm,
that I saw it in my VO too.

Matej

--
Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
 
There is no reason to suppose that most human beings are engaged
in maximizing anything unless it be unhappiness, and even this
with incomplete success.
    -- Ronald Coase
       Introduction to ``The Firm, the Market, and the Law''

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Re: syntax/vo_base.vim

Noel Henson
On Sunday 04 September 2005 01:59 pm, Matej Cepl wrote:

> Noel Henson wrote:
> > I wonder why it raised it's head? Didn't we have that fixed? Did the
> > UTF-8 install use an older version of VO?
>
> Just to confirm, that I saw this bug as well (and I was the reporter
> reporting this to ignorant-ASCII-only-American Noel last time :-)), but
> then I was distracted from reporting by Kate and KJS. So just to
> confirm, that I saw it in my VO too.
>
> Matej

I don't know why you guys need all those other letters. I get along just
fine without them. ;)

OK. So how do I set vim to use them? I'll check out Stefan's solution to
make sure everything works as expected.

Noel
7-bit ASCII user


--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Re: syntax/vo_base.vim

Matej Cepl-2
Noel Henson wrote:
> OK. So how do I set vim to use them? I'll check out Stefan's solution to
> make sure everything works as expected.

You don't have to set anything (provided you have font with wide enough
coverage -- Courier New, DeJa Mono, Andale Mono should be OK). Just use
digraphs :he :digraphs. So for example, my problem was with Č (which has a
digraph C<) and Š (which is S<). Stefan's problem was with Ü (which has a
digraph U:).

Best,

Matěj

--
Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
 
When you come to the fork in the road, take it
   -- L.P. Berra


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Re: syntax/vo_base.vim

Matej Cepl-2
Matej Cepl wrote:
> You don't have to set anything (provided you have font with wide enough
> coverage -- Courier New, DeJa Mono, Andale Mono should be OK). Just use
> digraphs :he :digraphs. So for example, my problem was with Č (which has a
> digraph C<) and Š (which is S<). Stefan's problem was with Ü (which has a
> digraph U:).

So for example you can add this to your ~/.gvimrc:

set encoding=utf-8
if has("gui_kde")
   set guifont=Andale\ Mono/12/-1/5/50/0/0/0/0/0
else
   "set guifont=-misc-fixed-medium-r-normal-*-13-120-*-*-c-*-iso10646-1
   "set guifont=Andale\ Mono\ 12
   set guifont=DejaVu\ Sans\ Mono\ 10
endif

I have created test file to show the problem, and it seems that every other
line is correctly marked. Do you have any explanation of the problem?

Best,

Matěj

--
Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
 
Less is more or less more.
   -- Y_Plentyn on #LinuxGER
      (from fortunes -- I cannot resist :-)

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner

test.otl (168 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: syntax/vo_base.vim

Stefan Schmiedl
Matej Cepl (05.09. 22:15):

> I have created test file to show the problem, and it seems that every other
> line is correctly marked. Do you have any explanation of the problem?
>

attached the look on my box

s.

--
Stefan Schmiedl
+-------------------------------+----------------------------------------+
|Approximity GmbH               | EDV-Beratung Schmiedl                  |
|http://www.approximity.com     | Am Bräuweiher 4, 93499 Zandt, Germany  |
|mailto:[hidden email]  | Tel. (09944) 3068-98, Fax -97          |
+-------------------------------+----------------------------------------+

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner

vo.jpg (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: syntax/vo_base.vim

Noel Henson
On Monday 05 September 2005 06:02 pm, Stefan Schmiedl wrote:
> Matej Cepl (05.09. 22:15):
> > I have created test file to show the problem, and it seems that every
> > other line is correctly marked. Do you have any explanation of the
> > problem?
>
> attached the look on my box
>
> s.

OK. After finally figuring out how to get digraphs to work (to work to the
point that I could recreate the error), I think I have figured out the
problem. If you take one of the headings that is failing and duplicate it
several times, you should notice that proper highlighting comes and goes.  
It should be fine on alternating lines. If you set your encoding to latin1,
the problem goes away. Set it back to utf-8 and the problem returns. In
either case, the folding works correctly. So, my current hypothesis is that
there is an error in Vim's highlighting. I'm going to try to quantitize it
some more so I can perhaps come up with a patch for Vim or make it clear
enough for a Vim developer to find and fix.

To get around this, you can use Stefan's syntax file. I tested it and it
does get around this particular problem but introduces many others. Since
his method ends headings at the end of the heading line, proper
encapsulation of subheadings, body text, tables, etc. does not occur and
they are not properly colored. They take on the coloring of their parent
heading. Proper folding does seem to occur.

That's about all I have for you on this so far.

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner