mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated vim plugins
This commit is contained in:
@ -0,0 +1,259 @@
|
||||
require 'spec_helper'
|
||||
|
||||
def set_file_content(string)
|
||||
string = normalize_string_indent(string)
|
||||
File.open(filename, 'w'){ |f| f.write(string) }
|
||||
vim.edit filename
|
||||
end
|
||||
|
||||
def get_file_content()
|
||||
vim.write
|
||||
IO.read(filename).strip
|
||||
end
|
||||
|
||||
def before(string)
|
||||
set_file_content(string)
|
||||
end
|
||||
|
||||
def after(string)
|
||||
get_file_content().should eq normalize_string_indent(string)
|
||||
end
|
||||
|
||||
def type(string)
|
||||
string.scan(/<.*?>|./).each do |key|
|
||||
if /<.*>/.match(key)
|
||||
vim.feedkeys "\\#{key}"
|
||||
else
|
||||
vim.feedkeys key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Multiple Cursors" do
|
||||
let(:filename) { 'test.txt' }
|
||||
|
||||
specify "#multiline replacement" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#single line replacement" do
|
||||
before <<-EOF
|
||||
hello hello hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world world world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#mixed line replacement" do
|
||||
before <<-EOF
|
||||
hello hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#new line in insert mode" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>chello<CR>world<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#new line in insert mode middle of line" do
|
||||
before <<-EOF
|
||||
hello world
|
||||
hello world
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vlxi<cr><Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'o'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>voworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'O'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vOworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
hello
|
||||
world
|
||||
hello
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#find command basic" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
vim.normal ':MultipleCursorsFind hello<CR>'
|
||||
type 'cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual line mode replacement" do
|
||||
before <<-EOF
|
||||
hello world
|
||||
hello world
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>Vchi!<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hi!
|
||||
hi!
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#skip key" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-x>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#prev key" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n><C-p>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
hello
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'I'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vIworld <Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world hello
|
||||
world hello
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'A'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vA world<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello world
|
||||
hello world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#undo" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>cworld<Esc>u'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
end
|
||||
|
||||
# 'd' is an operator pending command, which are not supported at the moment.
|
||||
# This should result in a nop, but we should still remain in multicursor mode.
|
||||
specify "#normal mode 'd'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vdx<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hell
|
||||
hell
|
||||
EOF
|
||||
end
|
||||
end
|
25
sources_non_forked/vim-multiple-cursors/spec/spec_helper.rb
Normal file
25
sources_non_forked/vim-multiple-cursors/spec/spec_helper.rb
Normal file
@ -0,0 +1,25 @@
|
||||
require 'vimrunner'
|
||||
require 'vimrunner/rspec'
|
||||
|
||||
Vimrunner::RSpec.configure do |config|
|
||||
|
||||
# Use a single Vim instance for the test suite. Set to false to use an
|
||||
# instance per test (slower, but can be easier to manage).
|
||||
config.reuse_server = true
|
||||
|
||||
# Decide how to start a Vim instance. In this block, an instance should be
|
||||
# spawned and set up with anything project-specific.
|
||||
config.start_vim do
|
||||
# vim = Vimrunner.start
|
||||
|
||||
# Or, start a GUI instance:
|
||||
vim = Vimrunner.start_gvim
|
||||
|
||||
# Setup your plugin in the Vim instance
|
||||
plugin_path = File.expand_path('../..', __FILE__)
|
||||
vim.add_plugin(plugin_path, 'plugin/multiple_cursors.vim')
|
||||
|
||||
# The returned value is the Client available in the tests.
|
||||
vim
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user