Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lua/hlchunk/mods/chunk/chunk_conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local BaseConf = require("hlchunk.mods.base_mod.base_conf")
---@field textobject? string
---@field max_file_size? number
---@field error_sign? boolean
---@field straight? boolean

---@class HlChunk.ChunkConf : HlChunk.BaseConf
---@field use_treesitter boolean
Expand All @@ -16,6 +17,7 @@ local BaseConf = require("hlchunk.mods.base_mod.base_conf")
---@field error_sign boolean
---@field duration number
---@field delay number
---@field straight boolean
---@overload fun(conf?: table): HlChunk.ChunkConf
local ChunkConf = class(BaseConf, function(self, conf)
local default_conf = {
Expand All @@ -38,6 +40,7 @@ local ChunkConf = class(BaseConf, function(self, conf)
error_sign = true,
duration = 200,
delay = 300,
straight = false,
}
conf = vim.tbl_deep_extend("force", default_conf, conf or {}) --[[@as HlChunk.ChunkConf]]
BaseConf.init(self, conf)
Expand All @@ -50,6 +53,7 @@ local ChunkConf = class(BaseConf, function(self, conf)
self.error_sign = conf.error_sign
self.duration = conf.duration
self.delay = conf.delay
self.straight = conf.straight
end)

return ChunkConf
11 changes: 8 additions & 3 deletions lua/hlchunk/mods/chunk/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ end
function ChunkMod:get_chunk_data(range, virt_text_list, row_list, virt_text_win_col_list)
local beg_blank_len = cFunc.get_indent(range.bufnr, range.start)
local end_blank_len = cFunc.get_indent(range.bufnr, range.finish)
local start_col = math.max(math.min(beg_blank_len, end_blank_len) - self.meta.shiftwidth, 0)
local start_col
if self.conf.straight then
start_col = math.max(math.min(beg_blank_len, end_blank_len), 0)
else
start_col = math.max(math.min(beg_blank_len, end_blank_len) - self.meta.shiftwidth, 0)
end

if beg_blank_len > 0 then
if not self.conf.straight and beg_blank_len > 0 then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional. straight = true is meant to highlight the current scope's indent level rather than highlighting the line at the previous indent.

local virt_text_len = beg_blank_len - start_col
local beg_virt_text = self.conf.chars.left_top
.. self.conf.chars.horizontal_line:rep(virt_text_len - 2)
Expand Down Expand Up @@ -108,7 +113,7 @@ function ChunkMod:get_chunk_data(range, virt_text_list, row_list, virt_text_win_
end
vim.list_extend(virt_text_list, chars)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also intentional. With straight = true we wouldn't want the vertical line connecting the start and end of the scope to overlap with the line starting the scope and the end line.

if end_blank_len > 0 then
if not self.conf.straight and end_blank_len > 0 then
local virt_text_len = end_blank_len - start_col
local end_virt_text = self.conf.chars.left_bottom
.. self.conf.chars.horizontal_line:rep(virt_text_len - 2)
Expand Down
Loading