diff --git a/doc/cp.nvim.txt b/doc/cp.nvim.txt index 9361121..d6d1d73 100644 --- a/doc/cp.nvim.txt +++ b/doc/cp.nvim.txt @@ -202,49 +202,12 @@ Debug Builds ~ } < -============================================================================== -MAPPINGS *cp-mappings* - -cp.nvim provides mappings for all primary actions. These dispatch -through the same code path as |:CP|. - - *(cp-run)* -(cp-run) Run tests in I/O view. Equivalent to :CP run. - - *(cp-panel)* -(cp-panel) Open full-screen test panel. Equivalent to :CP panel. - - *(cp-edit)* -(cp-edit) Open the test case editor. Equivalent to :CP edit. - - *(cp-next)* -(cp-next) Navigate to the next problem. Equivalent to :CP next. - - *(cp-prev)* -(cp-prev) Navigate to the previous problem. Equivalent to :CP prev. - - *(cp-pick)* -(cp-pick) Launch the contest picker. Equivalent to :CP pick. - - *(cp-interact)* -(cp-interact) Open interactive mode. Equivalent to :CP interact. - -Example configuration: >lua - vim.keymap.set('n', 'cr', '(cp-run)') - vim.keymap.set('n', 'cp', '(cp-panel)') - vim.keymap.set('n', 'ce', '(cp-edit)') - vim.keymap.set('n', 'cn', '(cp-next)') - vim.keymap.set('n', 'cN', '(cp-prev)') - vim.keymap.set('n', 'cc', '(cp-pick)') - vim.keymap.set('n', 'ci', '(cp-interact)') -< - ============================================================================== CONFIGURATION *cp-config* -Configuration is done via `vim.g.cp`. Set this before using the plugin: +Configuration is done via `vim.g.cp_config`. Set this before using the plugin: >lua - vim.g.cp = { + vim.g.cp_config = { languages = { cpp = { extension = 'cc', @@ -311,7 +274,7 @@ the default; per-platform overrides can tweak 'extension' or 'commands'. For example, to run CodeForces contests with Python by default: >lua - vim.g.cp = { + vim.g.cp_config = { platforms = { codeforces = { default_language = 'python', @@ -322,7 +285,7 @@ For example, to run CodeForces contests with Python by default: Any language is supported provided the proper configuration. For example, to run CSES problems with Rust using the single schema: >lua - vim.g.cp = { + vim.g.cp_config = { languages = { rust = { extension = 'rs', diff --git a/lua/cp/init.lua b/lua/cp/init.lua index 3cb36c1..fac3044 100644 --- a/lua/cp/init.lua +++ b/lua/cp/init.lua @@ -17,7 +17,7 @@ local function ensure_initialized() if initialized then return end - local user_config = vim.g.cp or {} + local user_config = vim.g.cp_config or {} local config = config_module.setup(user_config) config_module.set_current_config(config) initialized = true @@ -34,13 +34,4 @@ function M.is_initialized() return initialized end ----@deprecated Use `vim.g.cp` instead -function M.setup(user_config) - vim.deprecate('require("cp").setup()', 'vim.g.cp', 'v0.7.7', 'cp.nvim', false) - - if user_config then - vim.g.cp = vim.tbl_deep_extend('force', vim.g.cp or {}, user_config) - end -end - return M diff --git a/lua/cp/setup.lua b/lua/cp/setup.lua index e3bb38d..fce1a0c 100644 --- a/lua/cp/setup.lua +++ b/lua/cp/setup.lua @@ -160,8 +160,6 @@ function M.setup_contest(platform, contest_id, problem_id, language) vim.bo[bufnr].buftype = '' vim.bo[bufnr].swapfile = false - state.set_language(lang) - if cfg.hooks and cfg.hooks.setup_code and not vim.b[bufnr].cp_setup_done then local ok = pcall(cfg.hooks.setup_code, state) if ok then diff --git a/plugin/cp.lua b/plugin/cp.lua index 2689e71..b91a3d5 100644 --- a/plugin/cp.lua +++ b/plugin/cp.lua @@ -154,17 +154,3 @@ end, { return {} end, }) - -local function cp_action(action) - return function() - require('cp').handle_command({ fargs = { action } }) - end -end - -vim.keymap.set('n', '(cp-run)', cp_action('run'), { desc = 'CP run tests' }) -vim.keymap.set('n', '(cp-panel)', cp_action('panel'), { desc = 'CP open panel' }) -vim.keymap.set('n', '(cp-edit)', cp_action('edit'), { desc = 'CP edit test cases' }) -vim.keymap.set('n', '(cp-next)', cp_action('next'), { desc = 'CP next problem' }) -vim.keymap.set('n', '(cp-prev)', cp_action('prev'), { desc = 'CP previous problem' }) -vim.keymap.set('n', '(cp-pick)', cp_action('pick'), { desc = 'CP pick contest' }) -vim.keymap.set('n', '(cp-interact)', cp_action('interact'), { desc = 'CP interactive mode' })