chore(icons): support mini.icons (#202)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
f99bf767b5
commit
46ec0a50a7
@ -30,7 +30,7 @@ Install `avante.nvim` using [lazy.nvim](https://github.com/folke/lazy.nvim):
|
|||||||
-- add any opts here
|
-- add any opts here
|
||||||
},
|
},
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-tree/nvim-web-devicons",
|
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
|
||||||
"stevearc/dressing.nvim",
|
"stevearc/dressing.nvim",
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
"MunifTanjim/nui.nvim",
|
"MunifTanjim/nui.nvim",
|
||||||
|
@ -413,8 +413,16 @@ function Sidebar:render_input_container()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local filetype = api.nvim_get_option_value("filetype", { buf = self.code.bufnr })
|
local filetype = api.nvim_get_option_value("filetype", { buf = self.code.bufnr })
|
||||||
|
|
||||||
|
---@type string
|
||||||
|
local icon
|
||||||
|
if _G.MiniIcons ~= nil then
|
||||||
|
icon, _, _ = MiniIcons.get("filetype", filetype)
|
||||||
|
else
|
||||||
|
icon = require("nvim-web-devicons").get_icon_by_filetype(filetype, {})
|
||||||
|
end
|
||||||
|
|
||||||
local code_file_fullpath = api.nvim_buf_get_name(self.code.bufnr)
|
local code_file_fullpath = api.nvim_buf_get_name(self.code.bufnr)
|
||||||
local icon = require("nvim-web-devicons").get_icon_by_filetype(filetype, {})
|
|
||||||
local code_filename = fn.fnamemodify(code_file_fullpath, ":t")
|
local code_filename = fn.fnamemodify(code_file_fullpath, ":t")
|
||||||
local header_text = string.format(" Chat with %s %s (<Tab>: switch focus)", icon, code_filename)
|
local header_text = string.format(" Chat with %s %s (<Tab>: switch focus)", icon, code_filename)
|
||||||
|
|
||||||
@ -1358,17 +1366,16 @@ function Sidebar:create_input()
|
|||||||
local function show_hint()
|
local function show_hint()
|
||||||
close_hint() -- Close the existing hint window
|
close_hint() -- Close the existing hint window
|
||||||
|
|
||||||
local hint_text = "Press " .. Config.mappings.submit.insert .. " to submit"
|
local hint_text = "Press "
|
||||||
if vim.fn.mode() ~= "i" then
|
.. (vim.fn.mode() ~= "i" and Config.mappings.submit.normal or Config.mappings.submit.insert)
|
||||||
hint_text = "Press " .. Config.mappings.submit.normal .. " to submit"
|
.. " to submit"
|
||||||
end
|
|
||||||
|
|
||||||
local buf = api.nvim_create_buf(false, true)
|
local buf = api.nvim_create_buf(false, true)
|
||||||
api.nvim_buf_set_lines(buf, 0, -1, false, { hint_text })
|
api.nvim_buf_set_lines(buf, 0, -1, false, { hint_text })
|
||||||
|
|
||||||
-- Get the current window size
|
-- Get the current window size
|
||||||
local win_width = api.nvim_win_get_width(self.input.winid)
|
local win_width = api.nvim_win_get_width(self.input.winid)
|
||||||
local width = #hint_text + 2
|
local width = #hint_text
|
||||||
|
|
||||||
-- Set the floating window options
|
-- Set the floating window options
|
||||||
local opts = {
|
local opts = {
|
||||||
@ -1390,11 +1397,8 @@ function Sidebar:create_input()
|
|||||||
api.nvim_win_set_hl_ns(hint_window, Highlights.hint_ns)
|
api.nvim_win_set_hl_ns(hint_window, Highlights.hint_ns)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.input:on(event.InsertEnter, show_hint)
|
self.input:on_mount(show_hint)
|
||||||
|
self.input:on_unmount(close_hint)
|
||||||
self.input:on_unmount(function()
|
|
||||||
close_hint()
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Show hint in insert mode
|
-- Show hint in insert mode
|
||||||
api.nvim_create_autocmd("ModeChanged", {
|
api.nvim_create_autocmd("ModeChanged", {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user