Created
June 12, 2018 12:26
-
-
Save tom-seddon/bc1aeeaf51f88ab09d22bffb8dc098a8 to your computer and use it in GitHub Desktop.
Scrappy, crappy Solidity mode for Emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun solidity-mode-make-imenu-generic-expression () | |
(let* ((space "[[:space:]]+") | |
(maybe-space "[[:space:]]*") | |
(ident-group "\\([A-Za-z_][A-Za-z0-9_]*\\)") | |
(modifier (mapconcat 'identity | |
'("static" "native" "export" "ephemeral" "pinned" | |
"const" "property" "public" "protected" "private" | |
"abstract" "virtual" "override" "divergent") | |
"\\|")) | |
(modifiers (concat "\\(?:\\(?:" modifier "\\)" space "\\)*"))) | |
`(("function" | |
,(concat "^" maybe-space "function" space ident-group "(") | |
1) | |
("contract" | |
,(concat "^" maybe-space "contract" space ident-group) | |
1) | |
("interface" | |
,(concat "^" maybe-space "interface" space ident-group) | |
1) | |
))) | |
(define-derived-mode solidity-mode | |
java-mode "solidity-mode" | |
"major mode for editing Solidity scripts." | |
;; there isn't much extra on top of c++-mode... | |
;; specific standard policies based on visual studio | |
(c-set-style "stroustrup") | |
(setq indent-tabs-mode t) | |
(setq tab-width 4) | |
;; imenu | |
(setq imenu-generic-expression | |
(solidity-mode-make-imenu-generic-expression)) | |
;; play nice with eassist | |
(setq eassist-force-imenu 't) | |
) | |
(defgroup solidity nil | |
"Major mode for editing Solidity scripts." | |
:prefix "solidity-" | |
:group 'languages) | |
(defvar solidity-load-hook nil | |
"hook for solidity-mode") | |
(run-hooks 'solidity-load-hook) | |
(provide 'solidity-mode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment