Skip to content

Commit

Permalink
Merge pull request #34 from elixir-lang/match-function-definitions
Browse files Browse the repository at this point in the history
Basic matching for function definitions
  • Loading branch information
keathley committed Feb 8, 2016
2 parents 6146b07 + 9cae73d commit 1a5801b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 9 additions & 1 deletion grammars/elixir.cson
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@
'name': 'keyword.other.special-method.elixir'
}
{
'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(?![?!])'
'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(?![?!])'
'name': 'keyword.control.elixir'
}
{
'comment': 'functions and arguments'
'match': '\\b(defp?|defmacrop?)\\b\\s*([_$a-zA-Z][$\\w]*[!?]?)?'
'captures': {
'1': { 'name': 'keyword.control.elixir' }
'2': { 'name': 'entity.name.function.elixir' }
}
}
{
'comment': ' as above, just doesn\'t need a \'end\' and does a logic operation'
'match': '(?<!\\.)\\b(and|not|or|when|xor|in|inlist|inbits)\\b'
Expand Down
12 changes: 6 additions & 6 deletions snippets/language-elixir.cson
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
'body': 'cond do\n\t$0\nend'
'def':
'prefix': 'def'
'body': 'def $1 do\n\t$0\nend'
'body': 'def ${1:function_name} do\n\t$0\nend'
'defp':
'prefix': 'defp'
'body': 'defp ${1:function_name} do\n\t$0\nend'
'defmacro':
'prefix': 'defmacro'
'body': 'defmacro $1 do\n\t$0\nend'
'body': 'defmacro ${1:macro_name} do\n\t$0\nend'
'defmacrop':
'prefix': 'defmacrop'
'body': 'defmacrop $1 do\n\t$0\nend'
'body': 'defmacrop ${1:macro_name} do\n\t$0\nend'
'defmodule':
'prefix': 'defmodule'
'body': 'defmodule $1 do\n\t$0\nend'
'defstruct':
'prefix': 'defstruct'
'body': 'defstruct [$1]'
'defp':
'prefix': 'defp'
'body': 'defp $1 do\n\t$0\nend'
'do':
'prefix': 'do'
'body': 'do\n\t$0\nend'
Expand Down

0 comments on commit 1a5801b

Please sign in to comment.