On Sat, 3 Feb 2007, Felix Obenhuber wrote:

> On 03 Feb 07 - 13:32, Dag Wieers wrote:
> > Is there a way to make this happen ? Eventually I did ':set syntax=adoc' 
> > and that gave me some colors.
> 
> I'm using
> 
> autocmd BufNewFile *.txt            source ~/.vim/txt.vimrc
> autocmd BufRead    *.txt            source ~/.vim/txt.vimrc
> 
> to get the vim adjustments described at the asciidoc site and to 
> 
> set syn=adoc
> 
> so the file is expected as syntax file... Thinks that there are lots of
> possibilities to get a syntax file working but don't know whats the best and
> smartest way.

Maybe a standardized .adoc extension may help wrt. this ? In that case 
calling the file adoc.vim may be fine as well.


> > Secondly, although the syntax file is a vast improvement, some things are 
> > not working. I have no understanding of writing syntax files but it would 
> > be desirable if eg.
> 
> Let me say that the file was a quick and dirty action. I had to write a small
> article with a fellow student and he complained about "the editor interface". 
> It
> was the first time he used something different to openoffice and word... So I
> took the twiki syntax file and adopted 'partly' to asciidoc. Sure I know that
> theres only a very small subset definend and the regex used are crappy over 
> and
> over. I've been in doubt about announcing it here because of being ashame...
> After sending my previous post I took a look at the file and noticed that some
> Twiki elements are also included... :-/. Release often and early...so we're
> here.

No problem, I took the time to improve it slightly. But I'm committed to 
work on it on other files I have at work to further improve it in the 
future. In my opinion, having it as part of asciidoc or vim will help 
scale the work to other people as well.


> >  - comments (//// comment ////) were marked as such.
> > 
> >  - titles are coloured as well (not just the lines) when you use the 
> >    syntax
> > 
> >        this is a title
> >        ---------------
> 
> I intend to use the ==sometitle format. We should first of all consider which
> elements we want to have coloured. Could imagine that a file blinking like a
> christmas tree won't be usable anymore. Things what IMHO definitly should be 
> marked
> are:
>  
>   * [[foo]]
>   * <<bar>>
>   * titles
>   * comments
>   * maybe links

Right, I just added better support for the '= titles', the 
'titles\n------' seems to be much hard though :)


> >  - bullets are coloured (first level is not coloured, second is ?)
> > 
> > Lastly, I found a problem with the URL syntax where you have named links 
> > like eg. http://dag.wieers.com/[Dag Wieers' Homepage]. The current syntax 
> > colours only up to [Dag .
> 
> As you see - there's something to do...

Well, I now understand the complexity :)


> > Now, what would be required to have the adoc.syntax shipped with the next 
> > release of vim (even in an incomplete state) and with the next 
> > release of asciidoc ? This way packagers can place the syntax file in the 
> > asciidoc package until it gets shipped with vim.
> 
> Would be great, but in the current state of the file there's no way to ship it
> without driving some people who are familiar with regex and vim to madness ;-)

I understand, but a simple comment at the top stating that this is a work 
in progress and contact information may get us a long way. Also important 
is making sure the syntax get loaded for asciidoc documents automatically.
This hoewever is practically not possible atm.


> > Also, what is the reason this is called adoc.vim and not eg. asciidoc.vim ?
> > Is adoc going to be the 'standard' extension for asciidoc ?
> 
> Ohh. Don't think so. I'll rename to the syntax name defined in the file to 
> asciidoc. 
> The binding between file suffix and syntax can be individualy done as decribed
> above...
> 
> Stuart: did you define any naming conventions?
>
> > Nevertheless, I'm grateful for your initiative :)
> 
> Thanks. Take this as ignition spark. As you've seen my vim and regex skills 
> are
> quite poor so feel free to rewrite, extend or anything else.

I did, here's my work on it. I lack any git skills so I hope you don't 
mind doing a diff.

Also, if I compare the asciidoc syntax file against the one that ship wit 
vim 7 I see a lot more complexity that is not in the official ones. I 
understand this is to allow backward compatibility with older vim 
releases. (< 5.8)

Given the fact that even RHEL 2.1 ships with vim 6 I wonder if the need 
to be backward compatible with ancient vim's is warranted.

Stuart: How about pushing this into the next asciidoc release so we can 
all advantage from it and can send patches against the upstream syntax 
file ?

Thanks in advance,
--   dag wieers,  [EMAIL PROTECTED],  http://dag.wieers.com/   --
[all I want is a warm bed and a kind word and unlimited power]
" Vim syntax file
" Language: Asciidoc style

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

"syn match adocName     /[^\!]\(\u[a-z0-9]\+\)\{2,}/ms=s+1
syn match adocName     /^\w*\u\w*[a-z0-9]\w*\u\w*/
syn match adocURL      
/\(http\|https\|gopher\|mailto\|news\|ftp\|file\):\(\S\+\)/
syn match adocRule     /^-\{4,}/
syn match adocBullet   /^\s*[\*\-]\s/
syn match adocNumItem  /^\(\s\)\+\d\+[.)]\s/
syn match adocToDo     /TODO/
syn match adocEmail    /[EMAIL PROTECTED](.\S+\)*/
syn match adocSpecialChar /{amp}\w+;/

syn region adocL0 start="^=" end="$"
syn region adocL1 start="^==" end="$"
syn region adocL2 start="^===" end="$"
syn region adocL3 start="^====" end="$"
syn region adocL4 start="^=====" end="$"

syn region adocL0 start="^=" end="=$" oneline
syn region adocL1 start="^-" end="-$" oneline
syn region adocL2 start="^\~" end="\~$" oneline
syn region adocL3 start="^\^" end="\^$" oneline
syn region adocL4 start="^+" end="+$" oneline
syn region adocDefinition start="^" end="::$" oneline
syn match adocRef /<<[a-z0-9]*>>/
syn region adocFon start="footnote:" end="]"
syn region adocMacro start="\[\[" end="\]\]" oneline
syn region adocLink start="\[\"" end="\"\]" oneline
syn region adocBold start="\'\{3}" end="\'\{3}"
syn region adocItalic start="\'\{2}[^\']"  end="\'\{2}\([^\']\|$\)"
syn region adocMeta start="^#" end="$" oneline
syn region adocComment start="^////\+$" end="^////\+$"

if version <= 508 || !exists("did_adoc_syntax_inits")
  if version < 508
    let did_adoc_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  HiLink adocL0          Title
  HiLink adocL1          adocL0
  HiLink adocL2          adocL1
  HiLink adocL3          adocL2
  HiLink adocL4          adocL3
  HiLink adocRef         PreProc
  HiLink adocMacro       Identifier
  HiLink adocLink        Underlined 
"  HiLink adocName        Underlined
  HiLink adocURL         Underlined
  HiLink adocEmail       PreProc
  HiLink adocBullet      Identifier
  HiLink adocFon         Label
  HiLink adocRule        Identifier
  HiLink adocNumItem     Label
  HiLink adocBold        Type
  HiLink adocItalic      SpecialKey
  HiLink adocMeta        Comment
  HiLink adocToDo        Todo
  HiLink adocComment     Comment
  HiLink adocDefinition  Label
  HiLink adocSpecialChar Identifier
      
  delcommand HiLink
endif

let b:current_syntax = "adoc"
_______________________________________________
Asciidoc-discuss mailing list
Asciidoc-discuss@metaperl.com
http://metaperl.com/cgi-bin/mailman/listinfo/asciidoc-discuss

Reply via email to