Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Sublime Text experience from anyone? #74

Open
nugged opened this issue Jun 12, 2023 · 8 comments
Open

More Sublime Text experience from anyone? #74

nugged opened this issue Jun 12, 2023 · 8 comments

Comments

@nugged
Copy link
Contributor

nugged commented Jun 12, 2023

Tried to install it manually, and lost a whole day to make Perl::Critic work but nope. It works in vscode out of the box, but not in ST4. Sigh.

@bscan
Copy link
Owner

bscan commented Jun 12, 2023

Hi @nugged, sorry for the painful experience here. I agree it's certainly easier to get running in vscode, as vscode provides the node.js runtime, but the Navigator works in Sublime Text as well. I just tested using Sublime Text 4 with the latest binary release (tested on Windows) and it worked for me, including Perl::Critic. Binary from here: https://github.com/bscan/PerlNavigator/releases/tag/v0.5.5

I downloaded a fresh copy of ST4, installed the LSP client, and used these settings.

{
    "clients": {
        "perlnavigator": {
            "enabled": true,
            "command": ["D:\\Applications\\perlnavigator.exe","--stdio"],
            "selector": "source.perl",
            "settings": {
                 "perlnavigator.perlPath": "c:\\path\\to\\perl.exe",
            }
        },
    }
}

What platform are you using? Are you seeing any errors? Or any perl compilation results?

@nugged
Copy link
Contributor Author

nugged commented Jun 12, 2023

MacOS (M1)

I did:

cd ~/git/PerlNavigator
npm run ci-all
cd server
npx tsc

I build it (main), it works well regarding syntax errors & warnings.
It sees perlbrew's perl successfully, even. With no other specials

        "perlnavigator": {
            "enabled": true,
            "command": ["node", "~/git/PerlNavigator/server/out/server.js","--stdio"],
            "selector": "source.perl",
            "settings": {
                "perlnavigator.perlcriticEnabled": true,
                "perlnavigator.enableWarnings": true,
                "perlnavigator.perlcriticSeverity": 3
        },

then code:

#!/bin/env perl
use warnings; use strict; use 5.30.0; use utf8;
binmode STDOUT, ":encoding(UTF-8)"; $| = 1;

our $ThisOus = "It Is!";

my $abc = "It Is also never used!";

BEGIN { 
    warn "Warning iside BEGIN!";
    warn "I am Perl $^V ($]) and located " . ($^X =~ s|.+/perl5|~/perl5|r);
}

syntax_error

in ST4:
image

but in opposition to vscode:
image

it doesn't give anything from Perl::Critic (vscode does).

What I tried manually inside the guts:

$>cat /tmp/info.pl | perl criticWrapper.pl -f criticWrapper.pl

Perlcritic on criticWrapper.pl and using profile $HOME/.perlcriticrc
Perl Critic violations:
3~|~2~|~27~|~Version string used~|~ValuesAndExpressions::ProhibitVersionStrings~||~
4~|~3~|~40~|~Magic variable "$|" should be assigned as "local"~|~Variables::RequireLocalizedPunctuationVars~||~
3~|~5~|~1~|~Package variable declared or used~|~Variables::ProhibitPackageVars~||~
3~|~10~|~5~|~"warn" used instead of "carp"~|~ErrorHandling::RequireCarping~||~
3~|~11~|~5~|~"warn" used instead of "carp"~|~ErrorHandling::RequireCarping~||~
3~|~11~|~54~|~Regular expression without "/x" flag~|~RegularExpressions::RequireExtendedFormatting~||~

but I lost how to debug full chain why it drowns somewhere in ST4 guts

@bscan
Copy link
Owner

bscan commented Jun 13, 2023

Unfortunately, I have not been able to reproduce. I installed the latest version of Perl Navigator on a Mac and Perl::Critic worked for me. I tested with the MacOS binary and with building from source. However, I got logging working in Sublime Text if you update to the latest version of Perl Navigator and enable perlnavigator.logging. Hopefully more details are available with the log. Thanks!

    "settings": {
         "perlnavigator.logging": true,
    }
image

@nugged
Copy link
Contributor Author

nugged commented Jun 13, 2023

Yeah, I tried logging, but in Sublime, it's not THAT trivial :). That's why calling for ideas on how I can inject my code somewhere to debug deeper into why in ST4 it's acting up.

Saying this: it DOES NOT log into the console in ST4.

@nugged
Copy link
Contributor Author

nugged commented Jun 13, 2023

Woohooo!!!! :)

image

LSP-config:

// Settings in here override those in "LSP/LSP.sublime-settings"
{
    "log_debug": false,
    "clients": {
        "LSP-perl": {
            "enabled": true,
            "selector": "source.perl",
            "command": ["node", "~/git/PerlNavigator/server/out/server.js","--stdio"],
            "settings": {
                "perlnavigator.enableWarnings": true,
                "perlnavigator.perlcriticEnabled": true,
            },
        },
    }
}

On the dozen-one iteration, it started to work, but I am still unsure in which place something changed "to be right instead of to be wrong".

Ok, good.

UPDATE: it even works with simplified config, all the rest by default:

// Settings in here override those in "LSP/LSP.sublime-settings"
{
    "clients": {
        "LSP-perl": {
            "enabled": true,
            "selector": "source.perl",
            "command": ["node", "~/git/PerlNavigator/server/out/server.js","--stdio"],
        },
    }
}

And works well with .bash-profiled Perl (perlbrew), catching up the proper Perl and modules.

image

@nugged
Copy link
Contributor Author

nugged commented Jun 13, 2023

Now next step is to find out how to make PerlTidy work from it. It works in VSCode, not yet in Sublime :P.

UPDATE: ... still have not succeeded yet.

@bscan
Copy link
Owner

bscan commented Jun 13, 2023

Sounds like progress is happening. Thanks for continuing to work on this. Pertidy works for me in both "Format Selection" and "Format File" modes on Sublime Text. Regarding logging, I just fixed the logging capabilities for ST4 last night, so you'll need to grab the latest version of Perl Navigator (and enable logging in the settings). Then it will show up in the "LSP: Toggle Log Panel".

perltidy

@nugged
Copy link
Contributor Author

nugged commented Jun 13, 2023

Whoa! Logging capabilities will help. Let's see, I'll check now why it fails on Tidy now for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants