fix(lint): make neovim 0.11 typecheck happy (#1844)
This commit is contained in:
@@ -14,6 +14,7 @@ local Config = require("avante.config")
|
||||
---@field _group number | nil
|
||||
---@field _popup NuiPopup | nil
|
||||
---@field _prev_winid number | nil
|
||||
---@field _ns_id number | nil
|
||||
local M = {}
|
||||
M.__index = M
|
||||
|
||||
@@ -27,6 +28,7 @@ function M:new(message, callback, opts)
|
||||
this.callback = callback
|
||||
this._container_winid = opts.container_winid or vim.api.nvim_get_current_win()
|
||||
this._focus = opts.focus
|
||||
this._ns_id = vim.api.nvim_create_namespace("avante_confirm")
|
||||
return this
|
||||
end
|
||||
|
||||
@@ -144,8 +146,8 @@ function M:open()
|
||||
vim.api.nvim_buf_set_lines(popup.bufnr, 0, -1, false, content)
|
||||
Utils.lock_buf(popup.bufnr)
|
||||
|
||||
buttons_line:set_highlights(0, popup.bufnr, buttons_line_num, buttons_start_col)
|
||||
keybindings_line:set_highlights(0, popup.bufnr, keybindings_line_num)
|
||||
buttons_line:set_highlights(self._ns_id, popup.bufnr, buttons_line_num, buttons_start_col)
|
||||
keybindings_line:set_highlights(self._ns_id, popup.bufnr, keybindings_line_num)
|
||||
focus_button()
|
||||
end
|
||||
|
||||
@@ -359,6 +361,7 @@ function M:close()
|
||||
self._popup = nil
|
||||
return true
|
||||
end
|
||||
if self._ns_id then vim.api.nvim_del_namespace(self._ns_id) end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ function M:set_highlights(ns_id, bufnr, line, offset)
|
||||
local text = section[1]
|
||||
local highlight = section[2]
|
||||
if type(highlight) == "function" then highlight = highlight() end
|
||||
if highlight then vim.api.nvim_buf_add_highlight(bufnr, ns_id, highlight, line, col_start, col_start + #text) end
|
||||
if highlight then
|
||||
vim.highlight.range(bufnr, ns_id, highlight, { line, col_start }, { line, col_start + #text })
|
||||
end
|
||||
col_start = col_start + #text
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,6 +18,7 @@ local Utils = require("avante.utils")
|
||||
---@field spinner_timer uv_timer_t | nil
|
||||
---@field spinner_active boolean
|
||||
---@field default_value string | nil
|
||||
---@field popup_hint_id integer | nil
|
||||
local PromptInput = {}
|
||||
PromptInput.__index = PromptInput
|
||||
|
||||
@@ -87,6 +88,7 @@ function PromptInput:new(opts)
|
||||
obj.spinner_index = 1
|
||||
obj.spinner_timer = nil
|
||||
obj.spinner_active = false
|
||||
obj.popup_hint_id = vim.api.nvim_create_namespace("avante_prompt_input_hint")
|
||||
return obj
|
||||
end
|
||||
|
||||
@@ -184,7 +186,12 @@ function PromptInput:show_shortcuts_hints()
|
||||
|
||||
local buf = api.nvim_create_buf(false, true)
|
||||
api.nvim_buf_set_lines(buf, 0, -1, false, { display_text })
|
||||
vim.api.nvim_buf_add_highlight(buf, 0, "AvantePopupHint", 0, 0, -1)
|
||||
api.nvim_buf_set_extmark(buf, self.popup_hint_id, 0, 0, {
|
||||
end_row = 0,
|
||||
end_col = #display_text,
|
||||
hl_group = "AvantePopupHint",
|
||||
priority = 100,
|
||||
})
|
||||
|
||||
local width = fn.strdisplaywidth(display_text)
|
||||
|
||||
@@ -208,6 +215,7 @@ end
|
||||
function PromptInput:close_shortcuts_hints()
|
||||
if self.shortcuts_hints_winid and api.nvim_win_is_valid(self.shortcuts_hints_winid) then
|
||||
local buf = api.nvim_win_get_buf(self.shortcuts_hints_winid)
|
||||
if self.popup_hint_id then api.nvim_buf_clear_namespace(buf, self.popup_hint_id, 0, -1) end
|
||||
api.nvim_win_close(self.shortcuts_hints_winid, true)
|
||||
api.nvim_buf_delete(buf, { force = true })
|
||||
self.shortcuts_hints_winid = nil
|
||||
|
||||
Reference in New Issue
Block a user