diff --git a/doc/cp.txt b/doc/cp.txt index 6299713..8af2ff6 100644 --- a/doc/cp.txt +++ b/doc/cp.txt @@ -364,29 +364,18 @@ Example: Setting up and solving AtCoder contest ABC324 PICKER INTEGRATION *cp-picker* When picker integration is enabled in configuration, cp.nvim provides interactive -platform, contest, and problem selection using telescope.nvim or fzf-lua. +platform and contest selection using telescope.nvim or fzf-lua. :CP pick *:CP-pick* Launch configured picker for interactive problem selection. - Control Flow: Select Platform → Contest → Problem → Code! + Control Flow: Select Platform → Contest → Code! Requires picker = 'telescope' or picker = 'fzf-lua' in configuration. Requires corresponding plugin (telescope.nvim or fzf-lua) to be installed. -Picker Controls ~ - *cp-picker-controls* - The picker interface provides several keyboard shortcuts for enhanced control: - - Force refresh contest list, bypassing cache - Useful when contest lists are outdated or incomplete - Shows loading indicator during refresh operation - - Standard picker controls (telescope.nvim/fzf-lua): - Select current item and proceed to next step - / Cancel picker and return to editor - / Navigate to next item - / Navigate to previous item - / Start filtering/searching items +PICKER KEYMAPS *cp-picker-keys* + Force refresh contest list, bypassing cache. + Useful when contest lists are outdated or incomplete ============================================================================== RUN PANEL *cp-run* @@ -542,13 +531,13 @@ prevent them from being overridden: >lua ============================================================================== RUN PANEL KEYMAPS *cp-test-keys* - Navigate to next test case (configurable via + Navigate to next test case (configurable via run_panel.next_test_key) - Navigate to previous test case (configurable via + Navigate to previous test case (configurable via run_panel.prev_test_key) - Cycle through diff modes: none → git → vim (configurable + Cycle through diff modes: none → git → vim (configurable via run_panel.toggle_diff_key) - Exit run panel/interactive terminal and restore layout + Exit run panel/interactive terminal and restore layout Diff Modes ~ diff --git a/lua/cp/cache.lua b/lua/cp/cache.lua index 41500e8..bab413e 100644 --- a/lua/cp/cache.lua +++ b/lua/cp/cache.lua @@ -227,10 +227,6 @@ end ---@param file_path string ---@return FileState? function M.get_file_state(file_path) - vim.validate({ - file_path = { file_path, 'string' }, - }) - if not cache_data.file_states then return nil end @@ -244,18 +240,6 @@ end ---@param problem_id? string ---@param language? string function M.set_file_state(file_path, platform, contest_id, problem_id, language) - vim.validate({ - file_path = { file_path, 'string' }, - platform = { platform, 'string' }, - contest_id = { contest_id, 'string' }, - problem_id = { problem_id, { 'string', 'nil' }, true }, - language = { language, { 'string', 'nil' }, true }, - }) - - if not cache_data.file_states then - cache_data.file_states = {} - end - cache_data.file_states[file_path] = { platform = platform, contest_id = contest_id, @@ -269,10 +253,6 @@ end ---@param platform string ---@return table[]? function M.get_contest_list(platform) - vim.validate({ - platform = { platform, 'string' }, - }) - if not cache_data.contest_lists or not cache_data.contest_lists[platform] then return nil end @@ -283,11 +263,6 @@ end ---@param platform string ---@param contests table[] function M.set_contest_list(platform, contests) - vim.validate({ - platform = { platform, 'string' }, - contests = { contests, 'table' }, - }) - if not cache_data.contest_lists then cache_data.contest_lists = {} end @@ -302,10 +277,6 @@ end ---@param platform string function M.clear_contest_list(platform) - vim.validate({ - platform = { platform, 'string' }, - }) - if cache_data.contest_lists and cache_data.contest_lists[platform] then cache_data.contest_lists[platform] = nil M.save() @@ -319,10 +290,6 @@ end ---@param platform string function M.clear_platform(platform) - vim.validate({ - platform = { platform, 'string' }, - }) - if cache_data[platform] then cache_data[platform] = nil end diff --git a/lua/cp/config.lua b/lua/cp/config.lua index ed0c5f0..e5f0963 100644 --- a/lua/cp/config.lua +++ b/lua/cp/config.lua @@ -286,11 +286,6 @@ end ---@param problem_id? string ---@return string local function default_filename(contest_id, problem_id) - vim.validate({ - contest_id = { contest_id, 'string' }, - problem_id = { problem_id, { 'string', 'nil' }, true }, - }) - if problem_id then return (contest_id .. problem_id):lower() else diff --git a/lua/cp/pickers/init.lua b/lua/cp/pickers/init.lua index fd93a8f..ee6bbb9 100644 --- a/lua/cp/pickers/init.lua +++ b/lua/cp/pickers/init.lua @@ -108,7 +108,6 @@ function M.get_contests_for_platform(platform) }) end - cache.set_contest_list(platform, contests) logger.log(('loaded %d contests'):format(#contests)) return contests end diff --git a/lua/cp/pickers/telescope.lua b/lua/cp/pickers/telescope.lua index f5ae704..6362042 100644 --- a/lua/cp/pickers/telescope.lua +++ b/lua/cp/pickers/telescope.lua @@ -47,7 +47,7 @@ local function contest_picker(opts, platform) end end) - map('i', '', function() + map('i', '', function() local cache = require('cp.cache') cache.clear_contest_list(platform) actions.close(prompt_bufnr) diff --git a/lua/cp/runner/execute.lua b/lua/cp/runner/execute.lua index aa93cce..8bffa33 100644 --- a/lua/cp/runner/execute.lua +++ b/lua/cp/runner/execute.lua @@ -15,11 +15,6 @@ local filetype_to_language = constants.filetype_to_language ---@param contest_config table ---@return string local function get_language_from_file(source_file, contest_config) - vim.validate({ - source_file = { source_file, 'string' }, - contest_config = { contest_config, 'table' }, - }) - local extension = vim.fn.fnamemodify(source_file, ':e') local language = filetype_to_language[extension] or contest_config.default_language return language @@ -29,11 +24,6 @@ end ---@param substitutions table ---@return string[] local function substitute_template(cmd_template, substitutions) - vim.validate({ - cmd_template = { cmd_template, 'table' }, - substitutions = { substitutions, 'table' }, - }) - local result = {} for _, arg in ipairs(cmd_template) do local substituted = arg @@ -50,12 +40,6 @@ end ---@param substitutions table ---@return string[] local function build_command(cmd_template, executable, substitutions) - vim.validate({ - cmd_template = { cmd_template, 'table' }, - executable = { executable, { 'string', 'nil' }, true }, - substitutions = { substitutions, 'table' }, - }) - local cmd = substitute_template(cmd_template, substitutions) if executable then table.insert(cmd, 1, executable) @@ -67,11 +51,6 @@ end ---@param substitutions table ---@return {code: integer, stdout: string, stderr: string} function M.compile_generic(language_config, substitutions) - vim.validate({ - language_config = { language_config, 'table' }, - substitutions = { substitutions, 'table' }, - }) - if not language_config.compile then logger.log('no compilation step required') return { code = 0, stderr = '' } @@ -107,12 +86,6 @@ end ---@param timeout_ms number ---@return ExecuteResult local function execute_command(cmd, input_data, timeout_ms) - vim.validate({ - cmd = { cmd, 'table' }, - input_data = { input_data, 'string' }, - timeout_ms = { timeout_ms, 'number' }, - }) - local redirected_cmd = vim.deepcopy(cmd) if #redirected_cmd > 0 then redirected_cmd[#redirected_cmd] = redirected_cmd[#redirected_cmd] .. ' 2>&1' @@ -158,12 +131,6 @@ end ---@param is_debug boolean ---@return string local function format_output(exec_result, expected_file, is_debug) - vim.validate({ - exec_result = { exec_result, 'table' }, - expected_file = { expected_file, 'string' }, - is_debug = { is_debug, 'boolean' }, - }) - local output_lines = { exec_result.stdout } local metadata_lines = {} @@ -207,10 +174,6 @@ end ---@param is_debug? boolean ---@return {success: boolean, output: string?} function M.compile_problem(contest_config, is_debug) - vim.validate({ - contest_config = { contest_config, 'table' }, - }) - local state = require('cp.state') local source_file = state.get_source_file() if not source_file then @@ -249,12 +212,9 @@ function M.compile_problem(contest_config, is_debug) return { success = true, output = nil } end +---@param contest_config ContestConfig +---@param is_debug boolean function M.run_problem(contest_config, is_debug) - vim.validate({ - contest_config = { contest_config, 'table' }, - is_debug = { is_debug, 'boolean' }, - }) - local state = require('cp.state') local source_file = state.get_source_file() local output_file = state.get_output_file()