Skip to content

Commit 6fc9318

Browse files
committed
add floating dialog
1 parent ead3b3b commit 6fc9318

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

autoload/copilot.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
scriptencoding utf-8
22

3+
let thinkingWindow
34
let s:has_nvim_ghost_text = has('nvim-0.7') && exists('*nvim_buf_get_mark')
45
let s:vim_minimum_version = '9.0.0185'
56
let s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop')
@@ -320,6 +321,7 @@ function! s:UpdatePreview() abort
320321
endif
321322
if empty(text) || !s:has_ghost_text
322323
"call s:Echo('Done')"
324+
vim.api.nvim_win_close(thinkingWindow, true)
323325
return s:ClearPreview()
324326
endif
325327
if exists('b:_copilot.cycling_callbacks')
@@ -423,6 +425,30 @@ function! copilot#Schedule() abort
423425
return
424426
endif
425427
"call s:Echo('Copilot Thinking ' . "\uF1E6")"
428+
429+
local buf = vim.api.nvim_create_buf(false, true)
430+
431+
-- Set the buffer content to the desired icon or text
432+
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { " 🔍" })
433+
434+
-- Get the current editor dimensions
435+
local width = vim.api.nvim_get_option("columns")
436+
local height = vim.api.nvim_get_option("lines")
437+
438+
-- Calculate the position for the top right corner
439+
local win_opts = {
440+
relative = "editor",
441+
width = 3,
442+
height = 1,
443+
col = 0,
444+
row = height - 2,
445+
style = "minimal",
446+
border = "none",
447+
}
448+
449+
thinkingWindow = vim.api.nvim_open_win(buf, false, win_opts)
450+
451+
426452
call s:UpdatePreview()
427453
let delay = get(g:, 'copilot_idle_delay', 45)
428454
call timer_stop(get(g:, '_copilot_timer', -1))

0 commit comments

Comments
 (0)