Skip to content

Commit 163c87d

Browse files
authored
add :LlamaEnable, :LlamaDisable, :LlamaToggle commands and doc (#43)
1 parent 9cf5ed3 commit 163c87d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

autoload/llama.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,29 @@ function! s:rand(i0, i1) abort
7373
return a:i0 + rand() % (a:i1 - a:i0 + 1)
7474
endfunction
7575

76+
let s:llama_enabled = v:true
77+
78+
function! llama#disable()
79+
call llama#fim_cancel()
80+
autocmd! llama
81+
silent! iunmap <C-F>
82+
endfunction
83+
84+
function! llama#toggle()
85+
if s:llama_enabled
86+
call llama#disable()
87+
else
88+
call llama#init()
89+
endif
90+
let s:llama_enabled = !s:llama_enabled
91+
endfunction
92+
93+
function llama#setup_commands()
94+
command! LlamaEnable call llama#init()
95+
command! LlamaDisable call llama#disable()
96+
command! LlamaToggle call llama#toggle()
97+
endfunction
98+
7699
function! llama#init()
77100
if !executable('curl')
78101
echohl WarningMsg
@@ -81,6 +104,8 @@ function! llama#init()
81104
return
82105
endif
83106

107+
call llama#setup_commands()
108+
84109
let s:pos_x = 0 " cursor position upon start of completion
85110
let s:pos_y = 0
86111

doc/llama.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ Shortcut
2121
- Ctrl+B - accept just the first word of the suggestion
2222
- Ctrl+F - toggle FIM completion manually
2323

24+
================================================================================
25+
Commands
26+
27+
*:LlamaDisable*
28+
29+
Disable the related autocommands and keymap for this vim/nvim session.
30+
Equivalent to vimscript function: `llama#disable()`
31+
32+
*:LlamaEnable*
33+
34+
Enable the related autocommands and keymap for this vim/nvim session
35+
Equivalent to vimscript function: `llama#enable()`
36+
37+
*:LlamaToggle*
38+
39+
Toggle the related autocommands and keymap for this vim/nvim session
40+
Equivalent to vimscript function: `llama#toggle()`
41+
42+
2443
================================================================================
2544
How to start the server
2645

0 commit comments

Comments
 (0)