Allow double click to select to match

This commit is contained in:
Andy K. Massimino
2017-12-02 11:13:03 -05:00
parent 77d3de55f3
commit a4936b8aad
2 changed files with 16 additions and 0 deletions

View File

@@ -129,6 +129,10 @@ function! s:init_default_mappings()
" call s:map('i', '<c-x><cr>', '<plug>(matchup-delim-close)')
" XXX other maps..?
endif
if get(g:, 'matchup_mouse_enabled', 1)
call s:map('n', '<2-LeftMouse>', '<plug>(matchup-double-click)')
endif
endfunction
let s:modules = map(

View File

@@ -21,6 +21,9 @@ function! matchup#text_obj#init_module() " {{{1
execute 'o' . l:p1 . 'i' . l:p2 . '(1, 0' . l:p3
execute 'o' . l:p1 . 'a' . l:p2 . '(0, 0' . l:p3
endfor
nnoremap <silent> <plug>(matchup-double-click)
\ :<c-u>call matchup#text_obj#double_click()<cr>
endfunction
" }}}1
@@ -176,6 +179,15 @@ function! matchup#text_obj#delimited(is_inner, visual, type) " {{{1
call matchup#pos#set_cursor(l:l2, l:c2)
endfunction
" }}}1
function! matchup#text_obj#double_click() " {{{1
if empty(matchup#delim#get_current('all', 'both_all'))
execute "normal! \<2-LeftMouse>"
else
execute "normal v1\<plug>(matchup-a%)"
endif
endfunction
" }}}1
let &cpo = s:save_cpo