Giter Club home page Giter Club logo

perl.tmbundle's Introduction

Installation

You can install this bundle in TextMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you.

General

License

If not otherwise specified (see below), files in this repository fall under the following license:

Permission to copy, use, modify, sell and distribute this
software is granted. This software is provided "as is" without
express or implied warranty, and with no claim as to its
suitability for any purpose.

An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”.

perl.tmbundle's People

Contributors

2shortplanks avatar aeschli avatar alhadis avatar ashgti avatar azawawi avatar bradchoate avatar ciaran avatar fank avatar ferhaty avatar granth avatar infininight avatar jeg2 avatar kevinsawicki avatar ldaley avatar lilyball avatar marcusramberg avatar patrickcroninmm avatar pchaigno avatar punchyrascal avatar purge avatar sanssecours avatar sixeight avatar sorbits avatar soryu avatar vabc3 avatar zoo1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

perl.tmbundle's Issues

Perl syntax highlighting issue - s{foo}{bar} if $baz;

Originally from @NorthboundTrain in microsoft/vscode#131322

Issue Type: Bug

Perl's regex operators can use any pair of matching characters as delimiters (see https://perldoc.perl.org/perlop#Regexp-Quote-Like-Operators). When using a bracketing character as the delimiter, e.g. ({[, then the matching closing bracket can be used to close the operator, e.g. m<foo> or s{foo}{bar}. The bug only occurs when using the substitution operator (s///), and only when using bracketing delimiters, and only with a statement modifier (a trailing if, while, etc).

Screen Shot 2021-08-21 at 12 25 02 PM

s/foo/bar/; # OK
s/foo/bar/ unless $baz; # OK
s/foo/bar/ if $baz; # OK

s{foo}{bar}; # OK
s{foo}{bar} if $baz; # BROKEN
# lasts until a scalar variable is given; neither an @array nor a %hash works,
# but the $scalar does (but the remainder of the line is still FUBAR)
# next line is OK, though

s(foo)(bar) if $baz; # BROKEN - $clear;
s[foo][bar] if $baz; # BROKEN - $clear;
s<foo><bar> if $baz; # BROKEN - $clear;
s:foo:bar: if $baz; # OK
s#foo#bar# if $baz; # OK

# other statement modifiers
s(foo)(bar) for $baz; # BROKEN differently
s(foo)(bar) foreach $baz; # BROKEN - $clear
s(foo)(bar) unless $baz; # OK
s(foo)(bar) until $baz; # BROKEN differently
s(foo)(bar) when $baz; # BROKEN differently
s(foo)(bar) while $baz; # BROKEN differently

# other regex/quote-like operators are OK:
m/foo/ if $baz; # OK
m{foo} if $baz; # OK
q/foo/ if $baz; # OK
q{foo} if $baz; # OK
qq/foo/ if $baz; # OK
qq{foo} if $baz; # OK
qw/foo/ if $baz; # OK
qw{foo} if $baz; # OK

Non-predefined variables beginning with underscore not highlighted

With the exception of the predefined variables $_ and @_ (as well as %_), it appears that any variables beginning with an underscore _ (a convention used for "private" variables) do not get highlighted as such:
screen shot 2019-03-03 at 1 56 11 am

I imagine the issue might have to do with how $_, @_, and %_ appear to be treated specially.

Syntax highlighting bug on regular expressions containing '#' inside a conditional

The Perl syntax highlighting breaks on regular expressions that implicitly use the default input variable and contain the '#' character.
The syntax highlighting breaks if the following conditions are met:

  • The regex implicitly uses the default $_ variable
  • The regex is not the first item in the conditional
  • The regex follows an 'and' or 'or' operator

The rest of the line following the # is highlighted as a comment.

