From 20f7a1608e15cbf91d0c04fef9b896c08809d6e6 Mon Sep 17 00:00:00 2001 From: Matus Hedera Date: Sun, 20 Jul 2025 10:51:21 +0200 Subject: [PATCH] Unified sign options with sign_define now allows all options from sign_define introduces ifs because old syntax aliased 'texthl' to 'hl' --- doc/nvim-coverage.txt | 6 +++--- lua/coverage/signs.lua | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/doc/nvim-coverage.txt b/doc/nvim-coverage.txt index 933ce26..d14690a 100644 --- a/doc/nvim-coverage.txt +++ b/doc/nvim-coverage.txt @@ -105,13 +105,13 @@ Valid keys for {opts.highlights}: Valid keys for {opts.signs}: covered: ~ - Customize the highlight group and text used for covered signs. + Customize the highlight group and text used for covered signs. See :help sign_define for all supported options. Defaults to: `{ hl = "CoverageCovered", text = "▎" }` uncovered: ~ - Customize the highlight group and text used for uncovered signs. + Customize the highlight group and text used for uncovered signs. See :help sign_define for all supported options. Defaults to: `{ hl = "CoverageUncovered", text = "▎" }` partial: ~ - Customize the highlight group and text used for partial coverage signs. + Customize the highlight group and text used for partial coverage signs. See :help sign_define for all supported options. Defaults to: `{ hl = "CoveragePartial", text = "▎" }` *coverage.summary* diff --git a/lua/coverage/signs.lua b/lua/coverage/signs.lua index db5a7f6..485a5ef 100644 --- a/lua/coverage/signs.lua +++ b/lua/coverage/signs.lua @@ -21,18 +21,24 @@ local default_priority = 10 --- Defines signs. M.setup = function() - vim.fn.sign_define(M.name("covered"), { - text = config.opts.signs.covered.text, - texthl = config.opts.signs.covered.hl, - }) - vim.fn.sign_define(M.name("uncovered"), { - text = config.opts.signs.uncovered.text, - texthl = config.opts.signs.uncovered.hl, - }) - vim.fn.sign_define(M.name("partial"), { - text = config.opts.signs.partial.text, - texthl = config.opts.signs.partial.hl, - }) + local signs = config.opts.signs + + if signs.covered["hl"] ~= nil then + signs.covered["texthl"] = signs.covered["hl"] + signs.covered["hl"] = nil + end + if signs.uncovered["hl"] ~= nil then + signs.uncovered["texthl"] = signs.uncovered["hl"] + signs.covered["hl"] = nil + end + if signs.partial["hl"] ~= nil then + signs.partial["texthl"] = signs.partial["hl"] + signs.covered["hl"] = nil + end + + vim.fn.sign_define(M.name("covered"), config.opts.signs.covered) + vim.fn.sign_define(M.name("uncovered"), config.opts.signs.uncovered) + vim.fn.sign_define(M.name("partial"), config.opts.signs.partial) end --- Returns a namespaced sign name.