Skip to content

Commit

Permalink
feat(highlights): revamp markup headings, links and raw text
Browse files Browse the repository at this point in the history
  • Loading branch information
ramojus committed Feb 20, 2024
1 parent 9e37bca commit aa33868
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 9 deletions.
1 change: 1 addition & 0 deletions lua/mellifluous/colors/sets/alduin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function M.get_colors_dark(bg)
green = green, -- staged, additions
blue = grey, -- information, new files
purple = cyan, -- hints, merge
yellow = strings,

-- optional (for better terminal highlights)
cyan = cyan,
Expand Down
2 changes: 2 additions & 0 deletions lua/mellifluous/colors/sets/mellifluous.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function M.get_colors_dark(bg)
green = green, -- staged, additions
blue = blue, -- information, new files
purple = purple, -- hints, merge
yellow = yellow,
}
end

Expand Down Expand Up @@ -111,6 +112,7 @@ function M.get_colors_light(bg)
green = green, -- staged, additions
blue = blue, -- information, new files
purple = purple, -- hints, merge
yellow = yellow,
}
end

Expand Down
2 changes: 1 addition & 1 deletion lua/mellifluous/colors/sets/mountain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ function M.get_colors_dark(bg)
green = green, -- staged, additions
blue = blue, -- information, new files
purple = magenta, -- hints, merge
yellow = yellow,

-- optional (for better terminal highlights)
cyan = cyan,
yellow = yellow,
}
end

Expand Down
4 changes: 1 addition & 3 deletions lua/mellifluous/colors/sets/tender.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function M.get_colors_dark(bg)
green = green1, -- staged, additions
blue = blue1, -- information, new files
purple = blue2, -- hints, merge

-- optional (for better terminal highlights)
yellow = yellow2,
yellow = yellow1,
}
end

Expand Down
1 change: 1 addition & 0 deletions lua/mellifluous/colors/shades.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function M.get_recipes()
ui_green = { target = 'green', action = 'with_li', val = 'ui' },
ui_blue = { target = 'blue', action = 'with_li', val = 'ui' },
ui_purple = { target = 'purple', action = 'with_li', val = 'ui' },
ui_yellow = { target = 'yellow', action = 'with_li', val = 'ui' },
}
local recipes = {}

