Skip to content

Prismatic line decorations for the adventurous vim user

Notifications You must be signed in to change notification settings

steven-liou/modes.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

modes.nvim

Prismatic line decorations for the adventurous vim user

Highlight UI elements based on current mode. Inspired by the recent addition of vim bindings in Xcode.

Usage

-- Lazy package manager
{
  'steven-liou/modes.nvim',
  dependencies = {"nvim-tree/nvim-web-devicons"},
  config = function()
    vim.opt.cursorline = true
    require('modes').setup()
  end
}

modes.nvim

Options

Note: vim.opt.cursorline must be set to true for lines to be highlighted

Default colors can be overridden by passing values to the setup function or updating highlight groups.

require("modes").setup({
	colors = {
        black_text = "#1e1e1e",
        white_text = "#d4d4d4",
		normal = "#608b4e",
		insert = "#569cd6",
		change = "#41729F",
		visual = "#c586c0",
		replace = "#d16969",
		command = "#deb974",
		pending = "#4ec9b0",
		copy = "#f5c359",
		delete = "#c75c6a"
		undo = "#9745be",
		redo = "#9745be",
	},

    -- For highlight groups you wish to change the colors based on modes
	highlight_groups = {
		Cursorline = {
			bg = {
				enabled = true,
				opacity = {
					normal = 0.08,
					insert = 0.08,
					change = 0.1,
					visual = 0.1,
					replace = 0.1,
					command = 0.1,
					pending = 0.1,
					copy = 0.1,
					delete = 0.1,
					undo = 0.1,
					redo = 0.1,
				},
			},
		},
		CursorLineNr = { fg = { enabled = true }, bg = { enabled = true, opacity = 0.1 } },
		CursorLineSign = { fg = { enabled = true }, bg = { enabled = true, opacity = 0.1 } },
		CursorLineFold = { bg = { enabled = true, opacity = 0.1 } },
		FloatBorder = { fg = { enabled = true, opacity = 0.4 } },
		NvimSeparator = { fg = { enabled = true, opacity = 0.2 } }, -- for colorful-winsep.nvim
		IndentBlanklineContext = { fg = { enabled = true } }, -- for indent-blankline.nvim
		VirtColumn = { fg = { enabled = true, opacity = 0.2 } }, -- for virt-column.nvim
		MatchArea = { bg = { enabled = true, opacity = 0.1 } }, -- for hl_match_area.nvim
		IndentBlanklineIndent1 = { fg = { enabled = true, opacity = 0.5 } }, -- for indent-blankline.nvim
		IndentBlanklineIndent2 = { fg = { enabled = true, opacity = 0.5 } }, -- for indent-blankline.nvim
		IndentBlanklineIndent3 = { fg = { enabled = true, opacity = 0.5 } }, -- for indent-blankline.nvim
		IndentBlanklineIndent4 = { fg = { enabled = true, opacity = 0.5 } }, -- for indent-blankline.nvim
		IndentBlanklineIndent5 = { fg = { enabled = true, opacity = 0.5 } }, -- for indent-blankline.nvim
		IndentBlanklineIndent6 = { fg = { enabled = true, opacity = 0.5 } }, -- for indent-blankline.nvim
	},

	-- Highlight cursor
	set_cursor = true,
	-- Enable line number highlights to match cursorline
	set_number = true,
    set_yanked_background = { enabled = true, timeout = 2000 },



	-- for lualine.nvim
	lualine = {
		enabled = true,
		statusbar_side_opacity = {
			normal = 0.2,
			copy = 0.2,
			delete = 0.2,
			insert = 0.2,
			visual = 0.2,
			command = 0.2,
			replace = 0.2,
			pending = 0.2,
			undo = 0.2,
			redo = 0.2,
			change = 0.2,
			search = 0.1,
		},
		statusbar_middle_opacity = {
			normal = 0.08,
			copy = 0.12,
			delete = 0.15,
			insert = 0.15,
			visual = 0.12,
			command = 0.1,
			replace = 0.1,
			pending = 0.1,
			undo = 0.1,
			redo = 0.1,
			change = 0.1,
			search = 0.1,
		},
		diff_component = "x",
		diagnostics_component = "x",
		filetype_component = "y",
		aerial_component = "c",
	},

	-- for bufferline.nvim
	bufferline = {
		enabled = true,
		background_color = colors.shade_black,
		fill_color = colors.black,
		opacity = {
			normal = 0.08,
			copy = 0.08,
			delete = 0.1,
			insert = 0.06,
			visual = 0.1,
			command = 0.1,
			replace = 0.08,
			pending = 0.09,
			undo = 0.08,
			redo = 0.08,
			change = 0.1,
			search = 0.1,
		},
	},

	-- for gitsigns.nvim
	gitsigns = {
		enabled = true,
		opacity = 0.08,
	},
    -- for lsp diagnostic signs
	diagnostic_signs = {
		enabled = true,
		opacity = 0.1,
	},

	-- for todo-comments.nvim
	todos_comment = {
		enabled = true,
		comment_types = { "FIX", "HACK", "NOTE", "PERF", "TEST", "TODO", "WARN" },
		opacity = 0.1,
	},

	-- for noice.nvim
	noice = {
		enabled = true,
	},

	-- for capslock.nvim
	capslock = {
		enabled = true,
		color = "undo", -- color name based on one of the colors definition key above, like "normal", "insert", "visual"...
		opacity = 0.1,
	},

	-- Highlight in active window only
	focus_only = false,

	-- Disable modes highlights in specified filetypes
	ignore_filetypes = {'NvimTree', 'TelescopePrompt'},
})
-- Exposed highlight groups, useful for themes
vim.cmd('hi ModesNormal guibg=#608b4e')
vim.cmd('hi ModesInsert guibg=#569cd6')
vim.cmd('hi ModesChange guibg=#9745be')
vim.cmd('hi ModesVisual guibg=#c586d0')
vim.cmd('hi ModesReplace guibg=#d16969')
vim.cmd('hi ModesCommand guibg=#deb974')
vim.cmd('hi ModesPending guibg=#78ccc5')
vim.cmd('hi ModesCopy guibg=#f5c359')
vim.cmd('hi ModesDelete guibg=#c75c6a')
vim.cmd('hi ModesUndo guibg=#9745be')
vim.cmd('hi ModesRedo guibg=#9745be')

Known issues

  • Some Which Key presets conflict with this plugin. For example, d and y operators will not apply highlights if operators = true because Which Key takes priority

Workaround:

require('which-key').setup({
  plugins = {
    presets = {
      operators = false,
    },
  },
})

About

Prismatic line decorations for the adventurous vim user

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 100.0%