Applying Settings in vimrc Or gvimrc Based on v:servername

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Applying Settings in vimrc Or gvimrc Based on v:servername

JohannS-2
While working on a Windows machine, I found that I could
selectively load settings or plugins based on the Vim
servername by do a regular expression check against the
v:servername variable right in vimrc.

Example:
  if v:servername =~ '^\cHPWORK\d*'
    ru HP/HPSpecificPlugin.vim
  endif

I had been relying on this featured when sharing a vimrc
file for XWindows under Linux.  What I found is that this
technique does not seem to work.  I traced in the Vim
source code and it seems like v:servername is set fairly
late in start up process for Vim after the script files
have been run.  Thus when vimrc is executed v:servername
is blank and all these v:servername checks are false.

Is there a place in the startup process or a sensable
technique under XWindows to trigger loading something
globally based on the v:servername value?  I am using this
technique as an alternative to an auto command that
assumes a particular filename or file extension.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200211135416.GB4961%40linux.site.
Reply | Threaded
Open this post in threaded view
|

Re: Applying Settings in vimrc Or gvimrc Based on v:servername

Tony Mechelynck
On Tue, Feb 11, 2020 at 7:36 PM <[hidden email]> wrote:

>
> While working on a Windows machine, I found that I could
> selectively load settings or plugins based on the Vim
> servername by do a regular expression check against the
> v:servername variable right in vimrc.
>
> Example:
>   if v:servername =~ '^\cHPWORK\d*'
>     ru HP/HPSpecificPlugin.vim
>   endif
>
> I had been relying on this featured when sharing a vimrc
> file for XWindows under Linux.  What I found is that this
> technique does not seem to work.  I traced in the Vim
> source code and it seems like v:servername is set fairly
> late in start up process for Vim after the script files
> have been run.  Thus when vimrc is executed v:servername
> is blank and all these v:servername checks are false.
>
> Is there a place in the startup process or a sensable
> technique under XWindows to trigger loading something
> globally based on the v:servername value?  I am using this
> technique as an alternative to an auto command that
> assumes a particular filename or file extension.

Try placing the check in an autocommand for the VimEnter event, which
is triggered at the very end of startup. The autocommand can be
defined in your vimrc.

Best regards,
Tony.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXsx9ofmgJDsD6RRv-pGDy3H7hK53QxZa1_Rz16Yjxmfww%40mail.gmail.com.