chore(cmd): add manual refresh and update types (#44)

* chore(cmd): add manual refresh and update types

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* chore: add refresh mapping

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-08-17 13:41:34 -04:00
committed by GitHub
parent d0d4f8a27c
commit 95b42e835f
5 changed files with 48 additions and 38 deletions

View File

@@ -141,7 +141,7 @@ function Sidebar:intialize()
local filetype = api.nvim_get_option_value("filetype", { buf = self.code.buf })
local selected_code_buf = self.renderer:get_component_by_id("selected_code").bufnr
api.nvim_buf_set_option(selected_code_buf, "filetype", filetype)
api.nvim_set_option_value("filetype", filetype, { buf = selected_code_buf })
api.nvim_set_option_value("wrap", false, { win = self.renderer:get_component_by_id("selected_code").winid })
api.nvim_create_autocmd("BufEnter", {
@@ -209,24 +209,6 @@ function Sidebar:intialize()
return self
end
function Sidebar:refresh()
local buf = vim.api.nvim_get_current_buf()
local focused = self.view.buf == buf or self.bufnr.result == buf or self.bufnr.input == buf
if focused or not self.view:is_open() then
return
end
local ft = vim.api.nvim_get_option_value("filetype", { buf = buf })
local listed = vim.api.nvim_get_option_value("buflisted", { buf = buf })
if ft == "Avante" or not listed then
return
end
return self
end
---@param content string concatenated content of the buffer
---@param focus? boolean whether to focus the result view
function Sidebar:update_content(content, focus, callback)