davidhq / sublimeethereum Goto Github PK
View Code? Open in Web Editor NEWEthereum Solidity, Vyper, Yul and StarkNet Cairo language syntaxes
License: MIT License
Ethereum Solidity, Vyper, Yul and StarkNet Cairo language syntaxes
License: MIT License
Solidity allows having blocks (delimited by braces) inside a function, which are useful to limit scope of local variables. The Solidity syntax highlighting breaks when these are encountered.
Code example to reproduce:
pragma solidity ^0.5.5;
contract Test {
function foo(uint256 a) public {
a = 2 + 3;
bar();
{
uint256 b = a - 3;
if (b == 5) {
revert();
}
}
bar();
}
function bar() public {
}
}
I've downloaded all the necessary packages and sublime is sintaxing everything properly bar uint256 or any variant of it.
Hi guys!
We develop linter that allow to verify style guide, security and best practices issues! There is Solhint - https://github.com/protofire/solhint
Your extension is awesome, I am using it - and I think it would be a nice feature to add support of linter.
I believe solhint will be very helpful for your project!
- Ilya
I'm using macOS, Sublime 3.
Check #18.
..Still a happy new year ;)
i know sublime only from friends.
Now i try to setup it on my windows, and try to add the grammar for .sol and all around..
// To have it by learning a bit more "easy"..
But in the web all package install how-to`s produce errors and not adding the packages ... :((
Perhaps it will be possible to add here in the GitHub into the point "install" a tiny instruction for it ?
Package fails for arrays:
uint[] public array = [0,1,2];
only the first element is correctly colored.
have added EtherumSoliditySnippets package in sublime4 successfully,
but it doesn't work,
then I remove it and repeat the process,still so.
My sublime text 4 version is 4113.
Looking forward to your reply.
The 0.6 release introduced a couple new keywords and features that break syntax highlighting:
receive
and ether
keywords replace the old anonymous fallback functionvirtual
, and override
must be added when overridingabstract
try/catch
statement is a whole new beast: https://solidity.readthedocs.io/en/latest/control-structures.html#try-catchA summary of the changes can be found here: https://solidity.readthedocs.io/en/latest/060-breaking-changes.html
I've tried to install on Sublime 3, on Mac Os 10.9, following both the manual and console installation.
The solidity script remain still all monocolor.
//
inside a string breaks the syntax for the rest of the file
Hello again! Thanks for working on such a great plugin :)
Starting on Solidity v0.5.0, some types (e.g. bytes
) require a mandatory location attribute (memory
, storage
or calldata
). This confuses the highlighter when a function argument has no name, making it believe the storage location is the name.
E.g. the following code:
pragma solidity ^0.5.5;
contract Test {
function foo(bytes memory a, uint256 b, uint256, uint256 d) public {}
function bar(bytes memory, uint256 b, uint256, uint256 d) public {}
}
(note that GitHub's highlighting seems to have the same issue, namely, on the bar
function memory
is highlighted as if it was an argument name)
It currently breaks formatting for everything after it.
It has been in their module list for a while, but now it'll finally be usable.
See this Reddit thread for a lot more links and (un)related discussion.
Hello again :)
As you can see, memory keyword is correctly highlighted in the variable declaration but calldata is not.
Regards.
EDIT: Here is the code so you can easily copy it for testing.
contract Foo {
struct Bar {
uint a;
}
function testCalldata(Bar[] calldata _data) public {
for (uint i=0; i<_data.length; i++) {
Bar calldata d = _data[i];
}
}
function testMemory(Bar[] memory _data) public {
for (uint i=0; i<_data.length; i++) {
Bar memory d = _data[i];
}
}
}
https://github.com/ethereum/solidity/blob/develop/Changelog.md
These changes ought to be taken into account. Thanks for your help guys.
This would be very nice to have.
The Package doesn't seem to come up when searched in package control install package. Is there alternative way to install?
I noticed three different colour schemes for inherited contracts declaration:
Is this intentional? Or maybe because of my old SublimeText?
(SublimeText build 3059, SublimeEthereum fresh cloned from Github)
I have installed Ethereum Package for Sublime Text 2/3 but it is not working
And Solidity does not appear in the options under "VIew / Syntax"
Any idea?
Thanks in advance
The syntax highlighting seems to break if there's a type in the list of arguments for a modifier that has a .
in it.
Here's a minimal example:
/*
Test
*/
pragma solidity ^0.5.0;
library A {
struct MyStruct {
uint value;
}
}
library B {
modifier modifierExample(A.MyStruct storage s) {
require(s.value == 6);
_;
}
function doSomething(A.MyStruct storage s) modifierExample(s) {
}
}
I've attached a screenshot of the highlighting for this contract.
See github-linguist/linguist#3973 (comment) and following comments.
(This repo is used as a git sub-module for Solidity syntax highlighting across GitHub.)
I released Linguist v7.2.0 this morning which included an update to all grammars including SublimeEthereum which is used for Solidity highlighting (...)
The grammar has switched from a TextMate compatible grammar to a Sublime Text compatible grammar - Linguist does not support
.sublime-syntax
grammars: (followed by a list of supported grammars)
The grammar was changed from .tmLanguage
to .sublime-syntax
in commit abca952 (not part of any PR).
The change landed in tagged release v1.1.0
; the previous tag with .tmLanguage
is v1.0.3
.
this line
- match: (=|!|>|<|\||&)
should have support for the conditional ?
definitely, but maybe there should also be an addition for _
's?
I saw that this very popular atom plugin: https://github.com/caktux/language-ethereum used your repo a few years ago to add Ethereum language support to atom. However, it has not been updated in years. Have you considered translating this sublime plugin to also an atom plugin? Ideally, if this caktux person has done the translation already, you can look at what they did and learn to do it yourself. It would be cool if you got the credit for it too since it used your repo!
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;
struct MyStruct {
uint x;
uint y;
}
struct is not colored at all
Hi, it's me again ^^'
Here you can see what I mean:
Here is the code:
contract Foo {
uint256 public constant MY_CONST = 10;
function testWithoutConstant(uint256[10] calldata _param) public pure {
return _param[0];
}
function testWithConstant(uint256[MY_CONST] calldata _param) public pure {
return _param[0];
}
}
Regards.
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:
But when using the ^
like so: pragma solidity 0.4.17;
will yield:
Please let me know if there is anymore information I can provide, and thank you for creating SublimeEthereum!
this line
- match: \b(address|string\d*|bytes\d*|int\d*|uint\d*|bool|hash\d*)\b(?:\s+(?:indexed\s+)?([A-Za-z_]\w*)\s*[,\)])?
should be stripped of hash and also should have added functionality for all (u)fixedMxN types.
Do you think it would be possible at all to get highlighting similar to that of a contract with a library?
Not sure if this is the same issue as #31, but I wanted to make sure it was called out specifically - when a line inside a function begins with the word return
, it seems to always be highlighted red, regardless of whether that is the first part of a variable name or function. I've attached a screenshot for the variable name variant of this issue.
Hi, a modifier in the constructor doesn't get highlighted as in general functions. Eg: constructor() initializer {}
It also breaks the highlighting of fallback()
and receive()
special functions if they are declared after the constructor.
Thanks.
scientific notation:
int256 public i1 = 1e10;
int256 public i2 = 1e-1 * 100;
int256 public i3 = 1e1 hours;
int256 public i4 = 123_000;
int256 public i5 = 1_2e345_678 / 1_2e345_677;
all cases have some issues.
Solidity documentation.
I noticed there's an issue with highlighting a string that's composed of "
's and '
's in this line on Github; the same thing happens when you switch the "
and '
.
It seems to be fine on Sublime though, so I'm not sure what the issue is.
Any ideas?
Some instructions should be colored but they are not:
delegatecall
returndatacopy
and returndatasize
switch
, case
, and default
.same code so you can copy it:
pragma solidity ^0.4.24;
contract Router {
function() external payable {
address delegate = address(0x123);
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, delegate, ptr, calldatasize, 0, 0)
let size := returndatasize
returndatacopy(ptr, 0, size)
switch result
case 0 {revert(ptr, size)}
default {return (ptr, size)}
}
}
}
I love snippets. There are a few useful ones in Vim format here and I'd be happy to implement them inside the SublimeEthereum package.
calling a function containing return at the beginning of it's name highlights the return
part in red. This should not be the case, the complete function name should be in light blue as it is a normal function call. return
should only be highlighted in red when it actually is the return statement.
Issue probably applies with other keywords too.
Syntax color does not work in .sol files containing only functions. For instance helpers.
I guess function have to be within Contract to be recognized.
Hello,
As you may have seen this package is now used by linguist to provide syntax highlighting for solidity files in Github.
Unless I have not understood how linguist works then there may be a problem with the grammar rules of this package. Some solidity files do not get highlighted properly in github and the problem seems to be the /* */
(multiline comments).
In the raiden network repository we just introduced .gitattributes
and some of our smart contracts are now properly highlighted while some are not.
The simplest example i can provide is this file in the raiden network repository which is not properly highlighted, presumably due to the multiline comment:
https://github.com/raiden-network/raiden/blob/master/raiden/smart_contracts/Standard_Token.sol
The same file, in my fork, with the multiline comment removed is highlighted properly:
https://github.com/LefterisJP/raiden/blob/testity/raiden/smart_contracts/Standard_Token.sol
There could also be another reason why this is happening and I may be wrong. I just want to try and find out why not all the files are properly highlighted.
Receive the following error in console:
Package Control: Error downloading package. HTTP exception InvalidCertificateException (Host codeload.github.com returned an invalid certificate ([SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590))) downloading https://codeload.github.com/davidhq/SublimeEthereum/zip/v1.0.3.
error: Package Control
Unable to download Ethereum. Please view the console for more details.
Idk if this is a short fix or not but in I've noticed that the second multiple inheritance instance is not highlighted in this package. Small, but would be nice to have for consistency.
Example:
contract foo is bar, zen {
***********************^
*****************this needs highlighting
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.