Comments (5)
This is now resolved. I copied the textmate grammar into this repository, and set the extension to override the default Perl grammar. The grammar includes a number of bug fixes, including this one. It also fixes most of the outstanding reported bugs in the textmate repo, so moving it upstream at some point may be helpful as well. Available in the Marketplace as 0.8.0.
The grammars are outside of the language server and only applied to vscode.
from perlnavigator.
Hi @maros, thanks for filing an issue, I'm able to reproduce. However, the Navigator doesn't currently override the default Perl syntax highlighting. This is an issue in the base vscode even without using this extension. These types of issues are tracked in the upstream repo here: https://github.com/textmate/perl.tmbundle/issues . The Navigator currently only augments the syntax highlighting by adding additional keywords for Moo, Moose, Object::Pad, with additional TextMate grammars.
However, it is possible to override the built-in highlighting with a replacement grammar, which I've been considering. There is a long list of syntax highlighting bugs that I would love to fix. It appears that the TextMate repo is no longer under active development, so fixing them here would make sense and allow for more rapid iteration. Because of this, I'll leave this ticket open for now.
Thanks!
from perlnavigator.
Just gonna shamelessly plug that my tree-sitter grammar parses this correctly. I don't know enough about LSPs, but if there's a way to use tree-sitter to help i'm happy to get involved
from perlnavigator.
I know nothing about vscode, but the post above made me curious about what vscode does re: highlighting. It seems there is a plugin that allows for highlighting via treesitter. Although it may not be able to use the perl highlighter -- based on my reading of how it works. Too bad. The new perl tree-sitter highlighting works very well.
from perlnavigator.
Thanks @rabbiveesh and @WhoIsSethDaniel! Unfortunately, vscode doesn't natively allow for using tree-sitter. They explored using it in this PR microsoft/vscode#161479 , but decided it wasn't worth it, especially given how many people have been pulled into working on Copilot.
Language Servers do support semantic highlighting where additional information can be sent per token. This is necessary because the TextMate based regexes are fundamentally limited by lack of knowledge about imports and types, plus they're painful to deal with (as I'm sure you know). Quick example from Python where the PyLance LSP is adding highlighting to imports based on if the identifiers are variables, classes, constants, or functions:
I'm not opposed to adding Semantic highlighting to the Navigator, but it could be a lot of work and my concern is that vscode would still need updated Textmate grammars anyway. I'm also not sure how the two highlighters will interact, especially when fixing broken scopes instead of simply adding additional semantic information.
Have you guys thought about Github syntax highlighting? This is the other major consumer of the perl TextMate grammars and is similarly broken, except Github/Linguist supports tree-sitter already https://github.com/github-linguist/linguist/blob/master/vendor/README.md . Example:
use 5.38
use constant SHIFT_LEFT => 4;
my $test = 1234; # Correctly highlighted as a comment
my $shifted_test = $test << SHIFT_LEFT;
say $shifted_test; # Incorrectly highlighted as a string
from perlnavigator.
Related Issues (20)
- lsp-mode defaults to using PerlNavigator HOT 1
- VSCode - Seem unable to get perltidy to trigger HOT 2
- TypeError *.replace|replaceAll is not a function in neovim HOT 3
- inquistor failed with error: Can't Regexp::Common::FIRSTKEY HOT 3
- perlnavigator triggers a registerCapability handler for workspace/didChangeConfiguration despite dynamicRegistration set to false HOT 1
- Critic timeout HOT 2
- Highlighting of split HOT 2
- Publish 0.8.0 to open-vsx registry HOT 1
- Incorrect syntax errors reported with Carp::cluck HOT 2
- Allow use of more predefined VS Code variables in include paths HOT 1
- File::Find dies when a duplicate file is found HOT 2
- Extension not working out of the box in vscode for me HOT 4
- Publish new release to npm HOT 3
- Making linter failure easier to find HOT 7
- Set logging = true for all editors HOT 2
- Formatting document or selected text issue HOT 18
- Error with Nvchad HOT 4
- Is it possible to open modules directly (path is from Cygwin)? HOT 2
- Tidy formatting does not work "out of the box" (MacOS)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perlnavigator.