1
0
mirror of https://github.com/amix/vimrc synced 2025-06-17 19:35:00 +08:00

Added and updated some plugins

Added: vim-ruby, typescript-vim, vim-javascript
Updated: rust-vim
This commit is contained in:
Amir Salihefendic
2019-11-16 18:43:18 +01:00
parent ff0ede6b30
commit 97e3db7fe9
108 changed files with 12408 additions and 869 deletions

View File

@ -0,0 +1,24 @@
require 'spec_helper'
describe "Indenting" do
specify "multi-line arguments" do
assert_correct_indenting <<~EOF
User.new(
:first_name => 'Some',
:second_name => 'Guy'
)
EOF
assert_correct_indenting <<~EOF
User.new(:first_name => 'Some',
:second_name => 'Guy')
EOF
assert_correct_indenting <<~EOF
User.new(
:first_name => 'Some',
:second_name => 'Guy'
)
EOF
end
end

View File

@ -0,0 +1,73 @@
require 'spec_helper'
describe "Indenting" do
specify "if-clauses" do
assert_correct_indenting <<~EOF
if foo
bar
end
EOF
assert_correct_indenting <<~EOF
if foo
bar
else
baz
end
EOF
assert_correct_indenting <<~EOF
bar if foo
something_else
EOF
end
specify "heredocs" do
assert_correct_indenting <<~EOF
def one
two = <<-THREE
four
THREE
end
EOF
assert_correct_indenting <<~EOF
def one
two = <<THREE
four
THREE
end
EOF
assert_correct_indenting <<~EOF
def one
two = <<~THREE
four
THREE
end
EOF
# See https://github.com/vim-ruby/vim-ruby/issues/318 for details
assert_correct_indenting <<~EOF
def foo
<<-EOS
one
\#{two} three
four
EOS
end
EOF
end
specify "comments" do
assert_correct_indenting <<~EOF
def one
example do |something|
=begin
something that is ignored
=end
end
end
EOF
end
end

View File

@ -0,0 +1,167 @@
require 'spec_helper'
describe "Indenting" do
after :each do
vim.command 'let g:ruby_indent_block_style = "expression"'
end
specify "indented blocks with expression style" do
vim.command 'let g:ruby_indent_block_style = "expression"'
assert_correct_indenting <<~EOF
a.
b.
c do |x|
something
end
next_line
EOF
assert_correct_indenting <<~EOF
a.
b.
c { |x|
something
}
next_line
EOF
end
specify "indented blocks with do style" do
vim.command 'let g:ruby_indent_block_style = "do"'
assert_correct_indenting <<~EOF
a.
b.
c do |x|
something
end
next_line
EOF
# Check that "do" style indentation does not mess up indentation
# following the bock.
assert_correct_indenting <<~EOF
a.
b.
c do |x|
something
end
next_line
EOF
# Check that "do" style indenting works properly for brace blocks.
assert_correct_indenting <<~EOF
a.
b.
c { |x|
something
}
next_line
EOF
end
specify "'do' indenting" do
assert_correct_indenting <<~EOF
do
something
end
EOF
assert_correct_indenting <<~EOF
def foo
a_hash = {:do => 'bar'}
end
EOF
assert_correct_indenting <<~EOF
def foo(job)
job.do!
end
EOF
end
specify "blocks with assignment on the previous line" do
assert_correct_indenting <<~EOF
foo =
something do
"other"
end
EOF
assert_correct_indenting <<~EOF
@foo ||=
something do
"other"
end
EOF
end
specify "blocks with multiline parameters" do
assert_correct_indenting <<~EOF
def foo
opts.on('--coordinator host=HOST[,port=PORT]',
'Specify the HOST and the PORT of the coordinator') do |str|
h = sub_opts_to_hash(str)
puts h
end
end
EOF
end
specify "case-insensitive matching" do
vim.set 'ignorecase'
assert_correct_indenting <<~EOF
module X
Class.new do
end
end
EOF
vim.set 'ignorecase&'
end
specify "blocks with tuple arguments" do
assert_correct_indenting <<~EOF
proc do |(a, b)|
puts a
puts b
end
EOF
assert_correct_indenting <<~EOF
proc do |foo, (a, b), bar|
puts a
puts b
end
EOF
assert_correct_indenting <<~EOF
proc do |(a, (b, c)), d|
puts a, b
puts c, d
end
EOF
end
specify "blocks with default arguments" do
assert_correct_indenting <<~EOF
proc do |a = 1|
puts a
end
EOF
# See https://github.com/vim-ruby/vim-ruby/issues/304
assert_correct_indenting <<~EOF
proc do |a: "asdf", b:|
proc do
puts a, b
end
end
EOF
end
end

View File

