Syntax regions?

Viki
2013-10-16
2013-10-18
  • Jean Jordaan
    Jean Jordaan
    2013-10-16

    One of the best things for me in vimwiki is embedded syntax regions.
    E.g. I can write

    {{{mail
    From: ...
    Subject: ...
    
    Message 
    }}}
    

    to get a message formatted as an email, or

    {{{python
    for i in doc_ids:
        print i
    }}}
    

    to get Python format, for any format that Vim knows.

    Can viki also do this?

     
    • Tom Link
      Tom Link
      2013-10-16

      One of the best things for me in vimwiki is embedded syntax regions.

      I had prepared support for syntax highlighting of #Code regions for some
      time. I enabled it in the master version @github.

      {{{python
      for i in doc_ids:
      print i
      }}}

      Code syntax=python <<---

      for i in doc_ids:
      print i


      Syntax highlighting for a #Code region is loaded when setting the filetype. I.e. new #Code regions maybe are not be highlighted properly.

      HTH

       
  • Jean Jordaan
    Jean Jordaan
    2013-10-17

    Ah, cool. The docs are a bit confusing:

    g:viki#code_syntax             (default: ['sql'])
        Properly highlight #Code regions if the filetype is included in 
        the list below.
    

    But nothing "below". Looking at viki_vim/autoload/viki.vim I see what is "below".

    In viki_vim/syntax/viki.vim I see a commented-out block to process g:viki#code_syntax.

    I did :let g:viki#code_syntax = ['python'].
    For this:

    #Code syntax=python <<EOF
    #this is code
    for x in y
    EOF
    

    I see text in green, and syntax info hi<vikiRegion> trans<vikiRegion> lo<Statement>.

     
    Last edit: Jean Jordaan 2013-10-17
    • Tom Link
      Tom Link
      2013-10-18

      I see text in green, and syntax info |hi<vikiRegion> trans<vikiRegion>
      lo<Statement>|.
      Are you sure you tried the latest version? I'm asking because I removed
      g:viki#code_syntax.

      Anyway, in the meantime I re-introduced g:viki#code_syntax, which now
      holds a list of filetypes that are always enabled. Thus, if you
      frequently use python, you might want to add

       let g:viki#code_syntax = ['python']
      

      to .vimrc.

      HTH

       
  • Jean Jordaan
    Jean Jordaan
    2013-10-18

    I tried that on

    https://github.com/tomtom/viki_vim.git
    commit 80a7c8bf578792e118fb0aabe0a2d133597356a9
    

    Ah, looks like I was one day behind!
    Updated now ...