https://github.com/lukoshkin/highlight-whitespace
Highlight unwanted whitespace and more in Vim/Neovim
https://github.com/lukoshkin/highlight-whitespace
neovim-lua-plugin trailing-spaces vim-markdown whitespace
Last synced: about 1 year ago
JSON representation
Highlight unwanted whitespace and more in Vim/Neovim
- Host: GitHub
- URL: https://github.com/lukoshkin/highlight-whitespace
- Owner: lukoshkin
- License: mit
- Created: 2022-07-18T19:59:19.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-01T18:25:30.000Z (over 1 year ago)
- Last Synced: 2025-03-25T06:23:04.648Z (about 1 year ago)
- Topics: neovim-lua-plugin, trailing-spaces, vim-markdown, whitespace
- Language: Lua
- Homepage:
- Size: 15.1 MB
- Stars: 12
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Highlight Whitespace
Highlight unwanted whitespace across you project files. The fun part is that
you can come up with your own palette of colors used for a specific pattern
per a filetype!
---
Почитать на [русском :ru:](/README.ru.md)

Go to the [Current Colorscheme](#current-colorscheme) section
to see what each color stands for.
(Unfortunately placing it here breaks syntax
highlighting for all multi-line code blocks below it)
## Installation
With [**lazy.nvim**](https://github.com/folke/lazy.nvim)
```lua
{
"lukoshkin/highlight-whitespace",
config=true,
}
```
With [**packer.nvim**](https://github.com/wbthomason/packer.nvim)
```lua
use "lukoshkin/highlight-whitespace"
```
## Customization
`tws` keyword - "main" pattern for trailing whitespace highlighting
`clear_on_bufleave` - boolean opt to clear highlighting in the current buffer
before switching to another
lazy.nvim
```lua
{
"lukoshkin/highlight-whitespace",
opts = {
tws = "\\s\\+$",
clear_on_bufleave = false,
palette = {
markdown = {
tws = 'RosyBrown',
['\\S\\@<=\\s\\(\\.\\|,\\)\\@='] = 'CadetBlue3',
['\\S\\@<= \\{2,\\}\\S\\@='] = 'SkyBlue1',
['\\t\\+'] = 'plum4',
},
other = {
tws = 'PaleVioletRed',
['\\S\\@<=\\s,\\@='] = 'coral1',
['\\S\\@<=\\(#\\|--\\)\\@
packer.nvim
```lua
use {
'lukoshkin/highlight-whitespace',
config = function ()
require'highlight-whitespace'.setup {
tws = '\\s\\+$',
clear_on_bufleave = false,
palette = {
markdown = {
tws = 'RosyBrown',
['\\S\\@<=\\s\\(\\.\\|,\\)\\@='] = 'CadetBlue3',
['\\S\\@<= \\{2,\\}\\S\\@='] = 'SkyBlue1',
['\\t\\+'] = 'plum4',
},
other = {
tws = 'PaleVioletRed',
['\\S\\@<=\\s,\\@='] = 'coral1',
['\\S\\@<=\\(#\\|--\\)\\@
### Ignoring filetypes
Ignoring specific filetypes is possible by setting an empty table next to a
filetype in the `palette`.
To highlight only python and markdown filetypes
```lua
palette = {
python = {
-- some patterns
},
markdown = {
-- some patterns
},
other = {},
}
```
To ignore highlighting only in javascript
```lua
palette = {
javascript = {},
other = {
-- some patterns
},
}
```
## Current Colorscheme
This section refers to the GIF at the README beginning
---
$$
{\color{PaleVioletRed}red}\text{ color
─ trailing whitespace in Python (other than md)}
$$
$$
{\color{#3B3B3B}dark\ gray}\text{
─ leading and trailing whitespace in comment sections}
$$
$${\color{RosyBrown}brown}\text{ ─ in markdown}$$
---
$$
{\color{#CDBE70}yellow}\text{ color
─ redundant (multiple) spaces in Python}
$$
$${\color{#87CEFF}blue}\text{ ─ in markdown}$$
---
$${\color{#FF7256}orange}\text{ color ─ a space before a comma in Python}$$
$${\color{#7AC5CD}"green"}\text{ ─ in markdown}$$
---
$${\color{#8B668B}purple}\text{ color ─ tab indents instead of spaces}$$