Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.MD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The changelog starts from version 0.1.4 as too much was added in each version be

- payable

- Added support for Imenu

## Version 0.1.9

- Integrated [company-solidity](https://github.com/ssmolkin1/company-solidity) into solidity-mode, providing autocompletion out of the box if the user has [company-mode](http://company-mode.github.io) installed.
Expand Down
22 changes: 22 additions & 0 deletions solidity-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,24 @@ Cursor must be at the function's name. Does not currently work for constructors
(interactive)
(solidity--start-gasestimate (thing-at-point 'symbol 'no-properties)))

;;; Support for imenu
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @atimchenko92. Thank you very much. My colleague @rakanalh who uses Imenu tested it and it works.

I have one request only. Can you add a changelog entry here? Something like:
"Added support for Imenu".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added entry to changelog as well. My pleasure! :)

(defun solidity-mode-imenu-generic-expression ()
(let* ((spacetabs "[\t\n ]+")
(optional-spacetabs "[\t\n ]*")
(ident-group "\\([A-Za-z_][A-Za-z0-9_]*\\)")
(ctr-ident-group "\\(constructor\\)")
(modifier (mapconcat 'identity
'("payable" "public" "private" "external" "internal" "view" "pure")
"\\|"))
(modifiers (concat "\\(?:\\(?:" modifier "\\)" spacetabs "\\)*")))
`(("function", (concat "^" optional-spacetabs "function" spacetabs ident-group) 1)
("modifier", (concat "^" optional-spacetabs "modifier" spacetabs ident-group) 1)
("constructor", (concat "^" optional-spacetabs ctr-ident-group) 1)
("contract", (concat "^" optional-spacetabs "contract" spacetabs ident-group) 1)
("library", (concat "^" optional-spacetabs "library" spacetabs ident-group) 1)
("interface", (concat "^" optional-spacetabs "interface" spacetabs ident-group) 1)
)))

;;;###autoload
(define-derived-mode solidity-mode c-mode "solidity"
"Major mode for editing solidity language buffers."
Expand Down Expand Up @@ -524,6 +542,10 @@ Cursor must be at the function's name. Does not currently work for constructors
(set (make-local-variable 'comment-line-break-function)
'c-indent-new-comment-line)

;; set imenu
(setq imenu-generic-expression
(solidity-mode-imenu-generic-expression))

;; set keymap
(use-local-map solidity-mode-map)
;; set hooks
Expand Down