feat: bindings and --debug flag
This commit is contained in:
parent
038fcd36f8
commit
6a6cf2c594
8 changed files with 142 additions and 46 deletions
|
|
@ -34,8 +34,12 @@
|
|||
---@field setup_io_input? fun(bufnr: integer, state: cp.State)
|
||||
---@field setup_io_output? fun(bufnr: integer, state: cp.State)
|
||||
|
||||
---@class RunConfig
|
||||
---@field width number
|
||||
|
||||
---@class CpUI
|
||||
---@field ansi boolean
|
||||
---@field run RunConfig
|
||||
---@field panel PanelConfig
|
||||
---@field diff DiffConfig
|
||||
---@field picker string|nil
|
||||
|
|
@ -116,6 +120,7 @@ M.defaults = {
|
|||
filename = nil,
|
||||
ui = {
|
||||
ansi = true,
|
||||
run = { width = 0.3 },
|
||||
panel = { diff_mode = 'none', max_output_lines = 50 },
|
||||
diff = {
|
||||
git = {
|
||||
|
|
@ -157,6 +162,11 @@ local function validate_language(id, lang)
|
|||
extension = { lang.extension, 'string' },
|
||||
commands = { lang.commands, { 'table' } },
|
||||
})
|
||||
|
||||
if not lang.commands.run then
|
||||
error(('[cp.nvim] languages.%s.commands.run is required'):format(id))
|
||||
end
|
||||
|
||||
if lang.commands.build ~= nil then
|
||||
vim.validate({ build = { lang.commands.build, { 'table' } } })
|
||||
if not has_tokens(lang.commands.build, { '{source}', '{binary}' }) then
|
||||
|
|
@ -232,6 +242,14 @@ function M.setup(user_config)
|
|||
vim.validate({ user_config = { user_config, { 'table', 'nil' }, true } })
|
||||
local cfg = vim.tbl_deep_extend('force', vim.deepcopy(M.defaults), user_config or {})
|
||||
|
||||
if not next(cfg.languages) then
|
||||
error('[cp.nvim] At least one language must be configured')
|
||||
end
|
||||
|
||||
if not next(cfg.platforms) then
|
||||
error('[cp.nvim] At least one platform must be configured')
|
||||
end
|
||||
|
||||
vim.validate({
|
||||
hooks = { cfg.hooks, { 'table' } },
|
||||
ui = { cfg.ui, { 'table' } },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue