Skip to content

Color highlighting internally for custom component #586

Answered by shadmansaleh
AckslD asked this question in Q&A
Discussion options

You must be logged in to vote

You will have to use create_component_highlight_group and component_format_highlight pair. Then lualine will set correct background color based on section and mode .

You can follow the structure on diagnostics/diff components . For your case you'll need something like this

local M = require('lualine.component'):extend()
local highlight = require 'lualine.highlight'

function M:init(options)
  M.super.init(self, options)
  self.status_symbols = {
    unclean = '',
    clean = '',
  }

  self.colors = {
    clean = highlight.create_component_highlight_group(
      {fg =  '#48b0bd'}, 'summery_clean', self.options),
    unclean = highlight.create_component_highlight_group(
    {fg = '#e55561'

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@AckslD
Comment options

@shadmansaleh
Comment options

@AckslD
Comment options

@shadmansaleh
Comment options

@AckslD
Comment options

Answer selected by AckslD
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants