Giter Club home page Giter Club logo

sublimeethereum's Introduction

SublimeText syntax highlighting for Solidity, Vyper, Yul and Cairo

Version of syntax that GitHub is using for Solidity grammar and Vyper is in linguist branch. This grammar gives all .sol / .vy files (example) its colors (= does syntax highlighting).

Ethereum

Ethereum is a platform for decentralized applications. Decentralized applications are built with Smart Contracts.

StarkNet

StarkNet is a permissionless decentralized ZK-Rollup operating as an L2 network over Ethereum, where any dApp can achieve unlimited scale for its computation, without compromising Ethereum’s composability and security.

Included grammars

This package contains syntax highlighting for Ethereum's Smart Contract languages Solidity, Vyper, Yul as well as StarkNet Cairo language.

Solidity is the biggest Ethereum language and has similarity to JavaScript. Solidity was initially proposed in August 2014 by dr. Gavin Wood. The language was later developed by the Ethereum project's Solidity team, led by Christian Reitwiessner.

Vyper is a contract-oriented, pythonic programming language that targets the Ethereum Virtual Machine (EVM) as well. It lacks some general features and through this strives to be more secure by default.

Yul is an intermediate EVM programming language that is compiled to bytecode for addressing the needs of different backends. The Solidity compiler has an experimental implementation that uses Yul as an intermediate language.

Cairo is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly. Cairo and similar proof systems can be used to provide scalability to blockchains.

Linguist branch has an implementation with regexes and is used in GitHub. Main branch (= used in sublime package to enable .sol syntax highlighting for SublimeText editor) uses more advanced context stack approach to achieve optimal and more detailed results from what is possible with regex based approach.

Installation in SublimeText editor

  1. SublimeText menu / Preferences / Package Control
  2. Select: Install Package
  3. Type Ethereum and press ENTER
  4. With a .sol / .vy / .cairo file open, select: View -> Syntax (-> Open all with current extension as) -> Ethereum -> Cairo / Solidity / Vyper / Yul
  5. Close and re-open any files to activate the syntax highlighting

This will provide Solidity .sol, Vyper .vy and Cairo .cairo syntax highlighting.

SublimeEthereum on Package Control.

Features

  • Solidity.sublime-syntax: syntax rules for Ethereum Solidity language
    • Ethereum plugin automatically uses Solidity language syntax when you are in a Solidity (.sol) file
    • vscode-solidity is another good grammar implementation, it was originally derived from SublimeEthereum
  • Vyper.YAML-tmLanguage: syntax rules for Ethereum Vyper language
    • Ethereum plugin automatically uses Vyper language syntax when you are in a Vyper (.vy) file
  • Yul.YAML-tmLanguage: syntax rules for Ethereum Yul language
    • Ethereum plugin automatically uses Yul language syntax when you are in a Yul (.yul) or Yul+ (.yulp) file
  • Cairo.YAML-tmLanguage: syntax rules for StarkNet Cairo language
    • Ethereum plugin automatically uses Cairo language syntax when you are in a Cairo (.cairo) file
    • Cairo language grammar is derived from Atom grammar in this repository by GitHub user xshitaka.

License

All of Sublime Ethereum is licensed under the MIT license.

Copyright Ⓒ 2015-2222 uniqpath

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

sublimeethereum's People

Contributors

aelerinya avatar cubedro avatar davidhq avatar ekpyron avatar lastperson avatar ldct avatar leopoldjoy avatar nventuro avatar pchaigno avatar ralph-pichler avatar skozin avatar u2 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  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  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

sublimeethereum's Issues

Add support for Solidity 0.6 features

The 0.6 release introduced a couple new keywords and features that break syntax highlighting:

A summary of the changes can be found here: https://solidity.readthedocs.io/en/latest/060-breaking-changes.html

Highlighter fails on integer contstants

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.

Wrong highlighting on anonymous function arguments with location

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 {}
}

is highlighted as follows:
image

(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)

GitHub does not support `.sublime-syntax`

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.

Incorrect highlighting of variable names beginning with return

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.

screen shot 2019-02-22 at 5 41 34 pm

When used from Linguist some files don't get properly highlighted

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.

Some highlighter problems inside assembly

Some instructions should be colored but they are not:
Screenshot (8)

  • 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)}
        }
    }
}

Request: snippets

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.

uint256 wont highlight purple

I've downloaded all the necessary packages and sublime is sintaxing everything properly bar uint256 or any variant of it.

Minor issue caused by shadowing?

contract Len {
    uint[] internal arr;
    function foo() external view {
        uint length = arr.length;
        for (uint i = 0; i < length; i++) {}
    }
}

length variable is incorrectly colored:
example

Blocks inside a function break syntax highlighting

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 {

    }
}

This renders as follows in v1.1.22:
image

changing colors of inherited contracts

I noticed three different colour schemes for inherited contracts declaration:

  1. contracts with only-letter names
  2. contract with digits in its name and succeeding contracts
  3. contract with arguments in parentheses and succeeding contracts

Is this intentional? Or maybe because of my old SublimeText?

(SublimeText build 3059, SublimeEthereum fresh cloned from Github)

Syntax-color does not work in helper

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.

Add support of Solidity linter

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

Syntax highlighting breaks for certain types of for loops

For for loops that contain an = in the third statement, syntax parsing seems to break going forward. The following for loop would break, for example:

for (uint i = 0; i < n; i = i + 2) {
...
}

I've provided a screenshot as well.

image

Highlighting fails in Github when using ^ in Solidity version

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!

Solidity 0.6 top-level structs

pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;

struct MyStruct {
    uint x;
    uint y;
}

struct is not colored at all

Not installing

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.

Solidity sintax not working in Sublime Text

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

Highlighting issues with abi.* commands

pragma solidity 0.5.4;
pragma experimental ABIEncoderV2;

contract C {
	function() external {
		abi.encode(1);
		abi.decode(msg.data, (bytes4, uint, uint));
	}
}

looks incorrect for me:
screenshot 6
I guess it's because of

  • special status of abi object
  • and unique turple of types in decode

Incorrect highlighting of function names beginning with return

screenshot_20190131_143452

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.

Any plan to make one for Atom?

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!

Syntax highlighting breaks on modifiers with certain types of arguments

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.

screen shot 2019-02-14 at 5 37 38 pm

How To Install without error's

..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 ?

calldata keyword doesn't get highlighted in a variable declaration

Hello again :)

Screenshot at 2022-03-28_13:27:43

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];
        }
    }
}

Incompatibility with different strings specifiers

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 '.

Screenshot (Github):
image

It seems to be fine on Sublime though, so I'm not sure what the issue is.

Screenshot (Sublime):
image

Any ideas?

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.