Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Mar 29, 2015
2 parents 2082894 + 4e4f82a commit d1d3ef7
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 202 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: viml
language: generic

env:
- PPA=yes
Expand All @@ -7,7 +7,7 @@ env:
install:
- if [ x"$PPA" == "xyes" ] ; then sudo add-apt-repository ppa:pi-rho/dev -y; fi
- sudo apt-get update -q
- sudo apt-get install vim-gtk
- sudo apt-get install vim-nox

before_script:
- vim --version
Expand Down
62 changes: 39 additions & 23 deletions autoload/incsearch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ call s:cli.connect('Digraphs')
call s:cli.connect('Delete')
call s:cli.connect('DrawCommandline')
call s:cli.connect('ExceptionExit')
call s:cli.connect('LiteralInsert')
" call s:cli.connect('Exit')
" NOTE:
" <CR> in {rhs} wil be remapped even after exiting vital-over comman line
Expand Down Expand Up @@ -180,30 +181,45 @@ function! s:pattern_saver.on_leave(cmdline) abort
endfunction
call s:cli.connect(s:pattern_saver)

function! s:cli.keymapping() abort
return extend({
\ "\<Tab>" : {
\ "key" : "<Over>(incsearch-next)",
\ "noremap" : 1,
\ },
\ "\<S-Tab>" : {
\ "key" : "<Over>(incsearch-prev)",
\ "noremap" : 1,
\ },
\ "\<C-j>" : {
\ "key" : "<Over>(incsearch-scroll-f)",
\ "noremap" : 1,
\ },
\ "\<C-k>" : {
\ "key" : "<Over>(incsearch-scroll-b)",
\ "noremap" : 1,
let s:default_keymappings = {
\ "\<Tab>" : {
\ "key" : "<Over>(incsearch-next)",
\ "noremap" : 1,
\ },
\ "\<S-Tab>" : {
\ "key" : "<Over>(incsearch-prev)",
\ "noremap" : 1,
\ },
\ "\<C-j>" : {
\ "key" : "<Over>(incsearch-scroll-f)",
\ "noremap" : 1,
\ },
\ "\<C-k>" : {
\ "key" : "<Over>(incsearch-scroll-b)",
\ "noremap" : 1,
\ },
\ "\<C-l>" : {
\ "key" : "<Over>(buffer-complete)",
\ "noremap" : 1,
\ },
\ "\<CR>" : {
\ "key": "\<CR>",
\ "noremap": 1
\ },
\ }

" https://github.com/haya14busa/incsearch.vim/issues/35
if has('mac')
call extend(s:default_keymappings, {
\ '"+gP' : {
\ 'key': "\<C-r>+",
\ 'noremap': 1
\ },
\ "\<C-l>" : {
\ "key" : "<Over>(buffer-complete)",
\ "noremap" : 1,
\ },
\ "\<CR>" : {"key": "\<CR>", "noremap": 1},
\ }, g:incsearch_cli_key_mappings)
\ })
endif

function! s:cli.keymapping() abort
return extend(s:default_keymappings, g:incsearch_cli_key_mappings)
endfunction

let s:inc = {
Expand Down
9 changes: 4 additions & 5 deletions autoload/vital/_incsearch.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let s:self_version = expand('<sfile>:t:r')
let s:self_file = expand('<sfile>')

" Note: The extra argument to globpath() was added in Patch 7.2.051.
let s:globpath_third_arg = v:version > 702 || v:version == 702 && has('patch51')
Expand Down Expand Up @@ -146,7 +147,7 @@ function! s:_get_sid_by_script(path) abort
endfunction

function! s:_file2module(file) abort
let filename = fnamemodify(a:file, ':p:gs?[\\/]\+?/?')
let filename = fnamemodify(a:file, ':p:gs?[\\/]?/?')
let tail = matchstr(filename, 'autoload/vital/_\w\+/\zs.*\ze\.vim$')
return join(split(tail, '[\\/]\+'), '.')
endfunction
Expand All @@ -162,13 +163,13 @@ if filereadable(expand('<sfile>:r') . '.VIM')
return s:_unify_path_cache[a:path]
endif
let value = tolower(fnamemodify(resolve(fnamemodify(
\ a:path, ':p')), ':~:gs?[\\/]\+?/?'))
\ a:path, ':p')), ':~:gs?[\\/]?/?'))
let s:_unify_path_cache[a:path] = value
return value
endfunction
else
function! s:_unify_path(path) abort
return resolve(fnamemodify(a:path, ':p:gs?[\\/]\+?/?'))
return resolve(fnamemodify(a:path, ':p:gs?[\\/]?/?'))
endfunction
endif

