diff --git a/lua/modes/init.lua b/lua/modes/init.lua index 60b23b2..d246fef 100644 --- a/lua/modes/init.lua +++ b/lua/modes/init.lua @@ -56,7 +56,10 @@ function modes.set_colors() normal = util.get_bg_from_hl('Normal', 'Normal'), } colors = { - copy = config.colors.copy or util.get_bg_from_hl('ModesCopy', '#f5c359'), + copy = config.colors.copy or util.get_bg_from_hl( + 'ModesCopy', + '#f5c359' + ), delete = config.colors.delete or util.get_bg_from_hl( 'ModesDelete', '#c75c6a' @@ -114,6 +117,8 @@ end ---@class Config ---@field colors Colors ---@field line_opacity Opacity +---@field set_cursor boolean +---@field focus_only boolean ---@param opts Config function modes.setup(opts) @@ -126,6 +131,7 @@ function modes.setup(opts) insert = 0.15, visual = 0.15, }, + set_cursor = true, focus_only = false, } opts = opts or default_config @@ -156,9 +162,11 @@ function modes.setup(opts) vim.cmd('hi Visual guibg=' .. dim_colors.visual) -- Set guicursor modes - vim.opt.guicursor:append('v-sm:block-ModesVisual') - vim.opt.guicursor:append('i-ci-ve:ver25-ModesInsert') - vim.opt.guicursor:append('r-cr-o:hor20-ModesOperator') + if config.set_cursor then + vim.opt.guicursor:append('v-sm:block-ModesVisual') + vim.opt.guicursor:append('i-ci-ve:ver25-ModesInsert') + vim.opt.guicursor:append('r-cr-o:hor20-ModesOperator') + end local on_key = vim.on_key or vim.register_keystroke_callback on_key(function(key) diff --git a/readme.md b/readme.md index b8ec2df..f4feb87 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,6 @@ Highlight UI elements based on current mode. Inspired by the recent addition of ```lua use({ 'mvllow/modes.nvim', - event = 'BufRead', -- optional lazy loading config = function() vim.opt.cursorline = true require('modes').setup() @@ -26,7 +25,6 @@ use({ Default colors can be overridden by passing values to the setup function or updating highlight groups. ```lua --- Pass colors through setup require('modes').setup({ colors = { copy = "#f5c359", @@ -34,11 +32,20 @@ require('modes').setup({ insert = "#78ccc5", visual = "#9745be", }, + + -- Cursorline highlight opacity line_opacity = 0.1, + + -- Highlight cursor + set_cursor = true, + + -- Highlight in active window only focus_only = false }) +``` --- Or use highlight groups (useful for themes) +```lua +-- Exposed highlight groups, useful for themes vim.cmd('hi ModesCopy guibg=#f5c359') vim.cmd('hi ModesDelete guibg=#c75c6a') vim.cmd('hi ModesInsert guibg=#78ccc5') @@ -55,7 +62,6 @@ _Workaround:_ require('which-key').setup({ plugins = { presets = { - -- Disable operators operators = false, }, },