From 07e7dd47f21bf3e0af19cae282b5748ad430313c Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 9 Oct 2024 12:57:44 +0300 Subject: [PATCH] llama.vim : handle space --- examples/llama.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/llama.vim b/examples/llama.vim index 10f81f733..24289fbe0 100644 --- a/examples/llama.vim +++ b/examples/llama.vim @@ -127,14 +127,16 @@ function! llama#fim() abort inoremap :call llama#cancel_virtual_text() 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 == 8 - execute 'inoremap :call llama#cancel_virtual_text()' + execute 'inoremap :call llama#cancel_virtual_text()' elseif l:key == 27 - execute 'inoremap :call llama#cancel_virtual_text()' + execute 'inoremap :call llama#cancel_virtual_text()' + elseif l:key == 32 + execute 'inoremap :call llama#cancel_virtual_text()' elseif l:key == 127 - execute 'inoremap :call llama#cancel_virtual_text()' + execute 'inoremap :call llama#cancel_virtual_text()' else execute 'inoremap ' . nr2char(l:key) . ' :call llama#cancel_virtual_text()' . nr2char(l:key) endif @@ -153,11 +155,7 @@ function! llama#accept_virtual_text() let l:line_cur = getline('.') - let l:pos0 = l:pos_x - 2 - - if l:pos_x == len(l:line_cur) - let l:pos0 = l:pos_x - 1 - endif + let l:pos0 = l:pos_x == len(l:line_cur) ? l:pos_x - 1 : l:pos_x - 2 " insert the suggestion at the cursor location 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 iunmap - 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 == 8 execute 'iunmap ' elseif l:key == 27 execute 'iunmap ' + elseif l:key == 32 + execute 'iunmap ' elseif l:key == 127 execute 'iunmap ' else