1
0
mirror of https://github.com/amix/vimrc synced 2025-07-04 14:56:29 +08:00

updated plugins and added eslint goodies

This commit is contained in:
Max Alcala
2016-02-19 10:35:36 -06:00
parent a1deb28314
commit f3143286d3
402 changed files with 14389 additions and 4024 deletions

View File

@ -1,7 +1,11 @@
sudo: false
language: ruby
rvm:
- 1.9.3
before_install: sudo apt-get install vim-gtk
addons:
apt:
packages:
- vim-gtk
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

View File

@ -0,0 +1,23 @@
# Problems summary
## Expected
## Environment Information
* OS:
* Neovim/Vim/Gvim version:
## Provide a minimal .vimrc with less than 50 lines
" Your minimal.vimrc
## Generate a logfile if appropriate
1. export NVIM_PYTHON_LOG_FILE=/tmp/log
2. export NVIM_PYTHON_LOG_LEVEL=DEBUG
3. nvim -u minimal.vimrc
4. recreate your issue
5. cat /tmp/log_{PID}
## Screen shot (if possible)
## Upload the log file

View File

@ -1,17 +1,22 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.4)
rake (10.0.4)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1)
vimrunner (0.3.0)
diff-lcs (1.2.5)
rake (10.4.2)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.1)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
vimrunner (0.3.1)
PLATFORMS
ruby
@ -20,3 +25,6 @@ DEPENDENCIES
rake
rspec
vimrunner
BUNDLED WITH
1.10.6

View File

