Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kaplanz/retrail.nvim

Whitespace management for Neovim
https://github.com/kaplanz/retrail.nvim

neovim neovim-plugin whitespace

Last synced: 3 months ago
JSON representation

Whitespace management for Neovim

Awesome Lists containing this project

README

        

# retrail.nvim

Retrail is a small Neovim plugin for managing trailing whitespace. It has two
main features:
1. Highlight trailing whitespace.
1. Trim trailing whitespace upon `:write`.

## Installation

Install this plugin using your favorite plugin manager. For example, using
[lazy]:

```lua
{
"kaplanz/retrail.nvim",
opts = {}, -- calls `setup` using provided `opts`
},
```

To manually set up the plugin, call the `setup` function:

```lua
require("retrail").setup()
```

## Configuration

While the [defaults] should work for most users out of the box, the following
options can be configured as such:

```lua
require("retrail").setup {
-- Highlight group to use for trailing whitespace.
hlgroup = "Search",
-- Pattern to match trailing whitespace against. Edit with caution!
pattern = "\\v((.*%#)@!|%#)\\s+$",
-- Enabled filetypes.
filetype = {
-- Strictly enable only on `include`ed filetypes. When false, only disabled
-- on an `exclude`ed filetype.
strict = false,
-- Included filetype list.
include = {},
-- Excluded filetype list. Overrides `include` list.
exclude = {
"",
"aerial",
"alpha",
"checkhealth",
"cmp_menu",
"diff",
"lazy",
"lspinfo",
"man",
"mason",
"TelescopePrompt",
"toggleterm",
"Trouble",
"WhichKey",
},
},
-- Enabled buftypes.
buftype = {
-- Strictly enable only on `include`ed buftypes. When false, only disabled
-- on an `exclude`ed buftype.
strict = false,
-- Included buftype list.
include = {},
-- Excluded buftype list. Overrides `include` list.
exclude = {
"help",
"nofile",
"prompt",
"quickfix",
"terminal",
}
},
-- Trim on write behaviour.
trim = {
-- Auto trim on BufWritePre
auto = true,
-- Trailing whitespace as highlighted.
whitespace = true,
-- Final blank (i.e. whitespace only) lines.
blanklines = false,
}
}
```

## Commands
1. `:RetrailTrimWhitespace` Trim trailing whitespace
2. `:RetrailEnable` Enable trim trailing for the current buffer
3. `:RetrailDisable` Disable trim trailing for the current buffer
4. `:RetrailToggle` Toggle trim trailing for the current buffer

[defaults]: ./lua/retrail/config/defaults.lua
[lazy]: https://github.com/folke/lazy.nvim