diff --git a/lua/cp/health.lua b/lua/cp/health.lua index 563c065..c2193ec 100644 --- a/lua/cp/health.lua +++ b/lua/cp/health.lua @@ -34,20 +34,6 @@ local function check_python_env() end end -local function check_scrapers() - local plugin_path = utils.get_plugin_path() - - local scrapers = { 'atcoder.py', 'codeforces.py', 'cses.py' } - for _, scraper in ipairs(scrapers) do - local scraper_path = plugin_path .. '/scrapers/' .. scraper - if vim.fn.filereadable(scraper_path) == 1 then - vim.health.ok('Scraper found: ' .. scraper) - else - vim.health.error('Missing scraper: ' .. scraper) - end - end -end - local function check_luasnip() local has_luasnip, luasnip = pcall(require, 'luasnip') if has_luasnip then @@ -59,25 +45,6 @@ local function check_luasnip() end end -local function check_config() - vim.health.ok('Plugin ready') - - local cp = require('cp') - local context = cp.get_current_context() - if context.platform then - local info = context.platform - if context.contest_id then - info = info .. ' ' .. context.contest_id - if context.problem_id then - info = info .. ' ' .. context.problem_id - end - end - vim.health.info('Current context: ' .. info) - else - vim.health.info('No contest context set') - end -end - function M.check() local version = require('cp.version') vim.health.start('cp.nvim health check') @@ -87,9 +54,7 @@ function M.check() check_nvim_version() check_uv() check_python_env() - check_scrapers() check_luasnip() - check_config() end return M diff --git a/lua/cp/init.lua b/lua/cp/init.lua index 3319bb7..03e3d81 100644 --- a/lua/cp/init.lua +++ b/lua/cp/init.lua @@ -31,14 +31,6 @@ function M.setup(opts) end end -function M.get_current_context() - return { - platform = state.get_platform(), - contest_id = state.get_contest_id(), - problem_id = state.get_problem_id(), - } -end - function M.is_initialized() return true end diff --git a/lua/cp/setup.lua b/lua/cp/setup.lua index 7a77d62..629c3a2 100644 --- a/lua/cp/setup.lua +++ b/lua/cp/setup.lua @@ -30,7 +30,8 @@ end function M.setup_contest(platform, contest_id, problem_id, language) if not state.get_platform() then - logger.log('no platform set', vim.log.levels.ERROR) + logger.log('No platform configured. Use :CP [...] first.') + return end @@ -215,7 +216,10 @@ function M.navigate_problem(direction, language) local current_problem_id = state.get_problem_id() if not platform or not contest_id or not current_problem_id then - logger.log('no contest context', vim.log.levels.ERROR) + logger.log( + 'No platform configured. Use :CP [...] first.', + vim.log.levels.ERROR + ) return end diff --git a/lua/cp/ui/panel.lua b/lua/cp/ui/panel.lua index 3c99430..7fb1984 100644 --- a/lua/cp/ui/panel.lua +++ b/lua/cp/ui/panel.lua @@ -36,7 +36,7 @@ function M.toggle_interactive() if not platform then logger.log( - 'No platform %s configured. Use :CP [...] first.', + 'No platform configured. Use :CP [...] first.', vim.log.levels.ERROR ) return @@ -131,7 +131,7 @@ function M.toggle_run_panel(is_debug) if not platform then logger.log( - 'No platform %s configured. Use :CP [...] first.', + 'No platform configured. Use :CP [...] first.', vim.log.levels.ERROR ) return diff --git a/plugin/cp.lua b/plugin/cp.lua index da193dc..37c6f36 100644 --- a/plugin/cp.lua +++ b/plugin/cp.lua @@ -22,13 +22,13 @@ end, { if num_args == 2 then local candidates = {} - local cp = require('cp') - local context = cp.get_current_context() - if context.platform and context.contest_id then + local state = require('cp.state') + local platform, contest_id = state.get_platform(), state.get_contest_id() + if platform and contest_id then vim.list_extend(candidates, actions) local cache = require('cp.cache') cache.load() - local contest_data = cache.get_contest_data(context.platform, context.contest_id) + local contest_data = cache.get_contest_data(platform, contest_id) if contest_data and contest_data.problems then for _, problem in ipairs(contest_data.problems) do table.insert(candidates, problem.id) diff --git a/spec/command_parsing_spec.lua b/spec/command_parsing_spec.lua index c1a8d97..c6114e3 100644 --- a/spec/command_parsing_spec.lua +++ b/spec/command_parsing_spec.lua @@ -559,7 +559,7 @@ describe('cp command parsing', function() package.loaded['cp.cache'] = nil end) - it('completes platforms and global actions when no contest context', function() + it('completes platforms and global actions without contest configuration', function() local result = complete_fn('', 'CP ', 3) assert.is_table(result) diff --git a/spec/error_boundaries_spec.lua b/spec/error_boundaries_spec.lua index 65825db..7d88a0d 100644 --- a/spec/error_boundaries_spec.lua +++ b/spec/error_boundaries_spec.lua @@ -186,7 +186,7 @@ describe('Error boundary handling', function() has_validation_error = true elseif log_entry.msg - and (log_entry.msg:match('no contest set') or log_entry.msg:match('No contest configured')) + and (log_entry.msg:match('No platform ') or log_entry.msg:match('No contest ')) then has_appropriate_errors = has_appropriate_errors + 1 end