norcalli.nvim-colorizer.lua/plugin/colorizer.lua
Akianonymus 28b41de2f4 fragment | Implement better autocmd management | refactor
add a all_buffers option - colorizer will activate on all buffers, empty or not, still respect filetypes option

handle errors when detach is called multiple times from the same buffer

use bufdelete and bufdelete to remove the autocmds

use a more efficient compile parse_fn function

use custom ldoc template to generate vim help
2022-09-03 17:24:25 +05:30

30 lines
660 B
Lua

if vim.g.loaded_colorizer then
return
end
local command = vim.api.nvim_create_user_command
command("ColorizerAttachToBuffer", function()
require("colorizer").attach_to_buffer(0)
end, {})
-- Stop highlighting the current buffer (detach).
command("ColorizerDetachFromBuffer", function()
require("colorizer").detach_from_buffer(0)
end, {})
command("ColorizerReloadAllBuffers", function()
require("colorizer").reload_all_buffers()
end, {})
command("ColorizerToggle", function()
local c = require "colorizer"
if c.is_buffer_attached(0) then
c.detach_from_buffer(0)
else
c.attach_to_buffer(0)
end
end, {})
vim.g.loaded_colorizer = true