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
6
snippets/elixir-mode/after
Normal file
6
snippets/elixir-mode/after
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
## -*- mode: snippet -*-
|
||||||
|
# name : after
|
||||||
|
# key: after
|
||||||
|
# --
|
||||||
|
after ${1:500} ->
|
||||||
|
$0
|
|
@ -2,4 +2,4 @@
|
||||||
# name: call
|
# name: call
|
||||||
# key: call
|
# key: call
|
||||||
# --
|
# --
|
||||||
GenServer.call(${1:__MODULE__}, $0)
|
GenServer.call(${1:__MODULE__}, $0)
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
case $1 do
|
case $1 do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -2,4 +2,4 @@
|
||||||
# name: cast
|
# name: cast
|
||||||
# key: cast
|
# key: cast
|
||||||
# --
|
# --
|
||||||
GenServer.cast(${1:__MODULE__}, $0)
|
GenServer.cast(${1:__MODULE__}, $0)
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
cond do
|
cond do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
def ${1:function}${2:(${3:args})} do
|
def ${1:function}${2:(${3:args})} do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
defmacro $1 do
|
defmacro $1 do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
defmacrop $1 do
|
defmacrop $1 do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
defmodule $1 do
|
defmodule $1 do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
7
snippets/elixir-mode/defmodule_filename
Normal file
7
snippets/elixir-mode/defmodule_filename
Normal 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
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
defp $1 do
|
defp $1 do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
do
|
do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
@doc """
|
@doc """
|
||||||
$0
|
$0
|
||||||
"""
|
"""
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
for ${2:x} <- ${1:enum} do
|
for ${2:x} <- ${1:enum} do
|
||||||
$2$0
|
$2$0
|
||||||
end
|
end
|
7
snippets/elixir-mode/function
Normal file
7
snippets/elixir-mode/function
Normal 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
|
5
snippets/elixir-mode/function-one-line
Normal file
5
snippets/elixir-mode/function-one-line
Normal 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
|
|
@ -5,4 +5,4 @@
|
||||||
def handle_call($1, _from, state) do
|
def handle_call($1, _from, state) do
|
||||||
reply = $0
|
reply = $0
|
||||||
{:reply, reply, state}
|
{:reply, reply, state}
|
||||||
end
|
end
|
|
@ -5,4 +5,4 @@
|
||||||
def handle_cast($1, state) do
|
def handle_cast($1, state) do
|
||||||
$0
|
$0
|
||||||
{:noreply, state}
|
{:noreply, state}
|
||||||
end
|
end
|
|
@ -5,4 +5,4 @@
|
||||||
def handle_info($1, state) do
|
def handle_info($1, state) do
|
||||||
$0
|
$0
|
||||||
{:noreply, state}
|
{:noreply, state}
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
if ${1:condition} do
|
if ${1:condition} do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -6,4 +6,4 @@ if ${1:condition} do
|
||||||
$2
|
$2
|
||||||
else
|
else
|
||||||
$3
|
$3
|
||||||
end
|
end
|
|
@ -2,4 +2,4 @@
|
||||||
# name: io
|
# name: io
|
||||||
# key: io
|
# key: io
|
||||||
# --
|
# --
|
||||||
IO.puts("$1")$0
|
IO.puts("$1")$0
|
|
@ -2,4 +2,4 @@
|
||||||
# name: iop
|
# name: iop
|
||||||
# key: iop
|
# key: iop
|
||||||
# --
|
# --
|
||||||
IO.puts("$1 #{inspect $1}")$0
|
IO.puts("$1 #{inspect $1}")$0
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
$0
|
$0
|
||||||
"""
|
"""
|
|
@ -3,4 +3,4 @@
|
||||||
# key: pry
|
# key: pry
|
||||||
# group: debug
|
# group: debug
|
||||||
# --
|
# --
|
||||||
require IEx; IEx.pry
|
require IEx; IEx.pry
|
7
snippets/elixir-mode/receive
Normal file
7
snippets/elixir-mode/receive
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
## -*- mode: snippet -*-
|
||||||
|
# name : receive
|
||||||
|
# key: rcv
|
||||||
|
# --
|
||||||
|
receive do
|
||||||
|
$0
|
||||||
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
test "$1" do
|
test "$1" do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
|
@ -4,4 +4,4 @@
|
||||||
# --
|
# --
|
||||||
unless ${1:condition} do
|
unless ${1:condition} do
|
||||||
$0
|
$0
|
||||||
end
|
end
|
Loading…
Reference in a new issue