feat: config update to viom.g

This commit is contained in:
Barrett Ruth 2026-02-03 16:12:47 -05:00
parent 1a7e9517ba
commit ec487aa489
2 changed files with 66 additions and 71 deletions

View file

@ -205,13 +205,9 @@ Debug Builds ~
==============================================================================
CONFIGURATION *cp-config*
Here's an example configuration with lazy.nvim:
Configuration is done via `vim.g.cp_config`. Set this before using the plugin:
>lua
{
'barrettruth/cp.nvim',
cmd = 'CP',
build = 'uv sync',
opts = {
vim.g.cp_config = {
languages = {
cpp = {
extension = 'cc',
@ -270,7 +266,6 @@ Here's an example configuration with lazy.nvim:
picker = 'telescope',
},
}
}
<
By default, C++ (g++ with ISO C++17) and Python are preconfigured under
@ -279,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_config = {
platforms = {
codeforces = {
default_language = 'python',
@ -290,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_config = {
languages = {
rust = {
extension = 'rs',

View file

@ -11,25 +11,25 @@ if vim.fn.has('nvim-0.10.0') == 0 then
return {}
end
local user_config = {}
local config = nil
local initialized = false
local function ensure_initialized()
if initialized then
return
end
local user_config = vim.g.cp_config or {}
local config = config_module.setup(user_config)
config_module.set_current_config(config)
initialized = true
end
---@return nil
function M.handle_command(opts)
ensure_initialized()
local commands = require('cp.commands')
commands.handle_command(opts)
end
function M.setup(opts)
opts = opts or {}
user_config = opts
config = config_module.setup(user_config)
config_module.set_current_config(config)
initialized = true
end
function M.is_initialized()
return initialized
end