Tuesday, May 8, 2018

Re: how to use v:termrbgresp & friends

On Di, 01 Mai 2018, Danek Duvall wrote:

> On Tue, May 01, 2018 at 06:43:30PM +0200, Christian Brabandt wrote:
>
> > On Mo, 30 Apr 2018, Danek Duvall wrote:
> >
> > > I've been trying to use v:termrbgresp to determine what color scheme to
> > > use, but I can't figure out how to use it successfully.
> > >
> > > I tried simply testing against it in my .vimrc, but that doesn't work,
> > > probably because it hasn't been set yet. Sort of like v:termresponse,
> > > which requires that you use the TermResponse event.
> > >
> > > But when TermResponse fires, v:termrbgresp isn't set yet, either, and I
> > > can't find an event that seems like it should be the right thing to use.
> > > By the time I can type in ":echo v:termrbgresp", though, it's set. I just
> > > need a mechanism to tell me when it's okay to use its value.
> > >
> > > Should there be separate events for each of the terminal response codes?
> > > Maybe one that fires when all the ones that will have responses have them?
> > > Or a generic event that fires when a variable is set?
> > >
> > > Or am I missing something? I looked for examples, but couldn't find any.
> >
> > If nothing else, you can always defer to the VimEnter or possibly the
> > GuiEnter autocommand
>
> I'd tried VimEnter, but that didn't work, either. That fires even before
> TermResponse.

Yeah, it looks like even VimEnter fires earlier. I checked in the
debugger, v:termrbgresp is only set once the main_loop has been entered.
I think I remember a patch that moved the logic later in the vim
initialization phase, so it might be on purpose.

And TermResponse is only fired for when the v:termresponse variable is
set, not for the v:termrbgresp or v:termrfgresp variables. Not sure, if
it would make sense to fire TermResponse autocommand also for the other
v:term variables.

So the only workaround would be to start a timer that checks your the
values after startup.

Best,
Christian
--
Sommersprossen sind noch kein Gesichtspunkt und Kopfjucken noch
keine Gehirntätigkeit.

--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment