Merge pull request #237 from barrettruth/feat/vim-g-update
Some checks failed
luarocks / ci (push) Has been cancelled
luarocks / publish (push) Has been cancelled

refactor: rename `vim.g.cp_config` to `vim.g.cp`
This commit is contained in:
Barrett Ruth 2026-02-06 16:07:03 -05:00 committed by GitHub
commit 19e71ac7fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View file

@ -205,9 +205,9 @@ Debug Builds ~
============================================================================== ==============================================================================
CONFIGURATION *cp-config* CONFIGURATION *cp-config*
Configuration is done via `vim.g.cp_config`. Set this before using the plugin: Configuration is done via `vim.g.cp`. Set this before using the plugin:
>lua >lua
vim.g.cp_config = { vim.g.cp = {
languages = { languages = {
cpp = { cpp = {
extension = 'cc', extension = 'cc',
@ -274,7 +274,7 @@ the default; per-platform overrides can tweak 'extension' or 'commands'.
For example, to run CodeForces contests with Python by default: For example, to run CodeForces contests with Python by default:
>lua >lua
vim.g.cp_config = { vim.g.cp = {
platforms = { platforms = {
codeforces = { codeforces = {
default_language = 'python', default_language = 'python',
@ -285,7 +285,7 @@ For example, to run CodeForces contests with Python by default:
Any language is supported provided the proper configuration. For example, to Any language is supported provided the proper configuration. For example, to
run CSES problems with Rust using the single schema: run CSES problems with Rust using the single schema:
>lua >lua
vim.g.cp_config = { vim.g.cp = {
languages = { languages = {
rust = { rust = {
extension = 'rs', extension = 'rs',

View file

@ -17,7 +17,11 @@ local function ensure_initialized()
if initialized then if initialized then
return return
end end
local user_config = vim.g.cp_config or {} if vim.g.cp_config then
vim.deprecate('vim.g.cp_config', 'vim.g.cp', 'v0.7.6', 'cp.nvim', false)
vim.g.cp = vim.g.cp or vim.g.cp_config
end
local user_config = vim.g.cp or {}
local config = config_module.setup(user_config) local config = config_module.setup(user_config)
config_module.set_current_config(config) config_module.set_current_config(config)
initialized = true initialized = true
@ -34,12 +38,12 @@ function M.is_initialized()
return initialized return initialized
end end
---@deprecated Use `vim.g.cp_config` instead ---@deprecated Use `vim.g.cp` instead
function M.setup(user_config) function M.setup(user_config)
vim.deprecate('require("cp").setup()', 'vim.g.cp_config', 'v0.1.0', 'cp.nvim', false) vim.deprecate('require("cp").setup()', 'vim.g.cp', 'v0.1.0', 'cp.nvim', false)
if user_config then if user_config then
vim.g.cp_config = vim.tbl_deep_extend('force', vim.g.cp_config or {}, user_config) vim.g.cp = vim.tbl_deep_extend('force', vim.g.cp or {}, user_config)
end end
end end