if (/^#/ and $something) { moo(); } # Syntax highlighting is good
if ($something && /^#/) { moo(); } # Syntax highlighting is good
if ($something and /^#/) { moo(); } # Syntax highlighting breaks!

Ampersand sigil is not highlighted

image
The above isn't really meaningful or valid Perl, but it illustrates what I mean. The sigils $, @, and %, when used in reference indirection, are highlighted correctly, but & is not.

highlighting problems after `/\|/`

From @schuan01 on December 29, 2017 14:58

Steps to Reproduce:

  1. Copy the code after this steps in a new file.
  2. See the bad coloring(all red) after "my @linea = split /|/, $LINEA;"

---- EXAMPLE CODE ---

my $LINEA = $_;
	chomp( $LINEA );
	my @LINEA = split /\|/, $LINEA;
	
	$HOJATNO++;

	# creamos el lote
	if ( not ref $LOTE_REF ) {
		#Supongo que 
		my ( $EMISION, $ORDEN, $LOTE) = ( $LINEA[$POS_EMISION], $LINEA[$POS_ORDEN], $LINEA[$POS_LOTE] );
		
		$LOTE_REF = CE::Lote->new(-lote => $LOTE, -ambiente => $AMBIENTE, -cliente => $CLIENTE, -trabajo => $TRABAJO,-emision => $EMISION, -orden => $ORDEN );
	}
	
	#Leo datos que necesito
	my ( $SPOOL, $INTERNO, $HOJA ) = ( $LINEA[$POS_SPOOL], $LINEA[$POS_INTERNO], $LINEA[$POS_HOJA] );
	my ( $IMPRIME, $GENERA, $VISUALIZA ) = ($LINEA[$POS_IMPRIME], $LINEA[$POS_GENERA], $LINEA[$POS_VISUALIZA] );
	my ( $VALOR_CRITERIO1A, $VALOR_CRITERIO1B ) = ( $LINEA[$POS_CEDULA], $LINEA[$POS_TIPORECIBO] );
	my ( $VALOR_CRITERIO2A, $VALOR_CRITERIO2B ) = ( $LINEA[$POS_NROEMPLEADO], $LINEA[$POS_TIPORECIBO] );
	my $VALOR_CRITERIO3A = $LINEA[$POS_GENERACION];

Copied from original issue: microsoft/vscode#40944

if else indentation incorrect in Textmate 2

I'm just switching from Textmate regular and Textmate 2 is creating weird indentation with if/else/elsif conditionals. It has the same behavior in the Java bundle but NOT in the C bundle. The current behavior seems abnormal/highly non-standard to me. Using underscores to represent a single tab below:

Original Textmate Perl as well as Textmate 2 C bundle (correct):
if (blah == blah) {
_print "blah";
} elsif (blah == blah2) {
_print "blah";
} else {
_return 2;
}

Textmate 2 Perl and Textmate 2 Java bundle (incorrect/unusual indentation):
if (blah == blah) {
_print "blah";
_} elsif (blah == blah2) {
__print "blah";
__} else {
___return 2;
__}

Attached an image of the default TM2 indentation:
2013-02-28 10 34 23 am

Match operator not highlighted when used in assignment

Observed in Visual Studio Code 1.50.0.

A match operator will not be highlighted as regex if it uses / delimiters without the m prefix, is matching $_ implicitly, and is used in an assignment statement directly after the = (e.g. is not in parentheses).

Example code:

$_ = 'Hello world';
my ($match) = /Hello\s+(\S*)/;

image

One workaround is to use the m prefix:

image

Can we add collaborators from the Perl community?

First off, thanks very much for your work. :) Given how this is also used in VSCode and by GitHub for syntax highlighting, it has a lot of value to the Perl community.

Would you be open to adding one (or more?) competent Perl developers to help manage this specific repository? I'm fairly sure I could get some time at my $work scheduled to help get through the backlog as this would allow us to address at least one pain point (indented heredocs) that affects us at @maxmind.

Perl syntax misidentifies certain bit shifts as heredocs...

In the case

$a = $b << ($c + $d);

The syntax will interpret this as a heredoc.

The regex on line 1981 of Syntaxes/Perl.plist currently reads as:

<string>((&lt;&lt;) *((?![=\d\$ ])[^;,'"\s)])).\n?`

Where it should be something like

<string>((&lt;&lt;) *((?![=\d\$\( ])[^;,'"\s)])).\n?`

to fix this issue.

Regular expression breaks syntax highlighting

Regular expression breaks syntax highlighting for remainder of the file. The offending line (perl) is here:

if ((($var, $val) = /^\s*([_a-zA-Z0-9]+)\s*=\s*(.*)/) != 2) {

The *'s after each \s seem to be relevant; deleting one fixes the formatting (but deleting two breaks it again).

Steps to Reproduce:

  1. Do above
  2. See error

Originally from @zaharazod in microsoft/vscode#154706

Highlighting broken if tr{}{} / y{}{} contains '/'

From gisle/tcl.pm#20:

Affects March 2018 TextMate Perl bundle and recent Atom and VS Code.

If transliteration operators have curly braces as the delimiter, i.e. tr{}{} or y{}, and either the pattern or replacement contains exactly one /, then everything up until the next / is highlighted as a regex. See screenshot:

screen shot 2018-11-11 at 2 12 43 am

(Example from https://github.com/gisle/tcl.pm/blob/8935cbb97e5d74210cd4397e6c6ccffa792fc054/Makefile.PL#L269)

One workaround is to use a different delimiter such as square brackets [].

Multiline comments and certain strings broken

Multiline comments in the #`( comment ) style only have their first line marked as an actual comment, and the rest is incorrectly detected as code. Multine comments using =begin comment and =end comment work better but seem to have some odd behaviour as well (the comment in =end comment is in white while the rest is green with my theme).

Strings in certain places are not detected properly.

Issues as seen in this screenshot:

Image of syntax issues

Atom on the left, VS Code on the right. Atom has the same issues except when using the language-perl6 package (which is being used in the above screenshot). VS Code on the right is only using the syntax files from this repo.

I don't know what langauge-perl6 for Atom does to get it correct, but perhaps someone more familiar with syntax files/grammar can investigate that.

Interestingly, if the space in .split(', ') is removed, the syntax highlight seems to work better, except the string in .split(',') is highlighted in white with my VS Code theme. Regular strings in that theme are highlighted in red.

Additionally, is this repo even maintained anymore? VS Code relies solely on this repo for syntax highlighting and it's been broken for Perl 6 for a long time now.

Update Perl6 syntax highlighting to allow for kebab-case in addition to snake_case

From @WildYorkies on February 13, 2017 21:22

Steps to Reproduce:

  1. Make a file called test.pl6 or test.pm6
  2. Type the following in:
sub print-board() # Wrong

sub thing-for-that() # Wrong
  1. See that the words print and for are highlighted as if they are keywords.

  2. Change it to snake case and notice that it is like a normal variable again:

sub print_board() # Correct

sub thing_for_that() # Correct

Solution:

Update this file with the kebab case addition.

Copied from original issue: microsoft/vscode#20563

Perl: Incorrect Syntax Highlighting

From @atif089 on July 14, 2017 11:56

VSCode Version: Code 1.14.0
OS Version: Mac OSX
Configured Language: Perl

The the following code

if ( $product->{url} and $memcached_search ) {
    $product->{url}.=$product->{url}=~m{\?}?";":"?";
    $product->{url}.='s='.$memcached_search.'X'.++$pos;
}

Near ~m{\?}? if you add space between closing } and ? then the syntax looks fine otherwise it looks broken. I'm using the material theme but this appears on any theme.

I think the fix has something to do with the Perl tmLanguage file but I don't know where to find it and what rule I should be looking for :(

Demo : http://i.imgur.com/bjhypxh.gif

Copied from original issue: microsoft/vscode#30699

Highlight breaks with constants

From @AlexTalker in microsoft/vscode#81309

  • VSCode Version: 1.38.1
  • OS Version: Windows_NT x64 10.0.17763

Steps to Reproduce:

  1. Create a perl module like this:
use v5.10;
use strict;
use warning;

use constant FOO => 42;

my $x = 33;
$x = $x << FOO;

say($x);
  1. Notice that after utilization of FOO, color highlight breaks:
    image

Does this issue occur when all extensions are disabled?: Yes

The problem seems to be that this regular expression https://github.com/textmate/perl.tmbundle/blob/master/Syntaxes/Perl.plist#L2080 breaks rules of Perl syntax:

The terminating string may be either an identifier (a word), or some quoted text. An unquoted identifier works like double quotes. There may not be a space between the << and the identifier, unless the identifier is explicitly quoted. The terminating string must appear by itself (unquoted and with no surrounding white-space) on the terminating line.

https://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators

As it consumes a white-spaces successfully.
I don't know who's to blame here, so I make the issue here and you can if necessary duplicate it to TextMate project.

On huge projects, it is really annoying to break syntax of a large file by simple usage of a constant.

Properties named 'q' trigger the q quote highlighting

Originally reported by @darkliquid at atom/language-perl#7:

In the following example, the portion of the code from q; until the next ; is erroneously highlighted as a quoted string - specifically the 2nd print keyword is highlighted as a string instead of like the other prints.

sub q() {}
my $test = {};
bless $test;
print $test->q;
# this is some code that should not be string highlighted
print "end";

(This TextMate bundle is used by GitHub to highlight Perl code in files and snippets.)

Perl highlighting broken after a heredoc with "CSS" as the terminator

Consider the example below. When viewed in VSCode, the first "my $a" line is colored correctly while "my $b" is incorrectly colored.

# Example showing that CSS heredoc is treated differently
my $foo = <<"END";
Heredoc ending in end.
END

# Colored correctly:
my $a = "a";

my $foo = <<"CSS";
Heredoc ending in end.
CSS

# Colored incorrectly:
my $b = "b";

Perl Syntax Highlighting: Issue with highlighting in certain situations when using regex

From @chriscapaci on November 9, 2017 17:18

  • VSCode Version: 1.17.2
  • OS Version: Windows 10

Steps to Reproduce:

  1. Download attached file and remove .txt extension so extension is .pl (Perl code)
  2. Open file syntax_highlighting_issues.pl in VSCode
  3. Observe syntax highlighting (comments explaining what's going on)

NOTE: All usages of regex's in the code are valid as the project I work on contains all of them. Some may be uncommon, but they are valid and work, so highlighting should work with them.

syntax_highliting_issues.pl.txt

Reproduces without extensions: Yes

Copied from original issue: microsoft/vscode#37966

Syntax Highlight w/ Perl, Comment Not Detected After 'sub'

Originally from @mebouck in microsoft/vscode#127467:

Issue Type: Bug

A comment after a subroutine definition isn't detected, for example:

sub getPi  # calculate and return the value of pi

VS Code version: Code 1.57.1 (507ce72a4466fbb27b715c3722558bb15afa9f48, 2021-06-17T13:28:07.755Z)
OS version: Windows_NT x64 10.0.19042
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4900MQ CPU @ 2.80GHz (8 x 2794)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.91GB (10.10GB free)
Process Argv --crash-reporter-id 6d724ebe-c32e-4348-8853-6a2057864cf0
Screen Reader no
VM 0%
Extensions (11)
Extension Author (truncated) Version
Bookmarks ale 13.1.0
kixtart cya 0.0.1
autoit Dam 1.0.6
perl-syntax jac 0.0.7
vscode-dotnet-runtime ms- 1.1.0
python ms- 2021.6.944021595
vscode-pylance ms- 2021.6.3
jupyter ms- 2021.6.999662501
cpptools ms- 1.4.1
powershell ms- 2021.6.2
azurerm-vscode-tools msa 0.15.1
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
pythonvspyt639:30300192
pythontb:30283811
vspre833:30321513
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
pythondataviewer:30285071
vscus158:30321503
pythonvsuse255cf:30323309
vscorehov:30309549
vscod805cf:30301675
binariesv615:30325510

PERL syntax highlighter doesn't like 'split' PATTERN of a double-quote

From @leonid-s-usov in microsoft/vscode#113985

Issue Type: Bug

Thils line of PERL code

my @list = split /"/, $string;

will color all following lines as if withing a string because of the unbalanced quote.

This, however, is a valid PERL code that will split the $string by quotation mark symbols.

VS Code version: Code 1.52.1 (ea3859d4ba2f3e577a159bc91e3074c5d85c0523, 2020-12-16T16:30:02.420Z)
OS version: Darwin x64 19.6.0

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 1, 2, 2
Memory (System) 32.00GB (1.52GB free)
Process Argv -psn_0_3085041
Screen Reader no
VM 0%
Extensions (19)
Extension Author (truncated) Version
yacc car 1.3.1
mikrotik-routeros-script dev 2018.8.2
xml Dot 2.5.1
gitlens eam 11.1.3
go gol 0.20.1
sftp lix 1.12.9
lex lun 0.1.0
autoconf mae 0.1.0
perl-debug mor 0.6.3
python ms- 2020.12.424452561
jupyter ms- 2020.12.414227025
cmake-tools ms- 1.5.3
cpptools ms- 1.1.3
hexeditor ms- 1.3.0
java red 0.73.0
angelscript ren 1.0.1
cmake twx 0.0.17
vscode-lldb vad 1.6.1
vscode-java-debug vsc 0.30.0

Error parsing perl syntax: regex match with 'm' modifier

From @NorthboundTrain on February 22, 2018 14:13

Issue Type

Bug

Description

  1. open new editor window
  2. switch to Perl mode
  3. paste in the following syntax:
$foo =~ m/ff/i;
print "$foo is the name of the game\n";

$foo =~ m/ff/m;
print "$foo is the name of the game\n";

$foo =~ m{ff}i;
print "$foo is the name of the game\n";

$foo =~ m{ff}m;
print "$foo is the name of the game\n";
  1. the code is formatted incorrectly; the trailing 'm' modifier in the regex match is not recognized and is therefor not end the regex formatting.

VS Code Info

VS Code version: Code 1.20.1 (f88bbf9137d24d36d968ea6b2911786bfe103002, 2018-02-13T15:23:28.607Z)
OS version: Darwin x64 16.7.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz (4 x 3100)
Load (avg) 5, 4, 4
Memory (System) 16.00GB (2.25GB free)
Process Argv /Applications/Visual Studio Code.app/Contents/MacOS/Electron
Screen Reader no
VM 0%
Extensions (14)
Extension Author (truncated) Version
beautify Hoo 1.3.0
code-settings-sync Sha 2.8.7
vscode-languagetool ada 3.8.0
vscode-languagetool-en ada 3.8.0
project-manager ale 0.24.0
vscode-simpler-icons dav 1.5.2
permute-lines ear 0.0.2
macros ged 1.2.1
vsc-space-block-jumper jmf 1.2.2
printcode nob 2.0.4
remote-vscode raf 1.1.0
rehydrate Lla 0.0.1
vscode-dired rru 0.0.4
vscode-workspace-switcher sad 1.5.1

(1 theme extensions excluded)

Reproduces without extensions

Copied from original issue: microsoft/vscode#44204

Support indented here-docs (fix incorrect string highlighting)

From @skaurus on October 20, 2017 14:34

I'm talking about this: http://perldoc.perl.org/perlop.html#Indented-Here-docs

Steps to Reproduce:

  1. write perl code like that:
if ($cond) {
    my $string = <<~EOF;
        indented
        text
        will be
        indented
        just by 4 spaces
        and totally not 8
    EOF
    my $res = $self->method;
}
...
  1. code after closing EOF will be colored as if it's still inside the string.

Currently it works only if opening here-doc marker does not have a tilde; AND closing marker is not indented (at all).

Reproduces without extensions: Yes

Copied from original issue: microsoft/vscode#36640

Regex syntax highlighting is a bit broken

The syntax highlighting for a regular expression doesn't always end correctly - causing the grammar parser in text mate to think everything after the particular start of the regex to be interpreted and colored, etc as part of the regular expression.

I only see this then using a multi-line regex with a the preceding 'm':

$var =~ m/regex/m

There may be other cases.

Perl Syntax Highlighting breaks with //= on any new line

From @TalhaObaid on January 23, 2018 3:30

  • VSCode Version: Code 1.19.2 (490ef761b76b3f3b3832eff7a588aac891e5fe80, 2018-01-10T15:49:04.682Z)
  • OS Version: Darwin x64 16.7.0
  • Extensions:
Extension Author (truncated) Version
vscode-docker Pet 0.0.23
perltidy sfo 1.2.1

Steps to Reproduce:

  1. Create/open a file with Perl code in editor, having .pm/.pl extension.
  2. Write //= (); on a new line in the middle of the code.
  3. The rest of the code below will turn leaving the identifiers only

Reproduces without extensions: Yes

Copied from original issue: microsoft/vscode#42008

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.