Skip to content

Commit

Permalink
Docs/Add lazy.nvim example (norcalli#99)
Browse files Browse the repository at this point in the history
* chore: adds scripts/start_minimal.sh script

* ref: updates luadoc to accept nil for setup opts

* doc: updates readme to add lazy.nvim setup example
  • Loading branch information
catgoose authored Nov 19, 2024
1 parent 4b7fba6 commit 5d32edf
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

- [colorizer.lua](#colorizerlua)
- [Installation and Usage](#installation-and-usage)
- [Use with commands](#use-with-commands)
- [Use from lua](#use-from-lua)
- [Plugin managers](#plugin-managers)
- [Lazy.nvim](#lazynvim)
- [Packer](#packer)
- [Manual](#manual)
- [User commands](#user-commands)
- [Lua API](#lua-api)
- [Why another highlighter?](#why-another-highlighter)
- [Customization](#customization)
- [Updating color even when buffer is not focused](#updating-color-even-when-buffer-is-not-focused)
Expand All @@ -20,6 +24,9 @@
A high-performance color highlighter for Neovim which has **no external
dependencies**! Written in performant Luajit.

As long as you have `malloc()` and `free()` on your system, this will work.
Which includes Linux, OSX, and Windows.

![Demo.gif](https://raw.githubusercontent.com/norcalli/github-assets/master/nvim-colorizer.lua-demo-short.gif)

## Installation and Usage
Expand All @@ -30,12 +37,26 @@ unsure, [read this excellent guide](https://github.com/termstandard/colors).

Use your plugin manager or clone directly into your package.

### Plugin managers

#### Lazy.nvim

```lua
{
"NvChad/nvim-colorizer.lua",
event = "BufReadPre",
opts = { -- setup opts
},
}
```

#### Packer

```lua
use("NvChad/nvim-colorizer.lua")
```

As long as you have `malloc()` and `free()` on your system, this will work.
Which includes Linux, OSX, and Windows.
#### Manual

One line setup. This will create an `autocmd` for `FileType *` to highlight
every filetype.
Expand All @@ -46,7 +67,7 @@ every filetype.
require("colorizer").setup()
```

### Use with commands
### User commands

| Command | Description |
| ----------------------------- | ----------------------------------------------------------- |
Expand All @@ -55,7 +76,7 @@ require("colorizer").setup()
| **ColorizerReloadAllBuffers** | Reload all buffers that are being highlighted currently |
| **ColorizerToggle** | Toggle highlighting of the current buffer |

### Use from lua
### Lua API

```lua
-- All options that can be passed to `user_default_options` in setup() can be
Expand Down Expand Up @@ -282,6 +303,12 @@ Run `minimal.lua` to startup neovim:
nvim --clean -u minimal.lua expect.txt
```

Also there is a script that you can run from the root of the repo:

```bash
scripts/start_minimal.sh
```

## Extras

Documentaion is generated using ldoc. See
Expand All @@ -292,6 +319,8 @@ Documentaion is generated using ldoc. See
- [ ] Add more color types ( var, advanced css functions )
- [ ] Add more display modes. E.g - sign column
- [ ] Use a more space efficient trie implementation.
- [ ] Support custom parsers
- [ ] Allow custom color names

## Similar projects

Expand Down
2 changes: 1 addition & 1 deletion doc/colorizer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ setup({opts}) *colorizer.setup*


Parameters: ~
{opts} - table: User provided options
{opts} - table|nil: User provided options

See also:~
|colorizer.config|
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/colorizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ <h3>Parameters:</h3>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">opts</span>
table: User provided options
table|nil: User provided options
</li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion lua/colorizer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ end
-- }
--</pre>
---Setup colorizer with user options
---@param opts table: User provided options
---@param opts table|nil: User provided options
---@usage `require("colorizer").setup()`
---@see colorizer.config
function M.setup(opts)
Expand Down
4 changes: 4 additions & 0 deletions scripts/start_minimal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

cd test || exit
nvim --clean -u minimal.lua expect.txt

0 comments on commit 5d32edf

Please sign in to comment.