Expand Down
3 changes: 3 additions & 0 deletions lua/mellifluous/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ local config = {
properties = {},
types = {},
operators = {},
markup = {
headings = { bold = true }
}
},
transparent_background = {
enabled = false,
Expand Down
3 changes: 2 additions & 1 deletion lua/mellifluous/highlights/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ local M = {}
function M.set(hl, colors)
local config = require('mellifluous.config').config

require('mellifluous.highlights.plugins.treesitter').set(hl, colors)

for plugin in pairs(config.plugins) do
if (type(config.plugins[plugin]) == 'table' and config.plugins[plugin].enabled == true)
or (type(config.plugins[plugin]) == 'boolean' and config.plugins[plugin] == true) then
require('mellifluous.highlights.plugins.' .. plugin).set(hl, colors)
end
end

require('mellifluous.highlights.plugins.treesitter').set(hl, colors)
require('mellifluous.highlights.plugins.semantic_tokens').set(hl, colors)
end

Expand Down
53 changes: 49 additions & 4 deletions lua/mellifluous/highlights/plugins/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ function M.set(hl, colors)
hl.set('@markup.math', { fg = colors.other_keywords }) -- Math environments like LaTeX's `$ ... $`
hl.set('@markup.environment', { fg = colors.other_keywords }) -- Text environments of markup languages.
hl.set('@markup.environment.name', { link = '@markup.environment' }) -- Text/string indicating the type of text environment. Like the name of a `\begin` block in LaTeX.
hl.set('@markup.link', { fg = hl.get('@string.special.url').fg }) -- Footnotes, text references, citations, etc.
hl.set('@markup.link.label', { fg = colors.constants }) -- Link, reference descriptions
hl.set('@markup.link', { fg = colors.constants, style = { underline = true } }) -- Footnotes, text references, citations, etc.
hl.set('@markup.link.markdown_inline', { fg = hl.get('@markup.link').fg }) -- Everything in a markdown link that's not a label or url (`[]()`)
hl.set('@markup.link.label', { link = '@markup.link' }) -- Link, reference descriptions
hl.set('@markup.link.url', { link = '@string.special.url' }) -- URIs like hyperlinks or email addresses.
hl.set('@markup.raw', { link = 'Character' }) -- Literal or verbatim text (e.g., inline code)
hl.set('@markup.raw.block', { link = 'Character' }) -- Literal or verbatim text as a stand-alone block
hl.set('@markup.raw', { fg = colors.fg2 }) -- Literal or verbatim text (e.g., inline code)
hl.set('@markup.raw.block', { link = '@markup.raw' }) -- Literal or verbatim text as a stand-alone block
hl.set('@markup.list', { link = 'Operator' }) -- List markers
hl.set('@markup.list.unchecked', { link = 'Todo' }) -- Unchecked todo-style list markers
hl.set('@markup.list.checked', { fg = hl.get('@markup.list.unchecked').fg, bg = 'NONE' }) -- Checked todo-style list markers
Expand All @@ -108,6 +109,50 @@ function M.set(hl, colors)
hl.set('@tag', { link = 'Keyword' }) -- Tags like HTML tag names.
hl.set('@tag.attribute', { link = 'Function', style = {} }) -- HTML tag attributes.
hl.set('@tag.delimiter', { link = 'Operator', style = {} }) -- Tag delimiters like `<` `>` `/`.
hl.set('@markup.heading.1.marker', { fg = colors.ui_red, style = {} })
hl.set('@markup.heading.2.marker', { fg = colors.ui_orange, style = {} })
hl.set('@markup.heading.3.marker', { fg = colors.ui_yellow, style = {} })
hl.set('@markup.heading.4.marker', { fg = colors.ui_green, style = {} })
hl.set('@markup.heading.5.marker', { fg = colors.ui_blue, style = {} })
hl.set('@markup.heading.6.marker', { fg = colors.ui_purple, style = {} })
hl.set('@markup.heading.1',
{
fg = shader.get_higher_contrast(colors.ui_red, 10),
bg = colors.bg:with_overlay(colors.ui_red, 16),
style = config.styles.markup.headings
})
hl.set('@markup.heading.2',
{
fg = shader.get_higher_contrast(colors.ui_orange, 10),
bg = colors.bg:with_overlay(colors.ui_orange, 16),
style = config.styles.markup.headings
})
hl.set('@markup.heading.3',
{
fg = shader.get_higher_contrast(colors.ui_yellow, 10),
bg = colors.bg:with_overlay(colors.ui_yellow, 16),
style = config.styles.markup.headings
})
hl.set('@markup.heading.4',
{
fg = shader.get_higher_contrast(colors.ui_green, 10),
bg = colors.bg:with_overlay(colors.ui_green, 16),
style = config.styles.markup.headings
})
hl.set('@markup.heading.5',
{
fg = shader.get_higher_contrast(colors.ui_blue, 10),
bg = colors.bg:with_overlay(colors.ui_blue, 16),
style = config.styles.markup.headings
})
hl.set('@markup.heading.6',
{
fg = shader.get_higher_contrast(colors.ui_purple, 10),
bg = colors.bg:with_overlay(colors.ui_purple, 16),
style = config.styles.markup.headings
})
hl.set('@markup.heading', { link = '@markup.heading.1' })
hl.set('@markup.heading.gitcommit', { fg = hl.get('@markup.heading').fg })


-- For compatitibilty with older neovim versions (TODO: remove after a few months)
Expand Down

0 comments on commit aa33868

Please sign in to comment.