mistricky / codesnap.nvim

📸 Snapshot plugin with rich features that can make pretty code snapshots for Neovim
MIT License
473 stars 15 forks source link

Code highlighting in PHP is... weird? #81

Closed nexxai closed 2 months ago

nexxai commented 2 months ago

I apologize for the less than descriptive title, but let me explain with screenshots.

Let's say I have this PHP class:

Screenshot 2024-04-08 at 10 04 55 PM

If I select this text:

Screenshot 2024-04-08 at 10 05 31 PM

the highlighting works perfectly: faaa5d4c-b43f-4522-a984-0ed4652d1bcb

But if I simply miss including the <?php tag at the top of every PHP file in the selection:

Screenshot 2024-04-08 at 10 06 38 PM

Everything stays dark: 71b59030-99bf-471a-bbab-91d0e5422e08

Now, OK, at first glance it seems like it's using the opening tag to figure out the language, and since it isn't sure, it doesn't do anything, but it does highlight very common coding words but only ever in PHP DocBlock comments: 82062d6c-7ba9-492e-938e-570373f2f081

Is there anything I can do about this, or am I just kind of stuck?

mistricky commented 2 months ago

Seems like this issue is related to https://github.com/mistricky/codesnap.nvim/issues/67

mistricky commented 2 months ago

The syntax highlighting is implements by syntect, I just figure it out, the syntect have two diffience language type names "PHP" & "PHP Source", if need to highlight PHP code snippet should use "PHP Source" instead of "PHP".

mistricky commented 2 months ago

I'm already improve the strategy of highlight PHP filetype. I have test it on the latest version v1.1.12, it's works propertly for me.

image

Can you test this issue with the latest version of CodeSnap.nvim (v1.1.12)? if there still have any problem, please let me know. @nexxai Thx for this issue report

nexxai commented 2 months ago

image

Looks perfect. Thanks!