mise++
This commit is contained in:
parent
6471e799a8
commit
931e9d4aee
93 changed files with 6881 additions and 8 deletions
|
@ -0,0 +1,89 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting anonymous functions' do
|
||||
i <<~EOF
|
||||
def do
|
||||
some_func = fn x -> x end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def do
|
||||
some_func = function do x -> x end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
assert_raise Queue.Empty, fn ->
|
||||
Q.new |> Q.deq!
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Test do
|
||||
def lol do
|
||||
Enum.map([1,2,3], fn x ->
|
||||
x * 3
|
||||
end)
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
fizzbuzz = fn
|
||||
0, 0, _ -> "FizzBuzz"
|
||||
0, _, _ -> "Fizz"
|
||||
_, 0, _ -> "Buzz"
|
||||
_, _, x -> x
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
fizzbuzz = function do
|
||||
0, 0, _ -> "FizzBuzz"
|
||||
0, _, _ -> "Fizz"
|
||||
_, 0, _ -> "Buzz"
|
||||
_, _, x -> x
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
{:ok, 0} = Mod.exec!(cmd, fn progress ->
|
||||
if event_handler do
|
||||
event_handler.({:progress_updated, progress})
|
||||
end
|
||||
end
|
||||
)
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defp handle_chunk(:err, line, state) do
|
||||
update_in(state[:stderr], fn
|
||||
true -> true
|
||||
false -> false
|
||||
end)
|
||||
|
||||
Map.update(state, :stderr, [line], &(&1 ++ [line]))
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defp handle_chunk(:err, line, state) do
|
||||
update_in(state[:stderr], fn
|
||||
hello -> :ok
|
||||
world -> :ok
|
||||
end)
|
||||
|
||||
Map.update(state, :stderr, [line], &(&1 ++ [line]))
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
fn ->
|
||||
end
|
||||
EOF
|
||||
end
|
569
vim/plugins/vim-elixir-master/spec/indent/basic_spec.rb
Normal file
569
vim/plugins/vim-elixir-master/spec/indent/basic_spec.rb
Normal file
|
@ -0,0 +1,569 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Basic indenting' do
|
||||
i <<~EOF
|
||||
|
||||
defmodule Hello do
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def some_func do
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def some_func do
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def some_func do
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
def some_other_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
|
||||
def some_other_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
|
||||
def some_other_func do
|
||||
IO.puts "hello world"
|
||||
IO.puts "hello world"
|
||||
IO.puts "hello world"
|
||||
IO.puts "hello world"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
|
||||
def some_other_func do
|
||||
if blah? do
|
||||
blah
|
||||
else
|
||||
not_blah
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
|
||||
def some_other_func do
|
||||
if blah? do
|
||||
blah
|
||||
else
|
||||
not_blah
|
||||
end
|
||||
if blah? do
|
||||
blah
|
||||
else
|
||||
not_blah
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
IO.puts "hello world"
|
||||
end
|
||||
|
||||
def some_other_func do
|
||||
if blah? do
|
||||
blah
|
||||
if blah? do
|
||||
blah
|
||||
else
|
||||
not_blah
|
||||
end
|
||||
else
|
||||
not_blah
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
cond do
|
||||
{:abc} -> false
|
||||
_ -> true
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
cond do
|
||||
{:abc} -> false
|
||||
|
||||
_ -> true
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
cond do
|
||||
{:abc} ->
|
||||
say_hello
|
||||
say_goodbye
|
||||
|
||||
_ ->
|
||||
say_hello
|
||||
say_goodbye
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello.World do
|
||||
def some_func do
|
||||
cond do
|
||||
{:abc} ->
|
||||
cond do
|
||||
{:abc} ->
|
||||
say_hello
|
||||
say_goodbye
|
||||
_ ->
|
||||
say_hello
|
||||
say_goodbye
|
||||
end
|
||||
say_hello
|
||||
say_goodbye
|
||||
|
||||
_ ->
|
||||
say_hello
|
||||
say_goodbye
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
case word do
|
||||
:one -> :two
|
||||
:high -> :low
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
case word do
|
||||
:one -> :two
|
||||
|
||||
:high -> :low
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
case word do
|
||||
:one ->
|
||||
:two
|
||||
|
||||
:high ->
|
||||
:low
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
case word do
|
||||
:one ->
|
||||
case word do
|
||||
:one ->
|
||||
:two
|
||||
|
||||
:high ->
|
||||
:low
|
||||
end
|
||||
:two
|
||||
|
||||
:high ->
|
||||
:low
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
defmacro hello do
|
||||
quote do
|
||||
blah
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
unless blah do
|
||||
blah
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
if stinky?, do: clean
|
||||
if smelly?, do: clean
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
name =
|
||||
"one"
|
||||
street =
|
||||
"two"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
%w(= == === != !== <= >= <> && || + - * / ~~~ ^^^ <<< >>> ||| &&&).each do |bin_op|
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
name #{bin_op}
|
||||
"one"
|
||||
street #{bin_op}
|
||||
"two"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
name #{bin_op} "one"
|
||||
street #{bin_op} "two"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
def hi do
|
||||
fn hello ->
|
||||
:world
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
name = "one"
|
||||
street = "two"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
def hi do
|
||||
fn hello -> :world end
|
||||
fn hello -> :world end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
def hi do
|
||||
fn hello ->
|
||||
case hello do
|
||||
:one ->
|
||||
case word do
|
||||
:one ->
|
||||
:two
|
||||
|
||||
:high ->
|
||||
:low
|
||||
end
|
||||
:two
|
||||
|
||||
:high ->
|
||||
:low
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
hello =
|
||||
"str"
|
||||
|> Pipe.do_stuff
|
||||
|> Pipe.do_stuff
|
||||
|
||||
|> Pipe.do_stuff
|
||||
|> Pipe.do_stuff(fn ->
|
||||
more stuff
|
||||
end)
|
||||
|
||||
|> Pipe.do_stuff
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
:hello
|
||||
end
|
||||
|
||||
defp hi do
|
||||
:hello
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
[
|
||||
:one,
|
||||
:two,
|
||||
fn ->
|
||||
:three
|
||||
end,
|
||||
:four
|
||||
]
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
{
|
||||
:one,
|
||||
:two,
|
||||
fn ->
|
||||
:three
|
||||
end,
|
||||
:four
|
||||
}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
%Struct{
|
||||
:one,
|
||||
:two,
|
||||
fn ->
|
||||
:three
|
||||
end,
|
||||
:four
|
||||
}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
%{
|
||||
:one,
|
||||
:two,
|
||||
fn ->
|
||||
:three
|
||||
end,
|
||||
:four
|
||||
}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
try do
|
||||
raise "boom"
|
||||
rescue
|
||||
e in errs ->
|
||||
IO.puts "one"
|
||||
|
||||
_ ->
|
||||
IO.puts "one"
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
try do
|
||||
raise "wtf"
|
||||
catch
|
||||
e ->
|
||||
IO.puts "one"
|
||||
|
||||
_ ->
|
||||
IO.puts "one"
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
receive do
|
||||
{:hello, world} ->
|
||||
:ok
|
||||
after
|
||||
1000 ->
|
||||
IO.puts "one"
|
||||
|
||||
2000 ->
|
||||
IO.puts "one"
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
receive do
|
||||
{:hello, world} ->
|
||||
:ok
|
||||
|
||||
_ ->
|
||||
:err
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
fn
|
||||
:ok ->
|
||||
IO.puts :ok
|
||||
_ ->
|
||||
IO.puts :err
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
defp hi do
|
||||
fn
|
||||
:ok -> IO.puts :ok
|
||||
_ -> IO.puts :err
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
fun2 = fn :foo ->
|
||||
:bar
|
||||
'end'
|
||||
end
|
||||
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
fun2 = fn :foo ->
|
||||
:bar
|
||||
'end'
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
fun3 = fn :foo ->
|
||||
:bar
|
||||
:send
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hi do
|
||||
def hello_world do
|
||||
"end"
|
||||
'end'
|
||||
end
|
||||
EOF
|
||||
end
|
|
@ -0,0 +1,60 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Binary operators' do
|
||||
i <<~EOF
|
||||
word =
|
||||
"h"
|
||||
<> "e"
|
||||
<> "l"
|
||||
<> "l"
|
||||
<> "o"
|
||||
|
||||
IO.puts word
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def hello do
|
||||
expected = "hello"
|
||||
<> "world"
|
||||
IO.puts expected
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def hello do
|
||||
expected =
|
||||
"hello"
|
||||
<> "world"
|
||||
IO.puts expected
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
alias Rumbl.Repo
|
||||
alias Rumbl.Category
|
||||
|
||||
for category <- ~w(Action Drama Romance Comedy Sci-fi) do
|
||||
Repo.get_by(Category, name: category) ||
|
||||
Repo.insert!(%Category{name: category})
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
data = [
|
||||
"blah",
|
||||
"blah2", # *
|
||||
"blah3"
|
||||
]
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
data = [
|
||||
"blah",
|
||||
# +
|
||||
"blah2",
|
||||
"blah3"
|
||||
]
|
||||
EOF
|
||||
end
|
109
vim/plugins/vim-elixir-master/spec/indent/blocks_spec.rb
Normal file
109
vim/plugins/vim-elixir-master/spec/indent/blocks_spec.rb
Normal file
|
@ -0,0 +1,109 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting blocks' do
|
||||
i <<~EOF
|
||||
do
|
||||
something
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Test do
|
||||
def lol do
|
||||
IO.inspect :end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def name, do: IO.puts "bobmarley"
|
||||
# expect next line starting here
|
||||
|
||||
def name(param) do
|
||||
param
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def name, do: IO.puts "bobmarley"
|
||||
|
||||
def name(param) do
|
||||
param
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def f do
|
||||
if true, do: 42
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def f do
|
||||
x = :do
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Test do
|
||||
def test do
|
||||
one =
|
||||
user
|
||||
|> build_assoc(:videos)
|
||||
|> Video.changeset()
|
||||
|
||||
other =
|
||||
user2
|
||||
|> build_assoc(:videos)
|
||||
|> Video.changeset()
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule MyMod do
|
||||
def how_are_you do
|
||||
IO.puts "I'm filling bad :("
|
||||
IO.puts "really bad"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule MyMod do
|
||||
def how_are_you do
|
||||
"function return"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
scope "/", API do
|
||||
pipe_through :api # Use the default browser stack
|
||||
|
||||
get "/url", Controller, :index
|
||||
post "/url", Controller, :create
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def hello do
|
||||
{:ok, _} = TaskRunner.TaskStore.start_link(name: @task_store)
|
||||
{:ok, _} = Workspace.start_link
|
||||
{:ok, pending_task_sup} = TaskRunner.PendingTaskSupervisor.start_link
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def handle_info(:tick, state = %{policy_iteration: []}) do
|
||||
state = put_in(state[:policy_iteration], state.policy)
|
||||
{:noreply, state}
|
||||
end
|
||||
EOF
|
||||
end
|
111
vim/plugins/vim-elixir-master/spec/indent/case_spec.rb
Normal file
111
vim/plugins/vim-elixir-master/spec/indent/case_spec.rb
Normal file
|
@ -0,0 +1,111 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting case statements' do
|
||||
i <<~EOF
|
||||
case some_function do
|
||||
:ok ->
|
||||
:ok
|
||||
{ :error, :message } ->
|
||||
{ :error, :message }
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
case Connection.open(rabbitmq) do
|
||||
{:ok, conn} ->
|
||||
Woody.info "CONNECTION_SUCCESSFUL"
|
||||
{:ok, chan} = Channel.open(conn)
|
||||
{:error, error} ->
|
||||
Woody.info "CONNECTION_FAILED"
|
||||
:timer.sleep(10000)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule M do
|
||||
defp _fetch(result, key, deep_key) do
|
||||
case _fetch(result, key) do
|
||||
{:ok, val} ->
|
||||
case _fetch(val, deep_key) do
|
||||
:error -> {:error, :deep}
|
||||
res -> res
|
||||
end
|
||||
|
||||
:error -> {:error, :shallow}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
case Connection.open(rabbitmq) do
|
||||
{:ok, conn} ->
|
||||
Woody.info "CONNECTION_SUCCESSFUL"
|
||||
{:ok, chan} = Channel.open(conn)
|
||||
{:error, error} ->
|
||||
Woody.info "CONNECTION_FAILED"
|
||||
:timer.sleep(10000)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~'EOF'
|
||||
decoded_msg = case JSON.decode(msg) do
|
||||
{:error, _} ->
|
||||
a = "a"
|
||||
b = "dasdas"
|
||||
">#{a}<>#{b}<"
|
||||
{:ok, decoded} -> decoded
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
case Repo.insert(changeset) do
|
||||
{:ok, user} ->
|
||||
conn
|
||||
|> put_flash(:info, "%{user.name} created!")
|
||||
|> redirect(to: user_path(conn, :index))
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
case st do
|
||||
sym ->
|
||||
code = if true do
|
||||
:ok
|
||||
else
|
||||
:error
|
||||
end
|
||||
Logger.info(code)
|
||||
st
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
case world do
|
||||
"apple" ->
|
||||
IO.puts "its an apple"
|
||||
|
||||
IO.puts "no really, its an apple"
|
||||
"orange" ->
|
||||
IO.puts "its not an apple"
|
||||
IO.puts "believe it or not"
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
case o do
|
||||
a ->
|
||||
e(fn -> f end)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
case pattern do
|
||||
:* -> :ok
|
||||
_ -> :error
|
||||
end
|
||||
EOF
|
||||
end
|
56
vim/plugins/vim-elixir-master/spec/indent/comment_spec.rb
Normal file
56
vim/plugins/vim-elixir-master/spec/indent/comment_spec.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting *after* comments' do
|
||||
i <<~EOF
|
||||
# do
|
||||
IO.puts :test
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Foo do
|
||||
def run do
|
||||
list =
|
||||
File.read!("/path/to/file")
|
||||
|> String.split()
|
||||
# now start a new line
|
||||
# used to start here
|
||||
# but now starts here
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Foo do
|
||||
def run(task) when task in [:t1, :t2] do
|
||||
end
|
||||
|
||||
# now starts a new line
|
||||
# use to start here
|
||||
# but now starts here
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
receive do
|
||||
{{:lock_ready, ^key}, ^pid} ->
|
||||
after
|
||||
# NOTE: @jbodah 2017-03-28: we should do some math to adjust the timeout
|
||||
timeout ->
|
||||
{:error, :timed_out_waiting_for_lock}
|
||||
end
|
||||
EOF
|
||||
|
||||
it "bulk indenting comments" do
|
||||
expect(<<~EOF).to be_elixir_indentation
|
||||
defmodule Test do
|
||||
# SELECT *
|
||||
# FROM table
|
||||
# WHERE column = 123
|
||||
# AND another_column = 456
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
||||
|
12
vim/plugins/vim-elixir-master/spec/indent/cond_spec.rb
Normal file
12
vim/plugins/vim-elixir-master/spec/indent/cond_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting cond statements' do
|
||||
i <<~EOF
|
||||
cond do
|
||||
foo -> 1
|
||||
bar -> 2
|
||||
end
|
||||
EOF
|
||||
end
|
28
vim/plugins/vim-elixir-master/spec/indent/def_spec.rb
Normal file
28
vim/plugins/vim-elixir-master/spec/indent/def_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'def indentation' do
|
||||
i <<~EOF
|
||||
def handle_call({:release_lock, key}, _from, state) do
|
||||
case get_lock(state, key) do
|
||||
nil ->
|
||||
{:reply, {:error, :already_unlocked}, state}
|
||||
|
||||
_ ->
|
||||
new_state = delete_lock(state, key)
|
||||
{:reply, :ok, new_state}
|
||||
end
|
||||
end
|
||||
|
||||
def
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Hello do
|
||||
def hello do
|
||||
end
|
||||
#{"\n" * 40}
|
||||
def world do
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting documentation' do
|
||||
i <<~EOF
|
||||
defmodule Test do
|
||||
@doc """
|
||||
end
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
it "bulk indenting doc blocks" do
|
||||
expect(<<~EOF).to be_elixir_indentation
|
||||
defmodule Test do
|
||||
@doc """
|
||||
do not reindent
|
||||
any indent that i do
|
||||
please
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
i <<~EOF
|
||||
defmodule Test do
|
||||
@doc """
|
||||
it should
|
||||
have reasonable
|
||||
default start indent when typed
|
||||
"""
|
||||
EOF
|
||||
end
|
|
@ -0,0 +1,45 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting Ecto queries' do
|
||||
i <<~EOF
|
||||
defmodule New do
|
||||
def do_query do
|
||||
from user in Users,
|
||||
select: user.name,
|
||||
join: signup in Signups, where: user.id == signup.user_id
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def smth do
|
||||
from = 1
|
||||
to = 7
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
fromin,
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
query = from u in query, select: u.city
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def do_query do
|
||||
where = [category: "fresh and new"]
|
||||
order_by = [desc: :published_at]
|
||||
select = [:id, :title, :body]
|
||||
from Post, where: ^where, order_by: ^order_by, select: ^select
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def alphabetical(query) do
|
||||
from c in query, order_by: c.name
|
||||
end
|
||||
EOF
|
||||
end
|
26
vim/plugins/vim-elixir-master/spec/indent/ecto_spec.rb
Normal file
26
vim/plugins/vim-elixir-master/spec/indent/ecto_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'EctoEnum' do
|
||||
i <<~EOF
|
||||
defmodule Onemedical.Types do
|
||||
import EctoEnum
|
||||
defenum(Work.Occupation, :work_occupation, [
|
||||
:actor, :architect, :athlete, :baker, :bank_clerk, :banker, :barber, :blogger,
|
||||
:bricklayer, :broadcaster, :builder, :captain, :carpenter, :choreographer,
|
||||
:computer_engineer, :computer_programmer, :custom_officer, :dancer, :designer,
|
||||
:director, :doctor, :driver, :editor, :entertainer, :engineer, :facility_manager,
|
||||
:farmer, :fashion_designer, :geologist, :goldsmith, :graphic_designer, :hairdresser,
|
||||
:host_hostess, :house_girl, :interior_designer, :judge, :land_surveyor, :lecturer,
|
||||
:make_up_artist, :manager, :mechanic, :midwife, :model, :music_director, :musician,
|
||||
:nanny, :nurse, :pastor, :paediatrician, :photographer, :physicist, :pilot, :plumber,
|
||||
:police_officer, :printer, :producer, :publisher, :quality_inspector, :radiographer,
|
||||
:real_estate_agent, :referee, :refuse_collector, :registrar, :safety_engineer, :sales_manager,
|
||||
:script_writer, :secretary, :security_guard, :shoemaker, :songwriter, :sound_engineer,
|
||||
:stock_broker, :surveyor, :tailor, :teacher, :telecommunications_engineer, :usher,
|
||||
:waiter, :writer, :zookeeper, :other])
|
||||
defenum(Work.Type, :work_type, [
|
||||
:full_time, :part_time, :volunteer, :temporary
|
||||
])
|
||||
end
|
||||
EOF
|
||||
end
|
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting eelixir' do
|
||||
it 'anonymous function' do
|
||||
expect(<<~EOF).to be_eelixir_indentation
|
||||
<%= form_for @changeset, user_path(@conn, :create), fn f -> %>
|
||||
It is obviously true
|
||||
<% end %>
|
||||
EOF
|
||||
end
|
||||
|
||||
it 'if..do..end' do
|
||||
expect(<<~EOF).to be_eelixir_indentation
|
||||
<%= if true do %>
|
||||
It is obviously true
|
||||
<% end %>
|
||||
EOF
|
||||
end
|
||||
|
||||
it 'if..do..else..end' do
|
||||
expect(<<~EOF).to be_eelixir_indentation
|
||||
<%= if true do %>
|
||||
It is obviously true
|
||||
<% else %>
|
||||
This will never appear
|
||||
<% end %>
|
||||
EOF
|
||||
end
|
||||
end
|
263
vim/plugins/vim-elixir-master/spec/indent/embedded_views_spec.rb
Normal file
263
vim/plugins/vim-elixir-master/spec/indent/embedded_views_spec.rb
Normal file
|
@ -0,0 +1,263 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting embedded views' do
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<div>
|
||||
Some content
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<div class="theres a-/ in the class names from tailwind">
|
||||
<div class="some more classes">
|
||||
This is immediately nested
|
||||
<div>
|
||||
<input type="number" value="2" />
|
||||
There's a self-closing tag
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<div id="123456">
|
||||
Some content
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<div
|
||||
id="123456"
|
||||
>
|
||||
Some content
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<div />
|
||||
<p>Some paragraph</p>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<div>
|
||||
it
|
||||
<div>
|
||||
keeps
|
||||
<div>
|
||||
nesting
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assgins) do
|
||||
~L"""
|
||||
<div>
|
||||
<%= for i <- iter do %>
|
||||
<div><%= i %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<%= live_component @socket,
|
||||
Component,
|
||||
id: "<%= @id %>",
|
||||
user: @user do
|
||||
%>
|
||||
|
||||
<main>
|
||||
<header>
|
||||
<h1>Some Header</h1>
|
||||
</header>
|
||||
<section>
|
||||
<h1>Some Section</h1>
|
||||
<p>
|
||||
I'm some text
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<%= render_component,
|
||||
@socket,
|
||||
Component do %>
|
||||
|
||||
<p>Multi-line opening eex tag that takes a block</p>
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<div>
|
||||
<%= render_component,
|
||||
@socket,
|
||||
Component %>
|
||||
</div>
|
||||
|
||||
<%= render_component,
|
||||
@socket,
|
||||
Component %>
|
||||
<p>Multi-line single eex tag</p>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<Component
|
||||
foo={{
|
||||
foo: [
|
||||
'one',
|
||||
'two',
|
||||
'three'
|
||||
],
|
||||
bar: %{
|
||||
"foo" => "bar"
|
||||
}
|
||||
}}
|
||||
/>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def render(assigns) do
|
||||
~L"""
|
||||
<%= live_component @socket,
|
||||
Component,
|
||||
id: "<%= @id %>",
|
||||
team: @team do
|
||||
%>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
A deeply nested tree
|
||||
<div>
|
||||
with trailing whitespace
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="id-ends-with-greater-than->"
|
||||
propWithEexTag="<%= @id %>"
|
||||
anotherProp="foo"
|
||||
/>
|
||||
|
||||
<%= for i <- iter do %>
|
||||
<div><%= i %></div>
|
||||
<% end %>
|
||||
|
||||
<div
|
||||
opts={{
|
||||
opt1: "optA",
|
||||
opt2: "optB"
|
||||
}}
|
||||
id="hi"
|
||||
bye="hi" />
|
||||
|
||||
<ul>
|
||||
<li :for={{ item <- @items }}>
|
||||
{{ item }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div id="hi">
|
||||
Hi <p>hi</p>
|
||||
I'm ok, ok?
|
||||
<div>
|
||||
hi there!
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<p>hi</p>
|
||||
<hr />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Some.Surface.Component />
|
||||
|
||||
<Another
|
||||
prop="prop"
|
||||
prop2="prop2"
|
||||
>
|
||||
<div>content</div>
|
||||
</Another>
|
||||
|
||||
<div foo />
|
||||
|
||||
<div>hi</div>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
content
|
||||
</div>
|
||||
<div />
|
||||
<div>
|
||||
content in new div after a self-closing div
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
id="<%= @id %>"
|
||||
class="multi-line opening single letter p tag"
|
||||
>
|
||||
<%= @solo.eex_tag %>
|
||||
<Nested
|
||||
prop="nested"
|
||||
>
|
||||
content
|
||||
</Nested>
|
||||
</p>
|
||||
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
end
|
32
vim/plugins/vim-elixir-master/spec/indent/exunit_spec.rb
Normal file
32
vim/plugins/vim-elixir-master/spec/indent/exunit_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'exunit' do
|
||||
i <<~EOF
|
||||
test "test" do
|
||||
Mod.fun(fn ->
|
||||
map = %Mod.Map{
|
||||
id: "abc123",
|
||||
state: "processing",
|
||||
submod: %Mod.Submod{
|
||||
options: %{}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
test "test" do
|
||||
Mod.fun(fn ->
|
||||
map = %Mod.Map{
|
||||
id: "abc123",
|
||||
fun: fn ->
|
||||
IO.inspect :hello
|
||||
IO.inspect %{
|
||||
this_is: :a_map
|
||||
}
|
||||
end,
|
||||
submod: %Mod.Submod{
|
||||
options: %{}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
41
vim/plugins/vim-elixir-master/spec/indent/if_spec.rb
Normal file
41
vim/plugins/vim-elixir-master/spec/indent/if_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting if clauses' do
|
||||
i <<~EOF
|
||||
if foo do
|
||||
bar
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
if foo do
|
||||
bar
|
||||
else
|
||||
baz
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
"else"
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
if true do
|
||||
else
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def exec(command, progress_func \\ fn(_, state) -> state end, key \\ nil, output \\ nil) do
|
||||
if key do
|
||||
with_cache(key, output, fn -> do_exec(command, progress_func) end)
|
||||
else
|
||||
do_exec(command, progress_func)
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
29
vim/plugins/vim-elixir-master/spec/indent/keyword_spec.rb
Normal file
29
vim/plugins/vim-elixir-master/spec/indent/keyword_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Keywords' do
|
||||
i <<~EOF
|
||||
def handle_call({:get_in_line_for_lock, key}, from, state) do
|
||||
queue = state[:queues][key] || :queue.new
|
||||
queue = queue.in(from, queue)
|
||||
hello
|
||||
end
|
||||
EOF
|
||||
|
||||
# Has cond in milliseconds
|
||||
i <<~EOF
|
||||
if arg[:arg] do
|
||||
finish_time = Timex.Duration.now
|
||||
start_time = Mod.Mod.arg(@attr, fun(state))
|
||||
duration = Timex.Duration.diff(finish_time, start_time, :milliseconds)
|
||||
Mod.fun(:arg, arg, arg: arg, arg: arg, arg)
|
||||
e
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
Logger.metadata(
|
||||
task_id: state.recipe.task_id,
|
||||
hashed_id: state.recipe.config.some_id,
|
||||
task
|
||||
)
|
||||
EOF
|
||||
end
|
205
vim/plugins/vim-elixir-master/spec/indent/lists_spec.rb
Normal file
205
vim/plugins/vim-elixir-master/spec/indent/lists_spec.rb
Normal file
|
@ -0,0 +1,205 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting lists' do
|
||||
i <<~EOF
|
||||
def example do
|
||||
[ :foo,
|
||||
:bar,
|
||||
:baz ]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
[
|
||||
[
|
||||
:foo
|
||||
]
|
||||
]
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def project do
|
||||
[ name: "mix",
|
||||
version: "0.1.0",
|
||||
deps: deps ]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def config do
|
||||
[ name:
|
||||
"John" ]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
[ { :cowboy, github: "extend/cowboy" },
|
||||
{ :dynamo, "0.1.0-dev", github: "elixir-lang/dynamo" },
|
||||
{ :ecto, github: "elixir-lang/ecto" },
|
||||
{ :pgsql, github: "semiocast/pgsql" } ]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
[ [:a, :b, :c],
|
||||
[:d, :e, :f] ]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
[ app: :first,
|
||||
version: "0.0.1",
|
||||
dynamos: [First.Dynamo],
|
||||
compilers: [:elixir, :dynamo, :ecto, :app],
|
||||
env: [prod: [compile_path: "ebin"]],
|
||||
compile_path: "tmp/first/ebin",
|
||||
deps: deps ]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def project do
|
||||
[
|
||||
{ :bar, path: "deps/umbrella/apps/bar" },
|
||||
{ :umbrella, path: "deps/umbrella" }
|
||||
]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
a = [
|
||||
%{
|
||||
foo: 1,
|
||||
bar: 2
|
||||
}
|
||||
]
|
||||
|
||||
b = %{
|
||||
[
|
||||
:foo,
|
||||
:bar
|
||||
]
|
||||
}
|
||||
|
||||
[
|
||||
a,
|
||||
b
|
||||
]
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def create(conn, %{
|
||||
"grant_type" => "password",
|
||||
"username" => username,
|
||||
"password" => password
|
||||
}) do
|
||||
1
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def double(x) do
|
||||
add(
|
||||
x,
|
||||
y
|
||||
)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def double(x) do
|
||||
add(
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
z
|
||||
)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def double(x) do
|
||||
result = add(
|
||||
x,
|
||||
z
|
||||
)
|
||||
div(result, 2)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Module do
|
||||
@person1 { name: "name",
|
||||
age: 18,
|
||||
enabled?: true }
|
||||
@person2 { name: "other name",
|
||||
age: 21,
|
||||
enabled?: false }
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test_another_feature do
|
||||
assert json_response(conn, 200) == %{
|
||||
"results" => [
|
||||
%{
|
||||
"id" => result.id,
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Mod do
|
||||
def test do
|
||||
foo == %{
|
||||
}
|
||||
|
||||
assert json_response == %{
|
||||
"id" => "identifier"
|
||||
}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Mod do
|
||||
def fun do
|
||||
json_logger = Keyword.merge(Application.get_env(:logger, :json_logger, []), options)
|
||||
Application.put_env(:logger, :json_logger, json_logger)
|
||||
level = Keyword.get(json_logger, :level)
|
||||
|
||||
%{level: level, output: :console}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule Mod do
|
||||
def fun do
|
||||
Enum.each(s.routing_keys, fn k -> Queue.bind(chan, s.queue, s.exchange, routing_key: k) end)
|
||||
Basic.consume(chan, s.queue, nil, no_ack: true)
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def init(_) do
|
||||
children = [
|
||||
worker(QueueSet, [[name: @queue_set]]),
|
||||
worker(Producer, [[name: @producer]]),
|
||||
worker(ConsumerSupervisor, [[{@producer, max_demand: @max_executors}]])
|
||||
]
|
||||
|
||||
supervise(children, strategy: :one_for_one)
|
||||
end
|
||||
EOF
|
||||
end
|
13
vim/plugins/vim-elixir-master/spec/indent/macro_spec.rb
Normal file
13
vim/plugins/vim-elixir-master/spec/indent/macro_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Macros' do
|
||||
i <<~EOF
|
||||
defmodule DeadboltTest do
|
||||
use ExUnit.Case
|
||||
doctest Deadbolt
|
||||
|
||||
hello
|
||||
|
||||
end
|
||||
EOF
|
||||
end
|
47
vim/plugins/vim-elixir-master/spec/indent/map_spec.rb
Normal file
47
vim/plugins/vim-elixir-master/spec/indent/map_spec.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Map indent' do
|
||||
i <<~'EOF'
|
||||
DrMock.mock(fn ->
|
||||
params = %{
|
||||
|
||||
}
|
||||
end)
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
x = %{
|
||||
foo: :bar
|
||||
}
|
||||
|
||||
y = :foo
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
x =
|
||||
%{ foo: :bar }
|
||||
|
||||
y = :foo
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
x = %{
|
||||
foo: :bar }
|
||||
|
||||
y = :foo
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
test "test" do
|
||||
Mod.fun(fn ->
|
||||
map = %Mod.Map{
|
||||
id: "abc123",
|
||||
state: "processing",
|
||||
submod: %Mod.Submod{
|
||||
options: %{}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
145
vim/plugins/vim-elixir-master/spec/indent/pipeline_spec.rb
Normal file
145
vim/plugins/vim-elixir-master/spec/indent/pipeline_spec.rb
Normal file
|
@ -0,0 +1,145 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting pipeline' do
|
||||
i <<~EOF
|
||||
"a,b,c,d"
|
||||
|> String.split(",")
|
||||
|> Enum.reverse
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
[ h | t ] = "a,b,c,d"
|
||||
|> String.split(",")
|
||||
|> Enum.reverse
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
[ h | t ] = "a,b,c,d"
|
||||
|> String.split(",")
|
||||
|> Enum.reverse
|
||||
|
||||
{ :ok, h }
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
my_post = Post
|
||||
|> where([p], p.id == 10)
|
||||
|> where([p], u.user_id == 1)
|
||||
|> select([p], p)
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def test do
|
||||
"a,b,c,d"
|
||||
|> String.split(",")
|
||||
|> Enum.first
|
||||
|> case do
|
||||
"a" -> "A"
|
||||
_ -> "Z"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defrecord RECORD, field_a: nil, field_b: nil
|
||||
|
||||
rec = RECORD.new
|
||||
|> IO.inspect
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule MyMod do
|
||||
def export_info(users) do
|
||||
{:ok, infos} = users
|
||||
|> Enum.map(fn (u) -> do_something(u) end)
|
||||
|> Enum.map(fn (u) ->
|
||||
do_even_more(u)
|
||||
end)
|
||||
|> finall_thing
|
||||
|
||||
infos
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def build_command(input, output) do
|
||||
"embedded=here"
|
||||
|>
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def build_command(input, output) do
|
||||
'embedded=here'
|
||||
|>
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def build_command(input, output) do
|
||||
%{:hello => :world}
|
||||
|>
|
||||
end
|
||||
EOF
|
||||
|
||||
%w(<= >= == != === !== =~).each do |op|
|
||||
i <<~EOF
|
||||
def build_command(input, output) do
|
||||
true #{op} false
|
||||
|> IO.inspect
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
i <<~EOF
|
||||
upcased_names = names
|
||||
|> Enum.map(fn name ->
|
||||
String.upcase(name)
|
||||
end)
|
||||
|
||||
IO.inspect names
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
upcased_names = names
|
||||
|> Enum.map(fn name ->
|
||||
String.upcase(name) end)
|
||||
|
||||
IO.inspect names
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
upcased_names = names
|
||||
|> Enum.map(fn name ->
|
||||
String.upcase(name)
|
||||
end)
|
||||
|
||||
|> do_stuff
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def hello do
|
||||
do_something
|
||||
|> Pipe.to_me
|
||||
{:ok}
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmodule MyModule do
|
||||
def do_stuff do
|
||||
name =
|
||||
"Dr. Zaius"
|
||||
|> determine_name
|
||||
|
||||
hello
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
23
vim/plugins/vim-elixir-master/spec/indent/quote_spec.rb
Normal file
23
vim/plugins/vim-elixir-master/spec/indent/quote_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting quote statements' do
|
||||
i <<~EOF
|
||||
defmacro foo do
|
||||
quote do
|
||||
unquote(foo)
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
defmacro foo do
|
||||
if 1 = 1 do
|
||||
quote do
|
||||
unquote(foo)
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
22
vim/plugins/vim-elixir-master/spec/indent/receive_spec.rb
Normal file
22
vim/plugins/vim-elixir-master/spec/indent/receive_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'receive indent' do
|
||||
i <<~EOF
|
||||
receive do
|
||||
after
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def obtain_lock(pid, key, timeout \\ 60_000) do
|
||||
case GenServer.call(pid, {:obtain_lock, key}) do
|
||||
:will_notify ->
|
||||
receive do
|
||||
after
|
||||
timeout ->
|
||||
end
|
||||
res -> res
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
18
vim/plugins/vim-elixir-master/spec/indent/string_spec.rb
Normal file
18
vim/plugins/vim-elixir-master/spec/indent/string_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting strings' do
|
||||
it "bulk indenting strings" do
|
||||
expect(<<~EOF).to be_elixir_indentation
|
||||
defp sql do
|
||||
"""
|
||||
SELECT *
|
||||
FROM table
|
||||
WHERE column = 123
|
||||
AND another_column = 456
|
||||
"""
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
23
vim/plugins/vim-elixir-master/spec/indent/struct_spec.rb
Normal file
23
vim/plugins/vim-elixir-master/spec/indent/struct_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'defstruct' do
|
||||
i <<~EOF
|
||||
defmodule A do
|
||||
defmodule State do
|
||||
defstruct field: nil, field: nil, field: nil,
|
||||
field: [], field: nil, field: 0,
|
||||
field: false, field: %{}
|
||||
end
|
||||
|
||||
defmodule State do
|
||||
defstruct field: nil, field: nil, field: nil
|
||||
end
|
||||
|
||||
defmodule State do
|
||||
defstruct field: nil,
|
||||
field: [],
|
||||
field: false
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
41
vim/plugins/vim-elixir-master/spec/indent/try_spec.rb
Normal file
41
vim/plugins/vim-elixir-master/spec/indent/try_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'try indent' do
|
||||
i <<~EOF
|
||||
try do
|
||||
rescue
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
try do
|
||||
catch
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
try do
|
||||
after
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
test "it proceses the command" do
|
||||
out = "testfile"
|
||||
try do
|
||||
cmd = "thing \#{@test_file} \#{out}"
|
||||
{:ok, 0, _} = Thing.exec(cmd)
|
||||
after
|
||||
File.rm!(out)
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
try do
|
||||
foo()
|
||||
else
|
||||
value -> value
|
||||
end
|
||||
EOF
|
||||
end
|
29
vim/plugins/vim-elixir-master/spec/indent/tuples_spec.rb
Normal file
29
vim/plugins/vim-elixir-master/spec/indent/tuples_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting tuples' do
|
||||
i <<~EOF
|
||||
def xpto do
|
||||
{ :a,
|
||||
:b,
|
||||
:c }
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
def method do
|
||||
{
|
||||
:bar,
|
||||
path: "deps/umbrella/apps/bar"
|
||||
}
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
x = [
|
||||
{:text, "asd {"},
|
||||
{:text, "qwe"},
|
||||
]
|
||||
EOF
|
||||
end
|
121
vim/plugins/vim-elixir-master/spec/indent/with_spec.rb
Normal file
121
vim/plugins/vim-elixir-master/spec/indent/with_spec.rb
Normal file
|
@ -0,0 +1,121 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'with' do
|
||||
i <<~EOF
|
||||
with {:ok, msg} <- Msgpax.unpack(payload) do
|
||||
{:ok, rebuild(msg)}
|
||||
else
|
||||
error -> error
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
with {:ok, width} <- Map.fetch(opts, :width),
|
||||
double_width = width * 2,
|
||||
{:ok, height} <- Map.fetch(opts, :height)
|
||||
do
|
||||
{:ok, double_width * height}
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
with {:ok, width} <- Map.fetch(opts, :width),
|
||||
double_width = width * 2,
|
||||
{:ok, height} <- Map.fetch(opts, :height),
|
||||
do: {:ok, double_width * height}
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
with {:ok, width} <- Map.fetch(opts, :width),
|
||||
{:ok, height} <- Map.fetch(opts, :height)
|
||||
do
|
||||
{:ok, width * height}
|
||||
else
|
||||
:error ->
|
||||
{:error, :wrong_data}
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~EOF
|
||||
with {:ok, width} <- Map.fetch(opts, :width),
|
||||
{:ok, height} <- Map.fetch(opts, :height),
|
||||
do:
|
||||
{:ok,
|
||||
width * height * height * height * height * height * height * height * height * height *
|
||||
height * height * height * height * height * height * height},
|
||||
else: (:error -> {:error, :wrong_data})
|
||||
EOF
|
||||
|
||||
i <<~'EOF'
|
||||
# This file is responsible for configuring your application
|
||||
# and its dependencies with the aid of the Mix.Config module.
|
||||
use Mix.Config
|
||||
|
||||
import_config "#{Mix.env}.exs"
|
||||
EOF
|
||||
|
||||
i <<~'EOF'
|
||||
with {:ok, %File.Stat{size: size}} when size > 0 <- File.stat(first_frame_path) do
|
||||
File.rename(first_frame_path, output_path)
|
||||
{:ok, %Result{path: output_path}}
|
||||
else
|
||||
error ->
|
||||
{:error, error}
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~'EOF'
|
||||
def resend_confirmation(username) when is_binary(username) do
|
||||
with user = %User{confirmed_at: nil} <- get_by(username: username) do
|
||||
{:ok, user} =
|
||||
user
|
||||
|> DB.add_confirm_token
|
||||
|> update_user()
|
||||
Log.info(%Log{user: user.id, message: "send new confirmation"})
|
||||
send_welcome(user)
|
||||
{:ok, user}
|
||||
else
|
||||
nil ->
|
||||
{:error, "not found"}
|
||||
%User{email: email} ->
|
||||
Email.already_confirmed(email)
|
||||
{:error, "already confirmed"}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~'EOF'
|
||||
def create_user(params) do
|
||||
profile = UserProfile.registration_changeset(%UserProfile{}, params)
|
||||
|
||||
user_cs =
|
||||
%User{}
|
||||
|> User.registration_changeset(params)
|
||||
|> put_assoc(:user_profile, profile)
|
||||
|
||||
with {:ok, user} <- Repo.insert(user_cs, returning: false) do
|
||||
Log.info(%Log{user: user.id, message: "user created"})
|
||||
send_welcome(user)
|
||||
{:ok, user}
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~'EOF'
|
||||
def my_function do
|
||||
with :ok <- some_call,
|
||||
:ok <- another_call do
|
||||
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
i <<~'EOF'
|
||||
with {:ok, foo} <- thing(1),
|
||||
{:ok, bar} <- thing(2) do
|
||||
foo + bar
|
||||
end
|
||||
EOF
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue