Module colorizer
Requires Neovim >= 0.6.0 and set termguicolors
Highlights terminal CSI ANSI color codes.
See also:
Usage:
Establish the autocmd to highlight all filetypes. `lua require 'colorizer'.setup()` Highlight using all css highlight modes in every filetype `lua require 'colorizer'.setup(user_default_options = { css = true; })` ============================================================================== USE WITH COMMANDS *colorizer-commands* *:ColorizerAttachToBuffer* Attach to the current buffer and start highlighting with the settings as specified in setup (or the defaults). If the buffer was already attached(i.e. being highlighted), the settings will be reloaded with the ones from setup. This is useful for reloading settings for just one buffer. *:ColorizerDetachFromBuffer* Stop highlighting the current buffer (detach). *:ColorizerReloadAllBuffers* Reload all buffers that are being highlighted currently. Shortcut for ColorizerAttachToBuffer on every buffer. *:ColorizerToggle* Toggle highlighting of the current buffer. USE WITH LUA All options that can be passed to user_default_options in `setup` can be passed here. Can be empty too. `0` is the buffer number here Attach to current buffer <pre> require("colorizer").attach_to_buffer(0, { mode = "background", css = false, }) </pre> Detach from buffer <pre> require("colorizer").detach_from_buffer(0, { mode = "background", css = false, }) </pre>
Info:
- Author: Ashkan Kiani from-nvim-colorizer.lua@kiani.io
Functions
highlight_buffer () | Highlight the buffer region |
is_buffer_attached (buf) | Check if attached to a buffer. |
detach_from_buffer (buf, ns) | Stop highlighting the current buffer. |
attach_to_buffer (buf, options, typ) | Attach to a buffer and continuously highlight changes. |
setup (config) | Easy to use function if you want the full setup without fine grained control. |
get_buffer_options (buf) | Return the currently active buffer options. |
reload_all_buffers () | Reload all of the currently active highlighted buffers. |
clear_highlight_cache () | Clear the highlight cache and reload all buffers. |
Tables
user_default_options | defaults options. |
Fields
DEFAULT_NAMESPACE | Default namespace used in colorizer.buffer_utils.highlight_buffer and attach_to_buffer. |
Functions
- highlight_buffer ()
-
Highlight the buffer region
See also:
- is_buffer_attached (buf)
-
Check if attached to a buffer.
Parameters:
- buf number|nil: A value of 0 implies the current buffer.
Returns:
-
number|nil: if attached to the buffer, false otherwise.
See also:
- detach_from_buffer (buf, ns)
-
Stop highlighting the current buffer.
Parameters:
- buf number|nil: buf A value of 0 or nil implies the current buffer.
- ns number|nil: ns the namespace id, if not given DEFAULT_NAMESPACE is used
- attach_to_buffer (buf, options, typ)
-
Attach to a buffer and continuously highlight changes.
Parameters:
- buf integer: A value of 0 implies the current buffer.
- options table: Configuration options as described in setup
- typ string|nil: "buf" or "file" - The type of buffer option
- setup (config)
-
Easy to use function if you want the full setup without fine grained control.
Setup an autocmd which enables colorizing for the filetypes and options specified.
By default highlights all FileTypes.
Example config:~
{ filetypes = { "css", "html" }, user_default_options = { names = true } }
Setup with all the default options:~
require("colorizer").setup { filetypes = { "*" }, user_default_options, -- all the sub-options of filetypes apply to buftypes buftypes = {}, }
For all userdefaultoptions, see |userdefaultoptions|
Parameters:
- config table: Config containing above parameters.
Usage:
require'colorizer'.setup()
- get_buffer_options (buf)
-
Return the currently active buffer options.
Parameters:
- buf number|nil: Buffer number
- reload_all_buffers ()
- Reload all of the currently active highlighted buffers.
- clear_highlight_cache ()
- Clear the highlight cache and reload all buffers.
Tables
- user_default_options
-
defaults options.
user_default_options = { RGB = true, -- #RGB hex codes RRGGBB = true, -- #RRGGBB hex codes names = true, -- "Name" codes like Blue or blue RRGGBBAA = false, -- #RRGGBBAA hex codes AARRGGBB = false, -- 0xAARRGGBB hex codes rgb_fn = false, -- CSS rgb() and rgba() functions hsl_fn = false, -- CSS hsl() and hsla() functions css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn -- Available modes for
mode
: foreground, background, virtualtext mode = "background", -- Set the display mode. -- Available methods are false / true / "normal" / "lsp" / "both" -- True is same as normal tailwind = false -- Enable tailwind colors virtualtext = "■", }Fields:
- RGB boolean
- RRGGBB boolean
- names boolean
- RRGGBBAA boolean
- AARRGGBB boolean
- rgb_fn boolean
- hsl_fn boolean
- css boolean
- css_fn boolean
- mode string
- tailwind boolean|string
- virtualtext string
Fields
- DEFAULT_NAMESPACE
-
Default namespace used in colorizer.buffer_utils.highlight_buffer and attach_to_buffer.
See also: