@@ -21,6 +21,7 @@ local blank_mod = BaseMod:new({
2121 chars = {
2222 " ․" ,
2323 },
24+ tab_chars = {},
2425 style = {
2526 api .nvim_get_hl (0 , { name = " Whitespace" }),
2627 },
@@ -38,8 +39,16 @@ function blank_mod:render_line(index, indent)
3839 local render_char_num = math.floor (indent / shiftwidth )
3940 local win_info = fn .winsaveview ()
4041 local text = " "
41- for _ = 1 , render_char_num do
42- text = text .. " ." .. (" " ):rep (shiftwidth - 1 )
42+
43+ local space_tab = (" \t " ):rep (vim .o .tabstop )
44+ local line_val = fn .getline (index ):gsub (" \t " , space_tab )
45+ for i = 1 , render_char_num do
46+ local char = line_val :sub (shiftwidth * i - 1 , shiftwidth * i - 1 )
47+ if char == " \t " then
48+ text = text .. (" t" ) .. (" " ):rep (shiftwidth - 1 )
49+ else
50+ text = text .. " ." .. (" " ):rep (shiftwidth - 1 )
51+ end
4352 end
4453 text = text :sub (win_info .leftcol + 1 )
4554
@@ -50,7 +59,14 @@ function blank_mod:render_line(index, indent)
5059 count = count + 1
5160 local Blank_chars_num = Array :from (self .options .chars ):size ()
5261 local Blank_style_num = Array :from (self .options .style ):size ()
53- local char = self .options .chars [(count - 1 ) % Blank_chars_num + 1 ]:rep (shiftwidth )
62+
63+ local char
64+ if self .options .tab_chars and c :match (" t" ) then
65+ char = self .options .tab_chars [(count - 1 ) % Blank_chars_num + 1 ]:rep (shiftwidth )
66+ else
67+ char = self .options .chars [(count - 1 ) % Blank_chars_num + 1 ]:rep (shiftwidth )
68+ end
69+
5470 local style = " HLBlank" .. tostring ((count - 1 ) % Blank_style_num + 1 )
5571 row_opts .virt_text = { { char , style } }
5672 row_opts .virt_text_win_col = i - 1
0 commit comments