Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Which IDE's show tooltips for Perl builtins?

by LanX (Sage)
on Jul 26, 2022 at 12:55 UTC ( #11145742=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

It's impossible to check every possible Editor/IDE x available Plugin.

Could help me list all IDEs which offer/show a tooltip when hovering/typing/passing a builtin?

Like showing a balloon when the cursor is passing ...

SHORT EXPLANATION IN ONE-LINE split /PATTERN/,EXPR,LIMIT split /PATTERN/,EXPR split /PATTERN/ split

or even a condensed

SOME EXPLANATION split [ /PATTERN/, [ EXPR, [ LIMIT ] ] ]

Bonus-question

Do they also offer snippet expansion?

Possible Candidates ...

Komodo, IntelliJ, VS Code, Padre, Emacs, VIM, ...?

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

updates

s/SOME EXPLANATION/SHORT ... IN ONE-LINE/

Replies are listed 'Best First'.
Re: Which IDE's show tooltips for Perl builtins?
by davies (Prior) on Jul 26, 2022 at 14:07 UTC

    Notepad++ does not do it on mouseover, but does pretty much what you want while typing if autocomplete is on, so typing in spl offers split or splice, while split( offers four formats, the first of which is split(/PATTERN/). Notepadqq is pretty close and available on Linux, which Notepad++ is not. I haven't looked to see whether qq offers the same autocomplete options.

    Regards,

    John Davies

      Thanks John,

      I wonder how accurate the infos are if they adapt automatically to the current Perl version.

      I once wrote that Re^3: POD: getting usage snippets from perldoc and wanted to expand it to a IDE agnostic support module, but don't wanna reinvent the wheel...

      > if autocomplete is on, so typing in spl offers split or splice

      FWIW: I didn't think about code completion yet, but that's a good point too.

      Will it also offer to insert a snippet with jump-points for the arguments?

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

        I wonder how accurate the infos are if they adapt automatically to the current Perl version.

        Above my knowledge grade, I fear. But the language support system is written using plugins, so it would be possible to write a different plugin for every Perl version and then select the one currently in use.

        Will it also offer to insert a snippet with jump-points for the arguments?

        Not in the version I am using, but that does not mean it could not be done using a different plugin, which may even exist. I haven't looked.

        Regards,

        John Davies

      I just installed Notepad++ and tried it out.

      > I haven't looked to see whether qq offers the same autocomplete options.

      only if you type a round bracket so qq( will show qq/ won't

      > while split( offers four formats,

      Hmm, yes after typing ( it offered to permute thru 4 alternatives by clicking arrow buttons.

      I couldn't find a key which helps permuting. Counterintuitively choosing between between the functions split and splice was possible with arrow-keys.

      And I failed to expand one of those parameter options, be it as verbatim text or active snippet.

      But they are kept shown while typing, when inside parens.

      There is a hot-key C-S-Space to show those options again, but for arguments again only after an explicit open parenthesis.

      DISCLAIMER: first time experience, I've never really worked with N++ before and might have missed some options.

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

        > I haven't looked to see whether qq offers the same autocomplete options.
        Sorry - I was not being clear there. I was referring to notepadqq, the Linux package which approximates closely to notepad++.

        Regards,

        John Davies

Re: Which IDE's show tooltips for Perl builtins?
by haj (Priest) on Jul 26, 2022 at 16:29 UTC

    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.

      > 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!

      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

Re: Which IDE's show tooltips for Perl builtins?
by soonix (Canon) on Jul 26, 2022 at 13:57 UTC
    Hmmm... Perl Development Tools is from 2006, and the newest comment with data is from 2016, and it doesn't have a column about tooltips, only syntax colouring, but it's better than nothing...
      Thanks for that link░! :)

      What I was asking for could be hidden behind:

      • Suggest & complete
      • Docs & Help viewer
      • Code Snippets

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

      ░) tho I'm confused about the terminology, priorities and redundancy. And half the columns are centered around debugger support.

Re: Which IDE's show tooltips for Perl builtins?
by choroba (Cardinal) on Jul 26, 2022 at 14:23 UTC
    You probably already know, but for someone who doesn't: in cperl in Emacs, C-c C-h v to run cperl-get-help.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Well I usually activate M-x cperl-toggle-autohelp instead of remembering another carpal-tunnel-inducer ... ;-)

      Whenever your cursor is longer than 2 secs over a keyword it'll react. But last that I checked this showed the mini-docs in the bottom-line.

      I had to patch cperl-mode to show a yellow tool-tip instead.

      update

      well monkey-patched with an advice to be more precise ...

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

Re: Which IDE's show tooltips for Perl builtins?
by stevieb (Canon) on Jul 26, 2022 at 14:33 UTC

    intelliJ does. Here's an image of intelliJ IDEA running with the Camelcade Perl5 plugin.

      Hi Stevie

      thanks for the screenshot, but it shows the whole perldoc in the popup, not a short usage info.

      I've updated the OP to make that clearer.

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

        Installed IntelliJ Community Version and the Perl-Plugin which points to the CamelCade git-repo.

        Was a bit of a hassle to tell the editor/project to use the (preactivated) Portable Strawberry aka "System Perl", otherwise the modules were not indexed. IOW no defaulting to existing Perl.

        Typing Ctrl-Q "Quick Documentation" while over (not right after) a Perl symbol (here split ) showed the whole perldoc in a pop-up with scroll-bars.

        The IDE knows a feature "Quick definition" (Ctrl-Shift-I) which had no effect on split , similarly Ctrl-P and Alt-Q.

        Auto-completions listed arguments for just a small number of built-ins like say([$filehandle, @list]) but those args weren't included even that a help message suggested that pressing tab would help permutate. In this case - say - pressing Ctrl-P listed them again in a pop-up.

        There was an error message that Xsubs declaration file was missing, but regenerating it didn't help with the things described.

        Typing Ctrl-Shift-Space like in Notepad++ produced only a "No Suggestions" message.

        DISCLAIMER: First time user of this IDE, might have certainly missed obvious options.

        edit

        Code-Snippets are available, they are called "Live Templates" (Ctrl-J)

        Mostly for POD and Moose and those Perl standard statements known from Textmate and available in all IDEs.

        It has also some snippets for "special" syntax like do { }', like this two 'do are listed in the auto-completion list, chosing the template inserts do { ^ } with the cursor ^ inside the brackets.

        There is also a similar snippet sa for anonymous sub expanded to sub { ^ } but it's not listed in auto-completion when typing sub , even after a = ...!

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

Re: Which IDE's show tooltips for Perl builtins?
by GrandFather (Saint) on Jul 26, 2022 at 21:03 UTC

    Komodo can be set up to execute commands for Shift+F1 and Ctrl+F1 that default to Google searches but can be pointed at Perl docs instead. No facility for a mouse over popup that I can see though.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
      Thanks,

      I installed the newest Komodo12 IDE and tried it out (we have a company license anyway)

      The experience was messy because I was used to Komodo7 and they tried to "modernize" the UI...

      Took me a while to find the toolbox with all features

      > but can be pointed at Perl docs instead

      The toolbox has a komodo tool: Perldoc on selection (for builtin functions)

      It's supposed to run

      %(perl) -e print && perldoc -u -f %w | pod2html > "c:\temp\pod.html" && %(browser) c:\temp\pod.html

      which failed for me with a CMD error of unknown command, most probably because %(perl) and %(browser) need to be set up properly.

      I gave up, problems might be related to the fact that this machine has no ActiveState Perl but a portable Strawberry.

      Creating new tools and binding them to hotkeys is easy tho.

      > No facility for a mouse over popup that I can see though.

      There are auto-completes for many builtins, like spl will show splice and split

      Code-hinting is documented to show arguments on auto-complete. Well in theory, couldn't make them show in various languages┬░. NB the YT-video on the linked website doesn't play.

      Snippet expansion is available, but only for a small number of snippets and can be found in the Toolbox under Abbreviations/Keywords

      So after typing wh

      • 1. TAB expands to while
      • 2. TAB to
      while (EXPR) { }

      with tab-stops on EXPR and the inner block.

      The same for for or foreach doesn't work, mainly because the template for fore needs to be set up with additional EJS (Embedded JS AFAIK) to know the expansion triggers.

      It's a bit more complicated ... there is an autocomplete for foreach but not for for and the snippet's name is fore (most likely originally imported from textmate)

      Nobody cared to fix that.

      My colleagues are using Komodo and I can provide the data for more snippets and code-hints, if someone is inclined to maintain the Perl logic for Komodo in the future.

      Komodo Edit at least is OS now.

      From the state of the tool and the website I tend to believe that AS is slowly abandoning it.

      DISCLAIMER: Like always, I'm no expert for that tool, albeit I know it significantly better than Nodepad++ and intelliJ

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

      ┬░) OK there is only Strawberry installed on that box, this might be why...

Re: Which IDE's show tooltips for Perl builtins?
by SankoR (Prior) on Jul 27, 2022 at 14:27 UTC

      While PerlNavigator indeed works with many editors, it should be noted that it does not show tooltips for Perl builtins.

      Well Haj mentioned the various LSP solutions available.

      And I've seen this talk at TPC2022 and installed VS Code as reference for LSP plus the plugin░.

      Could you please tell me how to enable those tooltips?

      Probably I'm doing something wrong, but

      • I can neither see a code hint when pointing cursor or mouse
      • nor do I get code hints when typing a builtin

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

      ░) Actually Daxim already kept pointing me towards this plug-in for month, because he knew about my IDE "visions" ...

        Oh, I have no idea at all beyond what's in that talk and the README from that repo.

        I still use SciTE which can handle api files like the perl.api file now hosted in this repo. Turned it back on really quick and it looks like this: https://imgur.com/a/jI7IvMD which is almost exactly what you're asking for but SciTE is hardly an environment designed to rival "Komodo, IntelliJ, VS Code, Padre, Emacs, VIM" or anything that aims to be a full IDE.

        Addendum: Notepad++ and Padre (edit: and apparently Komodo) are based on Scintilla. SciTE was designed as a testbed for the Scintilla editing component way back in the late 90s and has kept up with the component's changes. I'd use Notepad++ but I no longer work on Windows and it doesn't work on Linux or ChromeOS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11145742]
Front-paged by davies
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2023-06-04 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (20 votes). Check out past polls.

    Notices?