davidhq / SublimeEthereum

Ethereum Solidity, Vyper, Yul and StarkNet Cairo language syntaxes
MIT License
116 stars 43 forks source link

Highlighting fails in Github when using ^ in Solidity version #29

Closed spacesailor24 closed 5 years ago

spacesailor24 commented 5 years ago

Hi there, I noticed that this repo is being used to provide the syntax highlighting in Github repositories using Linguist.

I also noticied that syntax highlighting works fine when there is no ^ present in the Solidity version like so: Using pragma solidity 0.4.17; will yield:

Good

But when using the ^ like so: pragma solidity 0.4.17; will yield:

Bad

Please let me know if there is anymore information I can provide, and thank you for creating SublimeEthereum!

davidhq commented 5 years ago

Please give me until tomorrow to check this. Thank you for the report.

spacesailor24 commented 5 years ago

Of course, again let me know if there is any additional information I can provide.

davidhq commented 5 years ago

I think the problem is more complex that I'm currently capable of tackling... probably, not sure yet...

What I planned to do for a long time and I still think it's rather easily doable (again, maybe with some help from community... would be welcome, of course) is this:

http://www.sublimetext.com/docs/3/syntax.html

Main point:

Sublime Text can use both .sublime-syntax and .tmLanguage files for syntax highlighting. This document describes .sublime-syntax files.

Basically .tmLanguage is the old way with regular expresions that is already showing cracks (as you can see with some open issues). .sublime-syntax works with stacks and contexts.

So quick question for you:

can you point me to some resources in understanding how exactly Linguist works for this case?

Would rewrite help here "automatically" or if not, then at least is it a good next step?

I won't be able to do anything on this project until rewrite (whenever that is, I hope soon, I started working on it "today"), will push some code on separate branch in a few days... EXCEPT I can do really small tweaks if I come to understand why pragma breaks when doing your Linguist magic...

As you can see here, it doesn't have anything to do with the sublime syntax definition itself (except as I say because it's the old way of doing things and Linguist would work better with new stack based syntax?):

screen shot 2018-12-29 at 22 56 31
davidhq commented 5 years ago

@alexvandesande could also probably join the conversation?

spacesailor24 commented 5 years ago

I'm confused because the original Adoption.sol contract I showed you now has proper syntax highlighting in Github even with the ^ before the solidity version:

Adoption.sol

However, this contract, Migrations.sol, doesn't have syntax highlighting and the reason is because it doesn't have the two blank lines before the contract definition:

Before adding an extra line:

Migrations.sol Before

After adding an extra line:

Migrations.sol After

Any thoughts? I see that nothing has changed in Master for this repository

davidhq commented 5 years ago

Hi @spacesailor24 -- a few more days and we can observe if it fixes the issue and if not, investigate from there... see here for progress report: https://github.com/davidhq/SublimeEthereum/issues/24

davidhq commented 5 years ago

new syntax parser has been published, now we wait for github linguist to pick it up

varasev commented 5 years ago

Something was broken with the latest changes:

image

The source file on the screen: https://github.com/poanetwork/poa-network-consensus-contracts/blob/master/contracts/BallotsStorage.sol

davidhq commented 5 years ago

Thank you, fixed... https://github.com/davidhq/SublimeEthereum/commit/704eefa83d014d626eafd04994b9d40a8068595d

varasev commented 5 years ago

Thanks. Also, something strange with colors - they were changed, I think. For example, on the screen the validatorSetContract variable has different colors (I didn't change anything in settings):

image

The corresponding file: https://github.com/poanetwork/pos-contracts/blob/master/contracts/BlockRewardAuRa.sol

davidhq commented 5 years ago

Hi, yes indeed some rather minor color changes do happen with new syntax parsing. All hopefully for the better.

I will examine this particular case later today and explain what happened and if I think it’s a good idea or if it needs discussion or it’s a bug.

davidhq commented 5 years ago

@varasev I pushed the updates, some colors are back as before and there are additional fixes. Thank you very much for these reports, please write back if anything is still broken.

davidhq commented 5 years ago

@spacesailor24 as for the original reported issue, I now identified one contract example here that is not properly identified by Linguist. And here is one that is properly highlighted.

GitHub hasn't yet updated their submodule reference to the latest version of SublimeEthereum but before they do that, I'll try to test locally and see if the new .sublime-syntax is even supported etc. So, soon we know a bit more and thank you again for the report.

varasev commented 5 years ago

@davidhq Thank you for fixing, it seems to be fine now, but I still see a few minor color inconsistencies:

image

In the same file: https://github.com/poanetwork/pos-contracts/blob/master/contracts/BlockRewardAuRa.sol

davidhq commented 5 years ago

In which IDE do you get such colors? I get this locally in my SublimeText:

screen shot 2019-01-20 at 13 37 56

So here it seems ok, please check again why difference at your side.

Also try some other theme and see if your theme brings in these inconsistencies.. I still probably can do something to fix this but we have to know where it comes from actually.

varasev commented 5 years ago

I use Sublime Text 3.0, build 3170 with packages Ethereum v1.1.3 and ColorSublime v2.1.0. The color scheme on my above screen is Dawn.

If I try to switch to some of default color schemes, I get the same issue. For example (Mariana color scheme):

image

davidhq commented 5 years ago

I think now in v1.1.5 it's fixed... btw a tip for any further problem detection → you can use :

While editing in Sublime Text, you can check what scopes have been applied to the text under the caret by pressing control+shift+p (OSX) or ctrl+alt+shift+p (Windows and Linux).

I used that to see that I used different scopes for two things you were showing and none of my themes were so exact as to apply some other styling to variable.language scope... I now removed this scope from syntax highlighting.

varasev commented 5 years ago

Thank you, it's ok now.