Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Apr 18, 2024
1 parent 89b6b2e commit 234cefd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
56 changes: 56 additions & 0 deletions lua/dotvim/extra/ui/copilot-chat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---@class dotvim.extra.ui.copilot_chat
local M = {}

function M.toggle()
if M.renderer then
return M.renderer:focus()
end

local n = require("nui-components")
local chat = require("CopilotChat")

local win_width = vim.o.columns
local win_height = vim.o.lines

local width = math.floor(win_width * 0.6)
local height = math.floor(win_height * 0.8)

local renderer = n.create_renderer {
width = width,
height = height,
relative = "editor",
position = {
row = math.floor((win_height - height) / 2),
col = math.floor((win_width - width) / 2),
},
}

local signal = n.create_signal {
prompt = "",
}

local buttons = function()
return n.columns {
n.button {
text = "Send",
on_click = function()
local prompt = signal:get("prompt")
if prompt == "" then
return
end

vim.api.nvim_command("CopilotChat send " .. prompt)
signal:set("prompt", "")
end,
},
n.button {
text = "Close",
on_click = function()
renderer:close()
end,
},
}
end
end

return M
3 changes: 3 additions & 0 deletions lua/dotvim/extra/ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ M.args_input = require("dotvim.extra.ui.args_input")
---@type dotvim.extra.ui.spectre
M.spectre = require("dotvim.extra.ui.spectre")

---@type dotvim.extra.ui.copilot_chat
M.copilot_chat = require("dotvim.extra.ui.copilot-chat")

return M

0 comments on commit 234cefd

Please sign in to comment.