Skip to content

Commit

Permalink
feat: add option minlevel close #23
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Jun 14, 2024
1 parent 16558bd commit 9bac70d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ available config values in setup table.

- char -- string type default is ``,
- exclude -- table type add exclude filetype in this table ie `{ 'markdown', 'xxx'}`
- minlevel -- number the min level that show indent line default is 1

```lua
config = function()
Expand Down
5 changes: 5 additions & 0 deletions lua/indentmini/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ local function on_line(_, _, bufnr, row)
for i = 1, indent - 1, cache.step do
local col = i - 1
local level = math.floor(col / cache.step) + 1
if level < opt.minlevel then
goto continue
end
local higroup = 'IndentLine'
if row > cache.reg_srow and row < cache.reg_erow and level == cache.cur_inlevel then
higroup = 'IndentLineCurrent'
Expand All @@ -112,6 +115,7 @@ local function on_line(_, _, bufnr, row)
buf_set_extmark(bufnr, ns, row, col, opt.config)
opt.config.virt_text_win_col = nil
end
::continue::
end
end

Expand Down Expand Up @@ -140,6 +144,7 @@ return {
opt.exclude = { 'dashboard', 'lazy', 'help', 'markdown', 'nofile', 'terminal', 'prompt' }
vim.list_extend(opt.exclude, conf.exclude or {})
opt.config.virt_text = { { conf.char or '' } }
opt.minlevel = conf.minlevel or 1
set_provider(ns, { on_win = on_win, on_line = on_line })
end,
}

0 comments on commit 9bac70d

Please sign in to comment.