diff --git a/CHANGELOG.develop b/CHANGELOG.develop index c0741a2b6..4e701df5b 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -325,6 +325,7 @@ sane way, here is the complete list of changed key bindings - perl6 (thanks to Bahtiar Gadimov and yuhan0) - prolog (thanks to Newres Al Haider) - reasonml (thanks to fredyr and Dave Aitken) +- solidity (thanks to Brooklyn Zelenka) - protobuf (thanks to Amol Mandhane) - restructuredtext (thanks to Wei-Wei Guo and Kalle Lindqvist) - semantic-web (thanks to Andreas Textor) @@ -2722,6 +2723,9 @@ Other: - Fixed =helm= menu display (thanks to Leslie Shawn Russell) **** Smex - Fixed ~SPC m :~ for current major mode commands (thanks to tinysong) +**** Solidity +- Key bindings: + - Added ~SPC m g~ Estimate gas at point (thanks to Brooklyn Zelenka) **** Source control - Install orgit only when org package is used (thanks to Boris Buliga) - Defer git-gutter loading (thanks to Aaron Jensen) diff --git a/layers/+lang/solidity/README.org b/layers/+lang/solidity/README.org new file mode 100644 index 000000000..6d9b6ce27 --- /dev/null +++ b/layers/+lang/solidity/README.org @@ -0,0 +1,73 @@ +#+TITLE: Solidity Layer + +[[file:img/solidity.png]] + +* Table of Contents :TOC_4_gh:noexport: +- [[#description][Description]] + - [[#features][Features:]] +- [[#install][Install]] + - [[#layer][Layer]] + - [[#linter][Linter]] + - [[#solc][solc]] + - [[#ethlint][Ethlint]] +- [[#options][Options]] +- [[#key-bindings][Key bindings]] + +* Description + +A layer to support Solidity development in Spacemacs. + +** Features: +- Syntax highlighting +- Syntax checking +- Gas estimation + +* Install +** Layer +To use this configuration layer, add it to your =~/.spacemacs=. You will need to +add =solidity= to the existing =dotspacemacs-configuration-layers= list in this +file. + +** Linter +*** solc +To use the solc flycheck checker, install [[https://solidity.readthedocs.io][solc]], and enable it in your =~/.spacemacs=. + +#+BEGIN_SRC emacs-lisp + (solidity :variables + solidity-flycheck-solc-checker-active t) +#+END_SRC + +Please note that you can't use [[https://github.com/ethereum/solc-js][solc-js]] for the solc flycheck checker. + +*** Ethlint +To use solium flycheck checker, install [[https://github.com/duaraghav8/Ethlint][Ethlint]]. + +#+BEGIN_SRC sh + npm i -g ethlint +#+END_SRC + +Then enable it in your =~/.spacemacs=: + +#+BEGIN_SRC emacs-lisp + (solidity :variables + solidity-flycheck-solium-checker-active t) +#+END_SRC + +And make sure that =.soliumrc.json= exists in the root directory of your DApp: + +#+BEGIN_SRC sh + solium --init +#+END_SRC + +* Options + +| Variable | Default value | Description | +|-------------------------------------------+---------------+------------------------------------------------------------| +| =solidity-flycheck-solc-checker-active= | =nil= | If non-nil, use solc flycheck checker for Solidity Mode. | +| =solidity-flycheck-solium-checker-active= | =nil= | If non-nil, use solium flycheck checker for Solidity Mode. | + +* Key bindings + +| Key Binding | Description | +|-------------+-----------------------| +| ~SPC m g~ | Estimate gas at point | diff --git a/layers/+lang/solidity/img/solidity.png b/layers/+lang/solidity/img/solidity.png new file mode 100644 index 000000000..4037b2a69 Binary files /dev/null and b/layers/+lang/solidity/img/solidity.png differ diff --git a/layers/+lang/solidity/layers.el b/layers/+lang/solidity/layers.el new file mode 100644 index 000000000..db8260e74 --- /dev/null +++ b/layers/+lang/solidity/layers.el @@ -0,0 +1,12 @@ +;;; layers.el --- Solidity Layer Configuration File for Spacemacs +;; +;; Copyright (c) 2012-2019 Sylvain Benner & Contributors +;; +;; Author: Seong Yong-ju +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(configuration-layer/declare-layer-dependencies '(node)) diff --git a/layers/+lang/solidity/packages.el b/layers/+lang/solidity/packages.el new file mode 100644 index 000000000..48666e3e0 --- /dev/null +++ b/layers/+lang/solidity/packages.el @@ -0,0 +1,38 @@ +;;; packages.el --- solidity layer packages file for Spacemacs. +;; +;; Copyright (c) 2012-2017 Sylvain Benner & Contributors +;; +;; Author: Brooklyn Zelenka +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +;;; Code: + +(defconst solidity-packages + '( + add-node-modules-path + flycheck + solidity-mode + solidity-flycheck)) + +(defun solidity/post-init-add-node-modules-path () + (add-hook 'solidity-mode-hook #'add-node-modules-path)) + +(defun solidity/init-solidity-mode () + (use-package solidity-mode + :defer t + :config + (spacemacs/set-leader-keys-for-major-mode 'solidity-mode + "g" #'solidity-estimate-gas-at-point))) + +(defun solidity/post-init-flycheck () + (spacemacs/enable-flycheck 'solidity-mode)) + +(defun solidity/init-solidity-flycheck () + (use-package solidity-flycheck + :defer t + :init + (add-hook 'solidity-mode-hook #'(lambda () (require 'solidity-flycheck)))))