From 6ea0b944ab9b6a8ab065ada8bdaad2a6004187db Mon Sep 17 00:00:00 2001 From: jiriks74 Date: Tue, 1 Oct 2024 13:40:05 +0200 Subject: [PATCH] fix(overseer): Crash when `.vscode` folder isn't present --- nvim/plugin/overseer.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/nvim/plugin/overseer.lua b/nvim/plugin/overseer.lua index 7612807..c5c93e7 100644 --- a/nvim/plugin/overseer.lua +++ b/nvim/plugin/overseer.lua @@ -3,6 +3,8 @@ if vim.g.did_load_overseer_plugin then end vim.g.did_load_overseer_plugin = true +local file_exists = require("user.file_exists").file_exists + require("which-key").add({ { "o", group = "[o]verseer", icon = "" }, { "ot", "OverseerToggle", desc = "[o]verseer: [t]oggle " }, @@ -18,11 +20,15 @@ local root_files = { '.git', } -if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/tasks.json") then - require('overseer').setup({ - strategy = { - "toggleterm", - quit_on_exit = "success", - }, - }) +local root = vim.fs.find(root_files, { upward = true })[1] + +if root then + if file_exists(root .. ".vscode/tasks.json") then + require('overseer').setup({ + strategy = { + "toggleterm", + quit_on_exit = "success", + }, + }) + end end