melkster/modicator.nvim

github github
cursorline
star 57
alert-circle 0
users 1
git-branch 1
CREATED

2022-10-04

UPDATED

7 days ago


💡 Modicator.nvim

Cursor line number mode indicator.

A small Neovim plugin that changes the foreground color of the CursorLineNr highlight based on the current Vim mode.

modicator

Setup

require('modicator').setup()

Note that modicator requires you to have termguicolors set. In Lua this is done by adding vim.o.termguicolors = true somewhere in your configuration.

Modicator sets the Normal mode highlight foreground based on the default foreground color of CursorLineNr so if you're using a colorscheme make sure that it gets loaded before this plugin.

With packer.nvim this is done like this:

use { 'melkster/modicator.nvim',
  after = 'onedark.nvim', -- Add your colorscheme plugin here
  setup = function()
    -- These are required for Modicator to work
    vim.o.cursorline = true
    vim.o.number = true
    vim.o.termguicolors = true
  end,
  config = function()
    require('modicator').setup({
      -- ...
    })
  end
}

Configuration

Use highlights.modes to set the color for each mode, and pass it to .setup(). The key for each color is the output mode() for that mode. Check out :help mode() for more information.

For normal mode, Modicator uses the CursorLineNr's fg highlight. The other highligt keys of CursorLineNr (bg, gui, bold, etc.) are preserved when you switch to other modes. Modicator only modifies CursorLineNr's fg color.

Default configuration:

local modicator = require('modicator')

-- NOTE: Modicator requires line_numbers and cursorline to be enabled
modicator.setup({
  show_warnings = true, -- Show warning if any required option is missing
  highlights = {
    modes = {
      ['i'] = modicator.get_highlight_fg('Question'),
      ['v'] = modicator.get_highlight_fg('Type'),
      ['V'] = modicator.get_highlight_fg('Type'),
      [''] = modicator.get_highlight_fg('Type'),
      ['s'] = modicator.get_highlight_fg('Keyword'),
      ['S'] = modicator.get_highlight_fg('Keyword'),
      ['R'] = modicator.get_highlight_fg('Title'),
      ['c'] = modicator.get_highlight_fg('Constant'),
    },
  },
})