Skip to content

Commit

Permalink
docs: added docs on formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 6, 2022
1 parent 9cfb611 commit cf26e2b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Check the [wiki](https://github.com/folke/noice.nvim/wiki/Configuration-Recipes)
routes = {}, -- @see the section on routes below
---@type table<string, NoiceFilter>
status = {}, --@see the section on statusline components below
---@type NoiceFormatOptions
format = {}, -- @see section on formatting
}
```

Expand Down Expand Up @@ -215,6 +217,46 @@ String or can also be a table like:

Right now there's only an option to set the `hl_group` used to render the virtual text.

## 🎨 Formatting

Formatting options can be specified with `config.format`.
For a list of the defaults, please refer to [config.format](https://github.com/folke/noice.nvim/blob/main/lua/noice/config/format.lua)

**Noice** includes the following formatters:

- **level**: message level with optional `icon` and `hl_group` per level
- **text**: any text with optional `hl_group`
- **title**: message title with optional `hl_group`
- **event**: message event with optional `hl_group`
- **kind**: message kind with optional `hl_group`
- **date**: formatted date with optional date format string
- **message**: message content itself with optional `hl_group` to override message highlights

Formatters are used in `format` definitions. **Noice** includes the following built-in formats:

```lua
{
-- default format
default = { "{level} ", "{title} ", "{message}" },
-- default format for vim.notify views
notify = { "{message}" },
-- default format for the history
details = {
"{level} ",
"{date} ",
"{event}",
{ "{kind}", before = { ".", hl_group = "Comment" } },
" ",
"{title} ",
"{message}",
},
}
```

Text before/after the formatter or in the before/after options, will only be rendered if the formatter itself rendered something.

The `format` view option, can be either a `string` (one of the built-in formats), or a table with a custom format definition.

## 🚗 Routes

A **route** has a `filter`, `view` and optional `opts` attribute.
Expand Down

0 comments on commit cf26e2b

Please sign in to comment.