From d9263b3718dca8fdd9fdaefa98ee63d6fd608733 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 6 Jun 2022 10:10:35 +0530 Subject: [PATCH] add error handling in statusline for devicons plugin --- lua/ui/statusline.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/ui/statusline.lua b/lua/ui/statusline.lua index 4a34f63..71fa0f8 100644 --- a/lua/ui/statusline.lua +++ b/lua/ui/statusline.lua @@ -71,7 +71,13 @@ M.fileInfo = function() filename = " " .. filename .. " " end - local ft_icon = require("nvim-web-devicons").get_icon(filename, extension) + local devicons_present, devicons = pcall(require, "nvim-web-devicons") + + if not devicons_present then + return " " + end + + local ft_icon = devicons.get_icon(filename, extension) icon = (ft_icon ~= nil and " " .. ft_icon) or icon return "%#St_file_info#" .. icon .. filename .. "%#St_file_sep#" .. sep_r