Elixir cleanup + 5 useful snippets (#245)
* removed trailing newline from elixir snippets * 5 convenience snippets I often use
This commit is contained in:
parent
7fc2b95e2f
commit
2bb3cc1b2e
|
@ -0,0 +1,6 @@
|
|||
## -*- mode: snippet -*-
|
||||
# name : after
|
||||
# key: after
|
||||
# --
|
||||
after ${1:500} ->
|
||||
$0
|
|
@ -2,4 +2,4 @@
|
|||
# name: call
|
||||
# key: call
|
||||
# --
|
||||
GenServer.call(${1:__MODULE__}, $0)
|
||||
GenServer.call(${1:__MODULE__}, $0)
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
case $1 do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -2,4 +2,4 @@
|
|||
# name: cast
|
||||
# key: cast
|
||||
# --
|
||||
GenServer.cast(${1:__MODULE__}, $0)
|
||||
GenServer.cast(${1:__MODULE__}, $0)
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
cond do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
def ${1:function}${2:(${3:args})} do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
defmacro $1 do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
defmacrop $1 do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
defmodule $1 do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
## -*- mode: snippet -*-
|
||||
# name : defmodule XXX end
|
||||
# key: dm
|
||||
# --
|
||||
defmodule ${1:`(concat (capitalize (file-name-nondirectory (directory-file-name (file-name-directory buffer-file-name)))) ".")`}${2:`(mapconcat 'capitalize (split-string (file-name-base) "_") "")`} do
|
||||
$0
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
defp $1 do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
@doc """
|
||||
$0
|
||||
"""
|
||||
"""
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
for ${2:x} <- ${1:enum} do
|
||||
$2$0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
## -*- mode: snippet -*-
|
||||
# name : function
|
||||
# key: dfun
|
||||
# --
|
||||
def $1($2)${3:$$(when (and yas-moving-away-p yas-modified-p) (concat " when " yas-text))} do
|
||||
$0
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
## -*- mode: snippet -*-
|
||||
# name : function-one-line
|
||||
# key: df
|
||||
# --
|
||||
def $1($2)${3:$$(when (and yas-moving-away-p yas-modified-p) (concat " when " yas-text))}, do: $0
|
|
@ -5,4 +5,4 @@
|
|||
def handle_call($1, _from, state) do
|
||||
reply = $0
|
||||
{:reply, reply, state}
|
||||
end
|
||||
end
|
|
@ -5,4 +5,4 @@
|
|||
def handle_cast($1, state) do
|
||||
$0
|
||||
{:noreply, state}
|
||||
end
|
||||
end
|
|
@ -5,4 +5,4 @@
|
|||
def handle_info($1, state) do
|
||||
$0
|
||||
{:noreply, state}
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
if ${1:condition} do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -6,4 +6,4 @@ if ${1:condition} do
|
|||
$2
|
||||
else
|
||||
$3
|
||||
end
|
||||
end
|
|
@ -2,4 +2,4 @@
|
|||
# name: io
|
||||
# key: io
|
||||
# --
|
||||
IO.puts("$1")$0
|
||||
IO.puts("$1")$0
|
|
@ -2,4 +2,4 @@
|
|||
# name: iop
|
||||
# key: iop
|
||||
# --
|
||||
IO.puts("$1 #{inspect $1}")$0
|
||||
IO.puts("$1 #{inspect $1}")$0
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
@moduledoc """
|
||||
$0
|
||||
"""
|
||||
"""
|
|
@ -3,4 +3,4 @@
|
|||
# key: pry
|
||||
# group: debug
|
||||
# --
|
||||
require IEx; IEx.pry
|
||||
require IEx; IEx.pry
|
|
@ -0,0 +1,7 @@
|
|||
## -*- mode: snippet -*-
|
||||
# name : receive
|
||||
# key: rcv
|
||||
# --
|
||||
receive do
|
||||
$0
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
test "$1" do
|
||||
$0
|
||||
end
|
||||
end
|
|
@ -4,4 +4,4 @@
|
|||
# --
|
||||
unless ${1:condition} do
|
||||
$0
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue