From 8b363a95cf69e57b8fecacabb838861c32c9c9c5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 21 Oct 2024 22:08:18 -0300 Subject: [PATCH 1/6] add message on copilot thinking --- autoload/copilot.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/copilot.vim b/autoload/copilot.vim index 5016a039..cc90bfc6 100644 --- a/autoload/copilot.vim +++ b/autoload/copilot.vim @@ -421,6 +421,7 @@ function! copilot#Schedule() abort call copilot#Clear() return endif + call s:Echo('Copilot Thinking ' . "\uF1E6") call s:UpdatePreview() let delay = get(g:, 'copilot_idle_delay', 45) call timer_stop(get(g:, '_copilot_timer', -1)) From 66ece6a48ffb79061aed008bbf6efc0d27b0eda6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 21 Oct 2024 22:20:39 -0300 Subject: [PATCH 2/6] add done message --- autoload/copilot.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/copilot.vim b/autoload/copilot.vim index cc90bfc6..ee9c16f6 100644 --- a/autoload/copilot.vim +++ b/autoload/copilot.vim @@ -319,6 +319,7 @@ function! s:UpdatePreview() abort call remove(text, -1) endif if empty(text) || !s:has_ghost_text + call s:Echo('Done') return s:ClearPreview() endif if exists('b:_copilot.cycling_callbacks') From ead3b3bb05f3b4a563e4f08be91e251690facd3a Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 21 Oct 2024 22:36:54 -0300 Subject: [PATCH 3/6] removing for now --- autoload/copilot.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/copilot.vim b/autoload/copilot.vim index ee9c16f6..a74aca57 100644 --- a/autoload/copilot.vim +++ b/autoload/copilot.vim @@ -319,7 +319,7 @@ function! s:UpdatePreview() abort call remove(text, -1) endif if empty(text) || !s:has_ghost_text - call s:Echo('Done') + "call s:Echo('Done')" return s:ClearPreview() endif if exists('b:_copilot.cycling_callbacks') @@ -422,7 +422,7 @@ function! copilot#Schedule() abort call copilot#Clear() return endif - call s:Echo('Copilot Thinking ' . "\uF1E6") + "call s:Echo('Copilot Thinking ' . "\uF1E6")" call s:UpdatePreview() let delay = get(g:, 'copilot_idle_delay', 45) call timer_stop(get(g:, '_copilot_timer', -1)) From 6fc93181ec13b7f08d30274388429c313ca3ad40 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 21 Oct 2024 23:46:16 -0300 Subject: [PATCH 4/6] add floating dialog --- autoload/copilot.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/autoload/copilot.vim b/autoload/copilot.vim index a74aca57..1f529d18 100644 --- a/autoload/copilot.vim +++ b/autoload/copilot.vim @@ -1,5 +1,6 @@ scriptencoding utf-8 +let thinkingWindow let s:has_nvim_ghost_text = has('nvim-0.7') && exists('*nvim_buf_get_mark') let s:vim_minimum_version = '9.0.0185' let s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop') @@ -320,6 +321,7 @@ function! s:UpdatePreview() abort endif if empty(text) || !s:has_ghost_text "call s:Echo('Done')" + vim.api.nvim_win_close(thinkingWindow, true) return s:ClearPreview() endif if exists('b:_copilot.cycling_callbacks') @@ -423,6 +425,30 @@ function! copilot#Schedule() abort return endif "call s:Echo('Copilot Thinking ' . "\uF1E6")" + + local buf = vim.api.nvim_create_buf(false, true) + + -- Set the buffer content to the desired icon or text + vim.api.nvim_buf_set_lines(buf, 0, -1, false, { " 🔍" }) + + -- Get the current editor dimensions + local width = vim.api.nvim_get_option("columns") + local height = vim.api.nvim_get_option("lines") + + -- Calculate the position for the top right corner + local win_opts = { + relative = "editor", + width = 3, + height = 1, + col = 0, + row = height - 2, + style = "minimal", + border = "none", + } + + thinkingWindow = vim.api.nvim_open_win(buf, false, win_opts) + + call s:UpdatePreview() let delay = get(g:, 'copilot_idle_delay', 45) call timer_stop(get(g:, '_copilot_timer', -1)) From ba03148dc37b88436c85a4157c6b68863954f8f2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 21 Oct 2024 23:53:31 -0300 Subject: [PATCH 5/6] fix to run on vim file --- autoload/copilot.vim | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/autoload/copilot.vim b/autoload/copilot.vim index 1f529d18..cdc29a5b 100644 --- a/autoload/copilot.vim +++ b/autoload/copilot.vim @@ -321,7 +321,11 @@ function! s:UpdatePreview() abort endif if empty(text) || !s:has_ghost_text "call s:Echo('Done')" - vim.api.nvim_win_close(thinkingWindow, true) + if has('nvim') + call nvim_win_close(thinkingWindow, v:true) + else + call win_execute(thinkingWindow, 'close') + endif return s:ClearPreview() endif if exists('b:_copilot.cycling_callbacks') @@ -426,27 +430,27 @@ function! copilot#Schedule() abort endif "call s:Echo('Copilot Thinking ' . "\uF1E6")" - local buf = vim.api.nvim_create_buf(false, true) + let buf = nvim_create_buf(v:false, v:true) - -- Set the buffer content to the desired icon or text - vim.api.nvim_buf_set_lines(buf, 0, -1, false, { " 🔍" }) + " Set the buffer content to the desired icon or text + call nvim_buf_set_lines(buf, 0, -1, v:false, [' 🔍']) - -- Get the current editor dimensions - local width = vim.api.nvim_get_option("columns") - local height = vim.api.nvim_get_option("lines") + " Get the current editor dimensions + let width = &columns + let height = &lines - -- Calculate the position for the top right corner - local win_opts = { - relative = "editor", - width = 3, - height = 1, - col = 0, - row = height - 2, - style = "minimal", - border = "none", - } + " Calculate the position for the top right corner + let win_opts = { + \ 'relative': 'editor', + \ 'width': 3, + \ 'height': 1, + \ 'col': 0, + \ 'row': height - 2, + \ 'style': 'minimal', + \ 'border': 'none', + \ } - thinkingWindow = vim.api.nvim_open_win(buf, false, win_opts) + let thinkingWindow = nvim_open_win(buf, v:false, win_opts) call s:UpdatePreview() From 01ccbed085d4807ae1eef82b2801c1e2d5df874c Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 21 Oct 2024 23:59:28 -0300 Subject: [PATCH 6/6] remove temporarily --- autoload/copilot.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autoload/copilot.vim b/autoload/copilot.vim index cdc29a5b..b7bded39 100644 --- a/autoload/copilot.vim +++ b/autoload/copilot.vim @@ -1,6 +1,6 @@ scriptencoding utf-8 -let thinkingWindow +"let thinkingWindow" let s:has_nvim_ghost_text = has('nvim-0.7') && exists('*nvim_buf_get_mark') let s:vim_minimum_version = '9.0.0185' let s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop') @@ -321,11 +321,11 @@ function! s:UpdatePreview() abort endif if empty(text) || !s:has_ghost_text "call s:Echo('Done')" - if has('nvim') + "if has('nvim') call nvim_win_close(thinkingWindow, v:true) else call win_execute(thinkingWindow, 'close') - endif + endif" return s:ClearPreview() endif if exists('b:_copilot.cycling_callbacks') @@ -430,7 +430,7 @@ function! copilot#Schedule() abort endif "call s:Echo('Copilot Thinking ' . "\uF1E6")" - let buf = nvim_create_buf(v:false, v:true) + "let buf = nvim_create_buf(v:false, v:true) " Set the buffer content to the desired icon or text call nvim_buf_set_lines(buf, 0, -1, v:false, [' 🔍']) @@ -450,7 +450,7 @@ function! copilot#Schedule() abort \ 'border': 'none', \ } - let thinkingWindow = nvim_open_win(buf, v:false, win_opts) + let thinkingWindow = nvim_open_win(buf, v:false, win_opts)" call s:UpdatePreview()