Expand Down Expand Up @@ -300,5 +301,3 @@ endfunction
function! vital#{s:self_version}#new() abort
return s:_import('')
endfunction

let s:self_file = s:_unify_path(expand('<sfile>'))
11 changes: 11 additions & 0 deletions autoload/vital/_incsearch/Data/List.vim
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ function! s:has_common_items(list1, list2) abort
return !empty(filter(copy(a:list1), 'index(a:list2, v:val) isnot -1'))
endfunction

function! s:intersect(list1, list2) abort
let items = []
" for funcref
for X in a:list1
if index(a:list2, X) != -1 && index(items, X) == -1
let items += [X]
endif
endfor
return items
endfunction

" similar to Ruby's group_by.
function! s:group_by(xs, f) abort
let result = {}
Expand Down
10 changes: 6 additions & 4 deletions autoload/vital/_incsearch/Over/Commandline/Base.vim
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ let s:base = {
\ "exit" : 0,
\ "keymapping" : {},
\ "suffix" : "",
\ "is_setted" : 0,
\ },
\ "highlights" : {
\ "prompt" : "NONE",
Expand Down Expand Up @@ -90,8 +91,9 @@ function! s:base.setchar(char, ...)
" 1 の場合は既に設定されていても上書きする
" 0 の場合は既に設定されていれば上書きしない
let overwrite = get(a:, 1, 1)
if overwrite || self.variables.input == self.char()
if overwrite || self.variables.is_setted == 0
let self.variables.input = a:char
let self.variables.is_setted = 1
endif
endfunction

Expand Down Expand Up @@ -421,6 +423,7 @@ function! s:base._input_char(char)
let self.variables.input_key = char
let self.variables.char = char
call self.setchar(self.variables.char)
let self.variables.is_setted = 0
call self.callevent("on_char_pre")
call self.insert(self.variables.input)
call self.callevent("on_char")
Expand Down Expand Up @@ -468,14 +471,13 @@ function! s:base._inputting()
let input = s:Input.getchar()
let old_line = self.getline()
let old_pos = self.getpos()
let old_forward = self.forward()
let old_backward = self.backward()
let keymapping = self._get_keymapping()
try
let t = reltime()
while s:is_input_waiting(keymapping, input)
\ && str2nr(reltimestr(reltime(t))) * 1000 < &timeoutlen
call self.setline(old_backward . input . old_forward)
call self.setline(old_line)
call self.insert(input)
call self.setpos(old_pos)
call self.draw()
let input .= s:Input.getchar(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
scriptencoding utf-8
let s:save_cpo = &cpo
set cpo&vim

function! s:_vital_loaded(V)
let s:Input = a:V.import("Over.Input")
endfunction

function! s:_vital_depends()
return [
\ "Over.Input",
\ ]
endfunction

let s:module = {
\ "name" : "LiteralInsert",
\}

function! s:module.on_char_pre(cmdline)
if a:cmdline.is_input("\<C-v>")
\ || a:cmdline.is_input("\<C-q>")
let old_line = a:cmdline.getline()
let old_pos = a:cmdline.getpos()
call a:cmdline.insert('^')
call a:cmdline.setpos(old_pos)
call a:cmdline.draw()
let char = s:Input.getchar()
call a:cmdline.setline(old_line)
call a:cmdline.setpos(old_pos)
call a:cmdline.setchar(char)
endif
endfunction

function! s:make()
return deepcopy(s:module)
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ endfunction

function! s:module.on_char_pre(cmdline)
if self.is_no_insert(a:cmdline.char())
\ && a:cmdline.char() == a:cmdline.variables.input
call a:cmdline.setchar("", 0)
endif
endfunction
Expand Down
Loading

0 comments on commit d1d3ef7

Please sign in to comment.