llama.vim : handle space
This commit is contained in:
parent
0c649c8967
commit
07e7dd47f2
1 changed files with 10 additions and 10 deletions
|
@ -127,14 +127,16 @@ function! llama#fim() abort
|
||||||
inoremap <buffer> <Tab> <C-O>:call llama#cancel_virtual_text()<CR>
|
inoremap <buffer> <Tab> <C-O>:call llama#cancel_virtual_text()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
for l:key in range(33, 127) + [8, 27]
|
for l:key in range(32, 127) + [8, 27]
|
||||||
if l:key != 0x7C
|
if l:key != 0x7C
|
||||||
if l:key == 8
|
if l:key == 8
|
||||||
execute 'inoremap <buffer> <Bs> <C-O>:call llama#cancel_virtual_text()<CR><Bs>'
|
execute 'inoremap <buffer> <Bs> <C-O>:call llama#cancel_virtual_text()<CR><Bs>'
|
||||||
elseif l:key == 27
|
elseif l:key == 27
|
||||||
execute 'inoremap <buffer> <Esc> <C-O>:call llama#cancel_virtual_text()<CR><Esc>'
|
execute 'inoremap <buffer> <Esc> <C-O>:call llama#cancel_virtual_text()<CR><Esc>'
|
||||||
|
elseif l:key == 32
|
||||||
|
execute 'inoremap <buffer> <Space> <C-O>:call llama#cancel_virtual_text()<CR><Space>'
|
||||||
elseif l:key == 127
|
elseif l:key == 127
|
||||||
execute 'inoremap <buffer> <Del> <C-O>:call llama#cancel_virtual_text()<CR><Del>'
|
execute 'inoremap <buffer> <Del> <C-O>:call llama#cancel_virtual_text()<CR><Del>'
|
||||||
else
|
else
|
||||||
execute 'inoremap <buffer> ' . nr2char(l:key) . ' <C-O>:call llama#cancel_virtual_text()<CR>' . nr2char(l:key)
|
execute 'inoremap <buffer> ' . nr2char(l:key) . ' <C-O>:call llama#cancel_virtual_text()<CR>' . nr2char(l:key)
|
||||||
endif
|
endif
|
||||||
|
@ -153,11 +155,7 @@ function! llama#accept_virtual_text()
|
||||||
|
|
||||||
let l:line_cur = getline('.')
|
let l:line_cur = getline('.')
|
||||||
|
|
||||||
let l:pos0 = l:pos_x - 2
|
let l:pos0 = l:pos_x == len(l:line_cur) ? l:pos_x - 1 : l:pos_x - 2
|
||||||
|
|
||||||
if l:pos_x == len(l:line_cur)
|
|
||||||
let l:pos0 = l:pos_x - 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" insert the suggestion at the cursor location
|
" insert the suggestion at the cursor location
|
||||||
call setline(l:pos_y, l:line_cur[:l:pos0] . s:content[0])
|
call setline(l:pos_y, l:line_cur[:l:pos0] . s:content[0])
|
||||||
|
@ -179,12 +177,14 @@ function! llama#cancel_virtual_text()
|
||||||
" remove the mappings
|
" remove the mappings
|
||||||
iunmap <buffer> <Tab>
|
iunmap <buffer> <Tab>
|
||||||
|
|
||||||
for l:key in range(33, 127) + [8, 27]
|
for l:key in range(32, 127) + [8, 27]
|
||||||
if l:key != 0x7C
|
if l:key != 0x7C
|
||||||
if l:key == 8
|
if l:key == 8
|
||||||
execute 'iunmap <buffer> <Bs>'
|
execute 'iunmap <buffer> <Bs>'
|
||||||
elseif l:key == 27
|
elseif l:key == 27
|
||||||
execute 'iunmap <buffer> <Esc>'
|
execute 'iunmap <buffer> <Esc>'
|
||||||
|
elseif l:key == 32
|
||||||
|
execute 'iunmap <buffer> <Space>'
|
||||||
elseif l:key == 127
|
elseif l:key == 127
|
||||||
execute 'iunmap <buffer> <Del>'
|
execute 'iunmap <buffer> <Del>'
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue