From cadee677ba693ae527d5bc12b5ad5be94819074e Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Wed, 28 Aug 2024 13:49:16 -0300 Subject: [PATCH] feat: make `nvim-web-devicons` an optional dependency (#328) * chore: make `web-devicons` optional * docs: update readme install instructions --- README.md | 5 +++-- lua/avante/sidebar.lua | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2bafc5b..c2db14b 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,13 @@ Install `avante.nvim` using [lazy.nvim](https://github.com/folke/lazy.nvim): -- add any opts here }, dependencies = { - "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons "stevearc/dressing.nvim", "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", - --- The below is optional, make sure to setup it properly if you have lazy=true + --- The below dependencies are optional, + "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons { + -- Make sure to setup it properly if you have lazy=true 'MeanderingProgrammer/render-markdown.nvim', opts = { file_types = { "markdown", "Avante" }, diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index 286306a..a43f9d3 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -427,7 +427,12 @@ function Sidebar:render_input() ---@diagnostic disable-next-line: undefined-global icon, _, _ = MiniIcons.get("filetype", filetype) else - icon = require("nvim-web-devicons").get_icon_by_filetype(filetype, {}) + local ok, devicons = pcall(require, "nvim-web-devicons") + if ok then + icon = devicons.get_icon_by_filetype(filetype, {}) + else + icon = "" + end end local code_file_fullpath = api.nvim_buf_get_name(self.code.bufnr)