1
1
; ;; solidity-mode.el --- Major mode for ethereum's solidity language
2
2
3
- ; ; Copyright (C) 2015 Lefteris Karapetsas
3
+ ; ; Copyright (C) 2015-2018 Lefteris Karapetsas
4
4
5
5
; ; Author: Lefteris Karapetsas <[email protected] >
6
6
; ; Keywords: languages
7
- ; ; Version: 0.1.2
7
+ ; ; Version: 0.1.3
8
8
9
9
; ; This program is free software; you can redistribute it and/or modify
10
10
; ; it under the terms of the GNU General Public License as published by
49
49
:type 'string
50
50
:package-version '(solidity . " 0.1.1" ))
51
51
52
- (defcustom solidity-solc-extra-args " "
53
- " Extra arguments to add to pass to the solidity compiler."
54
- :group 'solidity
55
- :type 'string
56
- :package-version '(solidity . " 0.1.2" ))
57
-
58
52
(defvar solidity-mode-map
59
53
(let ((map (make-keymap )))
60
54
(define-key map " \C -j" 'newline-and-indent )
63
57
64
58
(defvar solidity-checker t " The solidity flycheck syntax checker." )
65
59
(defvar solidity-mode t " The solidity major mode." )
66
- (defvar flycheck-solidity-executable t " The solc executable used by flycheck." )
67
60
68
61
;;;### autoload
69
62
(add-to-list 'auto-mode-alist '(" \\ .sol\\ '" . solidity-mode))
@@ -451,13 +444,27 @@ Highlight the 1st result."
451
444
452
445
; ;; --- interface with flycheck if existing ---
453
446
(when (eval-when-compile (require 'flycheck nil 'noerror ))
447
+ ; ; Avoid reference to free variable warnings
448
+ (defvar flycheck-solidity-checker-executable )
449
+
450
+ (flycheck-def-option-var flycheck-solidity-addstd-contracts nil solidity-checker
451
+ " Whether to add standard solidity contracts.
452
+
453
+ When non-nil, enable add also standard solidity contracts via
454
+ `--add-std' ."
455
+ :type 'boolean
456
+ :safe #'booleanp
457
+ :package-version '(solidity-mode . " 0.1.3" ))
458
+
454
459
; ; add dummy source-inplace definition to avoid errors
455
460
(defvar source-inplace t )
456
461
; ; add a solidity mode callback to set the executable of solc for flycheck
457
462
; ; define solidity's flycheck syntax checker
458
463
(flycheck-define-checker solidity-checker
459
464
" A Solidity syntax checker using the solc compiler"
460
- :command (" /usr/bin/solc" source-inplace)
465
+ :command (" solc"
466
+ (option-flag " --add-std" flycheck-solidity-addstd-contracts)
467
+ source-inplace)
461
468
:error-patterns
462
469
((error line-start (file-name) " :" line " :" column " :" " Error: " (message ))
463
470
(error line-start " Error: " (message ))
@@ -467,7 +474,7 @@ Highlight the 1st result."
467
474
(add-to-list 'flycheck-checkers 'solidity-checker )
468
475
(add-hook 'solidity-mode-hook
469
476
(lambda ()
470
- (let ((solidity-command (concat solidity-solc-path " " solidity-solc-extra-args )))
477
+ (let ((solidity-command (concat solidity-solc-path)))
471
478
(setq flycheck-solidity-checker-executable solidity-command)))))
472
479
473
480
(provide 'solidity-mode )
0 commit comments