Skip to content

Commit 7540083

Browse files
ggerganovarthw
authored andcommitted
llama.vim : fix info text display [no ci] (ggml-org#9787)
1 parent 6b997df commit 7540083

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

examples/llama.vim

+7-17
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,9 @@ function! llama#fim_cancel()
482482
" clear the virtual text
483483
let l:bufnr = bufnr('%')
484484

485-
let l:id_vt_fim = nvim_create_namespace('vt_fim')
486-
let l:id_vt_info = nvim_create_namespace('vt_info')
485+
let l:id_vt_fim = nvim_create_namespace('vt_fim')
487486

488487
call nvim_buf_clear_namespace(l:bufnr, l:id_vt_fim, 0, -1)
489-
call nvim_buf_clear_namespace(l:bufnr, l:id_vt_info, 0, -1)
490488

491489
" remove the mappings
492490
silent! iunmap <buffer> <Tab>
@@ -644,13 +642,11 @@ function! s:fim_on_stdout(job_id, data, event) dict
644642
" display virtual text with the suggestion
645643
let l:bufnr = bufnr('%')
646644

647-
let l:id_vt_fim = nvim_create_namespace('vt_fim')
648-
let l:id_vt_info = nvim_create_namespace('vt_info')
645+
let l:id_vt_fim = nvim_create_namespace('vt_fim')
649646

650647
" construct the info message
651648
if g:llama_config.show_info > 0 && l:has_info
652-
" prefix the info string with whitespace in order to offset it to the right of the fim overlay
653-
let l:prefix = repeat(' ', len(s:content[0]) - len(s:line_cur_suffix) + 3)
649+
let l:prefix = ' '
654650

655651
if l:truncated
656652
let l:info = printf("%s | WARNING: the context is full: %d / %d, increase the server context size or reduce g:llama_config.ring_n_chunks",
@@ -668,21 +664,15 @@ function! s:fim_on_stdout(job_id, data, event) dict
668664
endif
669665

670666
if g:llama_config.show_info == 1
671-
" display it in the statusline
667+
" display the info in the statusline
672668
let &statusline = l:info
673-
elseif g:llama_config.show_info == 2
674-
" display it to the right of the current line
675-
call nvim_buf_set_extmark(l:bufnr, l:id_vt_info, s:pos_y - 1, s:pos_x - 1, {
676-
\ 'virt_text': [[l:info, 'llama_hl_info']],
677-
"\ 'virt_text_pos': 'eol',
678-
\ 'virt_text_pos': 'right_align',
679-
\ })
669+
let l:info = ''
680670
endif
681671
endif
682672

683-
" display the suggestion
673+
" display the suggestion and append the info to the end of the first line
684674
call nvim_buf_set_extmark(l:bufnr, l:id_vt_fim, s:pos_y - 1, s:pos_x - 1, {
685-
\ 'virt_text': [[s:content[0], 'llama_hl_hint']],
675+
\ 'virt_text': [[s:content[0], 'llama_hl_hint'], [l:info, 'llama_hl_info']],
686676
\ 'virt_text_win_col': virtcol('.') - 1
687677
\ })
688678

0 commit comments

Comments
 (0)