Skip to content

Commit 867590f

Browse files
committed
Update font-lock keywords for newest elixir.
1 parent ffeb68d commit 867590f

File tree

1 file changed

+75
-32
lines changed

1 file changed

+75
-32
lines changed

elixir-mode.el

Lines changed: 75 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,65 +70,113 @@
7070
:type 'string
7171
:group 'elixir)
7272

73+
(defvar elixir-mode-define-names '(
74+
"def"
75+
"defdelegate"
76+
"defimpl"
77+
"defmacro"
78+
"defmacrop"
79+
"defmodule"
80+
"defoverridable"
81+
"defp"
82+
"defprotocol"
83+
"defrecord"
84+
"destructure")
85+
"Elixir mode def-like keywords.")
7386
(defvar elixir-mode-keyword-names '(
7487
"->"
88+
"bc"
89+
"lc"
90+
"in"
91+
"inbits"
92+
"inlist"
93+
"quote"
94+
"unquote"
95+
"unquote_splicing"
96+
"var"
7597
"do"
7698
"after"
7799
"for"
78-
"defmodule"
79-
"private"
80100
"def"
101+
"defdelegate"
102+
"defimpl"
103+
"defmacro"
104+
"defmacrop"
105+
"defmodule"
106+
"defoverridable"
107+
"defp"
108+
"defprotocol"
109+
"defrecord"
110+
"destructure"
111+
"alias"
112+
"refer"
113+
"require"
114+
"import"
115+
"use"
81116
"if"
117+
"true"
118+
"false"
82119
"when"
83120
"case"
84-
"match"
121+
"cond"
122+
"throw"
85123
"then"
86124
"else"
87125
"elsif"
88126
"try"
89127
"catch"
128+
"rescue"
129+
"fn"
130+
"receive"
90131
"end")
91132
"Elixir mode keywords.")
92133
(defvar elixir-mode-module-names '(
93-
"Atom"
94-
"BitString"
134+
"Behavior"
135+
"Binary"
136+
"Bitwise"
137+
"Builtin"
138+
"Elixir"
95139
"Code"
96-
"Date"
97-
"DateTime"
98140
"EEx"
99-
"ETS"
141+
"Enum"
100142
"ExUnit"
143+
"Exception"
101144
"File"
102-
"Float"
145+
"GenServer"
103146
"Function"
104147
"GenServer"
105148
"GenTCP"
106-
"IEX"
107-
"Integer"
149+
"HashDict"
108150
"IO"
151+
"Keyword"
109152
"List"
110153
"Math"
111-
"Method"
112154
"Module"
113-
"Numeric"
114-
"OrderedDict"
115-
"OS"
155+
"Node"
156+
"OptrionParser"
157+
"OrdDict"
116158
"Port"
117159
"Process"
118160
"Record"
119-
"Reference"
120161
"Regexp"
121-
"Set"
122-
"String"
123-
"Timer"
162+
"System"
124163
"Tuple"
164+
"URI"
125165
"UnboundMethod")
126166
"Elixir mode modules.")
127167
(defvar elixir-mode-builtin-names '(
128-
"Erlang")
168+
"Erlang"
169+
"__MODULE__"
170+
"__FUNCTION__"
171+
"__LINE__"
172+
"__FILE__"
173+
"__LOCAL__"
174+
)
129175
"Elixir mode builtins.")
130176
(defvar elixir-mode-operator-names '(
131177
"+"
178+
"++"
179+
"<>"
132180
"-"
133181
"/"
134182
"*"
@@ -156,6 +204,9 @@
156204
":="
157205
"<-")
158206
"Elixir mode operators.")
207+
(defvar elixir-basic-offset 2)
208+
(defvar elixir-key-label-offset 0)
209+
(defvar elixir-match-label-offset 2)
159210

160211
(defvar font-lock-operator-face 'font-lock-operator-face)
161212
(defface font-lock-operator-face
@@ -166,27 +217,19 @@
166217
"For use with operators."
167218
:group 'font-lock-faces)
168219

169-
(defvar font-lock-atom-face 'default)
170-
(defface font-lock-operator-face
171-
'((((type tty) (class color)) nil)
172-
(((class color) (background light))
173-
(:foreground "magenta"))
174-
(t nil))
175-
"For use with atoms."
176-
:group 'font-lock-faces)
177-
178220
(defconst elixir-mode-font-lock-defaults
179221
(list
180222
'("#.*$" . font-lock-comment-face) ; comments
181-
'("^\\<def\\s_+\\([^( \t\n]+\\)" . font-lock-function-name-face) ; methods
223+
`(,(concat "^\\s *\\<" (regexp-opt elixir-mode-define-names t) "\\>\\s +\\([^( \t\n]+\\)") 2 font-lock-function-name-face) ; methods
182224
`(,(concat "\\<" (regexp-opt elixir-mode-keyword-names t) "\\>") . font-lock-keyword-face) ; keywords
183225
`(,(concat "\\<" (regexp-opt elixir-mode-builtin-names t) "\\>") . font-lock-builtin-face) ; builtins
184226
`(,(concat "\\<" (regexp-opt elixir-mode-module-names t) "\\>") . font-lock-type-face) ; core modules
185227
(when elixir-mode-highlight-operators `(,(concat "\\<" (regexp-opt elixir-mode-operator-names t) "\\>") . font-lock-operator-face)) ; operators
186228
'("\\(\\w*\\)\\s-*:?=" . font-lock-variable-name-face) ; variables
187229
'("-[Rr].*[ \n\t]" . font-lock-constant-face) ; regexes
188-
'("\\<\\(true\\|false\\|nil\\)\\>" . font-lock-atom-face) ; atoms, boolean
189-
'("'\\w*" . font-lock-atom-face)) ; atoms, generic
230+
'("\\<\\(true\\|false\\|nil\\)\\>" . font-lock-reference-face) ; atoms, boolean
231+
'("\\w*:\s" . font-lock-reference-face)
232+
'(":\\w*" . font-lock-reference-face)) ; atoms, generic
190233
"Highlighting for Elixir mode.")
191234

192235
(defun elixir-mode-cygwin-path (expanded-file-name)

0 commit comments

Comments
 (0)