From 1e74b7dd6c1b4c6750e6f917f91012c450aece86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maria=20Jos=C3=A9=20Solano?= Date: Mon, 21 Aug 2023 00:38:45 -0700 Subject: [PATCH] feat: Add a list_opener setting (#63) * feat: add open_qf_command setting * docs: document open_qf_command * refactor: rename open_qf_command to list_opener --- README.md | 1 + lua/git-conflict.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf23cd3..aafdb40 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ I recommend using the {tag|version} field of your package manager, so your versi default_mappings = true, -- disable buffer local mapping created by this plugin default_commands = true, -- disable commands created by this plugin disable_diagnostics = false, -- This will disable the diagnostics in a buffer whilst it is conflicted + list_opener = 'copen', -- command or function to open the conflicts list highlights = { -- They must have background color, otherwise the default color will be used incoming = 'DiffAdd', current = 'DiffText', diff --git a/lua/git-conflict.lua b/lua/git-conflict.lua index 705da26..dbd750d 100644 --- a/lua/git-conflict.lua +++ b/lua/git-conflict.lua @@ -69,12 +69,14 @@ local job = utils.job --- @class GitConflictConfig --- @field default_mappings GitConflictMappings --- @field disable_diagnostics boolean +--- @field list_opener string|function --- @field highlights ConflictHighlights --- @field debug boolean --- @class GitConflictUserConfig --- @field default_mappings boolean|GitConflictMappings --- @field disable_diagnostics boolean +--- @field list_opener string|function --- @field highlights ConflictHighlights --- @field debug boolean @@ -136,6 +138,7 @@ local config = { default_mappings = DEFAULT_MAPPINGS, default_commands = true, disable_diagnostics = false, + list_opener = 'copen', highlights = { current = 'DiffText', incoming = 'DiffAdd', @@ -479,7 +482,11 @@ local function set_commands() M.conflicts_to_qf_items(function(items) if #items > 0 then fn.setqflist(items, 'r') - vim.cmd([[copen]]) + if type(config.list_opener) == 'function' then + config.list_opener() + else + vim.cmd(config.list_opener) + end end end) end, { nargs = 0 })