http://qs321.pair.com?node_id=11145760


in reply to Which IDE's show tooltips for Perl builtins?

One of the Perl language servers, PLS, offers this capability to some extent. This should work with all editors/IDEs with language server support, in particular with VSCode.

In Emacs with lsp-mode, it shows the first line of the perldoc entry, in your example SHORT EXPLANATION IN ONE-LINE, in the minibuffer (as Eldoc usually does). This works for builtin functions and predefined variables, but is pretty useless for modules where the first line of the perldoc entry usually is the constant heading NAME.

PLS also offers the whole perldoc entry (markdown formatted) on request (in Emacs: M-x lsp-describe-thing-at-point). I am not too enthusiastic about this feature because hyperlinks in the perldoc text are resolved against https://metacpan.org/ which means you might not get the documentation which matches your installed version. Also, it doesn't work for modules in your current workspace.

The other Perl language servers either don't support hover or use it for different things - the specification does not clearly specify what should happen on hover. Caveat Emptor.

  • Comment on Re: Which IDE's show tooltips for Perl builtins?

Replies are listed 'Best First'.
Re^2: Which IDE's show tooltips for Perl builtins?
by LanX (Saint) on Jul 26, 2022 at 22:20 UTC
    > in your example SHORT EXPLANATION IN ONE-LINE, in the minibuffer (as Eldoc usually does).

    This could probably be of interest for you, it redirects the help message from the minibuffer to a tooltip at point.

    Probably not the best lisp style, I hacked it about ten years ago, but it never failed me.

    It's basically monkey-patching cperl-describe-perl-symbol with an around-function to show the tooltip at the point of the cursor.

    I think pos-tip.el needs to be installed first.

    (require 'pos-tip) (require 'cl) (add-hook 'cperl-mode-hook (lambda () ;; (cperl-toggle-autohelp) (setq cperl-lazy-help-time 2) (defadvice cperl-describe-perl-symbol (around cperl-describe-p +erl-symbol-tooltip activate) "redirect message to tooltip" (flet ((message (fmt &rest args) (pos-tip-show (apply 'format fmt args)))) ad-do-it)) ))

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Ah, I was wondering about that patch. Thanks!

Re^2: Which IDE's show tooltips for Perl builtins? (PLS with VSCode)
by LanX (Saint) on Jul 29, 2022 at 15:51 UTC
    I tried to use PLS with VSCode and Strawberry5.32 portable on Win ... but failed.

    The plugin was easily installed but complained that pls couldn't be started.

    I reckoned that a cpanm installation of pls was needed, which is kind of huge because of Perl::Critic and PPI.

    But it failed because of IO::Async

    I fell back on --force installations for IO::Async and PLS, but on startup I VS-Code is still complaining

    [Error - 17:41:45] Starting client failed Launching server using command pls failed.

    I think I know now why the Perl-Navigator is using a JS Server for the communication.

    On a side note: I'm pretty sure The CamelCade plugin for intelliJ showed Perl::Critic output too, but without a need of installation. I suppose this was all bundled inside the plugin.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Similar problems with Perl::LanguageServer in the same setting

      ! Installing the dependencies failed: Module 'AnyEvent::AIO' is not in +stalled, Module 'IO::AIO' is not installed, Module 'Coro' is not inst +alled, Module 'AnyEvent' is not installed ! Bailing out the installation for Perl-LanguageServer-v2.3.0.

      Me too, I'm bailing out now, not attempting to force install.

      From an installation point of view was the Perl-Navigator the most stable product, tho lacking many features advertised in other products.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery