Fix detach when setup is called multiple times | #25

regen docs for previous commit
This commit is contained in:
Akianonymus 2022-09-28 11:26:17 +05:30
parent 20fd0091ef
commit 77e3db4891
2 changed files with 34 additions and 4 deletions

View file

@ -70,6 +70,10 @@
<td class="summary">Obvious.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#byte_is_valid_colorchar">byte_is_valid_colorchar (byte)</a></td>
<td class="summary">Obvious.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_last_modified">get_last_modified (path)</a></td>
<td class="summary">Get last modified time of a file</td>
</tr>
@ -147,6 +151,31 @@
</dd>
<dt>
<a name = "byte_is_valid_colorchar"></a>
<strong>byte_is_valid_colorchar (byte)</strong>
</dt>
<dd>
Obvious.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">byte</span>
number
</li>
</ul>
<h3>Returns:</h3>
<ol>
boolean
</ol>
</dd>
<dt>
<a name = "get_last_modified"></a>

View file

@ -371,6 +371,7 @@ function colorizer.setup(config)
all = { file = false, buf = false },
default_options = merge(USER_DEFAULT_OPTIONS, user_default_options),
}
BUFFER_OPTIONS, BUFFER_LOCAL = {}, {}
local function COLORIZER_SETUP_HOOK(typ)
local filetype = vim.bo.filetype
@ -412,8 +413,7 @@ function colorizer.setup(config)
end
end
local au_group_id = augroup(AUGROUP_NAME, {})
AUGROUP_ID = au_group_id
AUGROUP_ID = augroup(AUGROUP_NAME, {})
local aucmd = { buf = "BufWinEnter", file = "FileType" }
local function parse_opts(typ, tbl)
@ -446,12 +446,13 @@ function colorizer.setup(config)
end
end
autocmd({ aucmd[typ] }, {
group = au_group_id,
group = AUGROUP_ID,
pattern = typ == "file" and (SETUP_SETTINGS.all[typ] and "*" or list) or nil,
callback = function()
COLORIZER_SETUP_HOOK(typ)
end,
})
COLORIZER_SETUP_HOOK(typ)
elseif tbl then
vim.notify_once(string.format("colorizer: Invalid type for %stypes %s", typ, vim.inspect(tbl)), "ErrorMsg")
end
@ -461,7 +462,7 @@ function colorizer.setup(config)
parse_opts("buf", buftypes)
autocmd("ColorScheme", {
group = au_group_id,
group = AUGROUP_ID,
callback = function()
require("colorizer").clear_highlight_cache()
end,