bscan / PerlNavigator

Perl Language Server that includes syntax checking, perl critic, and code navigation
MIT License
207 stars 40 forks source link

Please provide documentation how to use perltidy in Visual Studio Code #147

Open horshack opened 1 month ago

horshack commented 1 month ago

I try to format my perl-code with perltidy in Visual Studio Code. This can be done because mentioned in

https://github.com/bscan/PerlNavigator/

Currently Implemented Features: Code formatting via Perl::Tidy

Ok, but how can I do this? I tried it with the VSCode extension "Perl Simple" described in https://stackoverflow.com/questions/79089661/how-to-use-perltidy-to-reformat-code-in-visual-studio-code/79093098#79093098 like this:

+++ VSCode has a beautifier way for every kind of file.

A VSCode extension must get installed to use it. I installed the extension: Simple Perl. After that I highlighted some perl code in some perl file. Right-click - Menue: Format selection. The code gets formatted. +++

I tried the same with PerlNavigator, but this changes nothing in the code. perltidy seems not to get called.

Could you please describe in

https://github.com/bscan/PerlNavigator/

how I can reformat code in Visual Studio Code with the extension PerlNavigator?

bscan commented 1 month ago

Hi @horshack, thanks for filing the issue. Additional documentation sounds good to me, especially since Perl Navigator supports both "Format Selection" and "Format Document" options, as shown below.

284102994-55f58d48-7c0f-4d80-bfca-98180208ffe2

I'm surprised it works in "Simple Perl", but not in "Perl Navigator". Neither of them have perltidy bundled, so it must already be installed in your version of perl. Are you using the system install of Perl? If you need to point to a different installation of Perl, you can set the params "perlnavigator.perlPath". Did you provide any settings to simple-perl?

horshack commented 1 month ago

Hello,

I have installed the Perlmodule perltidy in my local systemwide perl - /usr/bin/perl

I did not provide any settings in the VSCode extension "Simple Perl", it works in reformatting like described.

Now I disable the VSCode extention "Simple Perl" and install and activate the VSCode extention "Perl Navigator".

Restarting VSCode.

I provide some misformatted perl code. Select all lines in file, right-click, Menu: format selection. Error: Configuare Default Formatter

I press the button configure... I select from a dropdown list the only single option: Perl Navigator bcan.perlnavigator. Nothing happens, nothing happens to the code.

Restarting Vscode: I provide some misformatted perl code. Select all lines in file, right-click, Menu: format selection., nothing happens to the code.

I usually do not use system perl but perlbrew. For perlbrew I don't know how to configure it in VScode. When I do: perlbrew user 5-34.0 I get this as "which perl". /Users/richard/perl5/perlbrew/perls/perl-5.34.0/bin/perl Do I have to type this whole perl-path into the parameter perlnavigator.perlPath?

Thanks for your good work, Richard

------ Originalnachricht ------ Von "bscan" @.> An "bscan/PerlNavigator" @.> Cc "Richard Lippmann" @.>; "Mention" @.> Datum 16.10.2024 22:41:00 Betreff Re: [bscan/PerlNavigator] Please provide documentation how to use perltidy in Visual Studio Code (Issue #147)

Hi @horshack https://github.com/horshack, thanks for filing the issue. Additional documentation sounds good to me, especially since Perl Navigator supports both "Format Selection" and "Format Document" options, as shown below.

284102994-55f58d48-7c0f-4d80-bfca-98180208ffe2.gif (view on web) https://github.com/user-attachments/assets/490b483e-0e92-42cb-ae97-9931f151f357

I'm surprised it works in "Simple Perl", but not in "Perl Navigator". Neither of them have perltidy bundled, so it must already be installed in your version of perl. Are you using the system install of Perl? If you need to point to a different installation of Perl, you can set the params "perlnavigator.perlPath". Did you provide any settings to simple-perl?

— Reply to this email directly, view it on GitHub https://github.com/bscan/PerlNavigator/issues/147#issuecomment-2417912740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABI3TFMSKUD47RJCGITEOTZ33FNZAVCNFSM6AAAAABQA53C4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJXHEYTENZUGA. You are receiving this because you were mentioned.Message ID: @.***>

bscan commented 1 month ago

Hi Richard, thanks for the context. A couple of ideas for path forward: You could try setting your perlbrew path in perlpath param. So if you go to the command pallette (CTRL+SHIFT+P) and then go to Preferences: Open User Settings (JSON) it would appear like:

"perlnavigator.perlPath": "/Users/richard/perl5/perlbrew/perls/perl-5.34.0/bin/perl",

If that still doesn't work, it would be worth checking the debug log to see what is printed. The logs are located in the output tab if you select "Perl Navigator LSP". Perhaps there is some error that I could help debug. 155436968-1309565e-1666-469e-9e67-0dbbd1f995f7