From 126724b93955c048bbeaac02f7d540d935031b90 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 24 Feb 2026 15:09:58 -0500 Subject: [PATCH] feat(health): add checkhealth integration Problem: need a way to diagnose config, data file, and dependency issues. Solution: add health module reporting config values, data directory status, task count, and curl/openssl availability. --- lua/todo/health.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lua/todo/health.lua diff --git a/lua/todo/health.lua b/lua/todo/health.lua new file mode 100644 index 0000000..72652f6 --- /dev/null +++ b/lua/todo/health.lua @@ -0,0 +1,55 @@ +local M = {} + +function M.check() + vim.health.start('todo.nvim') + + local ok, config = pcall(require, 'todo.config') + if not ok then + vim.health.error('Failed to load todo.config') + return + end + + local cfg = config.get() + vim.health.ok('Config loaded') + vim.health.info('Data path: ' .. cfg.data_path) + vim.health.info('Default view: ' .. cfg.default_view) + vim.health.info('Default category: ' .. cfg.default_category) + vim.health.info('Date format: ' .. cfg.date_format) + vim.health.info('Date syntax: ' .. cfg.date_syntax) + + local data_dir = vim.fn.fnamemodify(cfg.data_path, ':h') + if vim.fn.isdirectory(data_dir) == 1 then + vim.health.ok('Data directory exists: ' .. data_dir) + else + vim.health.warn('Data directory does not exist yet: ' .. data_dir) + end + + if vim.fn.filereadable(cfg.data_path) == 1 then + local store_ok, store = pcall(require, 'todo.store') + if store_ok then + local load_ok, err = pcall(store.load) + if load_ok then + local tasks = store.tasks() + vim.health.ok('Data file loaded: ' .. #tasks .. ' tasks') + else + vim.health.error('Failed to load data file: ' .. tostring(err)) + end + end + else + vim.health.info('No data file yet (will be created on first save)') + end + + if vim.fn.executable('curl') == 1 then + vim.health.ok('curl found (required for Google Calendar sync)') + else + vim.health.warn('curl not found (needed for Google Calendar sync)') + end + + if vim.fn.executable('openssl') == 1 then + vim.health.ok('openssl found (required for OAuth PKCE)') + else + vim.health.warn('openssl not found (needed for Google Calendar OAuth)') + end +end + +return M