Skip to content

How to render text with RGB color in statusline? #78

Answered by MunifTanjim
linrongbin16 asked this question in Q&A
Discussion options

You must be logged in to vote

I googled some questions, but they all told me to define a syntax highlighting group first...

I'm not sure is it already the best solution?

Nougat has a utility function for this:

local get_hl_name = require("nougat.color").get_hl_name

You can use it like this:

stl:add_item({
  hl = { bg = "yellow" },
  content = function(item, ctx)
    return core.highlight(get_hl_name({ fg = "red" }, item.hl or ctx.hl)) .. "CONTENT"
  end
})

Here, { fg = "red" } is the highlight definition you want. item.hl or ctx.hl is the fallback highlight definition for the current context.


Also for filetype icon, I just added nut.buf.filetype_icon: #79

You can use it like this:

stl:add_item({
  hl = { bg = color.b…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@linrongbin16
Comment options

Answer selected by linrongbin16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants