Skip to content

Commit

Permalink
fix: highlight should combine
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed May 30, 2024
1 parent e488a19 commit d78187f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/indentmini/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local ffi = require('ffi')
local opt = {
config = {
virt_text_pos = 'overlay',
hl_mode = 'replace',
hl_mode = 'combine',
ephemeral = true,
},
}
Expand Down Expand Up @@ -103,7 +103,9 @@ local function on_line(_, _, bufnr, row)
if row > cache.reg_srow and row < cache.reg_erow and level == cache.cur_inlevel then
higroup = 'IndentLineCurrent'
end
if not vim.o.expandtab then col = level - 1 end
if not vim.o.expandtab then
col = level - 1
end
if col >= cache.leftcol and non_or_space(row, col) then
opt.config.virt_text[1][2] = higroup
if is_empty and col > 0 then
Expand Down

5 comments on commit d78187f

@AyushRawal
Copy link
Contributor

Choose a reason for hiding this comment

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

setting hl_mode to combine causes highlighting issues with tab indentation and list option set
image

@glepnir
Copy link
Member Author

Choose a reason for hiding this comment

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

but when cursorline is true the highlight is wired when replace

@AyushRawal
Copy link
Contributor

Choose a reason for hiding this comment

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

you are right. indent-blankline.nvim solves the issue I am facing by setting nocombine to true in its highlights

@glepnir
Copy link
Member Author

Choose a reason for hiding this comment

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

there may need a hacky then..

@AyushRawal
Copy link
Contributor

Choose a reason for hiding this comment

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

this is what I am using now:

local indent_hl = vim.api.nvim_get_hl(0, { name = "IndentLine" })       
if vim.tbl_isempty(indent_hl) then                                      
  indent_hl = vim.api.nvim_get_hl(0, { name = "IblIndent" })            
end                                                                     
if vim.tbl_isempty(indent_hl) then                                      
  indent_hl = vim.api.nvim_get_hl(0, { name = "Whitespace" })           
end                                                                     
indent_hl.nocombine = true                                              
vim.api.nvim_set_hl(0, "IndentLine", indent_hl)                         
                                                                        
local scope_hl = vim.api.nvim_get_hl(0, { name = "IndentLineCurrent" }) 
if vim.tbl_isempty(scope_hl) then                                       
  scope_hl = vim.api.nvim_get_hl(0, { name = "IblScope" })              
end                                                                     
if vim.tbl_isempty(scope_hl) then                                       
  scope_hl = vim.api.nvim_get_hl(0, { name = "LineNr" })                
end                                                                     
scope_hl.nocombine = true                                               
vim.api.nvim_set_hl(0, "IndentLineCurrent", scope_hl)                   

Please sign in to comment.