feat: refactor file structure
This commit is contained in:
parent
9761cded88
commit
965e47a1df
17 changed files with 19 additions and 22 deletions
|
|
@ -178,7 +178,6 @@ function M.setup(user_config)
|
|||
|
||||
local config = vim.tbl_deep_extend('force', M.defaults, user_config or {})
|
||||
|
||||
-- Validate merged config values
|
||||
vim.validate({
|
||||
before_run = {
|
||||
config.hooks.before_run,
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ local function toggle_run_panel(is_debug)
|
|||
end
|
||||
|
||||
local ctx = problem.create_context(state.platform, state.contest_id, state.problem_id, config)
|
||||
local run = require('cp.run')
|
||||
local run = require('cp.runner.run')
|
||||
|
||||
if not run.load_test_cases(ctx, state) then
|
||||
logger.log('no test cases found', vim.log.levels.WARN)
|
||||
|
|
@ -270,7 +270,7 @@ local function toggle_run_panel(is_debug)
|
|||
tab_buf = tab_buf,
|
||||
}
|
||||
|
||||
local highlight = require('cp.highlight')
|
||||
local highlight = require('cp.ui.highlight')
|
||||
local diff_namespace = highlight.create_namespace()
|
||||
|
||||
local test_list_namespace = vim.api.nvim_create_namespace('cp_test_list')
|
||||
|
|
@ -347,7 +347,7 @@ local function toggle_run_panel(is_debug)
|
|||
vim.api.nvim_set_option_value('filetype', 'cptest', { buf = diff_buf })
|
||||
vim.api.nvim_set_option_value('winbar', 'Expected vs Actual', { win = diff_win })
|
||||
|
||||
local diff_backend = require('cp.diff')
|
||||
local diff_backend = require('cp.ui.diff')
|
||||
local backend = diff_backend.get_best_backend('git')
|
||||
local diff_result = backend.render(expected_content, actual_content)
|
||||
|
||||
|
|
@ -459,7 +459,7 @@ local function toggle_run_panel(is_debug)
|
|||
ansi_namespace
|
||||
)
|
||||
elseif desired_mode == 'git' then
|
||||
local diff_backend = require('cp.diff')
|
||||
local diff_backend = require('cp.ui.diff')
|
||||
local backend = diff_backend.get_best_backend('git')
|
||||
local diff_result = backend.render(expected_content, actual_content)
|
||||
|
||||
|
|
@ -513,7 +513,7 @@ local function toggle_run_panel(is_debug)
|
|||
return
|
||||
end
|
||||
|
||||
local run_render = require('cp.run_render')
|
||||
local run_render = require('cp.runner.run_render')
|
||||
run_render.setup_highlights()
|
||||
|
||||
local test_state = run.get_run_panel_state()
|
||||
|
|
@ -573,7 +573,7 @@ local function toggle_run_panel(is_debug)
|
|||
config.hooks.before_debug(ctx)
|
||||
end
|
||||
|
||||
local execute = require('cp.execute')
|
||||
local execute = require('cp.runner.execute')
|
||||
local contest_config = config.contests[state.platform]
|
||||
local compile_result = execute.compile_problem(ctx, contest_config, is_debug)
|
||||
if compile_result.success then
|
||||
|
|
@ -586,7 +586,7 @@ local function toggle_run_panel(is_debug)
|
|||
|
||||
vim.schedule(function()
|
||||
if config.run_panel.ansi then
|
||||
local ansi = require('cp.ansi')
|
||||
local ansi = require('cp.ui.ansi')
|
||||
ansi.setup_highlight_groups()
|
||||
end
|
||||
if current_diff_layout then
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ function M.compile_generic(language_config, substitutions)
|
|||
:wait()
|
||||
local compile_time = (vim.uv.hrtime() - start_time) / 1000000
|
||||
|
||||
local ansi = require('cp.ansi')
|
||||
local ansi = require('cp.ui.ansi')
|
||||
result.stdout = ansi.bytes_to_string(result.stdout or '')
|
||||
result.stderr = ansi.bytes_to_string(result.stderr or '')
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ local function run_single_test_case(ctx, contest_config, cp_config, test_case)
|
|||
.system({ 'sh', '-c', table.concat(redirected_cmd, ' ') }, { text = false })
|
||||
:wait()
|
||||
|
||||
local ansi = require('cp.ansi')
|
||||
local ansi = require('cp.ui.ansi')
|
||||
compile_result.stdout = ansi.bytes_to_string(compile_result.stdout or '')
|
||||
compile_result.stderr = ansi.bytes_to_string(compile_result.stderr or '')
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ local function run_single_test_case(ctx, contest_config, cp_config, test_case)
|
|||
:wait()
|
||||
local execution_time = (vim.uv.hrtime() - start_time) / 1000000
|
||||
|
||||
local ansi = require('cp.ansi')
|
||||
local ansi = require('cp.ui.ansi')
|
||||
local stdout_str = ansi.bytes_to_string(result.stdout or '')
|
||||
local actual_output = stdout_str:gsub('\n$', '')
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ function M.get_run_panel_state()
|
|||
end
|
||||
|
||||
function M.handle_compilation_failure(compilation_output)
|
||||
local ansi = require('cp.ansi')
|
||||
local ansi = require('cp.ui.ansi')
|
||||
local config = require('cp.config').setup()
|
||||
|
||||
local clean_text
|
||||
|
|
@ -17,7 +17,7 @@ local problem = require('cp.problem')
|
|||
local utils = require('cp.utils')
|
||||
|
||||
local function check_internet_connectivity()
|
||||
local result = vim.system({ 'ping', '-c', '1', '-W', '3', '8.8.8.8' }, { text = true }):wait()
|
||||
local result = vim.system({ 'ping', '-c', '5', '-W', '3', '8.8.8.8' }, { text = true }):wait()
|
||||
return result.code == 0
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ function M.restore_layout(state, tile_fn)
|
|||
local source_file
|
||||
if source_files ~= '' then
|
||||
local files = vim.split(source_files, '\n')
|
||||
-- Prefer known extensions first, but accept any extension
|
||||
local known_extensions = vim.tbl_keys(constants.filetype_to_language)
|
||||
for _, file in ipairs(files) do
|
||||
local ext = vim.fn.fnamemodify(file, ':e')
|
||||
Loading…
Add table
Add a link
Reference in a new issue