diff options
| author | jdhao <jdhao@hotmail.com> | 2022-08-28 14:56:35 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-28 14:56:35 +0800 |
| commit | 208b190a65c8b9175f770872a8ef00ca638029a7 (patch) | |
| tree | 17c0b4e5c5684dbcbde4e42b4a5778fa6ad459fd /lua | |
| parent | 7022eefe22b2297ffed2d41a632273b37e949a2b (diff) | |
| parent | 602254a88187821924c2de05e9c9596cc3cbbb88 (diff) | |
Merge pull request #84 from jdhao/indentline
update indent-blankline conf
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/config/indent-blankline.lua | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/lua/config/indent-blankline.lua b/lua/config/indent-blankline.lua index 0873720..597b508 100644 --- a/lua/config/indent-blankline.lua +++ b/lua/config/indent-blankline.lua @@ -1,3 +1,6 @@ +local api = vim.api + +local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" } require("indent_blankline").setup({ -- U+2502 may also be a good choice, it will be on the middle of cursor. -- U+250A is also a good choice @@ -5,19 +8,22 @@ require("indent_blankline").setup({ show_end_of_line = false, disable_with_nolist = true, buftype_exclude = { "terminal" }, - filetype_exclude = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" }, + filetype_exclude = exclude_ft, }) -vim.cmd([[ -function! Should_activate_indentblankline() abort - if index(g:indent_blankline_filetype_exclude, &filetype) == -1 - IndentBlanklineEnable - endif -endfunction +local gid = api.nvim_create_augroup("indent_blankline", { clear = true }) +api.nvim_create_autocmd("InsertEnter", { + pattern = "*", + group = gid, + command = "IndentBlanklineDisable" +}) -augroup indent_blankline - autocmd! - autocmd InsertEnter * IndentBlanklineDisable - autocmd InsertLeave * call Should_activate_indentblankline() -augroup END -]]) +api.nvim_create_autocmd("InsertLeave", { + pattern = "*", + group = gid, + callback = function() + if not vim.tbl_contains(exclude_ft, vim.bo.filetype) then + vim.cmd [[IndentBlanklineEnable]] + end + end +}) |
