@@ -17,7 +17,7 @@ function M.write_block(bufnr, lines, line, mark)
17
17
mark = mark or false
18
18
19
19
if type (lines ) == " string" then
20
- lines = vim .split (lines , " \n " , true )
20
+ lines = vim .split (lines , " \n " )
21
21
end
22
22
23
23
-- write content lines
@@ -45,6 +45,16 @@ function M.write_block(bufnr, lines, line, mark)
45
45
end
46
46
end
47
47
48
+ local indent_text = string.rep (" " , 2 * 4 )
49
+ for i = start_line , end_line do
50
+ vim .api .nvim_buf_set_extmark (bufnr , constants .OCTO_COMMENT_NS , i - 1 , 0 , {
51
+ virt_text = { { indent_text , " Whitespace" } },
52
+ virt_text_pos = " inline" ,
53
+ virt_text_repeat_linebreak = true ,
54
+ right_gravity = false ,
55
+ })
56
+ end
57
+
48
58
return vim .api .nvim_buf_set_extmark (bufnr , constants .OCTO_COMMENT_NS , math.max (0 , start_line - 1 - 1 ), 0 , {
49
59
end_line = math.min (end_line + 2 - 1 , vim .api .nvim_buf_line_count (bufnr )),
50
60
end_col = 0 ,
@@ -595,9 +605,20 @@ function M.write_comment(bufnr, comment, kind, line)
595
605
if vim .startswith (comment_body , constants .NO_BODY_MSG ) or utils .is_blank (comment_body ) then
596
606
comment_body = " "
597
607
end
598
- local content = vim .split (comment_body , " \n " , true )
608
+ local content = vim .split (comment_body , " \n " )
599
609
vim .list_extend (content , { " " })
610
+
611
+ -- Set extmark with virtual text at the beginning of the line
600
612
local comment_mark = M .write_block (bufnr , content , line , true )
613
+ --
614
+ -- -- Define the number of spaces for indentation (e.g., 4 spaces per indent level)
615
+ -- local indent_text = string.rep(" ", 2 * 4) -- Adjust 4 based on your desired indent width
616
+ -- vim.api.nvim_buf_set_extmark(bufnr, comment_vt_ns, line - 1, 0, {
617
+ -- virt_lines = { { { "foo" .. indent_text, "Normal" } }, { { "bar" .. indent_text, "Normal" } } },
618
+ -- virt_lines_leftcol = true,
619
+ -- end_row = line + 1,
620
+ -- virt_text_pos = "inline",
621
+ -- })
601
622
602
623
line = line + # content
603
624
0 commit comments