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

Programmatically detecting whether plugin scripts loaded?

Expand Messages
  • David Barnett
    Is there any way to detect programmatically from a vim script whether vim has started loading plugin scripts? It would be useful for plugin managers etc. to be
    Message 1 of 6 , Jul 8, 2013
      Is there any way to detect programmatically from a vim script whether vim has started loading plugin scripts? It would be useful for plugin managers etc. to be able to detect what phase of startup their code is being called from.

      Also, would there be any unwanted consequences if vim detected directories added to &runtimepath after startup and sourced those plugin scripts, too? For instance:
      == .vim/plugin/x.vim ==
      set rtp+=~/y/plugin/y.vim
      never ends up sourcing ~/y/plugin/y.vim. Should it?

      David

      --
      --
      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/groups/opt_out.
       
       
    • Nikolay Pavlov
      ... has started loading plugin scripts? It would be useful for plugin managers etc. to be able to detect what phase of startup their code is being called from.
      Message 2 of 6 , Jul 8, 2013


        On Jul 9, 2013 9:55 AM, "David Barnett" <daviebdawg@...> wrote:
        >
        > Is there any way to detect programmatically from a vim script whether vim has started loading plugin scripts? It would be useful for plugin managers etc. to be able to detect what phase of startup their code is being called from.
        >
        > Also, would there be any unwanted consequences if vim detected directories added to &runtimepath after startup and sourced those plugin scripts, too? For instance:
        >>
        >> == .vim/plugin/x.vim ==
        >> set rtp+=~/y/plugin/y.vim
        >
        > never ends up sourcing ~/y/plugin/y.vim. Should it?
        >
        > David

        VAM processes output of :scriptnames in this case and checks out whether some of the plugins are missing. It is the hacky workaround though.

        > --
        > --
        > 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/groups/opt_out.
        >  
        >  

        --
        --
        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/groups/opt_out.
         
         
      • lith
        ... I think you want set rtp+=~/y Should be loaded automatically after processing vimrc runtime plugin/y.vim HTH Tom -- -- You received this message from
        Message 3 of 6 , Jul 9, 2013
          > == .vim/plugin/x.vim ==
          > set rtp+=~/y/plugin/y.vim
          > never ends up sourcing ~/y/plugin/y.vim. Should it?

          I think you want

          set rtp+=~/y
          """ Should be loaded automatically after processing vimrc
          " runtime plugin/y.vim

          HTH
          Tom

          --
          --
          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/groups/opt_out.
        • Tony Mechelynck
          ... No it shouldn t. Remember: :runtime plugin/*.vim happens automatically once only, and that is near the end of startup, shortly before the GUIEnter event
          Message 4 of 6 , Jul 9, 2013
            On 09/07/13 07:55, David Barnett wrote:
            > Is there any way to detect programmatically from a vim script whether
            > vim has started loading plugin scripts? It would be useful for plugin
            > managers etc. to be able to detect what phase of startup their code is
            > being called from.
            >
            > Also, would there be any unwanted consequences if vim detected
            > directories added to &runtimepath after startup and sourced those plugin
            > scripts, too? For instance:
            >
            > == .vim/plugin/x.vim ==
            > set rtp+=~/y/plugin/y.vim
            >
            > never ends up sourcing ~/y/plugin/y.vim. Should it?

            No it shouldn't. Remember: ":runtime plugin/*.vim" happens automatically
            once only, and that is near the end of startup, shortly before the
            GUIEnter event in gvim, or shortly before the VimEnter event in Console
            Vim; it is bypassed if you start Vim with --noplugin or with -u NONE, or
            if before plugins are loaded (e.g. in your vimrc; and preferably in some
            :if branch) you ":set noloadplugins" (or ":set nolpl" for short, and of
            course without quotes).

            Once Vim has started loading plugins, modifying 'runtimepath' may have
            an effect on where filetype plugins, syntax scripts, indent scripts,
            autoload scripts, etc., will be looked for; it is too late to influence
            the loading of global plugins, since that has already begun and will not
            be done again in this Vim session.

            Also, 'runtimepath' is a list of directories, not of files. If
            ~/.vim/plugin/x.vim decides that some script should be run from some
            place not in 'runtimepath', it should ":source" it; or if the script is
            at some unusual place but still under 'runtimepath' you could use the
            ":runtime" command: to take a real-world example, you could have the
            following one-line global plugin:

            == $VIM/vimfiles/plugin/matchit.vim ==
            runtime macros/matchit.vim

            -- BTW, for the matchit help it is a little trickier: you could have a
            symlink $VIM/latest pointing to the latest $VIMRUNTIME (currently
            vim74a, but not so long ago it was vim73) and create a symlink
            $VIM/vimfiles/doc/matchit.txt -> ../../latest/macros/matchit.txt --
            don't forget to run :helptags on your $VIM/vimfiles/doc

            The fact that at line 7, matchit.txt still says "For Vim version 6.3."
            is not really an error: as $VIMRUNTIME/macros/matchit.vim tells us, that
            plugin hasn't changed since Vim 6.3.



            One possible way (untested, and among others) to know when global
            plugins are loaded would be to have the following two one-line scripts:

            == ~/.vim/plugin/A.vim ==
            doau PluginStart

            == ~/.vim/after/plugin/zzzzzzzz.vim ==
            doau PluginEnd

            (defining two new events). On Windows, replace /.vim/ by /vimfiles/, as
            usual. Caveat: this particular trick does of course not work on Vim
            executables compiled with -autocmd

            >
            > David

            Best regards,
            Tony.
            --
            A hard man is good to find.

            --
            --
            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/groups/opt_out.
          • David Barnett
            The set rtp+=~/y/plugin/y.vim part was a typo. I meant set rtp+=~/y Looks like that was obvious to most people, but just in case it wasn tà David -- -- You
            Message 5 of 6 , Jul 10, 2013
              The
              set rtp+=~/y/plugin/y.vim
              part was a typo. I meant
              set rtp+=~/y

              Looks like that was obvious to most people, but just in case it wasn't…

              David

              --
              --
              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/groups/opt_out.
            • lith
              ... Then: many plugins define a variable g:loaded_PLUGIN_NAME that is used by the plugin to make sure the file is sourced only once. You could query that
              Message 6 of 6 , Jul 10, 2013
                > set rtp+=~/y/plugin/y.vim
                >
                > part was a typo

                Then: many plugins define a variable g:loaded_PLUGIN_NAME that is used by the plugin to make sure the file is sourced only once. You could query that variable with exists('g:loaded_PLUGIN_NAME').

                Otherwise you can redirect (:h :redir) the output of scriptnames (:h :scriptnames) as suggested by ZyX and then match that string against the filename of the plugin.

                It depends on why you want to check if the plugin was loaded.

                --
                --
                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/groups/opt_out.
              Your message has been successfully submitted and would be delivered to recipients shortly.