@ -1,5 +1,7 @@
# vim-multiple-cursors [![Build Status](https://travis-ci.org/terryma/vim-multiple-cursors.svg)](https://travis-ci.org/terryma/vim-multiple-cursors)
# vim-multiple-cursors
[![Build Status](https://travis-ci.org/terryma/vim-multiple-cursors.svg)](https://travis-ci.org/terryma/vim-multiple-cursors)
[![Issue Stats](http://issuestats.com/github/terryma/vim-multiple-cursors/badge/pr?style=flat)](http://issuestats.com/github/terryma/vim-multiple-cursors)
[![Issue Stats](http://issuestats.com/github/terryma/vim-multiple-cursors/badge/issue?style=flat)](http://issuestats.com/github/terryma/vim-multiple-cursors)
## Contents
- [About](#about)
- [Features](#features)
@ -10,10 +12,11 @@
- [Interactions with other plugins](#interactions-with-other-plugins)
- [Highlight](#highlight)
- *[FAQ](#faq)*
- *[Known Issues](#known-issues)*
- *[Known issues](#known-issues)*
- *[Issue creation requirements](#issue-creation-requirements)*
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Credit](#credit)
- [Credit](#credit)
###Contributors
- [eapache](https://github.com/eapache)
@ -27,16 +30,22 @@
### It's great for quick refactoring
![Example1](assets/example1.gif?raw=true)
Vim command sequence: `2Gfp<C-n><C-n><C-n>cname`
### Add a cursor to each line of your visual selection
![Example2](assets/example2.gif?raw=true)
Vim command sequence: `2Gvip<C-n>i"<Right><Right><Right>",<Esc>vipJ$r]Idays = [`
### Do it backwards too! This is not just a replay of the above gif :)
![Example3](assets/example3.gif?raw=true)
Vim command sequence: `2Gdf[$r,0f,v<C-n>…<C-n>c<CR><Up><Del><Right><Right><Right><Del>`
### Add multiple cursors using regexes
![Example4](assets/example4.gif?raw=true)
To see what keystrokes are used for the above example, see [this issue](https://github.com/terryma/vim-multiple-cursors/issues/39).
To see what keystrokes are used for the above examples, see [the wiki page](https://github.com/terryma/vim-multiple-cursors/wiki/Keystrokes-for-example-gifs).
## Features
- Live update in Insert mode
@ -132,6 +141,15 @@ normal mode will "fail to replay" when multiple cursors are active. For example,
changing it from `{}` to `{'d':1}` makes normal-mode mappings beginning with `d`
(such as `dw` to delete a word) work in multi-cursor mode.
### ```g:multi_cursor_visual_maps``` (Default: see below)
Default value: `{'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}`
Any key in this map (values are ignored) will cause multi-cursor _Visual_ mode
to pause for map completion just like normal vim. Otherwise keys mapped in
visual mode will "fail to replay" when multiple cursors are active. For example,
changing it from `{}` to `{'i':1}` makes visual-mode mappings beginning with `i`
(such as `it` to select an "inner tag block") work in multi-cursor mode.
The default list contents should work for anybody, unless they have remapped a
key from an operator-pending command to a non-operator-pending command or
vice versa.
@ -144,9 +162,9 @@ such as `j` as if they were operator-pending commands can break things.
### ```Multiple_cursors_before/Multiple_cursors_after``` (Default: `nothing`)
Other plugins may trigger on keypresses when in insert mode. These plugins
Other plugins may trigger on keypresses when in insert mode. These plugins
generally provide a means to toggle their active state. These hooks allow
the user to provide functions in their .vimrc to do this when multiple-cursor-mode
the user to provide functions in their .vimrc to do this when multiple-cursor-mode
is entered.
For example, if you are using [Neocomplete](https://github.com/Shougo/neocomplete.vim),
@ -187,9 +205,10 @@ highlight link multiple_cursors_visual Visual
## Known Issues
- Select mode is not implemented
- I and A do not work in Visual mode yet (See #55)
Single key command to switch to Insert mode such as c or s from Visual mode or i, a, I, A in Normal mode should work without any issues. **NOTE**: vim's Visual block mode also supports I and A commands, however they do not work in this plugin's Visual mode at the moment. For now, to use I and A, switch to normal mode by pressing v first.
## Issue Creation Requirements
This is a community supported project. Contributor's time is precious and limited. To ensure your issue is not closed out of hand, please ensure it meets the requirements outlined in [CONTRIBUTING.md](CONTRIBUTING.md).
## Changelog
See [CHANGELOG.md](CHANGELOG.md)
@ -211,6 +230,4 @@ Obviously inspired by Sublime Text's [multiple selection][sublime-multiple-selec
[emacs-multiple-cursors]:https://github.com/magnars/multiple-cursors.el
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/terryma/vim-multiple-cursors/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

View File

@ -218,9 +218,12 @@ function! multiple_cursors#find(start, end, pattern)
let first = 1
while 1
if first
" Set `virtualedit` to 'onemore' for the first search to consistently
" match patterns like '$'
let saved_virtualedit = &virtualedit
let &virtualedit = "onemore"
" First search starts from the current position
let match = search(a:pattern, 'cW')
let first = 0
else
let match = search(a:pattern, 'W')
endif
@ -228,9 +231,26 @@ function! multiple_cursors#find(start, end, pattern)
break
endif
let left = s:pos('.')
call search(a:pattern, 'ceW')
" Perform an intermediate backward search to correctly match patterns like
" '^' and '$'
let match = search(a:pattern, 'bceW')
let right = s:pos('.')
" Reset the cursor and perform a normal search if the intermediate search
" wasn't successful
if !match || s:compare_pos(right, left) != 0
call cursor(left)
call search(a:pattern, 'ceW')
let right = s:pos('.')
endif
if first
let &virtualedit = saved_virtualedit
let first = 0
endif
if s:compare_pos(right, pos2) > 0
" Position the cursor at the end of the previous match so it'll be on a
" virtual cursor when multicursor mode is started. The `winrestview()`
" call below 'undoes' unnecessary repositionings
call search(a:pattern, 'be')
break
endif
call s:cm.add(right, [left, right])
@ -268,6 +288,7 @@ function! s:Cursor.new(position)
let obj = copy(self)
let obj.position = copy(a:position)
let obj.visual = []
let obj.saved_visual = []
" Stores text that was yanked after any commands in Normal or Visual mode
let obj.paste_buffer_text = getreg('"')
let obj.paste_buffer_type = getregtype('"')
@ -332,6 +353,7 @@ endfunction
" Remove the visual selection and its highlight
function! s:Cursor.remove_visual_selection() dict
let self.saved_visual = deepcopy(self.visual)
let self.visual = []
" TODO(terryma): Move functionality into separate class
call s:cm.remove_highlight(self.visual_hi_id)
@ -409,6 +431,7 @@ function! s:CursorManager.reset(restore_view, restore_setting, ...) dict
let self.saved_winview = []
let self.start_from_find = 0
let s:char = ''
let s:saved_char = ''
if a:restore_setting
call self.restore_user_settings()
endif
@ -507,7 +530,7 @@ function! s:CursorManager.update_current() dict
" adjust other cursor locations
if vdelta != 0
if self.current_index != self.size() - 1
let cur_line_length = len(getline(cur.line()))
let cur_column_offset = (cur.column() - col('.')) * -1
let new_line_length = len(getline('.'))
for i in range(self.current_index+1, self.size()-1)
let hdelta = 0
@ -519,7 +542,7 @@ function! s:CursorManager.update_current() dict
if cur.line() == c.line()
if vdelta > 0
" Added a line
let hdelta = cur_line_length * -1
let hdelta = cur_column_offset
else
" Removed a line
let hdelta = new_line_length
@ -626,6 +649,13 @@ function! s:CursorManager.restore_user_settings() dict
call setreg('"', s:paste_buffer_temporary_text, s:paste_buffer_temporary_type)
endfunction
" Reposition all cursors to the start or end of their region
function! s:CursorManager.reposition_all_within_region(start) dict
for c in self.cursors
call c.update_position(c.saved_visual[a:start ? 0 : 1])
endfor
endfunction
" Reselect the current cursor's region in visual mode
function! s:CursorManager.reapply_visual_selection() dict
call s:select_in_visual_mode(self.get_current().visual)
@ -670,6 +700,9 @@ endfunction
" This is the last user input that we're going to replicate, in its string form
let s:char = ''
" This is either `I` or `A`, as input in Visual mode, that we're going to use
" to make the appropriate transition into Insert mode
let s:saved_char = ''
" This is the mode the user is in before s:char
let s:from_mode = ''
" This is the mode the user is in after s:char
@ -898,12 +931,34 @@ endfunction
" to be called to continue the fanout process
function! s:detect_bad_input()
if !s:valid_input
" To invoke the appropriate `<Plug>(multiple-cursors-apply)` mapping, we
" need to revert back to the mode the user was in when the input was entered
call s:revert_mode(s:to_mode, s:from_mode)
" We ignore the bad input and force invoke s:apply_user_input_next
call feedkeys("\<Plug>(multiple-cursors-apply)")
let s:bad_input += 1
endif
endfunction
" Complete transition into Insert mode when `I` or `A` is input in Visual mode
function! s:handle_visual_IA_to_insert()
if !empty(s:saved_char) && s:char =~# 'v\|V' && s:to_mode ==# 'n'
if s:saved_char ==# 'I'
call s:cm.reposition_all_within_region(1)
endif
call feedkeys(tolower(s:saved_char))
let s:saved_char = ''
endif
endfunction
" Begin transition into Insert mode when `I` or `A` is input in Visual mode
function! s:handle_visual_IA_to_normal()
if s:char =~# 'I\|A' && s:from_mode =~# 'v\|V'
let s:saved_char = s:char
let s:char = s:from_mode " spoof a 'v' or 'V' input to transiton from Visual into Normal mode
endif
endfunction
" Apply the user input at the next cursor location
function! s:apply_user_input_next(mode)
let s:valid_input = 1
@ -931,6 +986,7 @@ function! s:apply_user_input_next(mode)
call s:update_visual_markers(s:cm.get_current().visual)
endif
call feedkeys("\<Plug>(multiple-cursors-wait)")
call s:handle_visual_IA_to_insert()
else
" Continue to next
call feedkeys("\<Plug>(multiple-cursors-input)")
@ -1050,8 +1106,8 @@ endfunction
let s:retry_keys = ""
function! s:display_error()
if s:bad_input == s:cm.size()
\ && s:from_mode ==# 'n'
\ && has_key(g:multi_cursor_normal_maps, s:char[0])
\ && ((s:from_mode ==# 'n' && has_key(g:multi_cursor_normal_maps, s:char[0]))
\ || (s:from_mode =~# 'v\|V' && has_key(g:multi_cursor_visual_maps, s:char[0])))
" we couldn't replay it anywhere but we're told it's the beginning of a
" multi-character map like the `d` in `dw`
let s:retry_keys = s:char
@ -1124,6 +1180,7 @@ function! s:wait_for_user_input(mode)
let s:char = s:retry_keys . s:saved_keys
if len(s:saved_keys) == 0
let s:char .= s:get_char()
call s:handle_visual_IA_to_normal()
else
let s:saved_keys = ""
endif

View File

@ -133,7 +133,7 @@ NOTE: Please make sure to always map something to |g:multi_cursor_quit_key|,
otherwise you'll have a tough time quitting from multicursor mode.
NOTE: Prior to version 1.3, the recommended way to map the keys is using the
expressoin quote syntax in Vim, using something like `"\<C-n>"` or `"\<Esc>"`
expression quote syntax in Vim, using something like `"\<C-n>"` or `"\<Esc>"`
(see h: expr-quote). After 1.3, the recommended way is to use a raw string
like above. If your key mappings don't appear to work, give the new syntax a
try.
@ -177,6 +177,16 @@ normal mode will "fail to replay" when multiple cursors are active. For example,
changing it from `{}` to `{'d':1}` makes normal-mode mappings beginning with `d`
(such as `dw` to delete a word) work in multi-cursor mode.
*g:multi_cursor_visual_maps* (Default: )
Default value: `{'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}`
Any key in this map (values are ignored) will cause multi-cursor _Visual_ mode
to pause for map completion just like normal vim. Otherwise keys mapped in
visual mode will "fail to replay" when multiple cursors are active. For example,
changing it from `{}` to `{'i':1}` makes visual-mode mappings beginning with `i`
(such as `it` to select an "inner tag block") work in multi-cursor mode.
The default list contents should work for anybody, unless they have remapped a
key from an operator-pending command to a non-operator-pending command or
vice versa.

View File

@ -1,7 +1,7 @@
"===============================================================================
" File: multiple_cursors.vim
" Author: Terry Ma
" Description: Emulate Sublime Text's multi selection feature
" Description: Emulate Sublime Text's multi selection feature
" Potential Features:
" - Create a blinking cursor effect? Good place to do it would be instead of
" waiting for user input, cycle through the highlight
@ -42,11 +42,14 @@ let s:settings_if_default = {
let s:default_insert_maps = {}
let s:default_normal_maps = {'!':1, '@':1, '=':1, 'q':1, 'r':1, 't':1, 'T':1, 'y':1, '[':1, ']':1, '\':1, 'd':1, 'f':1, 'F':1, 'g':1, '"':1, 'z':1, 'c':1, 'm':1, '<':1, '>':1}
let s:default_visual_maps = {'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}
let g:multi_cursor_insert_maps =
\ get(g:, 'multi_cursor_insert_maps', s:default_insert_maps)
let g:multi_cursor_normal_maps =
\ get(g:, 'multi_cursor_normal_maps', s:default_normal_maps)
let g:multi_cursor_visual_maps =
\ get(g:, 'multi_cursor_visual_maps', s:default_visual_maps)
call s:init_settings(s:settings)
@ -54,8 +57,12 @@ if g:multi_cursor_use_default_mapping
call s:init_settings(s:settings_if_default)
endif
if !exists('g:multi_cursor_start_word_key') && exists('g:multi_cursor_next_key')
let g:multi_cursor_start_word_key = g:multi_cursor_next_key
if !exists('g:multi_cursor_start_word_key')
if exists('g:multi_cursor_start_key')
let g:multi_cursor_start_word_key = g:multi_cursor_start_key
elseif exists('g:multi_cursor_next_key')
let g:multi_cursor_start_word_key = g:multi_cursor_next_key
endif
endif
" External mappings

View File

@ -58,6 +58,7 @@ end
describe "Multiple Cursors" do
let(:filename) { 'test.txt' }
let(:options) { [] }
specify "#benchmark" do
before <<-EOF

View File

@ -17,7 +17,7 @@ def before(string)
end
def after(string)
get_file_content().should eq normalize_string_indent(string)
expect(get_file_content()).to eq normalize_string_indent(string)
end
def type(string)
@ -163,9 +163,35 @@ describe "Multiple Cursors when normal_maps is empty" do
end
describe "Multiple Cursors when visual_maps is empty" do
let(:filename) { 'test.txt' }
let(:options) { ['let g:multi_cursor_visual_maps = {}'] }
# Operator-pending commands are handled correctly thanks to their inclusion
# in `g:multi_cursor_visual_maps`.
#
# When an operator-pending command like 'f' is missing from that setting's
# value, then it should result in a no-op, but we should still remain in
# multicursor mode.
specify "#visual mode 'i'" do
before <<-EOF
hello world x
hello world x
EOF
type 'fw<C-n><C-n>fx<Esc>'
after <<-EOF
hello x
hello x
EOF
end
end
describe "Multiple Cursors" do
let(:filename) { 'test.txt' }
let(:options) { [] }
let(:options) { ['set autoindent'] }
specify "#paste buffer normal x then p" do
before <<-EOF
@ -324,6 +350,38 @@ describe "Multiple Cursors" do
EOF
end
specify "#multiple new lines on one line in insert mode" do
before <<-EOF
'a','b','c','d','e'
EOF
type 'f,v<C-n><C-n><C-n>c<CR><Esc>'
after <<-EOF
'a'
'b'
'c'
'd'
'e'
EOF
end
specify "#multiple new lines on one line in insert mode with indents" do
before <<-EOF
'a','b','c','d','e'
EOF
type '4i<Space><Esc>f,v<C-n><C-n><C-n>c<CR><Esc>:%s/^/^<CR>'
after <<-EOF
^ 'a'
^ 'b'
^ 'c'
^ 'd'
^ 'e'
EOF
end
specify "#normal mode 'o'" do
before <<-EOF
hello
@ -371,6 +429,48 @@ describe "Multiple Cursors" do
EOF
end
specify "#find command start-of-line" do
before <<-EOF
hello
world
hello
world
EOF
vim.normal ':MultipleCursorsFind ^<CR>'
type 'Ibegin<Esc>'
after <<-EOF
beginhello
beginworld
begin
beginhello
beginworld
EOF
end
specify "#find command end-of-line" do
before <<-EOF
hello
world
hello
world
EOF
vim.normal ':MultipleCursorsFind $<CR>'
type 'Iend<Esc>'
after <<-EOF
helloend
worldend
end
helloend
worldend
EOF
end
specify "#visual line mode replacement" do
before <<-EOF
hello world
@ -417,6 +517,216 @@ describe "Multiple Cursors" do
EOF
end
specify "#visual mode 'i'" do
before <<-EOF
hi (hello world jan) bye
hi (hello world feb) bye
hi (hello world mar) bye
EOF
type 'fw<C-n><C-n><C-n>ibcone<Esc>'
after <<-EOF
hi (one) bye
hi (one) bye
hi (one) bye
EOF
end
specify "#visual mode 'a'" do
before <<-EOF
hi (hello world jan) bye
hi (hello world feb) bye
hi (hello world mar) bye
EOF
type 'fw<C-n><C-n><C-n>abcone<Esc>'
after <<-EOF
hi one bye
hi one bye
hi one bye
EOF
end
specify "#visual mode 'f'" do
before <<-EOF
hi (hello world jan) bye
hi (hello world feb) bye
hi (hello world mar) bye
EOF
type 'fw<C-n><C-n><C-n>f)cone<Esc>'
after <<-EOF
hi (hello one bye
hi (hello one bye
hi (hello one bye
EOF
end
specify "#visual mode 'F'" do
before <<-EOF
hi (hello world jan) bye
hi (hello world feb) bye
hi (hello world mar) bye
EOF
type 'fw<C-n><C-n><C-n>F(cbefore<Esc>'
after <<-EOF
hi beforeorld jan) bye
hi beforeorld feb) bye
hi beforeorld mar) bye
EOF
end
specify "#visual mode 't'" do
before <<-EOF
hello.jan
hello hi.feb
hello hi bye.mar
EOF
type '<C-n><C-n><C-n>t.cone<Esc>'
after <<-EOF
one.jan
one.feb
one.mar
EOF
end
specify "#visual mode 'T'" do
before <<-EOF
jan.world
feb.hi world
mar.bye hi world
EOF
type 'fw<C-n><C-n><C-n>T.cbefore<Esc>'
after <<-EOF
jan.beforeorld
feb.beforeorld
mar.beforeorld
EOF
end
specify "#visual line mode 'f'" do
before <<-EOF
hello jan world
hello feb world
hello mar world
EOF
type '<C-n><C-n><C-n>VfwvAafter<Esc>'
after <<-EOF
hello jan wafterorld
hello feb wafterorld
hello mar wafterorld
EOF
end
specify "#visual mode 'I'" do
before <<-EOF
hello world jan
hello world feb
hello world mar
EOF
type 'w<C-n><C-n><C-n>Ibefore<Esc>'
after <<-EOF
hello beforeworld jan
hello beforeworld feb
hello beforeworld mar
EOF
end
specify "#visual mode 'A'" do
before <<-EOF
hello world jan
hello world feb
hello world mar
EOF
type 'w<C-n><C-n><C-n>Aafter<Esc>'
after <<-EOF
hello worldafter jan
hello worldafter feb
hello worldafter mar
EOF
end
specify "#resize regions visual mode 'I'" do
before <<-EOF
hello world jan
hello world feb
hello world mar
EOF
type 'w<C-n><C-n><C-n>hhhIbefore<Esc>'
after <<-EOF
hello beforeworld jan
hello beforeworld feb
hello beforeworld mar
EOF
end
specify "#resize regions visual mode 'A'" do
before <<-EOF
hello world jan
hello world feb
hello world mar
EOF
type 'w<C-n><C-n><C-n>hhhAbefore<Esc>'
after <<-EOF
hello wobeforerld jan
hello wobeforerld feb
hello wobeforerld mar
EOF
end
specify "#no word boundries visual mode 'I'" do
before <<-EOF
hello hibye world
hello hibye world
hello hibye world
EOF
vim.normal ':MultipleCursorsFind bye<CR>'
type 'Ibefore<Esc>'
after <<-EOF
hello hibeforebye world
hello hibeforebye world
hello hibeforebye world
EOF
end
specify "#variable-length regions visual mode 'I'" do
before <<-EOF
hello hii world
hello hiiii world
hello hiiiiii world
EOF
vim.normal ':MultipleCursorsFind \<hi*\><CR>'
type 'Ibefore<Esc>'
after <<-EOF
hello beforehii world
hello beforehiiii world
hello beforehiiiiii world
EOF
end
specify "#normal mode 'I'" do
before <<-EOF
hello