mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 14:10:06 +08:00
Add preview func
This commit is contained in:
parent
650e1b2bed
commit
358bad295b
@ -207,6 +207,9 @@ function! s:next_item() abort
|
|||||||
else
|
else
|
||||||
normal! j
|
normal! j
|
||||||
endif
|
endif
|
||||||
|
if s:preview_able == 1
|
||||||
|
call s:preview()
|
||||||
|
endif
|
||||||
redrawstatus
|
redrawstatus
|
||||||
call s:MPT._build_prompt()
|
call s:MPT._build_prompt()
|
||||||
endfunction
|
endfunction
|
||||||
@ -217,6 +220,9 @@ function! s:previous_item() abort
|
|||||||
else
|
else
|
||||||
normal! k
|
normal! k
|
||||||
endif
|
endif
|
||||||
|
if s:preview_able == 1
|
||||||
|
call s:preview()
|
||||||
|
endif
|
||||||
redrawstatus
|
redrawstatus
|
||||||
call s:MPT._build_prompt()
|
call s:MPT._build_prompt()
|
||||||
endfunction
|
endfunction
|
||||||
@ -272,6 +278,27 @@ function! s:move_cursor() abort
|
|||||||
call s:MPT._build_prompt()
|
call s:MPT._build_prompt()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:preview_able = 0
|
||||||
|
function! s:toggle_preview() abort
|
||||||
|
if s:preview_able == 0
|
||||||
|
let s:preview_able = 1
|
||||||
|
call s:preview()
|
||||||
|
else
|
||||||
|
pclose
|
||||||
|
let s:preview_able = 0
|
||||||
|
endif
|
||||||
|
redraw!
|
||||||
|
call s:MPT._build_prompt()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:preview() abort
|
||||||
|
let line = getline('.')
|
||||||
|
let filename = fnameescape(split(line, ':\d\+:')[0])
|
||||||
|
let linenr = matchstr(line, ':\d\+:')[1:-2]
|
||||||
|
exe 'silent pedit! +' . linenr . ' ' . filename
|
||||||
|
resize 18
|
||||||
|
endfunction
|
||||||
|
|
||||||
let s:MPT._function_key = {
|
let s:MPT._function_key = {
|
||||||
\ "\<Tab>" : function('s:next_item'),
|
\ "\<Tab>" : function('s:next_item'),
|
||||||
\ "\<C-j>" : function('s:next_item'),
|
\ "\<C-j>" : function('s:next_item'),
|
||||||
@ -284,6 +311,7 @@ let s:MPT._function_key = {
|
|||||||
\ "\<2-LeftMouse>" : function('s:double_click'),
|
\ "\<2-LeftMouse>" : function('s:double_click'),
|
||||||
\ "\<C-f>" : function('s:start_filter'),
|
\ "\<C-f>" : function('s:start_filter'),
|
||||||
\ "\<C-r>" : function('s:start_replace'),
|
\ "\<C-r>" : function('s:start_replace'),
|
||||||
|
\ "\<C-p>" : function('s:toggle_preview'),
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
|
Loading…
Reference in New Issue
Block a user