fix(overseer): Crash when .vscode folder isn't present

This commit is contained in:
Jiří Štefka 2024-10-01 13:40:05 +02:00
parent 9e58b1629d
commit 6ea0b944ab

@ -3,6 +3,8 @@ if vim.g.did_load_overseer_plugin then
end end
vim.g.did_load_overseer_plugin = true vim.g.did_load_overseer_plugin = true
local file_exists = require("user.file_exists").file_exists
require("which-key").add({ require("which-key").add({
{ "<leader>o", group = "[o]verseer", icon = "" }, { "<leader>o", group = "[o]verseer", icon = "" },
{ "<leader>ot", "<Cmd>OverseerToggle<CR>", desc = "[o]verseer: [t]oggle " }, { "<leader>ot", "<Cmd>OverseerToggle<CR>", desc = "[o]verseer: [t]oggle " },
@ -18,11 +20,15 @@ local root_files = {
'.git', '.git',
} }
if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/tasks.json") then local root = vim.fs.find(root_files, { upward = true })[1]
if root then
if file_exists(root .. ".vscode/tasks.json") then
require('overseer').setup({ require('overseer').setup({
strategy = { strategy = {
"toggleterm", "toggleterm",
quit_on_exit = "success", quit_on_exit = "success",
}, },
}) })
end
end end