feat: config update to viom.g
This commit is contained in:
parent
1a7e9517ba
commit
ec487aa489
2 changed files with 66 additions and 71 deletions
115
doc/cp.nvim.txt
115
doc/cp.nvim.txt
|
|
@ -205,71 +205,66 @@ Debug Builds ~
|
||||||
==============================================================================
|
==============================================================================
|
||||||
CONFIGURATION *cp-config*
|
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
|
>lua
|
||||||
{
|
vim.g.cp_config = {
|
||||||
'barrettruth/cp.nvim',
|
languages = {
|
||||||
cmd = 'CP',
|
cpp = {
|
||||||
build = 'uv sync',
|
extension = 'cc',
|
||||||
opts = {
|
commands = {
|
||||||
languages = {
|
build = { 'g++', '-std=c++17', '{source}', '-o', '{binary}',
|
||||||
cpp = {
|
'-fdiagnostics-color=always' },
|
||||||
extension = 'cc',
|
run = { '{binary}' },
|
||||||
commands = {
|
debug = { 'g++', '-std=c++17', '-fsanitize=address,undefined',
|
||||||
build = { 'g++', '-std=c++17', '{source}', '-o', '{binary}',
|
'{source}', '-o', '{binary}' },
|
||||||
'-fdiagnostics-color=always' },
|
|
||||||
run = { '{binary}' },
|
|
||||||
debug = { 'g++', '-std=c++17', '-fsanitize=address,undefined',
|
|
||||||
'{source}', '-o', '{binary}' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
python = {
|
|
||||||
extension = 'py',
|
|
||||||
commands = {
|
|
||||||
run = { 'python', '{source}' },
|
|
||||||
debug = { 'python', '{source}' },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
platforms = {
|
python = {
|
||||||
cses = {
|
extension = 'py',
|
||||||
enabled_languages = { 'cpp', 'python' },
|
commands = {
|
||||||
default_language = 'cpp',
|
run = { 'python', '{source}' },
|
||||||
overrides = {
|
debug = { 'python', '{source}' },
|
||||||
cpp = { extension = 'cpp', commands = { build = { ... } } }
|
|
||||||
},
|
|
||||||
},
|
|
||||||
atcoder = {
|
|
||||||
enabled_languages = { 'cpp', 'python' },
|
|
||||||
default_language = 'cpp',
|
|
||||||
},
|
|
||||||
codeforces = {
|
|
||||||
enabled_languages = { 'cpp', 'python' },
|
|
||||||
default_language = 'cpp',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
open_url = true,
|
},
|
||||||
debug = false,
|
platforms = {
|
||||||
ui = {
|
cses = {
|
||||||
ansi = true,
|
enabled_languages = { 'cpp', 'python' },
|
||||||
run = {
|
default_language = 'cpp',
|
||||||
width = 0.3,
|
overrides = {
|
||||||
next_test_key = '<c-n>', -- or nil to disable
|
cpp = { extension = 'cpp', commands = { build = { ... } } }
|
||||||
prev_test_key = '<c-p>', -- or nil to disable
|
|
||||||
},
|
},
|
||||||
panel = {
|
|
||||||
diff_modes = { 'side-by-side', 'git', 'vim' },
|
|
||||||
max_output_lines = 50,
|
|
||||||
},
|
|
||||||
diff = {
|
|
||||||
git = {
|
|
||||||
args = { 'diff', '--no-index', '--word-diff=plain',
|
|
||||||
'--word-diff-regex=.', '--no-prefix' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
picker = 'telescope',
|
|
||||||
},
|
},
|
||||||
}
|
atcoder = {
|
||||||
|
enabled_languages = { 'cpp', 'python' },
|
||||||
|
default_language = 'cpp',
|
||||||
|
},
|
||||||
|
codeforces = {
|
||||||
|
enabled_languages = { 'cpp', 'python' },
|
||||||
|
default_language = 'cpp',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
open_url = true,
|
||||||
|
debug = false,
|
||||||
|
ui = {
|
||||||
|
ansi = true,
|
||||||
|
run = {
|
||||||
|
width = 0.3,
|
||||||
|
next_test_key = '<c-n>', -- or nil to disable
|
||||||
|
prev_test_key = '<c-p>', -- or nil to disable
|
||||||
|
},
|
||||||
|
panel = {
|
||||||
|
diff_modes = { 'side-by-side', 'git', 'vim' },
|
||||||
|
max_output_lines = 50,
|
||||||
|
},
|
||||||
|
diff = {
|
||||||
|
git = {
|
||||||
|
args = { 'diff', '--no-index', '--word-diff=plain',
|
||||||
|
'--word-diff-regex=.', '--no-prefix' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
picker = 'telescope',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
@ -279,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 = {
|
||||||
platforms = {
|
platforms = {
|
||||||
codeforces = {
|
codeforces = {
|
||||||
default_language = 'python',
|
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
|
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 = {
|
||||||
languages = {
|
languages = {
|
||||||
rust = {
|
rust = {
|
||||||
extension = 'rs',
|
extension = 'rs',
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,25 @@ if vim.fn.has('nvim-0.10.0') == 0 then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local user_config = {}
|
|
||||||
local config = nil
|
|
||||||
local initialized = false
|
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
|
---@return nil
|
||||||
function M.handle_command(opts)
|
function M.handle_command(opts)
|
||||||
|
ensure_initialized()
|
||||||
local commands = require('cp.commands')
|
local commands = require('cp.commands')
|
||||||
commands.handle_command(opts)
|
commands.handle_command(opts)
|
||||||
end
|
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()
|
function M.is_initialized()
|
||||||
return initialized
|
return initialized
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue