@@ -21,6 +21,7 @@ local blank_mod = BaseMod:new({
21
21
chars = {
22
22
" ․" ,
23
23
},
24
+ tab_chars = {},
24
25
style = {
25
26
api .nvim_get_hl (0 , { name = " Whitespace" }),
26
27
},
@@ -38,8 +39,16 @@ function blank_mod:render_line(index, indent)
38
39
local render_char_num = math.floor (indent / shiftwidth )
39
40
local win_info = fn .winsaveview ()
40
41
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
43
52
end
44
53
text = text :sub (win_info .leftcol + 1 )
45
54
@@ -50,7 +59,14 @@ function blank_mod:render_line(index, indent)
50
59
count = count + 1
51
60
local Blank_chars_num = Array :from (self .options .chars ):size ()
52
61
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
+
54
70
local style = " HLBlank" .. tostring ((count - 1 ) % Blank_style_num + 1 )
55
71
row_opts .virt_text = { { char , style } }
56
72
row_opts .virt_text_win_col = i - 1
0 commit comments