Skip to content

Commit

Permalink
feat: Add a list_opener setting (#63)
Browse files Browse the repository at this point in the history
* feat: add open_qf_command setting

* docs: document open_qf_command

* refactor: rename open_qf_command to list_opener
  • Loading branch information
MariaSolOs authored Aug 21, 2023
1 parent 562e8fd commit 1e74b7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 8 additions & 1 deletion lua/git-conflict.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -136,6 +138,7 @@ local config = {
default_mappings = DEFAULT_MAPPINGS,
default_commands = true,
disable_diagnostics = false,
list_opener = 'copen',
highlights = {
current = 'DiffText',
incoming = 'DiffAdd',
Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit 1e74b7d

Please sign in to comment.