Coder Social home page Coder Social logo

modicator.nvim's Introduction

Modicator.nvim ๐Ÿ’ก

Cursor line number mode indicator.

A small Neovim plugin that changes the color of your cursor's line number based on the current Vim mode.

Modicator has lualine.nvim support out of the box.

Modicator in use

Setup

require('modicator').setup()

Note that modicator requires you to have termguicolors, cursorline, number set. In Lua this is done by adding the following somewhere in your Neovim configuration:

vim.o.termguicolors = true
vim.o.cursorline = true
vim.o.number = true

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 lazy.nvim:

{
  'mawkler/modicator.nvim',
  dependencies = 'mawkler/onedark.nvim', -- Add your colorscheme plugin here
  init = function()
    -- These are required for Modicator to work
    vim.o.cursorline = true
    vim.o.number = true
    vim.o.termguicolors = true
  end,
  opts = {}
}

Or with packer.nvim:

use {
  'mawkler/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

Modicator uses the following highlight groups for each mode, respectively:

NormalMode
InsertMode
VisualMode
CommandMode
ReplaceMode
SelectMode
TerminalMode
TerminalNormalMode

For more information on how to create a highlight group, see :help nvim_set_hl.

Default configuration:

require('modicator').setup({
  -- Show warning if any required option is missing
  show_warnings = true,
  highlights = {
    -- Default options for bold/italic
    defaults = {
      bold = false,
      italic = false,
    },
  },
  integration = {
    lualine = {
      enabled = true,
      -- Letter of lualine section to use (if `nil`, gets detected automatically)
      mode_section = nil,
      -- Whether to use lualine's mode highlight's foreground or background
      highlight = 'bg',
    },
  },
})

Lualine integration

Modicator has built-in support lualine.nvim, meaning that if it detects lualine.nvim in your setup it will use the same colors for each mode as lualine.nvim uses. To disable this feature, you can set integration.lualine.enabled = false in your modicator configuration.

Note that Modicator will only create a highlight group from a lualine.nvim mode highlight if that highlight group doesn't already exist.

Modicator tries to find your lualine mode section automatically. However, you can specify the section to use manually in integration.lualine.mode_section, and whether to use the section highlight's bg or fg with integration.lualine.highlight.

modicator.nvim's lualine integration

Issues with other plugins

marks.nvim

By default, marks.nvim highlights number lines with marks using CursorLineNr, which makes all line numbers recolored by Modicator every time mode is changed.

To fix this issue, either set MarkSignNumHL to something else, or remove the highlight group completely by putting the following snippet anywhere in your configuration:

local marks_fix_group = vim.api.nvim_create_augroup('marks-fix-hl', {})
vim.api.nvim_create_autocmd({ 'VimEnter' }, {
  group = marks_fix_group,
  callback = function()
    vim.api.nvim_set_hl(0, 'MarkSignNumHL', {})
  end,
})

Development

To run test, run the following:

nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ { minimal_init = 'tests/init.lua' }"

modicator.nvim's People

Contributors

alexmozaidze avatar hatredholder avatar itzaeon avatar mawkler avatar yutkat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.