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

Re: php.net function list documentation inside vim?

Expand Messages
  • Benjamin R. Haskell
    ... Personally, I like the opposite. Instead of trying to bring the documentation into Vim, make it (much) quicker to get to the documentation in the browser
    Message 1 of 6 , Jul 5, 2011
      On Tue, 5 Jul 2011, nikhil jain wrote:

      > This is my second time usign mailing lists , so apologies if I am
      > doing something silly.
      >
      > I am not sure if this is a good idea, but is there a way to have the
      > php.net documentation about functions 'inside' vim. That way instead
      > of having to switch to the browser every time I want to do something
      > new, I can just search php.net function list inside vim.

      Personally, I like the opposite. Instead of trying to bring the
      documentation into Vim, make it (much) quicker to get to the
      documentation in the browser from within Vim.

      I have (something like) the following:

      ==> in ~/.vim/ftplugin/php.vim <==
      fun! PHPGetHelp(...)
      let fn = a:0 ? a:1 : expand('<cword>')
      let cmd = '!xdg-open '.shellescape('http://php.net/'.fn)
      silent! exe cmd
      endfun

      noremap K :call PHPGetHelp()<CR>
      ==================================

      Modify 'xdg-open' above to reflect whatever URL-launcher you prefer.
      (xdg-open is pretty widely available).

      Then typing K will pop open 'http://php.net/' + whatever word your
      cursor's over. php.net/{whatever} is a search page. If a function or
      section with that name matches exactly or is unambiguous, it will go
      directly to the proper page.


      > I am windows btw using gvim 7.3

      ... of course I notice this after writing that up.

      But, it works fine in Windows with the following, modified function:

      ==========================================
      fun! PHPGetHelp(...)
      let fn = a:0 ? a:1 : expand('<cword>')
      let cmd = '!start cmd /c start "" '.shellescape('http://php.net/'.fn)
      silent! exe cmd
      endfun
      ==========================================

      The first 'start' wraps a cmd.exe.
      The /c tells cmd.exe to exit after it runs the given command, which is a
      second 'start'.
      The "" tells the second 'start' that it's not really running a program,
      just using the default launcher for whatever follows.

      I don't actually use Windows when I don't have to, but I did test this.


      > Another question: the little documentation that is shown on pressing K
      > , only shows docs for a few functions. Is there a way to expand that
      > documentation to include more default php functions?

      I'm not sure how you're getting any PHP documentation... when I press K
      in a PHP file, it opens Vim function documentation. But, 'K' clued me
      in to the 'keywordprg' ('kp') setting. Creating a batch file somewhere
      in your %PATH% called phphelp.bat, you can do:

      ==> ~/.vim/ftplugin/php.vim <==
      setl kp=phphelp
      ===============================

      ==> phphelp.bat <==
      start "" http://php.net/%1
      ===================

      It needs the helper program since the 'keywordprg' puts a space between
      the program and the keyword being looked up. And it unfortunately pops
      open an extra shell window. My double-start version above avoids it
      (has a flash of a shell, but you don't get the 'Press Enter to
      continue...' prompt, so it disappears). But I'm not sure how to avoid
      it globally.


      Moral of the story: 'keywordprg' is almost what you want, my "custom"
      version above is better, IMO.

      --
      Best,
      Ben

      --
      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
    • Marc Weber
      ... Try github.com/MarcWeber/vim-addon-php-manual (docs are outdated). I could work like that. At least looking up function params etc is very fast. Marc Weber
      Message 2 of 6 , Jul 5, 2011
        Excerpts from nikhil jain's message of Tue Jul 05 08:51:17 +0200 2011:
        > This is my second time usign mailing lists , so apologies if I am doing
        > something silly.

        Try github.com/MarcWeber/vim-addon-php-manual (docs are outdated).
        I could work like that.

        At least looking up function params etc is very fast.

        Marc Weber

        --
        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
      • B V Raghav
        ... I am sure the php-docs there would be sufficient and relevant more often than not.. However, I wondered, if you can outline how to create allinonemod.txt
        Message 3 of 6 , Jul 16, 2011
          On Tuesday 05 July 2011 02:05 PM, Marc Weber wrote:
          > Excerpts from nikhil jain's message of Tue Jul 05 08:51:17 +0200 2011:
          >> This is my second time usign mailing lists , so apologies if I am doing
          >> something silly.
          >
          > Try github.com/MarcWeber/vim-addon-php-manual (docs are outdated).
          > I could work like that.

          I am sure the php-docs there would be sufficient and relevant more often
          than not.. However, I wondered, if you can outline how to create
          allinonemod.txt from php_manual_all_in_one.txt, probably, I shall update
          the manual folder and send it to you... and use it myself too...

          I am not familiar with git... so I said i would send it to you.

          >
          > At least looking up function params etc is very fast.
          >
          > Marc Weber
          >

          r

          --
          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
        • Marc Weber
          ... I ve pushed a new version. Telling you how to do it would have taken the same amount of time. The README contains complete instructions now. Having docs
          Message 4 of 6 , Jul 16, 2011
            Excerpts from B V Raghav's message of Sat Jul 16 15:04:43 +0200 2011:
            > I am not familiar with git... so I said i would send it to you.

            I've pushed a new version. Telling you how to do it would have taken the
            same amount of time.

            The README contains complete instructions now.

            Having docs for PHP 5.4 should not hurt cause AFAIK the docs contain
            notes about backward compatibility.

            Marc Weber

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