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

Updated plugins

This commit is contained in:
Amir Salihefendic
2018-03-31 11:56:26 -03:00
parent 7c643a2d9c
commit 02572caa95
84 changed files with 4588 additions and 1749 deletions

View File

@ -35,7 +35,7 @@ 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 = [`
Vim command sequence: `2Gvip<C-n>i"<Right><Right><Right>",<Esc>vipgJ$r]Idays = [`
### Do it backwards too! This is not just a replay of the above gif :)
![Example3](assets/example3.gif?raw=true)
@ -51,8 +51,8 @@ To see what keystrokes are used for the above examples, see [the wiki page](http
- Live update in Insert mode
- One key to rule it all! See [Quick Start](#quick-start) on what the key does in different scenarios
- Works in Normal, Insert, and Visual mode for any commands (including
multi-key commands, assuming you set `g:multicursor_insert_maps` and
`g:multicursor_normal_maps`; see Settings below for details)
multi-key commands, assuming you set `g:multicursor_normal_maps`;
see Settings below for details)
## Installation
Install using [Pathogen], [Vundle], [Neobundle], or your favorite Vim package manager.
@ -123,15 +123,6 @@ If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not q
### ```g:multi_cursor_exit_from_insert_mode``` (Default: 1)
If set to 0, then pressing `g:multi_cursor_quit_key` in _Insert_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors.
### ```g:multi_cursor_insert_maps``` (Default: `{}`)
Any key in this map (values are ignored) will cause multi-cursor _Insert_ mode
to pause for `timeoutlen` waiting for map completion just like normal vim.
Otherwise keys mapped in insert mode are ignored when multiple cursors are
active. For example, setting it to `{'\':1}` will make insert-mode mappings
beginning with the default leader key work in multi-cursor mode. You have to
manually set this because vim doesn't provide a way to see which keys _start_
mappings.
### ```g:multi_cursor_normal_maps``` (Default: see below)
Default value: `{'!':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}`

View File

@ -103,7 +103,7 @@ endfunction
function! s:fire_pre_triggers()
if !s:before_function_called
doautocmd User MultipleCursorsPre
silent doautocmd User MultipleCursorsPre
if exists('*Multiple_cursors_before')
exe "call Multiple_cursors_before()"
endif
@ -445,7 +445,7 @@ function! s:CursorManager.reset(restore_view, restore_setting, ...) dict
if exists('*Multiple_cursors_after')
exe "call Multiple_cursors_after()"
endif
doautocmd User MultipleCursorsPost
silent doautocmd User MultipleCursorsPost
let s:before_function_called = 0
endif
endfunction
@ -516,7 +516,6 @@ function! s:CursorManager.update_current() dict
if s:to_mode ==# 'V'
exec "normal! gvv\<Esc>"
endif
" Sets the cursor at the right place
exec "normal! gv\<Esc>"
call cur.update_visual_selection(s:get_visual_region(s:pos('.')))
@ -525,17 +524,18 @@ function! s:CursorManager.update_current() dict
" This should be executed after user input is processed, when unnamed
" register already contains the text.
call cur.save_unnamed_register()
call cur.remove_visual_selection()
elseif s:from_mode ==# 'i' && s:to_mode ==# 'n' && self.current_index != self.size() - 1
elseif s:from_mode ==# 'i' && s:to_mode ==# 'n' && self.current_index != 0
normal! h
elseif s:from_mode ==# 'n'
" Save contents of unnamed register after each operation in Normal mode.
call cur.save_unnamed_register()
endif
let vdelta = line('$') - s:saved_linecount
let pos = s:pos('.')
" If the total number of lines changed in the buffer, we need to potentially
" adjust other cursor locations
let vdelta = line('$') - s:saved_linecount
if vdelta != 0
if self.current_index != self.size() - 1
let cur_column_offset = (cur.column() - col('.')) * -1
@ -547,7 +547,7 @@ function! s:CursorManager.update_current() dict
let c = self.get(i)
" If there're other cursors on the same line, we need to adjust their
" columns. This needs to happen before we adjust their line!
if cur.line() == c.line()
if cur.line() == c.line() || cur.position == pos
if vdelta > 0
" Added a line
let hdelta = cur_column_offset
@ -583,7 +583,6 @@ function! s:CursorManager.update_current() dict
endif
endif
let pos = s:pos('.')
if cur.position == pos
return 0
endif
@ -598,7 +597,8 @@ endfunction
" Start tracking cursor updates
function! s:CursorManager.start_loop() dict
let self.starting_index = self.current_index
let self.current_index = 0
let self.starting_index = 0
endfunction
" Returns true if we're cycled through all the cursors
@ -1210,28 +1210,51 @@ function! s:wait_for_user_input(mode)
let s:saved_keys = ""
endif
if s:from_mode ==# 'i' && has_key(g:multi_cursor_insert_maps, s:last_char())
let c = getchar(0)
let char_type = type(c)
" ambiguous mappings are note supported; e.g.:
" imap jj JJ
" imap jjj JJJ
" will always trigger the 'jj' mapping
if s:from_mode ==# 'i' && mapcheck(s:char, "i") != ""
let poll_count = 0
while char_type == 0 && c == 0 && poll_count < &timeoutlen
sleep 1m
let map_dict = {}
while poll_count < &timeoutlen
let c = getchar(0)
let char_type = type(c)
let poll_count += 1
let poll_count += 1.5
if char_type == 0 && c != 0
let s:char .= nr2char(c)
elseif char_type == 1 " char with more than 8 bits (as string)
let s:char .= c
endif
let map_dict = maparg(s:char, "i", 0, 1)
" break if chars exactly match mapping or if chars don't match beging of mapping anymore
if map_dict != {} || mapcheck(s:char, "i") == ""
if get(map_dict, 'expr', 0)
" handle case where {rhs} is a function
exec 'let char_mapping = ' . map_dict['rhs']
else
let char_mapping = get(map_dict, 'rhs', s:char)
endif
" handle case where mapping is <esc>
exec 'let s:char = "'.substitute(char_mapping, '<', '\\<', 'g').'"'
break
endif
sleep 1m
endwhile
if char_type == 0 && c != 0
let s:char .= nr2char(c)
elseif char_type == 1 " char with more than 8 bits (as string)
let s:char .= c
endif
elseif s:from_mode !=# 'i' && s:char[0] ==# ":"
call feedkeys(s:char)
call s:cm.reset(1, 1)
return
elseif s:from_mode ==# 'n'
elseif s:from_mode ==# 'n' || s:from_mode =~# 'v\|V'
while match(s:last_char(), "\\d") == 0
if match(s:char, '\(^\|\a\)0') == 0
" fixes an edge case concerning the `0` key.
" The 0 key behaves differently from [1-9].
" It's consumed immediately when it is the
" first key typed while we're waiting for input.
" References: issue #152, pull #241
break
endif
let s:char .= s:get_char()
endwhile
endif

View File

@ -157,16 +157,6 @@ quit and delete all existing cursors. This is useful if you want to press
Escape and go back to Normal mode, and still be able to operate on all the
cursors.
*g:multi_cursor_insert_maps* (Default: `{}`)
Any key in this map (values are ignored) will cause multi-cursor _Insert_ mode
to pause for `timeoutlen` waiting for map completion just like normal vim.
Otherwise keys mapped in insert mode are ignored when multiple cursors are
active. For example, setting it to `{'\':1}` will make insert-mode mappings
beginning with the default leader key work in multi-cursor mode. You have to
manually set this because vim doesn't provide a way to see which keys _start_
mappings.
*g:multi_cursor_normal_maps* (Default: see below)
Default value: `{'!':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}`

View File

@ -40,12 +40,9 @@ let s:settings_if_default = {
\ 'skip_key': '<C-x>',
\ }
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 =

View File

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-
require 'spec_helper'
def set_file_content(string)
@ -136,6 +136,79 @@ describe "Multiple Cursors op pending & exit from insert|visual mode" do
EOF
end
specify "#normal mode '0': goes to 1st char of line" do
before <<-EOF
hello jan world
hello feb world
hello mar world
EOF
type '<C-n><C-n><C-n>vw0dw<Esc><Esc>'
after <<-EOF
jan world
feb world
mar world
EOF
end
specify "#normal mode 'd0': deletes backward to 1st char of line" do
before <<-EOF
hello jan world
hello feb world
hello mar world
EOF
type '<C-n><C-n><C-n>vwd0<Esc><Esc>'
after <<-EOF
jan world
feb world
mar world
EOF
end
end
describe "Multiple Cursors when using insert mapings" do
let(:filename) { 'test.txt' }
let(:options) { ['imap jj <esc>', 'imap jojo dude'] }
specify "#mapping doing <Esc>" do
before <<-EOF
hello world!
hello world!
bla bla bla
bla bla bla
EOF
type 'w<C-n><C-n>cjjidude<Esc>'
after <<-EOF
hello dude!
hello !
bla bla bla
bla bla bla
EOF
end
specify "#mapping using more than 2 characters" do
before <<-EOF
hello
hello
bla bla bla
bla bla bla
EOF
type '<C-n><C-n>A jojo<Esc>'
after <<-EOF
hello dude
hello dude
bla bla bla
bla bla bla
EOF
end
end
describe "Multiple Cursors when normal_maps is empty" do
@ -190,7 +263,53 @@ describe "Multiple Cursors when visual_maps is empty" do
end
describe "Multiple Cursors" do
describe "Multiple Cursors when changing the line count" do
let(:filename) { 'test.txt' }
let(:options) { ['set backspace=indent,eol,start'] }
specify "#backspace on first char of the line, then carriage return" do
before <<-EOF
madec
antoine
andre
joseph
EOF
type 'Gvip<C-n>i<BS><cr>'
after <<-EOF
madec
antoine
andre
joseph
EOF
end
specify "#del at EOL, then carriage return" do
before <<-EOF
madec
antoine
joseph
andre
EOF
type 'vip<C-n>A<DEL><cr>'
after <<-EOF
madec
antoine
joseph
andre
EOF
end
end
describe "Multiple Cursors misc" do
let(:filename) { 'test.txt' }
let(:options) { ['set autoindent'] }