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

I am trying to migrate from Komodo to VS Code as my IDE for Perl. Komodo is pretty much set up for Perl out of the box but for VS Code you have to download extensions for code intel, debugger, etc.

When you search for Perl on their extensions page, a whole sh*tload of them come up. Is anyone using VS Code? If so can you make recommendations which extensions to install?

UPDATE: Welp, further investigation shows that in order for VS Code to work properly with Perl, you need to install Perl::LanguageSever, and dependencies of that will not install properly on Windows. It apparently works with WSL, though you need to install the Perl dev libraries, according to some threads I found.

UPDATE 2: After some effort I got Perl::LanguageServer and its dependencies installed under WSL2/Ubuntu. I hit "run and debug," and the progress indicator runs for a couple of seconds, then it goes away and that's it. The script neither runs nor stops a a breakpoint and there are no error messages. So I'm stuck. If anyone has ideas please LMK.

UPDATE 3: SOLVED. In case anyone else tries to do this, here is what I learned. First, Perl::LanguageServer will not install on Windows. You will need to enable WSL2 and install it on Ubuntu. Follow the instructions on the github page for the module that instruct you to use apt to install some libraries before using cpan to install the module. Second, install VS Code on the Windows side using the MSI installer. Third, start VS Code from the Ubuntu side using the code command. You have to open a folder and make sure you trust that folder. Fourth, open the extensions tab and search for & install (in VS Code) Perl "Language Server and Debugger for Perl" Gerald Richter. Fifth create a Perl script, open the run and debug tab, then click Run and Debug.

At least that did it for me. Naturally, YMMV.

Replies are listed 'Best First'.
Re: VS Code plugins for Perl
by davies (Monsignor) on Jul 04, 2024 at 10:58 UTC

    If you want an AI tool, try Codeium. This was recommended by Merlyn on LinkedIn. I have tried it & like it.

    Regards,

    John Davies

      It seems that plugin ships your code to the dev's website, so be careful if you're using it for anything proprietary.

        Yes, I wouldn't trust it with anything confidential like keys, but Merlyn posted that it did not run any risk of infringing copyright, unlike copilot.

        Regards,

        John Davies

Re: VS Code plugins for Perl
by haj (Vicar) on Jul 09, 2024 at 09:59 UTC

    A well maintained Perl plugin for VSCode is PerlNavigator (link goes to the visualstudio marketplace).

    In comparison to Perl::LanguageServer, it does not support debugging, but it is up to date with current Perl and supports many Perl syntax extensions as well as developer tools like App::perlimports and Perl::Critic.

      Good to know, but I really need to have the debugging.
Re: VS Code plugins for Perl
by The_Dj (Scribe) on Jul 09, 2024 at 03:50 UTC
    Not helpful: I still think ViM For The Win

    Helpful:
    What Perl are you using?
    When I try installing Perl::LanguageSever on my StrawberryPerl 5.38.0x64, it fails on the dependency IO::AIO.
    Without digging too deep: AIO.xs:778:30: error: incompatible types when assigning to type 'struct w32_stat' from type 'struct _stat64'
    Pretty sure it's Perl and Win64 headers not playing nicely

    So I tried Portable StrawberryPerl 5.32.1x32 (The newest x32 available) and IO::AIO installs.
    Next, AnyEvent needs to be force installed cpanm AnyEvent --force because Windows
    But after that, Perl::LanguageServer installs.

    Probably better to fix IO::AIO on x64, but I don't have time to dig in to that

    Not the best, but if you don't mind developing in x32 then this'll get you going

      Ouch, IO::AIO is Lehmannware and doesn't seem to do well on MSWin.

      What about PLS instead? It doesn't have any tester results for MSWin, which is suspicious...

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Yeah, I was never able to get Perl::LanguageServer to work on 64bit Strawberry, either (though it looks like you tried harder than I did).

      PerlNavigator works with my Strawberry v5.38.0 for MSWin32-x64-multi-thread. Its homepage gives examples of how to set it up for VS Code, Sublime, emacs, neovim, and others... And it is starting to work with an alpha NppLspClient plugin on Notepad++, using the config below:

      [lspservers.perl] mode = "io" executable = 'c:\\usr\\local\\bin\\perlnavigator.exe' args = '--stdio' auto_start_server = true

      The upsides are that PerlNavigator uses the Microsoft LSP library, so is known to work well on Windows; and it doesn't have difficulties installing module prerequisites, because it's a standalone app, not a Perl-based application or module(s). The downside is, it's not a Perl-based application or module(s) ;-).


      update: sorry, I hadn't seen haj's post yet when I replied to this one. but mine does include tangential information which might be of use to non-VSCode users wanting similar functionality on other Windows editors.
      I did manage to get Perl::LanguageServer installed (in WSL2/Ubuntu), ad VS Code confirms it is installed. This is what is confusing. Plus I don't get any errors when I hit run and debug it exits without running or debugging the code.
      It's whatever comes stock with Ubuntu. Strawberry I guess?
        If you're on an actual Ubuntu desktop, then "perl -v" gives the answer you're looking for. Strawberry is a distribution of perl for Windows, which is what I think most people assumed when you said VSCode.

        (this conversation will likely now chain into "don't use the system perl for development, use perlbrew" or something like that. I'd recommend just using system perl until you have everything working, then consider installing your own with perlbrew)