From 3193e7a8a76f8c07efda4f44f500f434bbb1a1cd Mon Sep 17 00:00:00 2001 From: Edmund Milller Date: Thu, 17 May 2018 21:00:30 -0500 Subject: [PATCH 1/6] Add Solidity Add basic Solidity module --- init.example.el | 1 + modules/lang/solidity/README.org | 31 +++++++++++++++++++++++++++++++ modules/lang/solidity/config.el | 28 ++++++++++++++++++++++++++++ modules/lang/solidity/doctor.el | 8 ++++++++ modules/lang/solidity/packages.el | 6 ++++++ 5 files changed, 74 insertions(+) create mode 100644 modules/lang/solidity/README.org create mode 100644 modules/lang/solidity/config.el create mode 100644 modules/lang/solidity/doctor.el create mode 100644 modules/lang/solidity/packages.el diff --git a/init.example.el b/init.example.el index 92a2163f1..64b6d2b27 100644 --- a/init.example.el +++ b/init.example.el @@ -104,6 +104,7 @@ rust ; Fe2O3.unwrap().unwrap().unwrap().unwrap() scala ; java, but good sh ; she sells (ba|z)sh shells on the C xor + solidity ; do you need a blockchain? No. swift ; who asked for emoji variables? typescript ; javascript, but better web ; the tubes diff --git a/modules/lang/solidity/README.org b/modules/lang/solidity/README.org new file mode 100644 index 000000000..b407c498f --- /dev/null +++ b/modules/lang/solidity/README.org @@ -0,0 +1,31 @@ +#+TITLE: :lang solidity + +This module adds [[https://github.com/ethereum/solidity][Solidity]] support through [[https://github.com/ethereum/emacs-solidity][solidity-mode]] + ++ Syntax-checking (~flycheck~) ++ Code completion (~[[https://github.com/ssmolkin1/company-solidity][company-solidity]]~) ++ Gas estimation(~C-c C-g~) + +* Install +There are two options for linters. + +** [[https://github.com/ethereum/solc-js][Solc]] +#+BEGIN_SRC sh +npm install -g solc +#+END_SRC + +** [[http://solium.readthedocs.io/en/latest/user-guide.html#installation][Solium]] +#+BEGIN_SRC sh +npm install -g solium +#+END_SRC + +By default *solium* looks for ~.soliumrc.json~ in the project directory, but you can set it to your own ~.soliumrc.json~ with this in your private doom ~config.el~ + +#+BEGIN_SRC emacs-lisp +(setq flycheck-solidity-solium-soliumrcfile "/$HOME/.soliumrc.json") +#+END_SRC + +They can be chained together so it's recommended you use both. *Solc* is ran first, and then *Solium* if *Solc* doesn't catch any errors. + +* TODO ++ Snippets diff --git a/modules/lang/solidity/config.el b/modules/lang/solidity/config.el new file mode 100644 index 000000000..ef09f7bef --- /dev/null +++ b/modules/lang/solidity/config.el @@ -0,0 +1,28 @@ +;;; lang/solidity/config.el -*- lexical-binding: t; -*- + +;; +;; Plugins +;; + +(def-package! solidity-mode + :mode "\\.sol$" + :init + (setq solidity-solc-path "$HOME/.node_modules/bin/solcjs") + (setq solidity-solium-path "$HOME/.node_modules/bin/solium") + + (setq solidity-flycheck-solc-checker-active t) + (setq solidity-flycheck-solium-checker-active t) + + (setq flycheck-solidity-solc-addstd-contracts t) + :config + (setq solidity-comment-style 'slash)) + +(def-package! company-solidity + :when (featurep! :completion company) + :after solidity-mode + :config + (add-hook 'solidity-mode-hook + (lambda () + (set (make-local-variable 'company-backends) + (append '((company-solidity company-capf company-dabbrev-code)) + company-backends))))) diff --git a/modules/lang/solidity/doctor.el b/modules/lang/solidity/doctor.el new file mode 100644 index 000000000..851008c5d --- /dev/null +++ b/modules/lang/solidity/doctor.el @@ -0,0 +1,8 @@ +;; -*- lexical-binding: t; no-byte-compile: t; -*- +;;; lang/solidity/doctor.el + +(unless (executable-find "solc") + (warn! "Solc isn't installed.")) + +(unless (executable-find "solium -V") + (warn! "Solium isn't installed.")) diff --git a/modules/lang/solidity/packages.el b/modules/lang/solidity/packages.el new file mode 100644 index 000000000..e778adbdf --- /dev/null +++ b/modules/lang/solidity/packages.el @@ -0,0 +1,6 @@ +;; -*- no-byte-compile: t; -*- +;;; lang/solidity/packages.el + +(package! solidity-mode) +(when (featurep! :completion company) + (package! company-solidity)) From f4234779ce42a478a2f875839c4aa24f7529e90e Mon Sep 17 00:00:00 2001 From: Edmund Milller Date: Thu, 17 May 2018 21:51:42 -0500 Subject: [PATCH 2/6] Remove Company package It's been moved into solidity-mode already. --- modules/lang/solidity/packages.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/lang/solidity/packages.el b/modules/lang/solidity/packages.el index e778adbdf..fa8c36556 100644 --- a/modules/lang/solidity/packages.el +++ b/modules/lang/solidity/packages.el @@ -2,5 +2,3 @@ ;;; lang/solidity/packages.el (package! solidity-mode) -(when (featurep! :completion company) - (package! company-solidity)) From 01993aa69875e2770e9fc38fee8a993a4e19c6b8 Mon Sep 17 00:00:00 2001 From: Edmund Milller Date: Thu, 17 May 2018 21:52:34 -0500 Subject: [PATCH 3/6] Fix solc and solium pathes The bin files were links to the real thing. --- modules/lang/solidity/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lang/solidity/config.el b/modules/lang/solidity/config.el index ef09f7bef..c8678ae10 100644 --- a/modules/lang/solidity/config.el +++ b/modules/lang/solidity/config.el @@ -7,8 +7,8 @@ (def-package! solidity-mode :mode "\\.sol$" :init - (setq solidity-solc-path "$HOME/.node_modules/bin/solcjs") - (setq solidity-solium-path "$HOME/.node_modules/bin/solium") + (setq solidity-solc-path "~/.node_modules/lib/node_modules/solc/solcjs") + (setq solidity-solium-path "~/.node_modules/lib/node_modules/solium/bin/solium.js") (setq solidity-flycheck-solc-checker-active t) (setq solidity-flycheck-solium-checker-active t) From f5a0d89eda7d72e734014f17554c1e403938cc8c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 25 May 2018 19:04:01 +0200 Subject: [PATCH 4/6] lang/solidity: conform to Doom conventions --- modules/lang/solidity/config.el | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/modules/lang/solidity/config.el b/modules/lang/solidity/config.el index c8678ae10..653cdc6a0 100644 --- a/modules/lang/solidity/config.el +++ b/modules/lang/solidity/config.el @@ -4,25 +4,22 @@ ;; Plugins ;; -(def-package! solidity-mode - :mode "\\.sol$" - :init - (setq solidity-solc-path "~/.node_modules/lib/node_modules/solc/solcjs") - (setq solidity-solium-path "~/.node_modules/lib/node_modules/solium/bin/solium.js") +;; `solidity-mode' +(setq solidity-comment-style 'slash + solidity-flycheck-solc-checker-active t + solidity-flycheck-solium-checker-active t) - (setq solidity-flycheck-solc-checker-active t) - (setq solidity-flycheck-solium-checker-active t) - (setq flycheck-solidity-solc-addstd-contracts t) - :config - (setq solidity-comment-style 'slash)) +(def-package! solidity-flycheck ; included with solidity-mode + :when (featurep! :feature syntax-checker) + :after solidity-mode + :init (add-hook 'solidity-mode-hook #'flycheck-mode) + :config (setq flycheck-solidity-solc-addstd-contracts t) + (def-package! company-solidity :when (featurep! :completion company) :after solidity-mode :config - (add-hook 'solidity-mode-hook - (lambda () - (set (make-local-variable 'company-backends) - (append '((company-solidity company-capf company-dabbrev-code)) - company-backends))))) + (setq company-backends (delq 'company-solidity company-backends)) + (set! :company-backends 'solidity-mode 'company-solidity)) From 6be1ee17e5adf07d4088f6b1b9b41332d398847f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 25 May 2018 19:06:29 +0200 Subject: [PATCH 5/6] lang/solidity: improve binary checks in doctor.el --- modules/lang/solidity/doctor.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/lang/solidity/doctor.el b/modules/lang/solidity/doctor.el index 851008c5d..146d640ee 100644 --- a/modules/lang/solidity/doctor.el +++ b/modules/lang/solidity/doctor.el @@ -1,8 +1,8 @@ ;; -*- lexical-binding: t; no-byte-compile: t; -*- ;;; lang/solidity/doctor.el -(unless (executable-find "solc") - (warn! "Solc isn't installed.")) - -(unless (executable-find "solium -V") - (warn! "Solium isn't installed.")) +(when (require 'solidity-common nil t) + (unless (executable-find solidity-solc-path) + (warn! "Solc isn't installed.")) + (unless (executable-find solidity-solium-path) + (warn! "Solium isn't installed."))) From 9a730c00357103b54d3475239615be25b40680f4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 25 May 2018 19:10:49 +0200 Subject: [PATCH 6/6] lang/solidity: conform README to doom conventions --- modules/lang/solidity/README.org | 36 +++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/modules/lang/solidity/README.org b/modules/lang/solidity/README.org index b407c498f..69214de12 100644 --- a/modules/lang/solidity/README.org +++ b/modules/lang/solidity/README.org @@ -4,28 +4,44 @@ This module adds [[https://github.com/ethereum/solidity][Solidity]] support thro + Syntax-checking (~flycheck~) + Code completion (~[[https://github.com/ssmolkin1/company-solidity][company-solidity]]~) -+ Gas estimation(~C-c C-g~) - -* Install -There are two options for linters. ++ Gas estimation (~C-c C-g~) -** [[https://github.com/ethereum/solc-js][Solc]] +* Table of Contents :TOC: +- [[Module Flags][Module Flags]] +- [[Prerequisites][Prerequisites]] + - [[Solc][Solc]] + - [[Solium][Solium]] +- [[TODO][TODO]] + +* Module Flags +This module provides no flags. + +* Prerequisites +This module requires one or both linters for syntax checking: + ++ [[https://github.com/ethereum/solc-js][Solc]] ++ [[http://solium.readthedocs.io/en/latest/user-guide.html#installation][Solium]] + +If both are enabled *Solc* is run first, then *Solium* if *Solc* catches no +errors. + +** Solc #+BEGIN_SRC sh npm install -g solc #+END_SRC -** [[http://solium.readthedocs.io/en/latest/user-guide.html#installation][Solium]] +** Solium #+BEGIN_SRC sh npm install -g solium #+END_SRC -By default *solium* looks for ~.soliumrc.json~ in the project directory, but you can set it to your own ~.soliumrc.json~ with this in your private doom ~config.el~ +By default *solium* looks for ~.soliumrc.json~ in the project directory, but you +can set it to your own ~.soliumrc.json~ with this in your private doom +~config.el~ #+BEGIN_SRC emacs-lisp -(setq flycheck-solidity-solium-soliumrcfile "/$HOME/.soliumrc.json") +(setq flycheck-solidity-solium-soliumrcfile "~/.soliumrc.json") #+END_SRC -They can be chained together so it's recommended you use both. *Solc* is ran first, and then *Solium* if *Solc* doesn't catch any errors. - * TODO + Snippets