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

How can a highlight group combine custom attributes and a link?

Expand Messages
  • boss@...
    Hello! ... Foo xxx guifg=red links to Comment Are there any other ways to do this? ... Foo xxx guifg=red ... Foo xxx guifg=red links to Comment And I
    Message 1 of 9 , Jun 4, 2014
    • 0 Attachment
      Hello!

      I am aware of one way for a highlight group to contain both custom attributes and a link to another group:

      :hi Foo guifg=red
      :hi! link Foo Comment

      :hi Foo
      Foo xxx guifg=red
      links to Comment

      Are there any other ways to do this?

      The context is I have a plugin which defines a default highlight group:

      :hi default link Foo Comment

      In a user's vimrc, they specify the attributes they actually want:

      :hi Foo guifg=red

      However instead of seeing this:

      :hi Foo
      Foo xxx guifg=red

      ...they see this:

      :hi Foo
      Foo xxx guifg=red
      links to Comment

      And I cannot figure out why this is happening. (https://github.com/airblade/vim-gitgutter/issues/176)

      Thanks in advance!

      Yours,
      Andy Stewart

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Tony Mechelynck
      ... I think it is a minor bug. You didn t say if the highlight definition for Comment is actually guifg=red in the colorscheme you re using, but if it
      Message 2 of 9 , Jun 5, 2014
      • 0 Attachment
        On 04/06/14 17:19, boss@... wrote:
        > Hello!
        >
        > I am aware of one way for a highlight group to contain both custom attributes and a link to another group:
        >
        > :hi Foo guifg=red
        > :hi! link Foo Comment
        >
        > :hi Foo
        > Foo xxx guifg=red
        > links to Comment
        >
        > Are there any other ways to do this?
        >
        > The context is I have a plugin which defines a default highlight group:
        >
        > :hi default link Foo Comment
        >
        > In a user's vimrc, they specify the attributes they actually want:
        >
        > :hi Foo guifg=red
        >
        > However instead of seeing this:
        >
        > :hi Foo
        > Foo xxx guifg=red
        >
        > ...they see this:
        >
        > :hi Foo
        > Foo xxx guifg=red
        > links to Comment
        >
        > And I cannot figure out why this is happening. (https://github.com/airblade/vim-gitgutter/issues/176)
        >
        > Thanks in advance!
        >
        > Yours,
        > Andy Stewart
        >

        I think it is a minor bug. You didn't say if the highlight definition
        for "Comment" is actually "guifg=red" in the colorscheme you're using,
        but if it isn't you could check what happens.

        I *think* that using ":hi! link" with a bang on a from-group which
        already exists (as in your first example) should undo the preexisting
        definition and replace it with the link, while using ":hi default link"
        on a from-group which already exists (as in your second example, since
        plugins are processed after the vimrc) should completey ignore the link
        (and keep the preexisting definition).

        If the actual color for the Foo group is the same as for Comment in the
        first case but is red (and Comment is not red) in the second example,
        then highlight groups are created properly, it's just the display which
        is wrong; but how two different situations can be displayed identically
        in this "list groups" variant of the command beats me.

        If in both cases the highlight for Foo is the same, either red both
        times or the same as Comment both times, then either there is a bug or I
        have misunderstood the workings of either the exclamation mark or the
        "default" argument in the :highlight command.

        In any case Bram knows it better than I do, and that's why I'm adding
        him to the Cc list, though I think he would have got this mesage anyway.


        Best regards,
        Tony.
        --
        The man with the best job in the country is the Vice President. All he has
        to do is get up every morning and say, "How's the President?"
        -- Will Rogers

        The vice-presidency ain't worth a pitcher of warm spit.
        -- Vice President John Nance Garner

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Mark Lodato
        ... I am the user who is having the issues and I think I have discovered the underlying bug. As mentioned above, `:hi [default] link From To` should only do
        Message 3 of 9 , Jun 8, 2014
        • 0 Attachment
          On Friday, June 6, 2014 2:06:51 AM UTC-4, Tony Mechelynck wrote:
          > On 04/06/14 17:19, boss@... wrote:
          >
          > > Hello!
          >
          > >
          >
          > > I am aware of one way for a highlight group to contain both custom attributes and a link to another group:
          >
          > >
          >
          > > :hi Foo guifg=red
          >
          > > :hi! link Foo Comment
          >
          > >
          >
          > > :hi Foo
          >
          > > Foo xxx guifg=red
          >
          > > links to Comment
          >
          > >
          >
          > > Are there any other ways to do this?
          >
          > >
          >
          > > The context is I have a plugin which defines a default highlight group:
          >
          > >
          >
          > > :hi default link Foo Comment
          >
          > >
          >
          > > In a user's vimrc, they specify the attributes they actually want:
          >
          > >
          >
          > > :hi Foo guifg=red
          >
          > >
          >
          > > However instead of seeing this:
          >
          > >
          >
          > > :hi Foo
          >
          > > Foo xxx guifg=red
          >
          > >
          >
          > > ...they see this:
          >
          > >
          >
          > > :hi Foo
          >
          > > Foo xxx guifg=red
          >
          > > links to Comment
          >
          > >
          >
          > > And I cannot figure out why this is happening. (https://github.com/airblade/vim-gitgutter/issues/176)
          >
          > >
          >
          > > Thanks in advance!
          >
          > >
          >
          > > Yours,
          >
          > > Andy Stewart
          >
          > >
          >
          >
          >
          > I think it is a minor bug. You didn't say if the highlight definition
          >
          > for "Comment" is actually "guifg=red" in the colorscheme you're using,
          >
          > but if it isn't you could check what happens.
          >
          >
          >
          > I *think* that using ":hi! link" with a bang on a from-group which
          >
          > already exists (as in your first example) should undo the preexisting
          >
          > definition and replace it with the link, while using ":hi default link"
          >
          > on a from-group which already exists (as in your second example, since
          >
          > plugins are processed after the vimrc) should completey ignore the link
          >
          > (and keep the preexisting definition).
          >
          >
          >
          > If the actual color for the Foo group is the same as for Comment in the
          >
          > first case but is red (and Comment is not red) in the second example,
          >
          > then highlight groups are created properly, it's just the display which
          >
          > is wrong; but how two different situations can be displayed identically
          >
          > in this "list groups" variant of the command beats me.
          >
          >
          >
          > If in both cases the highlight for Foo is the same, either red both
          >
          > times or the same as Comment both times, then either there is a bug or I
          >
          > have misunderstood the workings of either the exclamation mark or the
          >
          > "default" argument in the :highlight command.

          I am the user who is having the issues and I think I have discovered the underlying bug. As mentioned above, `:hi [default] link From To` should only do the link if From has no settings, and if default is omitted, should issue the error "E414: group has settings, highlight link ignored". In fact, at least on Ubuntu 14.04 package vim-gtk 7.4.052-1ubuntu3, this only happens if From has no *terminal* settings, unless you are running the command from gvim once it has started. If From has only gui settings and either running console vim is used or the commands are found in the startup files, the `:hi link From To` acts as though From has no settings and performs the link anyway.

          Here is a simple example:

          $ vim -u NONE
          :hi Foo guifg=blue
          :hi link Foo Error

          The above should error out but it does not. Here is a full example to show that this happens on both vim and gvim:

          $ mv .vim vim-bak
          $ mv .vimrc vimrc-bak
          $ cat >.vimrc <<EOF
          hi GuiTest guifg=blue
          hi CtermTest ctermfg=blue
          hi GuiTest
          hi CtermTest
          hi default link GuiTest Error
          hi default link CtermTest Error
          hi GuiTest
          hi CtermTest
          EOF
          $ gvim # or vim

          This gives the following result:

          GuiTest xxx guifg=blue
          CtermTest xxx ctermfg=12
          GuiTest xxx guifg=blue
          links to Error
          CtermTest xxx ctermfg=12

          The expected result is that neither GuiTest nor CtermTest link to Error.

          Note, however, that if you try to run those same commands once the gui has started, you get the expected error message. But this only works in gvim; regular vim exhibits the same bug as putting it in the vimrc file.

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Tony Mechelynck
          ... I notice that in gvim, hi Error guibg=red guifg=black hi! link ErrorMsg Error (in a colorscheme) gives both explicit and links to definitions for
          Message 4 of 9 , Jun 8, 2014
          • 0 Attachment
            On 09/06/14 05:24, Mark Lodato wrote:
            > On Friday, June 6, 2014 2:06:51 AM UTC-4, Tony Mechelynck wrote:
            >> On 04/06/14 17:19, boss@... wrote:
            >>
            >>> Hello!
            >>
            >>>
            >>
            >>> I am aware of one way for a highlight group to contain both custom attributes and a link to another group:
            >>
            >>>
            >>
            >>> :hi Foo guifg=red
            >>
            >>> :hi! link Foo Comment
            >>
            >>>
            >>
            >>> :hi Foo
            >>
            >>> Foo xxx guifg=red
            >>
            >>> links to Comment
            >>
            >>>
            >>
            >>> Are there any other ways to do this?
            >>
            >>>
            >>
            >>> The context is I have a plugin which defines a default highlight group:
            >>
            >>>
            >>
            >>> :hi default link Foo Comment
            >>
            >>>
            >>
            >>> In a user's vimrc, they specify the attributes they actually want:
            >>
            >>>
            >>
            >>> :hi Foo guifg=red
            >>
            >>>
            >>
            >>> However instead of seeing this:
            >>
            >>>
            >>
            >>> :hi Foo
            >>
            >>> Foo xxx guifg=red
            >>
            >>>
            >>
            >>> ...they see this:
            >>
            >>>
            >>
            >>> :hi Foo
            >>
            >>> Foo xxx guifg=red
            >>
            >>> links to Comment
            >>
            >>>
            >>
            >>> And I cannot figure out why this is happening. (https://github.com/airblade/vim-gitgutter/issues/176)
            >>
            >>>
            >>
            >>> Thanks in advance!
            >>
            >>>
            >>
            >>> Yours,
            >>
            >>> Andy Stewart
            >>
            >>>
            >>
            >>
            >>
            >> I think it is a minor bug. You didn't say if the highlight definition
            >>
            >> for "Comment" is actually "guifg=red" in the colorscheme you're using,
            >>
            >> but if it isn't you could check what happens.
            >>
            >>
            >>
            >> I *think* that using ":hi! link" with a bang on a from-group which
            >>
            >> already exists (as in your first example) should undo the preexisting
            >>
            >> definition and replace it with the link, while using ":hi default link"
            >>
            >> on a from-group which already exists (as in your second example, since
            >>
            >> plugins are processed after the vimrc) should completey ignore the link
            >>
            >> (and keep the preexisting definition).
            >>
            >>
            >>
            >> If the actual color for the Foo group is the same as for Comment in the
            >>
            >> first case but is red (and Comment is not red) in the second example,
            >>
            >> then highlight groups are created properly, it's just the display which
            >>
            >> is wrong; but how two different situations can be displayed identically
            >>
            >> in this "list groups" variant of the command beats me.
            >>
            >>
            >>
            >> If in both cases the highlight for Foo is the same, either red both
            >>
            >> times or the same as Comment both times, then either there is a bug or I
            >>
            >> have misunderstood the workings of either the exclamation mark or the
            >>
            >> "default" argument in the :highlight command.
            >
            > I am the user who is having the issues and I think I have discovered the underlying bug. As mentioned above, `:hi [default] link From To` should only do the link if From has no settings, and if default is omitted, should issue the error "E414: group has settings, highlight link ignored". In fact, at least on Ubuntu 14.04 package vim-gtk 7.4.052-1ubuntu3, this only happens if From has no *terminal* settings, unless you are running the command from gvim once it has started. If From has only gui settings and either running console vim is used or the commands are found in the startup files, the `:hi link From To` acts as though From has no settings and performs the link anyway.
            >
            > Here is a simple example:
            >
            > $ vim -u NONE
            > :hi Foo guifg=blue
            > :hi link Foo Error
            >
            > The above should error out but it does not. Here is a full example to show that this happens on both vim and gvim:
            >
            > $ mv .vim vim-bak
            > $ mv .vimrc vimrc-bak
            > $ cat >.vimrc <<EOF
            > hi GuiTest guifg=blue
            > hi CtermTest ctermfg=blue
            > hi GuiTest
            > hi CtermTest
            > hi default link GuiTest Error
            > hi default link CtermTest Error
            > hi GuiTest
            > hi CtermTest
            > EOF
            > $ gvim # or vim
            >
            > This gives the following result:
            >
            > GuiTest xxx guifg=blue
            > CtermTest xxx ctermfg=12
            > GuiTest xxx guifg=blue
            > links to Error
            > CtermTest xxx ctermfg=12
            >
            > The expected result is that neither GuiTest nor CtermTest link to Error.
            >
            > Note, however, that if you try to run those same commands once the gui has started, you get the expected error message. But this only works in gvim; regular vim exhibits the same bug as putting it in the vimrc file.
            >

            I notice that in gvim,


            hi Error guibg=red guifg=black
            hi! link ErrorMsg Error

            (in a colorscheme) gives both explicit and "links to" definitions for
            ErrorMsg in the output of ":hi" (without arguments). No error, even if
            the colorscheme is "reloaded" by ":sy off | sy on" in a running GUI. The
            actual highlight is the linked value in this case, not the explicit
            definition and not a blend of the two. To avoid this apparent "double
            definition", replace this couple of lines by

            hi Error guibg=red guifg=black
            hi clear ErrorMsg
            hi link ErrorMsg Error

            then reload the colorscheme again.


            Best regards,
            Tony.
            --
            You have taken yourself too seriously.

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Bram Moolenaar
            Mark Lodato wrote: [...] ... Yes, it appears the if settings already exist only checks for term settings, not gui settings. This is inconsistant. I suppose
            Message 5 of 9 , Jun 9, 2014
            • 0 Attachment
              Mark Lodato wrote:

              [...]

              > I am the user who is having the issues and I think I have discovered
              > the underlying bug. As mentioned above, `:hi [default] link From To`
              > should only do the link if From has no settings, and if default is
              > omitted, should issue the error "E414: group has settings, highlight
              > link ignored". In fact, at least on Ubuntu 14.04 package vim-gtk
              > 7.4.052-1ubuntu3, this only happens if From has no *terminal*
              > settings, unless you are running the command from gvim once it has
              > started. If From has only gui settings and either running console vim
              > is used or the commands are found in the startup files, the `:hi link
              > From To` acts as though From has no settings and performs the link
              > anyway.
              >
              > Here is a simple example:
              >
              > $ vim -u NONE
              > :hi Foo guifg=blue
              > :hi link Foo Error
              >
              > The above should error out but it does not. Here is a full example to
              > show that this happens on both vim and gvim:
              >
              > $ mv .vim vim-bak
              > $ mv .vimrc vimrc-bak
              > $ cat >.vimrc <<EOF
              > hi GuiTest guifg=blue
              > hi CtermTest ctermfg=blue
              > hi GuiTest
              > hi CtermTest
              > hi default link GuiTest Error
              > hi default link CtermTest Error
              > hi GuiTest
              > hi CtermTest
              > EOF
              > $ gvim # or vim
              >
              > This gives the following result:
              >
              > GuiTest xxx guifg=blue
              > CtermTest xxx ctermfg=12
              > GuiTest xxx guifg=blue
              > links to Error
              > CtermTest xxx ctermfg=12
              >
              > The expected result is that neither GuiTest nor CtermTest link to Error.
              >
              > Note, however, that if you try to run those same commands once the gui
              > has started, you get the expected error message. But this only works
              > in gvim; regular vim exhibits the same bug as putting it in the vimrc
              > file.

              Yes, it appears the "if settings already exist" only checks for term
              settings, not gui settings. This is inconsistant. I suppose we can
              change that without causing trouble for existing setups.

              --
              There is a fine line between courage and foolishness.
              Unfortunately, it's not a fence.

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            • Mark Lodato
              ... Yes, that would be most appreciated. In my case, I had set GitGutterAdd with only gui settings in my vimrc, and the gitgutter plugin unintentionally
              Message 6 of 9 , Jun 9, 2014
              • 0 Attachment
                On Mon, Jun 9, 2014 at 7:14 AM, Bram Moolenaar <Bram@...> wrote:
                > Yes, it appears the "if settings already exist" only checks for term
                > settings, not gui settings. This is inconsistant. I suppose we can
                > change that without causing trouble for existing setups.

                Yes, that would be most appreciated. In my case, I had set
                GitGutterAdd with only gui settings in my vimrc, and the gitgutter
                plugin unintentionally overrode it using `hi default link`, even on
                gvim.

                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/d/optout.
              • Christian Brabandt
                ... Here is a patch. Best, Christian -- Wahrhaftigkeit ist die größte List. -- Georg Christoph Lichtenberg -- -- You received this message from the vim_use
                Message 7 of 9 , Jun 10, 2014
                • 0 Attachment
                  On Mo, 09 Jun 2014, Bram Moolenaar wrote:

                  > Yes, it appears the "if settings already exist" only checks for term
                  > settings, not gui settings. This is inconsistant. I suppose we can
                  > change that without causing trouble for existing setups.

                  Here is a patch.

                  Best,
                  Christian
                  --
                  Wahrhaftigkeit ist die größte List.
                  -- Georg Christoph Lichtenberg

                  --
                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/d/optout.
                • Bram Moolenaar
                  ... Thanks. But when checking the GUI fg and bg colors, we should also check the cterms colors. Again for consistency. -- This is an airconditioned room, do
                  Message 8 of 9 , Jun 12, 2014
                  • 0 Attachment
                    Christian wrote:

                    > On Mo, 09 Jun 2014, Bram Moolenaar wrote:
                    >
                    > > Yes, it appears the "if settings already exist" only checks for term
                    > > settings, not gui settings. This is inconsistant. I suppose we can
                    > > change that without causing trouble for existing setups.
                    >
                    > Here is a patch.

                    Thanks. But when checking the GUI fg and bg colors, we should also
                    check the cterms colors. Again for consistency.


                    --
                    This is an airconditioned room, do not open Windows.

                    /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                    /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                    \\\ an exciting new programming language -- http://www.Zimbu.org ///
                    \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                    --
                    --
                    You received this message from the "vim_use" maillist.
                    Do not top-post! Type your reply below the text you are replying to.
                    For more information, visit http://www.vim.org/maillist.php

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/d/optout.
                  • boss@...
                    Thanks, everyone, for the rapid help. Much appreciated! -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below
                    Message 9 of 9 , Jun 13, 2014
                    • 0 Attachment
                      Thanks, everyone, for the rapid help. Much appreciated!

                      --
                      --
                      You received this message from the "vim_use" maillist.
                      Do not top-post! Type your reply below the text you are replying to.
                      For more information, visit http://www.vim.org/maillist.php

                      ---
                      You received this message because you are subscribed to the Google Groups "vim_use" group.
                      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                      For more options, visit https://groups.google.com/d/optout.
                    Your message has been successfully submitted and would be delivered to recipients shortly.