Skip to content

Commit 5bd143a

Browse files
committed
wip: add hint popup
1 parent 69d0934 commit 5bd143a

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

lua/copilot-lsp/init.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
local M = {}
2+
3+
function M.setup(opts)
4+
opts = opts or {}
5+
end
6+
7+
return M

lua/copilot-lsp/nes/ui.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local M = {}
55
---@param ns_id integer
66
local function _dismiss_suggestion_ui(bufnr, suggestion_ui, ns_id)
77
pcall(vim.api.nvim_win_close, suggestion_ui.preview_winnr, true)
8+
pcall(vim.api.nvim_win_close, suggestion_ui.hint_winnr, true)
89
pcall(vim.api.nvim_buf_clear_namespace, bufnr, ns_id, 0, -1)
910
end
1011

@@ -130,6 +131,33 @@ function M._display_next_suggestion(edits, ns_id)
130131
ui.preview_winnr = preview_winnr
131132
end
132133

134+
local hint_bufnr = vim.api.nvim_create_buf(false, true)
135+
vim.api.nvim_buf_set_lines(hint_bufnr, 0, -1, false, { " ⇥ <C-e>" })
136+
137+
vim.bo[hint_bufnr].modifiable = false
138+
vim.bo[hint_bufnr].buflisted = false
139+
vim.bo[hint_bufnr].buftype = "nofile"
140+
vim.bo[hint_bufnr].bufhidden = "wipe"
141+
142+
local hint_winnr = vim.api.nvim_open_win(hint_bufnr, false, {
143+
relative = "cursor",
144+
width = 10,
145+
height = 1,
146+
row = (suggestion.range["end"].line + same_line) - vim.api.nvim_win_get_cursor(0)[1] - 1,
147+
col = 0,
148+
zindex = 150,
149+
150+
-- bufpos = {
151+
-- suggestion.range["end"].line,
152+
-- 0,
153+
-- },
154+
style = "minimal",
155+
border = "none",
156+
})
157+
vim.wo[hint_winnr].winhighlight = "Normal:FloatTitle"
158+
159+
ui.hint_winnr = hint_winnr
160+
133161
suggestion.ui = ui
134162

135163
vim.b[bufnr].nes_state = suggestion

lua/copilot-lsp/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
---@class nes.EditSuggestionUI
1313
---@field preview_winnr? integer
14+
---@field hint_winnr? integer
1415

1516
---@class nes.Apply.Opts
1617
---@field jump? boolean | { hl_timeout: integer? } auto jump to the end of the new edit

0 commit comments

Comments
 (0)