Skip to content

Commit

Permalink
feat(hl): add 'TreesitterContextLineNumberBottom'
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielkonge committed Jan 25, 2024
1 parent 2972717 commit 1ce2ae4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,21 @@ context line numbers if `line_numbers` is set. Per default it links to `LineNr`.
Use the highlight group `TreesitterContextSeparator` to change the colors of the
separator if `separator` is set. By default it links to `FloatBorder`.

Use the highlight group `TreesitterContextBottom` to change the highlight of the
last line of the context window. By default it links to `NONE`.
However, you can use this to create a border by applying an underline highlight, e.g:
Use the highlight groups `TreesitterContextBottom` and/or
`TreesitterContextLineNumberBottom` to change the highlight of the last line of
the context window. By default it links to `NONE`.
However, you can use this to create a border by applying an underline highlight, e.g,
for an underline across the screen:

```vim
hi TreesitterContextBottom gui=underline guisp=Grey
hi TreesitterContextLineNumberBottom gui=underline guisp=Grey
```

Or an underline below the line numbers only:

```vim
hi TreesitterContextLineNumberBottom gui=underline guisp=Grey
```

## Jumping to context (upwards)
Expand Down
1 change: 1 addition & 0 deletions lua/treesitter-context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ local function init()

api.nvim_set_hl(0, 'TreesitterContext', { link = 'NormalFloat', default = true })
api.nvim_set_hl(0, 'TreesitterContextLineNumber', { link = 'LineNr', default = true })
api.nvim_set_hl(0, 'TreesitterContextLineNumberBottom', { link = 'NONE', default = true })
api.nvim_set_hl(0, 'TreesitterContextBottom', { link = 'NONE', default = true })
api.nvim_set_hl(0, 'TreesitterContextSeparator', { link = 'FloatBorder', default = true })
end
Expand Down
12 changes: 11 additions & 1 deletion lua/treesitter-context/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ local function highlight_bottom(bufnr, row)
})
end

---@param bufnr integer
---@param row integer
local function highlight_lno_bottom(bufnr, row)
add_extmark(bufnr, row, 0, {
end_line = row + 1,
hl_group = 'TreesitterContextLineNumberBottom',
hl_eol = true,
})
end

--- @param buf integer
--- @param text string[]
--- @param highlights StatusLineHighlight[][]
Expand Down Expand Up @@ -293,7 +303,7 @@ local function render_lno(win, bufnr, contexts, gutter_width)

set_lines(bufnr, lno_text)
highlight_lno_str(bufnr, lno_text, lno_highlights)
highlight_bottom(bufnr, #lno_text - 1)
highlight_lno_bottom(bufnr, #lno_text - 1)
end

---@param winid? integer
Expand Down

0 comments on commit 1ce2ae4

Please sign in to comment.