Skip to content

Commit e8bc634

Browse files
committed
Fix problematic fontization of some builtin types
Fixes #11 `uintXX` and `bytesXX`, like `uint256` should always have the same font colour now. If a variable has a keyword as part of its name it should not have two colours anymore during fontization. Example of problematic variable: `blocked`
1 parent c738988 commit e8bc634

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

solidity-mode.el

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
(add-to-list 'auto-mode-alist '("\\.sol\\'" . solidity-mode))
6464

6565
(defun solidity-filter (condp lst)
66+
"A simple version of a list filter. Depending on CONDP filter LST."
6667
(delq nil
6768
(mapcar (lambda (x) (and (funcall condp x) x)) lst)))
6869

@@ -242,13 +243,15 @@
242243
"uint248"
243244
"uint256"
244245

245-
"msg"
246-
"block"
247-
"tx"
248-
249246
"ureal")
250247
"Built in data types of the solidity language.")
251248

249+
(defconst solidity-builtin-constructs
250+
'("msg"
251+
"block"
252+
"tx")
253+
"Built in constructs of the solidity language.")
254+
252255
(defvar solidity-identifier-regexp
253256
"\\([a-zA-z0-9]\\|_\\)+")
254257

@@ -270,6 +273,8 @@
270273
(defconst solidity-font-lock-keywords
271274
(list
272275
`(,(regexp-opt solidity-tofontify-keywords 'words) . font-lock-keyword-face)
276+
`(,(regexp-opt solidity-builtin-types 'words) . font-lock-type-face)
277+
`(,(regexp-opt solidity-builtin-constructs 'words) . font-lock-builtin-face)
273278
'(solidity-match-functions (1 font-lock-type-face)
274279
(2 font-lock-function-name-face))
275280
'(solidity-match-mappings (1 font-lock-type-face)
@@ -288,8 +293,7 @@
288293
(2 font-lock-variable-name-face))
289294
'(solidity-match-variable-decls (1 font-lock-keyword-face)
290295
(2 font-lock-variable-name-face))
291-
`(,(regexp-opt solidity-constants 'words) . font-lock-constant-face)
292-
`(,(regexp-opt solidity-builtin-types 'words) . font-lock-builtin-face))
296+
`(,(regexp-opt solidity-constants 'words) . font-lock-constant-face))
293297
"The font lock options for solidity.")
294298

295299
(defun solidity-match-regexp (re limit)

0 commit comments

Comments
 (0)