aboutsummaryrefslogtreecommitdiff
path: root/doc/colorizer-lua.txt
blob: 2d27d2709a18fa28bd9e695366922fd34f5fbcac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
*colorizer.lua* Highlight color codes like #RRGGBB and others.

Minimum version of neovim: 0.4.0

Author: Ashkan Kiani <from-nvim-colorizer.lua@kiani.io>

==============================================================================
INTRODUCTION                                       *colorizer-lua-introduction*

==============================================================================
QUICK START                                          *colorizer-lua-quickstart*

Establish the an autocmd to highlight all filetypes.
>
  lua require 'colorizer'.setup()

  " Highlight using all available possible highlight modes in every filetype
  lua require 'colorizer'.setup(nil, { css = true; })
<

==============================================================================
COMMANDS                                                   *colorizer-commands*

|:ColorizerAttachToBuffer|                             *: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|                         *:ColorizerDetachFromBuffer*

Stop highlighting the current buffer (detach).

|:ColorizerReloadAllBuffers|                         *:ColorizerReloadAllBuffers*

Reload all buffers that are being highlighted with new settings from the setup
settings (or the defaults). Shortcut for ColorizerAttachToBuffer on every
buffer.

==============================================================================
LUA API DEFINITION                                          *colorizer-lua-api*

Assumes the module is imported as `colorizer`

|colorizer-options|                                           *colorizer-options*

>
  DEFAULT_OPTIONS = {
    RGB     = true;         -- #RGB hex codes
    RRGGBB  = true;         -- #RRGGBB hex codes
    names   = true;         -- "Name" codes like Blue
    rgb_fn  = false;        -- CSS rgb() and rgba() functions
    hsl_fn  = false;        -- CSS hsl() and hsla() functions
    css     = false;        -- Enable all features above.
    css_fn  = false;        -- Enable all CSS *functions*: rgb_fn, hsl_fn
    -- Available modes: foreground, background
    mode    = 'background'; -- Set the display mode.
  }
<

MODES:
- 'foreground': sets the foreground text color.
- 'background': sets the background text color.


|colorizer.setup|                                               *colorizer.setup*

Easy to use function if you want the full setup without fine grained control.
Establishes an autocmd for `FileType`s .

PARAMETERS:
	`filetypes`	 (optional) filetypes to enable. see examples below
	`default_options`  (optional) |colorizer-options|
>
  colorizer.setup([filetypes=nil], [default_options={}])

  " In your VIMRC
  lua require'colorizer'.setup()

  -- From lua
  -- Attaches to every FileType mode
  require 'colorizer'.setup()
  
  -- Attach to certain Filetypes, add special configuration for `html`
  -- Use `background` for everything else.
  require 'colorizer'.setup {
    'css';
    'javascript';
    html = {
  	  mode = 'foreground';
    }
  }
  
  -- Use the `default_options` as the second parameter, which uses
  -- `foreground` for every mode. This is the inverse of the previous
  -- setup configuration.
  require 'colorizer'.setup({
    'css';
    'javascript';
    html = { mode = 'background' };
  }, { mode = 'foreground' })
  
  -- Use the `default_options` as the second parameter, which uses
  -- `foreground` for every mode. This is the inverse of the previous
  -- setup configuration.
  require 'colorizer'.setup {
    '*'; -- Highlight all files, but customize some others.
    css = { rgb_fn = true; }; -- Enable parsing rgb(...) functions in css.
    html = { names = false; } -- Disable parsing "names" like Blue or Gray
  }
<

|colorizer.highlight_buffer|                          *colorizer.highlight_buffer*

Highlight starting from `line_start` (0-indexed) for each line described by `lines` in the
buffer `buf` and attach it to the namespace `ns`.

PARAMETERS:
	`buf`		 buffer id.
	`ns`		 the namespace id. Create it with `vim.api.create_namespace`
	`lines`		 the lines to highlight from the buffer.
	`line_start`	 should be 0-indexed
	`options`	 |colorizer-options| to set. REQUIRED!
>
  colorizer.highlight_buffer(buf[, ns=DEFAULT_NAMESPACE],
		  lines, line_start, options)
<

|colorizer.attach_to_buffer|                          *colorizer.attach_to_buffer*

Attach to a buffer and continuously highlight changes.

If you don't specify `options`, it will be set from the setup options if
specified or the default in |colorizer-options|.

PARAMETERS:
	`buf`	 A value of 0 implies the current buffer.
	`options`  (optional) |colorizer-options| to set.
>
  colorizer.attach_to_buffer(buf[, options={}])
<

 vim:tw=78:ts=8:noet:ft=help:norl: