Skip to content

Commit

Permalink
Merge pull request #40 from lukas-reineke/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-reineke authored Jul 19, 2022
2 parents 297ef84 + 7ccf290 commit 1cd93a6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ require("headlines").setup {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
rmd = {
query = vim.treesitter.parse_query(
Expand Down Expand Up @@ -114,6 +116,8 @@ require("headlines").setup {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
norg = {
query = vim.treesitter.parse_query(
Expand Down Expand Up @@ -148,6 +152,8 @@ require("headlines").setup {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
org = {
query = vim.treesitter.parse_query(
Expand Down Expand Up @@ -177,6 +183,8 @@ require("headlines").setup {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
}
```
Expand Down
22 changes: 21 additions & 1 deletion doc/headlines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


Author: Lukas Reineke <[email protected]>
Version: 3.2.2
Version: 3.3.0

==============================================================================
CONTENTS *headlines*
Expand Down Expand Up @@ -122,6 +122,8 @@ Default config: >
quote_highlight = "Quote",
quote_string = "┃",
fat_headlines = true,
fat_headline_upper_string = "▃",
fat_headline_lower_string = "🬂",
},
rmd = {
query = vim.treesitter.parse_query(
Expand Down Expand Up @@ -152,6 +154,8 @@ Default config: >
quote_highlight = "Quote",
quote_string = "┃",
fat_headlines = true,
fat_headline_upper_string = "▃",
fat_headline_lower_string = "🬂",
},
norg = {
query = vim.treesitter.parse_query(
Expand Down Expand Up @@ -186,6 +190,8 @@ Default config: >
quote_highlight = "Quote",
quote_string = "┃",
fat_headlines = true,
fat_headline_upper_string = "▃",
fat_headline_lower_string = "🬂",
},
org = {
query = vim.treesitter.parse_query(
Expand Down Expand Up @@ -215,6 +221,8 @@ Default config: >
quote_highlight = "Quote",
quote_string = "┃",
fat_headlines = true,
fat_headline_upper_string = "▃",
fat_headline_lower_string = "🬂",
},
}
Expand Down Expand Up @@ -249,6 +257,18 @@ fat_headlines *headlines-fat_headlines*

Boolean to turn on fat headlines.

------------------------------------------------------------------------------
fat_headline_upper_string *headlines-fat_headline_upper_string*

Specifies the string that is repeated above a headline when
|headlines-fat_headlines| is on.

------------------------------------------------------------------------------
fat_headline_lower_string *headlines-fat_headline_lower_string*

Specifies the string that is repeated below a headline when
|headlines-fat_headlines| is on.

------------------------------------------------------------------------------
codeblock_highlight *headlines-codeblock_highlight*

Expand Down
17 changes: 12 additions & 5 deletions lua/headlines/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ M.config = {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
rmd = {
query = parse_query_save(
Expand Down Expand Up @@ -70,6 +72,8 @@ M.config = {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
norg = {
query = parse_query_save(
Expand Down Expand Up @@ -104,6 +108,8 @@ M.config = {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
org = {
query = parse_query_save(
Expand Down Expand Up @@ -133,6 +139,8 @@ M.config = {
quote_highlight = "Quote",
quote_string = "",
fat_headlines = true,
fat_headline_upper_string = "",
fat_headline_lower_string = "🬂",
},
}

Expand Down Expand Up @@ -209,9 +217,8 @@ M.refresh = function()
for _, match, metadata in c.query:iter_matches(root, bufnr) do
for id, node in pairs(match) do
local capture = c.query.captures[id]
local start_row, start_column, end_row, _ = unpack(
vim.tbl_extend("force", { node:range() }, (metadata[id] or {}).range or {})
)
local start_row, start_column, end_row, _ =
unpack(vim.tbl_extend("force", { node:range() }, (metadata[id] or {}).range or {}))

if capture == "headline" and c.headline_highlights then
local level = #vim.trim(q.get_node_text(node, bufnr))
Expand All @@ -226,7 +233,7 @@ M.refresh = function()
if c.fat_headlines then
local reverse_hl_group = M.make_reverse_highlight(hl_group)

local padding_above = { { (""):rep(width), reverse_hl_group } }
local padding_above = { { c.fat_headline_upper_string:rep(width), reverse_hl_group } }
if start_row > 0 then
local line_above = vim.api.nvim_buf_get_lines(bufnr, start_row - 1, start_row, false)[1]
if line_above == "" and start_row - 1 ~= last_fat_headline then
Expand All @@ -243,7 +250,7 @@ M.refresh = function()
end
end

local padding_below = { { ("🬂"):rep(width), reverse_hl_group } }
local padding_below = { { c.fat_headline_lower_string:rep(width), reverse_hl_group } }
local line_below = vim.api.nvim_buf_get_lines(bufnr, start_row + 1, start_row + 2, false)[1]
if line_below == "" then
nvim_buf_set_extmark(bufnr, M.namespace, start_row + 1, 0, {
Expand Down

0 comments on commit 1cd93a6

Please sign in to comment.