Skip to content

Commit

Permalink
Multiple stylua fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Kongsgaard authored and Daniel Kongsgaard committed Oct 12, 2023
1 parent 5d4315b commit fb94974
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lua/ibl/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ local validate_config = function(config)
utils.validate({
enabled = { config.current_indent.enabled, "boolean", true },
char = { config.current_indent.char, "string", true },
highlight = { config.current_indent.highlight, "string", true }
highlight = { config.current_indent.highlight, "string", true },
}, config.current_indent, "ibl.config.current_indent")
if config.current_indent.char then
vim.validate {
Expand Down
26 changes: 19 additions & 7 deletions lua/ibl/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ M.refresh = function(bufnr)
-- if cur_indent_stack_size >= 1, we should stop when we get to a line with no more whitespace in the whitespace_tbl
-- since that line won't have any indents to highlight
if
(cursor_row_stack_size >= 0 and cursor_row_stack_size > cur_indent_stack_size and (not blankline))
(cursor_row_stack_size >= 0 and cursor_row_stack_size > cur_indent_stack_size and not blankline)
or (cursor_row_stack_size >= 0 and cur_indent_stack_size >= 1 and #whitespace_tbl == 0)
then
current_indent_row_end = row - 1
Expand All @@ -418,7 +418,10 @@ M.refresh = function(bufnr)
whitespace_tbl = fn(buffer_state.tick, bufnr, row - 1, whitespace_tbl)
end

arr_whitespace_tbl[i] = whitespace_tbl
-- this do block is purely to help stylua with the scope
do
arr_whitespace_tbl[i] = whitespace_tbl
end

::continue::
end
Expand Down Expand Up @@ -481,8 +484,9 @@ M.refresh = function(bufnr)
local scope_start = row == scope_row_start
local scope_end = row == scope_row_end

local current_indent_active = row >= current_indent_row_start and row <= current_indent_row_end and
config.current_indent.enabled
local current_indent_active = row >= current_indent_row_start
and row <= current_indent_row_end
and config.current_indent.enabled

if scope_start and scope then
scope_col_start = whitespace_len
Expand All @@ -498,9 +502,17 @@ M.refresh = function(bufnr)
end

local char_map = vt.get_char_map(config, listchars, whitespace_only, blankline)
local virt_text, scope_hl =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single,
current_indent_active, current_indent_col)
local virt_text, scope_hl = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

-- #### set virtual text ####
vt.clear_buffer(bufnr, row)
Expand Down
13 changes: 11 additions & 2 deletions lua/ibl/virt_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@ end
---@param current_indent_active boolean
---@param current_indent_col number
---@return ibl.virtual_text, ibl.highlight
M.get = function(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single,
current_indent_active, current_indent_col)
M.get = function(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)
local scope_hl = utils.tbl_get_index(highlights.scope, scope_index)
local current_indent_hl = highlights.current_indent.char
local indent_index = 1
Expand Down
156 changes: 132 additions & 24 deletions specs/features/virt_text_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {})
end)
Expand All @@ -310,8 +319,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "f", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -340,8 +358,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "a", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -372,8 +399,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "a", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -404,8 +440,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "e", { "@ibl.whitespace.char.1" } },
Expand Down Expand Up @@ -434,8 +479,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "f", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -464,8 +518,17 @@ describe("virt_text", function()
local current_indent_active = true
local current_indent_col = 2

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "f", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -494,8 +557,17 @@ describe("virt_text", function()
local current_indent_active = true
local current_indent_col = 2

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "f", { "@ibl.whitespace.char.1", "@ibl.scope.char.1" } },
Expand Down Expand Up @@ -524,8 +596,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "a", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -558,8 +639,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "f", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -594,8 +684,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "f", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down Expand Up @@ -630,8 +729,17 @@ describe("virt_text", function()
local current_indent_active = false
local current_indent_col = -1

local virt_text =
vt.get(config, char_map, whitespace_tbl, scope_active, scope_index, scope_end, scope_col_start_single, current_indent_active, current_indent_col)
local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_end,
scope_col_start_single,
current_indent_active,
current_indent_col
)

assert.are.same(virt_text, {
{ "f", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
Expand Down

0 comments on commit fb94974

Please sign in to comment.