mirror of
https://github.com/amix/vimrc
synced 2024-12-24 19:03:07 +00:00
297 lines
5 KiB
Text
297 lines
5 KiB
Text
snippet do
|
|
do
|
|
${0:${VISUAL}}
|
|
end
|
|
snippet put IO.puts
|
|
IO.puts("${0}")
|
|
snippet ins IO.inspect
|
|
IO.inspect(${0})
|
|
snippet insl IO.inspect with label
|
|
IO.inspect(${0}label: "${1:label}")
|
|
snippet if if .. do .. end
|
|
if ${1} do
|
|
${0:${VISUAL}}
|
|
end
|
|
snippet if: if .. do: ..
|
|
if $1, do: ${0}
|
|
snippet ife if .. do .. else .. end
|
|
if $1 do
|
|
${2:${VISUAL}}
|
|
else
|
|
${0}
|
|
end
|
|
snippet ife: if .. do: .. else:
|
|
if $1, do: ${2}, else: ${0}
|
|
snippet unless unless .. do .. end
|
|
unless ${1} do
|
|
${0:${VISUAL}}
|
|
end
|
|
snippet unless: unless .. do: ..
|
|
unless $1, do: ${0}
|
|
snippet unlesse unless .. do .. else .. end
|
|
unless $1 do
|
|
${2:${VISUAL}}
|
|
else
|
|
${0}
|
|
end
|
|
snippet unlesse: unless .. do: .. else:
|
|
unless $1, do: ${2}, else: ${0}
|
|
snippet cond
|
|
cond do
|
|
${1} ->
|
|
${0:${VISUAL}}
|
|
end
|
|
snippet case
|
|
case ${1} do
|
|
${2} ->
|
|
${0}
|
|
end
|
|
snippet for
|
|
for ${1:item} <- ${2:items} do
|
|
${0}
|
|
end
|
|
snippet for:
|
|
for ${1:item} <- ${2:items}, do: ${0}
|
|
snippet fori
|
|
for ${1:item} <- ${2:items}, into: ${3} do
|
|
${0}
|
|
end
|
|
snippet wi
|
|
with ${1:item} <- ${2:items} do
|
|
${0}
|
|
end
|
|
snippet wie
|
|
with(
|
|
${1:item} <- ${2:items}
|
|
) do
|
|
${3}
|
|
else
|
|
${4} ->
|
|
${0}
|
|
end
|
|
snippet sp
|
|
@spec ${1:name}(${2:args}) :: ${3:returns}
|
|
snippet op
|
|
@opaque ${1:type_name} :: ${2:type}
|
|
snippet ty
|
|
@type ${1:type_name} :: ${2:type}
|
|
snippet typ
|
|
@typep ${1:type_name} :: ${2:type}
|
|
snippet cb
|
|
@callback ${1:name}(${2:args}) :: ${3:returns}
|
|
snippet df
|
|
def ${1:name}, do: ${2}
|
|
snippet dfw
|
|
def ${1:name}(${2:args}) when ${3:guard}, do:
|
|
snippet def
|
|
def ${1:name} do
|
|
${0}
|
|
end
|
|
snippet defd
|
|
@doc """
|
|
${1:doc string}
|
|
"""
|
|
def ${2:name} do
|
|
${0}
|
|
end
|
|
snippet defs
|
|
@spec ${1:name}(${2:arg types}) :: ${3:no_return}
|
|
def $1(${4:args}) do
|
|
${0}
|
|
end
|
|
snippet defsd
|
|
@doc """
|
|
${1:doc string}
|
|
"""
|
|
@spec ${2:name}(${3:arg types}) :: ${4:no_return}
|
|
def $2(${5:args}) do
|
|
${0}
|
|
end
|
|
snippet defw
|
|
def ${1:name}(${2:args}) when ${3:guard} do
|
|
${0}
|
|
end
|
|
snippet defim
|
|
defimpl ${1:protocol_name}, for: ${2:data_type} do
|
|
${0}
|
|
end
|
|
snippet defma
|
|
defmacro ${1:name} do
|
|
${0}
|
|
end
|
|
snippet defmo
|
|
defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do
|
|
${0}
|
|
end
|
|
snippet %M
|
|
%__MODULE__{
|
|
${1:key_name}: ${2:value}
|
|
}
|
|
snippet enfk
|
|
@enforce_keys [:${1:key_name}]
|
|
snippet dfp
|
|
defp ${1:name}, do: ${2}
|
|
snippet dfpw
|
|
defp ${1:name}(${2:args}) when ${3:guard}, do: ${4}
|
|
snippet defp
|
|
defp ${1:name} do
|
|
${0}
|
|
end
|
|
snippet defpw
|
|
defp ${1:name}(${2:args}) when ${3:guard} do
|
|
${0}
|
|
end
|
|
snippet defpr
|
|
defprotocol ${1:name}, [${0:function}]
|
|
snippet defr
|
|
defrecord ${1:record_name}, ${0:fields}
|
|
snippet doc
|
|
@doc """
|
|
${0}
|
|
"""
|
|
snippet docs
|
|
@doc ~S"""
|
|
${0}
|
|
"""
|
|
snippet docf
|
|
@doc false
|
|
snippet im
|
|
@impl true
|
|
snippet fn
|
|
fn ${1:args} -> ${0} end
|
|
snippet mdoc
|
|
@moduledoc """
|
|
${0}
|
|
"""
|
|
snippet mdocs
|
|
@moduledoc ~S"""
|
|
${0}
|
|
"""
|
|
snippet mdocf
|
|
@moduledoc false
|
|
snippet rec
|
|
receive do
|
|
${1} ->
|
|
${0}
|
|
end
|
|
snippet req
|
|
require ${0:Logger}
|
|
snippet imp
|
|
import ${0:module_name}
|
|
snippet ali
|
|
alias ${0:module_name}
|
|
snippet test
|
|
test "${1:test name}" do
|
|
${0}
|
|
end
|
|
snippet testc
|
|
test "${1:test_name}", ctx do
|
|
${0}
|
|
end
|
|
snippet testa
|
|
test "${1:test_name}", %{${2:arg: arg}} do
|
|
${0}
|
|
end
|
|
snippet des
|
|
describe "${1:test group subject}" do
|
|
${0}
|
|
end
|
|
snippet destag
|
|
@describetag :${1:describe tag}
|
|
snippet mtag
|
|
@moduletag :${1:module tag}
|
|
snippet dt
|
|
doctest ${1:filename}
|
|
snippet tp
|
|
@tag :pending
|
|
snippet exunit
|
|
defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do
|
|
use ExUnit.Case, async: true
|
|
|
|
${0}
|
|
end
|
|
snippet setup
|
|
setup do
|
|
${1}
|
|
end
|
|
snippet setupa
|
|
setup_all do
|
|
${1}
|
|
end
|
|
snippet try try .. rescue .. end
|
|
try do
|
|
${1:${VISUAL}}
|
|
rescue
|
|
${2} -> ${0}
|
|
end
|
|
snippet pry
|
|
require IEx; IEx.pry
|
|
${0}
|
|
snippet ppry
|
|
|> (fn x -> require IEx; IEx.pry; x end).()${0}
|
|
snippet qu
|
|
quote do
|
|
${1}
|
|
end
|
|
snippet beh
|
|
@behaviour ${1:Mix.Task}
|
|
${0}
|
|
snippet p
|
|
|> ${0}
|
|
snippet >e pipe to each
|
|
|> Enum.each(fn ${1} -> ${0} end)
|
|
snippet >m pipe to map
|
|
|> Enum.map(fn ${1} -> ${0} end)
|
|
snippet >f pipe to filter
|
|
|> Enum.filter(fn ${1} -> ${0} end)
|
|
snippet >r pipe to reduce
|
|
|> Enum.reduce(${1:acc}, fn ${2}, ${3:acc} -> ${0} end)
|
|
snippet >i pipe to inspect
|
|
|> IO.inspect()
|
|
snippet >il pipe to inspect with label
|
|
|> IO.inspect(label: "${1:label}")
|
|
snippet cs
|
|
@doc false
|
|
def child_spec(${1:_opts}) do
|
|
%{
|
|
id: __MODULE__,
|
|
start: {__MODULE__, :start_link, ${2:[]}},
|
|
restart: ${3::permanent},
|
|
shutdown: ${4:5000},
|
|
type: ${5::worker}
|
|
}
|
|
end
|
|
snippet genserver basic genserver structure
|
|
use GenServer
|
|
|
|
@doc false
|
|
def start_link(init_args) do
|
|
GenServer.start_link(__MODULE__, init_args, name: __MODULE__)
|
|
end
|
|
|
|
@impl true
|
|
def init(state) do
|
|
{:ok, state}
|
|
end
|
|
snippet super basic supervisor structure
|
|
use Supervisor
|
|
|
|
@doc false
|
|
def start_link(init_args) do
|
|
Supervisor.start_link(__MODULE__, init_args, name: __MODULE__)
|
|
end
|
|
|
|
@impl true
|
|
def init(_init_args) do
|
|
children = [${1}]
|
|
Supervisor.init(children, strategy: :one_for_one)
|
|
end
|
|
snippet impl
|
|
@impl true
|
|
def ${1:name} do
|
|
${0}
|
|
end
|
|
snippet wl word list
|
|
~w(${0})
|
|
snippet al atom list
|
|
~w(${0})a
|