Skip to content

Commit

Permalink
feat: add use_cursorline_background (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: Melker Ulander <[email protected]>
  • Loading branch information
konosubakonoakua and mawkler authored Oct 21, 2024
1 parent d1d327f commit 75f5b6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ require('modicator').setup({
bold = false,
italic = false,
},
-- Use `CursorLine`'s background color for `CursorLineNr`'s background
use_cursorline_background = false,
},
integration = {
lualine = {
Expand Down
5 changes: 5 additions & 0 deletions doc/modicator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,18 @@ DEFAULT CONFIGURATION: ~
-- Warn if any required option is missing. May emit false positives if some
-- other plugin modifies them, which in that case you can just ignore
show_warnings = false,

--- If true, CursorLineNr will use the same background with CursorLine
cursor_line_nr_background = false,

highlights = {
-- Default options for bold/italic
defaults = {
bold = false,
italic = false,
},
},

integration = {
lualine = {
enabled = true,
Expand Down
12 changes: 10 additions & 2 deletions lua/modicator/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ local M = {}
--- @field mode_section? LualineSectionLetter If `nil`, gets detected automatically. See `:help lualine-usage-and-customization`
--- @field highlight? 'bg' | 'fg' Whether to use the highlight's foreground or background

--- @class ModicatorHighlightOptions
--- @field defaults? { bold?: boolean, italic?: boolean } Default highlight options
--- @field use_cursorline_background? boolean Use `CursorLine`'s background color for `CursorLineNr`'s background

--- @class ModicatorOptions
--- @field show_warnings? boolean Show warning on VimEnter if any required option is missing
--- @field highlights? { defaults?: { bold?: boolean, italic?: boolean } }
--- @field highlights? ModicatorHighlightOptions
--- @field integration? { lualine?: ModicatorLualineIntegration }
local options = {
--- @type boolean
show_warnings = false,
highlights = {
defaults = {
bold = false,
italic = false,
},
use_cursorline_background = false,
},
integration = {
lualine = {
Expand Down Expand Up @@ -185,6 +189,10 @@ end
M.set_cursor_line_highlight = function(hl_name)
local hl_group = require('modicator.utils').get_highlight(hl_name)
local hl = vim.tbl_extend('force', options.highlights.defaults, hl_group)
if options.highlights.use_cursorline_background == true then
local cl = require('modicator.utils').get_highlight('CursorLine')
hl = vim.tbl_extend('keep', { bg = cl.bg }, hl)
end
api.nvim_set_hl(0, 'CursorLineNr', hl)

local is_register_executing = vim.fn.reg_executing() ~= ""
Expand Down

0 comments on commit 75f5b6e

Please sign in to comment.