Skip to content

Commit 1a5801b

Browse files
committed
Merge pull request #34 from elixir-lang/match-function-definitions
Basic matching for function definitions
2 parents 6146b07 + 9cae73d commit 1a5801b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

grammars/elixir.cson

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@
6161
'name': 'keyword.other.special-method.elixir'
6262
}
6363
{
64-
'match': '(?<!\\.)\\b(do|end|case|bc|lc|for|if|cond|with|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|quote|unquote|super|when)\\b(?![?!])'
64+
'match': '(?<!\\.)\\b(do|end|case|bc|lc|for|if|cond|with|unless|try|receive|fn|defmodule|defprotocol|defimpl|defrecord|defstruct|defdelegate|defcallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|quote|unquote|super|when)\\b(?![?!])'
6565
'name': 'keyword.control.elixir'
6666
}
67+
{
68+
'comment': 'functions and arguments'
69+
'match': '\\b(defp?|defmacrop?)\\b\\s*([_$a-zA-Z][$\\w]*[!?]?)?'
70+
'captures': {
71+
'1': { 'name': 'keyword.control.elixir' }
72+
'2': { 'name': 'entity.name.function.elixir' }
73+
}
74+
}
6775
{
6876
'comment': ' as above, just doesn\'t need a \'end\' and does a logic operation'
6977
'match': '(?<!\\.)\\b(and|not|or|when|xor|in|inlist|inbits)\\b'

snippets/language-elixir.cson

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
'body': 'cond do\n\t$0\nend'
88
'def':
99
'prefix': 'def'
10-
'body': 'def $1 do\n\t$0\nend'
10+
'body': 'def ${1:function_name} do\n\t$0\nend'
11+
'defp':
12+
'prefix': 'defp'
13+
'body': 'defp ${1:function_name} do\n\t$0\nend'
1114
'defmacro':
1215
'prefix': 'defmacro'
13-
'body': 'defmacro $1 do\n\t$0\nend'
16+
'body': 'defmacro ${1:macro_name} do\n\t$0\nend'
1417
'defmacrop':
1518
'prefix': 'defmacrop'
16-
'body': 'defmacrop $1 do\n\t$0\nend'
19+
'body': 'defmacrop ${1:macro_name} do\n\t$0\nend'
1720
'defmodule':
1821
'prefix': 'defmodule'
1922
'body': 'defmodule $1 do\n\t$0\nend'
2023
'defstruct':
2124
'prefix': 'defstruct'
2225
'body': 'defstruct [$1]'
23-
'defp':
24-
'prefix': 'defp'
25-
'body': 'defp $1 do\n\t$0\nend'
2626
'do':
2727
'prefix': 'do'
2828
'body': 'do\n\t$0\nend'

0 commit comments

Comments
 (0)