From 9bac70d4faa758d18d2cb699dda1cbf113e3d87a Mon Sep 17 00:00:00 2001 From: glepnir Date: Fri, 14 Jun 2024 14:48:46 +0800 Subject: [PATCH] feat: add option minlevel close #23 --- README.md | 1 + lua/indentmini/init.lua | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 1f0854d..81eb32d 100644 --- a/README.md +++ b/README.md @@ -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() diff --git a/lua/indentmini/init.lua b/lua/indentmini/init.lua index bea51fb..d146af9 100644 --- a/lua/indentmini/init.lua +++ b/lua/indentmini/init.lua @@ -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' @@ -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 @@ -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, }