Elixir cleanup + 5 useful snippets (#245)

* removed trailing newline from elixir snippets

* 5 convenience snippets I often use
This commit is contained in:
Wahed Mangal 2018-01-06 22:17:06 +01:00 committed by Andrea Crotti
parent 7fc2b95e2f
commit 2bb3cc1b2e
28 changed files with 55 additions and 23 deletions

View File

@ -0,0 +1,6 @@
## -*- mode: snippet -*-
# name : after
# key: after
# --
after ${1:500} ->
$0

View File

@ -2,4 +2,4 @@
# name: call
# key: call
# --
GenServer.call(${1:__MODULE__}, $0)
GenServer.call(${1:__MODULE__}, $0)

View File

@ -4,4 +4,4 @@
# --
case $1 do
$0
end
end

View File

@ -2,4 +2,4 @@
# name: cast
# key: cast
# --
GenServer.cast(${1:__MODULE__}, $0)
GenServer.cast(${1:__MODULE__}, $0)

View File

@ -4,4 +4,4 @@
# --
cond do
$0
end
end

View File

@ -4,4 +4,4 @@
# --
def ${1:function}${2:(${3:args})} do
$0
end
end

View File

@ -4,4 +4,4 @@
# --
defmacro $1 do
$0
end
end

View File

@ -4,4 +4,4 @@
# --
defmacrop $1 do
$0
end
end

View File

@ -4,4 +4,4 @@
# --
defmodule $1 do
$0
end
end

View File

@ -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

View File

@ -4,4 +4,4 @@
# --
defp $1 do
$0
end
end

View File

@ -4,4 +4,4 @@
# --
do
$0
end
end

View File

@ -4,4 +4,4 @@
# --
@doc """
$0
"""
"""

View File

@ -4,4 +4,4 @@
# --
for ${2:x} <- ${1:enum} do
$2$0
end
end

View File

@ -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

View File

@ -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

View File

@ -5,4 +5,4 @@
def handle_call($1, _from, state) do
reply = $0
{:reply, reply, state}
end
end

View File

@ -5,4 +5,4 @@
def handle_cast($1, state) do
$0
{:noreply, state}
end
end

View File

@ -5,4 +5,4 @@
def handle_info($1, state) do
$0
{:noreply, state}
end
end

View File

@ -4,4 +4,4 @@
# --
if ${1:condition} do
$0
end
end

View File

@ -6,4 +6,4 @@ if ${1:condition} do
$2
else
$3
end
end

View File

@ -2,4 +2,4 @@
# name: io
# key: io
# --
IO.puts("$1")$0
IO.puts("$1")$0

View File

@ -2,4 +2,4 @@
# name: iop
# key: iop
# --
IO.puts("$1 #{inspect $1}")$0
IO.puts("$1 #{inspect $1}")$0

View File

@ -4,4 +4,4 @@
# --
@moduledoc """
$0
"""
"""

View File

@ -3,4 +3,4 @@
# key: pry
# group: debug
# --
require IEx; IEx.pry
require IEx; IEx.pry

View File

@ -0,0 +1,7 @@
## -*- mode: snippet -*-
# name : receive
# key: rcv
# --
receive do
$0
end

View File

@ -4,4 +4,4 @@
# --
test "$1" do
$0
end
end

View File

@ -4,4 +4,4 @@
# --
unless ${1:condition} do
$0
end
end