From d2c93deee35fa4042fde28719ddcbad664544fcf Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 15 May 2023 14:53:07 -0500 Subject: [PATCH] fix(#11): work with failed filetypes --- lua/import-cost.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/import-cost.lua b/lua/import-cost.lua index 19d252d..f54d6f7 100644 --- a/lua/import-cost.lua +++ b/lua/import-cost.lua @@ -1,7 +1,11 @@ local M = {} local function is_ic_buf(bufnr) - local filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype') + local ok, filetype = pcall(vim.api.nvim_buf_get_option, bufnr, 'filetype') + + if not ok then + return false + end return vim.tbl_contains(M.config.filetypes, filetype) end