This plugin adds 3 kind of horizontal highlights for text filetypes, like
markdown
, rmd
, vimwiki
and orgmode
.
- Background highlighting for headlines
- Background highlighting for code blocks
- Whole window separator for horizontal line
Use your favourite plugin manager to install.
-- init.lua
require("packer").startup(
function()
use {
'lukas-reineke/headlines.nvim',
config = function()
require('headlines').setup()
end,
}
end
)
" init.vim
call plug#begin('~/.vim/plugged')
Plug 'lukas-reineke/headlines.nvim'
call plug#end()
lua << EOF
require("headlines").setup()
EOF
To configure headlines.nvim pass a config table into the setup function.
Default config:
require("headlines").setup {
markdown = {
source_pattern_start = "^```",
source_pattern_end = "^```$",
dash_pattern = "^---+$",
headline_pattern = "^#+",
headline_highlights = { "Headline" },
codeblock_highlight = "CodeBlock",
dash_highlight = "Dash",
dash_string = "-",
fat_headlines = true,
},
rmd = {
source_pattern_start = "^```",
source_pattern_end = "^```$",
dash_pattern = "^---+$",
headline_pattern = "^#+",
headline_signs = { "Headline" },
codeblock_sign = "CodeBlock",
dash_highlight = "Dash",
dash_string = "-",
fat_headlines = true,
},
vimwiki = {
source_pattern_start = "^{{{%a+",
source_pattern_end = "^}}}$",
dash_pattern = "^---+$",
headline_pattern = "^=+",
headline_highlights = { "Headline" },
codeblock_highlight = "CodeBlock",
dash_highlight = "Dash",
dash_string = "-",
fat_headlines = true,
},
org = {
source_pattern_start = "#%+[bB][eE][gG][iI][nN]_[sS][rR][cC]",
source_pattern_end = "#%+[eE][nN][dD]_[sS][rR][cC]",
dash_pattern = "^-----+$",
headline_pattern = "^%*+",
headline_highlights = { "Headline" },
codeblock_highlight = "CodeBlock",
dash_highlight = "Dash",
dash_string = "-",
fat_headlines = true,
},
}
To change any setting, pass a table with that option. Or add a completely new filetype.
You can turn off highlighting by passing false
require("headlines").setup {
markdown = {
headline_pattern = false,
},
yaml = {
dash_pattern = "^---+$",
dash_highlight = "Dash",
}
}
Please see :help headlines.txt
for more details.
All screenshots use my custom onedark color scheme.
vim.cmd [[highlight Headline1 guibg=#1e2718]]
vim.cmd [[highlight Headline2 guibg=#21262d]]
vim.cmd [[highlight CodeBlock guibg=#1c1c1c]]
vim.cmd [[highlight Dash guibg=#D19A66 gui=bold]]
require("headlines").setup {
org = {
headline_highlights = { "Headline1", "Headline2" },
},
}