@ -0,0 +1,317 @@
require 'spec_helper'
describe "Indenting" do
specify "method chaining" do
assert_correct_indenting <<~EOF
some_object.
method_one.
method_two.
method_three
EOF
assert_correct_indenting <<~EOF
some_object
.method_one
.method_two
.method_three
EOF
assert_correct_indenting <<~EOF
some_object&.
method_one&.
method_two&.
method_three
EOF
assert_correct_indenting <<~EOF
some_object
&.method_one
&.method_two
&.method_three
EOF
end
specify "arrays" do
assert_correct_indenting <<~EOF
foo = [one,
two,
three]
EOF
end
specify "tricky string interpolation" do
# See https://github.com/vim-ruby/vim-ruby/issues/75 for details
assert_correct_indenting <<~EOF
puts %{\#{}}
puts "OK"
EOF
assert_correct_indenting <<~EOF
while true
begin
puts %{\#{x}}
rescue ArgumentError
end
end
EOF
end
specify "continuations after round braces" do
assert_correct_indenting <<~EOF
opts.on('--coordinator host=HOST[,port=PORT]',
'Specify the HOST and the PORT of the coordinator') do |str|
h = sub_opts_to_hash(str)
puts h
end
EOF
end
describe "assignments" do
after :each do
vim.command 'let g:ruby_indent_assignment_style = "hanging"'
end
specify "continuations after assignment" do
assert_correct_indenting <<~EOF
variable =
if condition?
1
else
2
end
EOF
assert_correct_indenting <<~EOF
variable = # evil comment
case something
when 'something'
something_else
else
other
end
EOF
assert_correct_indenting <<~EOF
variable = case something
when 'something'
something_else
else
other
end
EOF
assert_correct_indenting <<~EOF
variable = if something == something_else
something_else
elsif other == none
none
else
other
end
EOF
assert_correct_indenting <<~EOF
variable = while
break something
end
EOF
assert_correct_indenting <<~EOF
variable = if [].
map { |x| x * 2 }.
filter { |x| x % 3 == 0 }.
empty?
something
end
EOF
vim.command 'let g:ruby_indent_assignment_style = "variable"'
assert_correct_indenting <<~EOF
variable = case something # evil comment
when 'something'
something_else
else
other
end
EOF
assert_correct_indenting <<~EOF
variable = if something == something_else
something_else
elsif other == none
none
else
other
end
EOF
assert_correct_indenting <<~EOF
variable = while
break something
end
EOF
assert_correct_indenting <<~EOF
variable = if [].
map { |x| x * 2 }.
filter { |x| x % 3 == 0 }.
empty?
something
end
EOF
end
end
specify "continuations after hanging comma" do
assert_correct_indenting <<~EOF
array = [
:one,
].each do |x|
puts x.to_s
end
EOF
end
specify "string interpolation" do
# For details, see:
#
# https://github.com/vim-ruby/vim-ruby/issues/93
# https://github.com/vim-ruby/vim-ruby/issues/160
#
assert_correct_indenting <<~EOF
command = %|\#{file}|
settings.log.info("Returning: \#{command}")
EOF
assert_correct_indenting <<~EOF
{
thing: "[\#{}]",
thong: "b"
}
EOF
assert_correct_indenting <<~EOF
{
a: "(\#{a})",
b: "(\#{b})",
c: "(c)",
d: "(d)",
e: "(e)",
}
EOF
end
specify "closing bracket not on its own line" do
# See https://github.com/vim-ruby/vim-ruby/issues/81 for details
assert_correct_indenting <<~EOF
one { two >>
three }
four
EOF
end
specify "lonesome single parenthesis in a method definition" do
# See https://github.com/vim-ruby/vim-ruby/issues/130 for details
assert_correct_indenting <<~EOF
def bar(
baz
)
return baz+1
end
EOF
end
specify "brackets on their own line, followed by a comma" do
# See https://github.com/vim-ruby/vim-ruby/issues/124 for details
assert_correct_indenting <<~EOF
bla = {
:one => [
{:bla => :blub}
],
:two => (
{:blub => :abc}
),
:three => {
:blub => :abc
},
:four => 'five'
}
EOF
end
specify "string with an and#" do
# See https://github.com/vim-ruby/vim-ruby/issues/108 for details
assert_correct_indenting <<~EOF
outside_block "and#" do
inside_block do
end
end
EOF
end
specify "continuation with a symbol at the end" do
# See https://github.com/vim-ruby/vim-ruby/issues/132 for details
assert_correct_indenting <<~EOF
foo = :+
# Next indents correctly
EOF
end
specify "continuation with a hanging comma" do
# See https://github.com/vim-ruby/vim-ruby/issues/139 for details
assert_correct_indenting <<~EOF
thing :foo
thing 'a',
'b'
EOF
end
specify "continuations in an if-clause condition" do
# See https://github.com/vim-ruby/vim-ruby/issues/215 for details
assert_correct_indenting <<~EOF
if foo || bar ||
bong &&
baz || bing
puts "foo"
end
EOF
end
specify "continuations with round brackets" do
# See https://github.com/vim-ruby/vim-ruby/issues/17 for details
assert_correct_indenting <<~EOF
foo and
(bar and
baz) and
bing
EOF
end
specify "block within an argument list" do
# See https://github.com/vim-ruby/vim-ruby/issues/312 for details
assert_correct_indenting <<~EOF
foo(
x: 1,
y: [1, 2, 3].map { |i|
i + 1
}
)
EOF
end
specify "backslashes" do
# See https://github.com/vim-ruby/vim-ruby/issues/311 for details
assert_correct_indenting <<~EOF
def foo
x = 1
string = ". \#{x}" \\
"xyz"
puts string
puts string
end
EOF
end
end

View File

@ -0,0 +1,31 @@
require 'spec_helper'
describe "Indenting" do
specify "end constructs" do
assert_correct_indenting <<~EOF
f do
g { def h; end }
end
EOF
assert_correct_indenting <<~EOF
if foo
bar ; end
something_else
EOF
assert_correct_indenting <<~EOF
if bar ; end
something_else
EOF
assert_correct_indenting <<~EOF
foo do
foo = 3 . class
foo = lambda { class One; end }
foo = lambda { |args| class One; end }
foo = bar; class One; end
end
EOF
end
end

View File

@ -0,0 +1,18 @@
require 'spec_helper'
describe "Indenting" do
specify "closing html tag after multiline eruby tag" do
assert_correct_indenting 'erb', <<~EOF
<form>
<div>
<%= text_field_tag :email, nil,
placeholder: "email" %>
text
<%= text_field_tag :password, nil,
placeholder: "password" %>
</div>
</form>
EOF
end
end

View File

@ -0,0 +1,10 @@
require 'spec_helper'
describe "Indenting" do
specify "identifiers containing keyword substrings" do
assert_correct_indenting <<~EOF
foo_def
42
EOF
end
end

View File

@ -0,0 +1,137 @@
require 'spec_helper'
describe "Indenting" do
after :each do
vim.command 'let g:ruby_indent_access_modifier_style = "normal"'
end
specify "default indented access modifiers" do
assert_correct_indenting <<~EOF
class OuterClass
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
class InnerClass
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
end
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
end
EOF
end
specify "indented access modifiers" do
vim.command 'let g:ruby_indent_access_modifier_style = "indent"'
assert_correct_indenting <<~EOF
class OuterClass
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
class InnerClass
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
end
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
end
EOF
end
specify "outdented access modifiers" do
vim.command 'let g:ruby_indent_access_modifier_style = "outdent"'
assert_correct_indenting <<~EOF
class OuterClass
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
class InnerClass
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
end
private :method
protected :method
def method; end
protected
def method; end
private
def method; end
public
def method; end
end
EOF
end
end

View File

@ -0,0 +1,40 @@
require 'spec_helper'
describe "Indenting" do
specify "method definitions prefixed with access modifiers" do
assert_correct_indenting <<~EOF
class Foo
public def one(x)
end
private def two(y)
code
end
end
EOF
end
specify "method definitions prefixed with any method call" do
assert_correct_indenting <<~EOF
class Foo
foobar def one(x)
end
foobar? def one(x)
end
foobar! def one(x)
end
фубар def one(x)
end
foobar
def one(x)
end
FooBar1 def two(y)
code
end
end
EOF
end
end

View File

@ -0,0 +1,66 @@
require 'spec_helper'
describe "Indenting" do
specify "nested blocks" do
assert_correct_indenting <<~EOF
var.func1(:param => 'value') do
var.func2(:param => 'value') do
puts "test"
end
end
EOF
assert_correct_indenting <<~EOF
var.func1(:param => 'value') {
var.func2(:param => 'value') {
foo({ bar => baz })
puts "test one"
puts "test two"
}
}
EOF
assert_correct_indenting <<~EOF
var.
func1(:param => 'value') {
var.func2(:param => 'value') {
puts "test"
}
}
EOF
end
specify "nested hashes" do
assert_correct_indenting <<~EOF
foo, bar = {
:bar => {
:one => 'two',
:five => 'six'
}
}
EOF
assert_correct_indenting <<~EOF
foo,
bar = {
:bar => {
:foo => { 'bar' => 'baz' },
:one => 'two',
:three => 'four'
}
}
EOF
end
specify "nested blocks with a continuation and function call inbetween" do
assert_correct_indenting <<~EOF
var.
func1(:param => 'value') {
func1_5(:param => 'value')
var.func2(:param => 'value') {
puts "test"
}
}
EOF
end
end

View File

@ -0,0 +1,46 @@
require 'spec_helper'
describe "Indenting" do
specify "splats with blocks in square brackets" do
assert_correct_indenting <<~EOF
x = Foo[*
y do
z
end
]
EOF
assert_correct_indenting <<~EOF
x = Foo[* # with a comment
y do
z
end
]
EOF
end
specify "splats with blocks in assignment" do
assert_correct_indenting <<~EOF
x = *
array.map do
3
end
EOF
end
specify "splats with blocks in round brackets" do
assert_correct_indenting <<~EOF
x = Foo(*y do
z
end)
EOF
assert_correct_indenting <<~EOF
x = Foo(
*y do
z
end
)
EOF
end
end