All Projects → ethereum → Emacs Solidity

ethereum / Emacs Solidity

The official solidity-mode for EMACS

Programming Languages

solidity
1140 projects

Projects that are alternatives of or similar to Emacs Solidity

Live Py Plugin
Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser
Stars: ✭ 222 (+85%)
Mutual labels:  emacs, emacs-mode
Swift Mode
Emacs support for Apple's Swift programming language.
Stars: ✭ 308 (+156.67%)
Mutual labels:  emacs, emacs-mode
Org Msg
OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
Stars: ✭ 153 (+27.5%)
Mutual labels:  emacs, emacs-mode
Psc Ide Emacs
Emacs integration for PureScript's psc-ide tool.
Stars: ✭ 130 (+8.33%)
Mutual labels:  emacs, emacs-mode
Clj Refactor.el
A collection of Clojure refactoring functions for Emacs
Stars: ✭ 694 (+478.33%)
Mutual labels:  emacs, emacs-mode
Writegood Mode
Minor mode for Emacs to improve English writing
Stars: ✭ 369 (+207.5%)
Mutual labels:  emacs, emacs-mode
Zoom
Fixed and automatic balanced window layout for Emacs
Stars: ✭ 252 (+110%)
Mutual labels:  emacs, emacs-mode
Webpaste.el
webpaste.el can paste whole buffers or parts of buffers to several pastebin-like services and supports failover if one service fails.
Stars: ✭ 67 (-44.17%)
Mutual labels:  emacs, emacs-mode
Nyan Mode
Nyan Cat for Emacs! Nyanyanyanyanyanyanyanyanyan!
Stars: ✭ 590 (+391.67%)
Mutual labels:  emacs, emacs-mode
Deft
Deft for Emacs
Stars: ✭ 521 (+334.17%)
Mutual labels:  emacs, emacs-mode
Fingers.el
Modal editing minor mode for Emacs
Stars: ✭ 51 (-57.5%)
Mutual labels:  emacs, emacs-mode
Jq Mode
Emacs major mode for editing jq queries.
Stars: ✭ 70 (-41.67%)
Mutual labels:  emacs, emacs-mode
Livepeerjs
JavaScript tools and applications that interact with Livepeer's smart contracts and peer-to-peer network
Stars: ✭ 116 (-3.33%)
Mutual labels:  ethereum
District0x Network Token
Smart Contracts and web app for district0x contribution
Stars: ✭ 119 (-0.83%)
Mutual labels:  ethereum
Dappeteer
🏌🏼‍E2E testing for dApps using Puppeteer + MetaMask
Stars: ✭ 117 (-2.5%)
Mutual labels:  ethereum
Cyb Archeology
🌎 Personal immortal robot for the The Great Web
Stars: ✭ 117 (-2.5%)
Mutual labels:  ethereum
Stocklook
crypto currency library for trading & market making bots, account management, and data analysis
Stars: ✭ 119 (-0.83%)
Mutual labels:  ethereum
Metamask Mobile
Port of MetaMask Ethereum Ðapp browser for mobile devices (iOS only for now)
Stars: ✭ 119 (-0.83%)
Mutual labels:  ethereum
Coinbase Pro Node
Coinbase Pro API written in TypeScript and covered by tests.
Stars: ✭ 116 (-3.33%)
Mutual labels:  ethereum
Doom Emacs
An Emacs framework for the stubborn martian hacker
Stars: ✭ 12,774 (+10545%)
Mutual labels:  emacs

#+TITLE: Emacs Solidity Mode #+AUTHOR: Lefteris Karapetsas

[[LICENSE][file:https://img.shields.io/badge/License-GPL%20v3-blue.svg]] [[http://melpa.org/#/solidity-mode][file:http://melpa.org/packages/solidity-mode-badge.svg]]

A simple language mode for the Solidity language. It is a constant work in progress as the language itself also progresses. For information about Solidity check the [[https://github.com/ethereum/wiki/wiki/Solidity-Tutorial][Tutorial]] and the [[https://github.com/ethereum/wiki/wiki/Solidity-Features][Features]] wiki pages.

  • Installation You can simply load the file in your emacs but the recommended way to install it is either via el-get or MELPA.

** El-get If you don't know how to use el-get you can find more information on its [[https://github.com/dimitri/el-get][webpage]]. First [[https://github.com/dimitri/el-get#basic-setup][install el-get]] and then (in emacs), press =Alt+x= (this is in emacs notation written as =M-x= ) and then type =el-get-install=. This will prompt you for a package, type =solidity-mode= and hit enter, this should install all you need.

** Melpa You can also obtain solidity-mode from [[http://melpa.org/#/][Melpa]] as can be seen [[http://melpa.org/#/solidity-mode][here]].

  • Configuration By default solidity-mode associates itself with any files ending in =.sol=.

If using =el-get= then you should have a specific package initializing lisp file. If not then you can put these anywhere in your =init.el=.

** Generic configuration Regardless of where you installed solidity mode from, you need to require the package: #+BEGIN_SRC lisp (require 'solidity-mode) #+END_SRC (append that line to your =~/.emacs= file)

You can also set the way the comments are inserted by emacs with commands like =comment-region=. The default is =/* .. */= and you can turn it to using =//= instead by putting the following into your emacs config:

#+BEGIN_SRC lisp (setq solidity-comment-style 'slash) ;; or (setq solidity-comment-style 'star) ;; this is the default #+END_SRC

** Keymap You can modify the default keybindings of the solidity mode keymap by adding a new key combination for each command you want to change. For example

#+BEGIN_SRC lisp (define-key solidity-mode-map (kbd "C-c C-g") 'solidity-estimate-gas-at-point) #+END_SRC

** Interface with linters *** Provide path to solc binary The =solc= binary is assumed to be part of the PATH. Wherever that is not the case you would have to manually set the location of the binary like below: #+BEGIN_SRC emacs-lisp (setq solidity-solc-path "/home/lefteris/ew/cpp-ethereum/build/solc/solc") #+END_SRC

Note: This better be set before requiring solidity mode.

*** Provide path to solium binary The =solium= binary is assumed to be part of the user's =PATH=. If this is not the case then set its location like below: #+BEGIN_SRC emacs-lisp (setq solidity-solium-path "/home/lefteris/.npm-global/bin/solium") #+END_SRC

** [Optional] Flycheck interface Solidity mode can also interface with [[https://github.com/flycheck/flycheck][flycheck]] if you have it. Make sure to download and install the flycheck package. Then configure it to either work on all modes or enable it only for solidity mode.

Flycheck can interface with solc and/or with [[http://solium.readthedocs.io/en/latest/][solium]]. We only support integration with solium >= =v0.2.0=

You have to specifically set the path to both executables and activate the checker integration by setting the following:

To activate flycheck you need the =solidity-flycheck= package and to add this in your emacs file:

#+BEGIN_SRC emacs-lisp (require 'solidity-flycheck) #+END_SRC

To activate =solc= checker #+BEGIN_SRC emacs-lisp (setq solidity-flycheck-solc-checker-active t) #+END_SRC

To activate =solium= checker #+BEGIN_SRC emacs-lisp (setq solidity-flycheck-solium-checker-active t) #+END_SRC

Keep in mind that you need to provide the path to either solc or solium unless emacs can already find it in your environment's =PATH=. Even if you can call it from the command line it does not mean that EMACS can see it as emacs may be started by systemd at which point =PATH= is not fully populated.

*** Configuring solc checker

You can configure flycheck's solc invocation with the following arguments

**** std contracts By default this is false. If you want to include the standard contracts just add the following to your emacs init file

#+BEGIN_SRC emacs-lisp (setq flycheck-solidity-solc-addstd-contracts t) #+END_SRC

*** Configuring solium checker You can configure flycheck's solium incocation with the following arguments

**** solium RC file By default solium looks at the current directory of the file you are editing in order to find =.soliumrc.json=. Having this file is required. But you can point to an external configuration file by putting the following anywhere in your emacs init file.

#+BEGIN_SRC emacs-lisp (setq flycheck-solidity-solium-soliumrcfile "/home/path/to/common/.soliumrc.json") #+END_SRC

*** Chaining both checkers If you enable both checkers then their results are chained. The variable =solidity-flycheck-chaining-error-level= controls how they are chained. Its value can be either =t=, =error=, =warning= or =info= and that controls the maximum error level of the solc checker after which solium will not run. If =t= is given solium will always run. The default is =warning=, so if anything over than a warning is found in solc solium will not run.

** [Optional] Autocompletion To achieve solidity autcompletion you will need the =company-solidity= package, a simple [[http://company-mode.github.io/][company-mode]] back-end for Solidity. To use it make sure that company-mode is installed and then:

#+BEGIN_SRC emacs-lisp (require 'company-solidity) #+END_SRC

*** What it does Give completion suggestions for Solidity keywords, global variables, and address methods.

*** What it isn't Smart. The completion suggestions are not context dependent.

*** Something to watch out for =company-mode= treats =.= as the end of a word, and will cut off compeletion suggestions when you type a =.=. So, when you've typed =msg= you will get =msg.sender=, =msg.value= etc. as completion suggestions. However, as soon as you type =msg.=, the suggestions will disappear.

*** Local Variables If you want autocomplete suggestions to include local variables, in addition to Solidity keywords, add the following to your =init.el=:

#+BEGIN_SRC emacs-lisp (add-hook 'solidity-mode-hook (lambda () (set (make-local-variable 'company-backends) (append '((company-solidity company-capf company-dabbrev-code)) company-backends)))) #+END_SRC

  • Commands

** Gas estimate of function under point You can get an estimate of the function under the cursor, by placing the curson on top of the function name and typing =C-c C-g=.

This will call =solidity-estimate-gas-at-point= and provide a max gas estimate, if possible, for the function.

  • Features
  • Syntax highlighting
  • Autocompletion
  • Indentation
  • On the fly syntax checking with flycheck
  • Gas estimation for function under point
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].