Loading ...
Sorry, an error occurred while loading the content.

Vim syntax: "highlight" keyword not highlighted inside functions

Expand Messages
  • François Ingelrest
    Hi all, ... highlight Comment guifg=White guibg=Black function! Foo() highlight Comment guifg=White guibg=Black endfunction ... The first highlight line is
    Message 1 of 12 , Nov 5, 2008
    • 0 Attachment
      Hi all,

      If I put this in a foo.vim file:

      ----
      highlight Comment guifg=White guibg=Black

      function! Foo()

      highlight Comment guifg=White guibg=Black

      endfunction
      ----

      The first "highlight" line is highlighted, but not the second one. It
      seems that's because it's inside a function. Is it intended, or is
      this a bug in the vim syntax file?

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Roberto Miura Honji
      I m using highlight inside a function and It s working. Do you call the function? If you only define a function on foo.vim, this only will be defined. Try
      Message 2 of 12 , Nov 6, 2008
      • 0 Attachment
        I'm using highlight inside a function and It's working.
        Do you call the function?
        If you only define a function on foo.vim, this only will be defined. Try append a follow line in a foo.vim: call Foo()

        2008/11/5 François Ingelrest <francois.ingelrest@...>

        Hi all,

        If I put this in a foo.vim file:

        ----
        highlight Comment guifg=White guibg=Black

        function! Foo()

           highlight Comment guifg=White guibg=Black

        endfunction
        ----

        The first "highlight" line is highlighted, but not the second one. It
        seems that's because it's inside a function. Is it intended, or is
        this a bug in the vim syntax file?





        --
        ----------------------------------------------
        Roberto Miura Honji
        LAS - Laboratório de Administração e Segurança de Sistemas
        Engenharia de Computação - 2006
        Instituto de Computação - UNICAMP

        email: miurahonji@... (principal)
        email: ra064201@...
        msn:   miurahonji@...
        -------------------------------------------

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---

      • François Ingelrest
        ... You get the same color highlighting inside and outside the function? For me the highlighting works inside functions for most statements, but not for the
        Message 3 of 12 , Nov 6, 2008
        • 0 Attachment
          On Thu, Nov 6, 2008 at 22:41, Roberto Miura Honji <miurahonji@...> wrote:
          > I'm using highlight inside a function and It's working.

          You get the same color highlighting inside and outside the function?
          For me the highlighting works inside functions for most statements,
          but not for the 'highlight' statement itself (see attached
          screenshot).

          > Do you call the function?
          > If you only define a function on foo.vim, this only will be defined. Try
          > append a follow line in a foo.vim: call Foo()

          This doesn't make a difference. Actually, I'm not sure the syntax file
          checks that functions are called to highlight them.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • François Ingelrest
          On Fri, Nov 7, 2008 at 08:08, François Ingelrest ... I should add that I m using Vim 7.2.26, compiled by myself using the sources from the CVS, so I guess the
          Message 4 of 12 , Nov 6, 2008
          • 0 Attachment
            On Fri, Nov 7, 2008 at 08:08, François Ingelrest
            <francois.ingelrest@...> wrote:
            > On Thu, Nov 6, 2008 at 22:41, Roberto Miura Honji <miurahonji@...> wrote:
            >> I'm using highlight inside a function and It's working.
            >
            > You get the same color highlighting inside and outside the function?
            > For me the highlighting works inside functions for most statements,
            > but not for the 'highlight' statement itself (see attached
            > screenshot).
            >
            >> Do you call the function?
            >> If you only define a function on foo.vim, this only will be defined. Try
            >> append a follow line in a foo.vim: call Foo()
            >
            > This doesn't make a difference. Actually, I'm not sure the syntax file
            > checks that functions are called to highlight them.

            I should add that I'm using Vim 7.2.26, compiled by myself using the
            sources from the CVS, so I guess the syntax file also comes from the
            CVS. I get the same result when using Vim -u NONE -U NONE, and
            enabling only syntax highlighting after that.

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Tony Mechelynck
            ... Yeah, looks like the syntax/vim.vim script doesn t recognise the same syntax groups for some statements when they are inside a function. With the default
            Message 5 of 12 , Nov 8, 2008
            • 0 Attachment
              On 07/11/08 08:08, François Ingelrest wrote:
              > On Thu, Nov 6, 2008 at 22:41, Roberto Miura Honji<miurahonji@...> wrote:
              >> I'm using highlight inside a function and It's working.
              >
              > You get the same color highlighting inside and outside the function?
              > For me the highlighting works inside functions for most statements,
              > but not for the 'highlight' statement itself (see attached
              > screenshot).
              >
              >> Do you call the function?
              >> If you only define a function on foo.vim, this only will be defined. Try
              >> append a follow line in a foo.vim: call Foo()
              >
              > This doesn't make a difference. Actually, I'm not sure the syntax file
              > checks that functions are called to highlight them.

              Yeah, looks like the syntax/vim.vim script doesn't recognise the same
              syntax groups for some statements when they are inside a function. With
              the default GUI colours, here's what I see:

              line
              word isolated (=> links to) inside func (=> links to)
              highlight Comment guifg=white guibg=black
              highlight vimHighlight => Statement vimIsCommand
              Comment vimHiGroup => Type vimIsCommand
              guifg vimHiGuiFgBg => Type vimIsCommand
              = vimHiKeyList vimOper => Statement
              white vimHiGroup => Type vimIsCommand
              guibg vimHiGuiFgBg => Type vimIsCommand
              = vimHiKeyList vimOper => Statement
              black vimHiGroup => Type vimIsCommand
              syn sync fromstart
              syn vimSyntax => Statement vimIsCommand
              sync vimSynType => Type vimIsCommand
              fromstart vimSyncC => Type vimIsCommand
              filetype plugin indent on
              filetype vimFTCmd => Statement vimCommand => Statement
              plugin vimFTOption => Type vimIsCommand
              indent vimFTOption => Type vimIsCommand
              on vimFTOption => Type vimCommand => Statement

              The other ones that I tried were highlighted identically inside
              functions and out of them.

              I found this out by means of the following command (which gives four
              replies but 1 and 3 are equal, and so are 2 and 4, AFAICT):

              command -nargs=0 -bar WhatSyntax echomsg
              synIDattr(synID(line("."),col("."),0),"name")
              synIDattr(synIDtrans(synID(line("."),col("."),0)),"name")
              synIDattr(synID(line("."),col("."),1),"name")
              synIDattr(synIDtrans(synID(line("."),col("."),1)),"name")


              Notice the many instances of various syntax groups becoming vimIsCommand
              (which has no highlights defined) when inside a function block.

              Maybe contains=TOP should be added to the definition of the vimFuncBody
              syntax group? Dr.Chip, what do you think?


              Best regards,
              Tony.
              --
              I've given up reading books; I find it takes my mind off myself.

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_dev" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Anton Sharonov
              ... Unfortunately, it is not true. At least for SVN, (and I suspect that for CVS it is as well the case) there are recent versions of the runtime files (don t
              Message 6 of 12 , Nov 9, 2008
              • 0 Attachment
                > I should add that I'm using Vim 7.2.26, compiled by myself
                > using the sources from the CVS, so I guess the syntax file also
                > comes from the CVS. I get the same result when using Vim -u
                > NONE -U NONE, and enabling only syntax highlighting after that.

                > ... so I guess the syntax file also
                > comes from the CVS. ...

                Unfortunately, it is not true. At least for SVN, (and I suspect
                that for CVS it is as well the case) there are recent versions of
                the runtime files (don't ask me why, for me it is also _very_
                confusing). Anyway, to get recent runtime files, please use
                rsync, as described on Tony's howto [1] about compiling vim.

                --
                Anton

                [1] Tony's how to for VIM compilation
                UNIX:
                http://users.skynet.be/antoine.mechelynck/vim/compunix.htm
                WINDOWS:
                http://users.skynet.be/antoine.mechelynck/vim/compile.htm

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_dev" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Anton Sharonov
                %s/there are recent versions/there is no recent versions/ Sorry for small typo. -- Anton ... --~--~---------~--~----~------------~-------~--~----~ You received
                Message 7 of 12 , Nov 9, 2008
                • 0 Attachment
                  %s/there are recent versions/there is no recent versions/

                  Sorry for small typo.

                  --
                  Anton

                  2008/11/9, Anton Sharonov <anton.sharonov@...>:
                  >> I should add that I'm using Vim 7.2.26, compiled by myself
                  >> using the sources from the CVS, so I guess the syntax file also
                  >> comes from the CVS. I get the same result when using Vim -u
                  >> NONE -U NONE, and enabling only syntax highlighting after that.
                  >
                  >> ... so I guess the syntax file also
                  >> comes from the CVS. ...
                  >
                  > Unfortunately, it is not true. At least for SVN, (and I suspect
                  > that for CVS it is as well the case) there are recent versions of
                  > the runtime files (don't ask me why, for me it is also _very_
                  > confusing). Anyway, to get recent runtime files, please use
                  > rsync, as described on Tony's howto [1] about compiling vim.
                  >
                  > --
                  > Anton
                  >
                  > [1] Tony's how to for VIM compilation
                  > UNIX:
                  > http://users.skynet.be/antoine.mechelynck/vim/compunix.htm
                  > WINDOWS:
                  > http://users.skynet.be/antoine.mechelynck/vim/compile.htm
                  >

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_dev" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • François Ingelrest
                  ... Thanks for pointing this. I ve updated my runtime files, but the highlight problem is nevertheless still there.
                  Message 8 of 12 , Nov 9, 2008
                  • 0 Attachment
                    On Sun, Nov 9, 2008 at 11:14, Anton Sharonov <anton.sharonov@...> wrote:
                    > Unfortunately, it is not true. At least for SVN, (and I suspect
                    > that for CVS it is as well the case) there are recent versions of
                    > the runtime files (don't ask me why, for me it is also _very_
                    > confusing). Anyway, to get recent runtime files, please use
                    > rsync, as described on Tony's howto [1] about compiling vim.

                    Thanks for pointing this. I've updated my runtime files, but the
                    highlight problem is nevertheless still there.

                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_dev" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • François Ingelrest
                    Hi all, No news on this issue? On Wed, Nov 5, 2008 at 17:10, François Ingelrest ... --~--~---------~--~----~------------~-------~--~----~ You received this
                    Message 9 of 12 , Nov 23, 2008
                    • 0 Attachment
                      Hi all,

                      No news on this issue?

                      On Wed, Nov 5, 2008 at 17:10, François Ingelrest
                      <francois.ingelrest@...> wrote:
                      > Hi all,
                      >
                      > If I put this in a foo.vim file:
                      >
                      > ----
                      > highlight Comment guifg=White guibg=Black
                      >
                      > function! Foo()
                      >
                      > highlight Comment guifg=White guibg=Black
                      >
                      > endfunction
                      > ----
                      >
                      > The first "highlight" line is highlighted, but not the second one. It
                      > seems that's because it's inside a function. Is it intended, or is
                      > this a bug in the vim syntax file?

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_dev" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Erik Falor
                      ... After looking at syntax/vim.vim, I noticed that the syntax cluster that defines what s allowed within a function body didn t include the syntax item for
                      Message 10 of 12 , Nov 24, 2008
                      • 0 Attachment
                        On Sun, Nov 23, 2008 at 05:56:41PM +0100, François Ingelrest wrote:
                        >
                        > Hi all,
                        >
                        > No news on this issue?
                        >
                        > On Wed, Nov 5, 2008 at 17:10, François Ingelrest
                        > <francois.ingelrest@...> wrote:
                        > > Hi all,
                        > >
                        > > If I put this in a foo.vim file:
                        > >
                        > > ----
                        > > highlight Comment guifg=White guibg=Black
                        > >
                        > > function! Foo()
                        > >
                        > > highlight Comment guifg=White guibg=Black
                        > >
                        > > endfunction
                        > > ----
                        > >
                        > > The first "highlight" line is highlighted, but not the second one. It
                        > > seems that's because it's inside a function. Is it intended, or is
                        > > this a bug in the vim syntax file?
                        >
                        > >

                        After looking at syntax/vim.vim, I noticed that the syntax cluster
                        that defines what's allowed within a function body didn't include the
                        syntax item for highlights. Neither did it include the syntax item for
                        abbreviations. I added those lines, and re-set the 'filetype' option,
                        and sure enough, the highlight and abbrev keywords were highlighted.
                        For all I know, there are other Vim script elements that aren't being
                        highlighted as well.

                        Offhand, I'd say that this is merely an oversight. Dr. Chip, would
                        you care to weigh in on this?

                        I've attached the patch with the aforementioned changes.

                        --
                        Erik Falor
                        Registered Linux User #445632 http://counter.li.org

                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_dev" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • Charles Campbell
                        ... I ve had a syntax/vim.vim, last modified Nov 7, that had vimHighlight in it. Still didn t have vimAbb, though; however, the header said NOT RELEASED so
                        Message 11 of 12 , Nov 24, 2008
                        • 0 Attachment
                          Erik Falor wrote:
                          > On Sun, Nov 23, 2008 at 05:56:41PM +0100, François Ingelrest wrote:
                          >
                          >> Hi all,
                          >>
                          >> No news on this issue?
                          >>
                          >> On Wed, Nov 5, 2008 at 17:10, François Ingelrest
                          >> <francois.ingelrest@...> wrote:
                          >>
                          >>> Hi all,
                          >>>
                          >>> If I put this in a foo.vim file:
                          >>>
                          >>> ----
                          >>> highlight Comment guifg=White guibg=Black
                          >>>
                          >>> function! Foo()
                          >>>
                          >>> highlight Comment guifg=White guibg=Black
                          >>>
                          >>> endfunction
                          >>> ----
                          >>>
                          >>> The first "highlight" line is highlighted, but not the second one. It
                          >>> seems that's because it's inside a function. Is it intended, or is
                          >>> this a bug in the vim syntax file?
                          >>>
                          >
                          > After looking at syntax/vim.vim, I noticed that the syntax cluster
                          > that defines what's allowed within a function body didn't include the
                          > syntax item for highlights. Neither did it include the syntax item for
                          > abbreviations. I added those lines, and re-set the 'filetype' option,
                          > and sure enough, the highlight and abbrev keywords were highlighted.
                          > For all I know, there are other Vim script elements that aren't being
                          > highlighted as well.
                          >
                          > Offhand, I'd say that this is merely an oversight. Dr. Chip, would
                          > you care to weigh in on this?
                          >
                          > I've attached the patch with the aforementioned changes.
                          >
                          >
                          I've had a syntax/vim.vim, last modified Nov 7, that had vimHighlight in
                          it. Still didn't have vimAbb, though; however, the header said "NOT
                          RELEASED" so it hasn't been on my website, I'm afraid. I've updated my
                          website:
                          http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax.
                          Eventually I'll push it on up to the Official Vim Master (aka Bram
                          Moolenaar).

                          Regards,
                          Chip Campbell



                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_dev" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • François Ingelrest
                          On Mon, Nov 24, 2008 at 21:30, Charles Campbell ... Thanks, it s fine now. --~--~---------~--~----~------------~-------~--~----~ You received this message from
                          Message 12 of 12 , Nov 24, 2008
                          • 0 Attachment
                            On Mon, Nov 24, 2008 at 21:30, Charles Campbell
                            <Charles.E.Campbell@...> wrote:
                            > I've had a syntax/vim.vim, last modified Nov 7, that had vimHighlight in
                            > it. Still didn't have vimAbb, though; however, the header said "NOT
                            > RELEASED" so it hasn't been on my website, I'm afraid. I've updated my
                            > website:
                            > http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax.

                            Thanks, it's fine now.

                            --~--~---------~--~----~------------~-------~--~----~
                            You received this message from the "vim_dev" maillist.
                            For more information, visit http://www.vim.org/maillist.php
                            -~----------~----~----~----~------~----~------~--~---
                          Your message has been successfully submitted and would be delivered to recipients shortly.