Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tenxsoydev/tabs-vs-spaces.nvim
Hint and fix deviating indentation.
https://github.com/tenxsoydev/tabs-vs-spaces.nvim
formatting highlight indentation lint lua neovim nvim spaces tabs
Last synced: 9 days ago
JSON representation
Hint and fix deviating indentation.
- Host: GitHub
- URL: https://github.com/tenxsoydev/tabs-vs-spaces.nvim
- Owner: tenxsoydev
- License: mit
- Created: 2023-03-20T13:33:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-30T17:54:23.000Z (5 months ago)
- Last Synced: 2024-07-31T20:51:45.728Z (3 months ago)
- Topics: formatting, highlight, indentation, lint, lua, neovim, nvim, spaces, tabs
- Language: Lua
- Homepage:
- Size: 14.6 KB
- Stars: 20
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - tenxsoydev/tabs-vs-spaces.nvim - Hint and fix deviating indentation. (Formatting / Comment)
README
# ðĪš tabs-vs-spaces.nvim
Hint and fix deviating indentation.
https://user-images.githubusercontent.com/34311583/226349494-edd8da2a-f533-404a-956c-93e0318674d7.mov
Ideally, leading and trailing spaces are taken care of by a project-specific formatter. Nevertheless, commits and codebases with indentation styles that deviate from a project defaults continue to exist.
There are several reasons why indentation styles might get mixed up.
- A project-specific linter/formatter is either not installed or not available in its required configuration.
- Quick editing single files outside a project's working directory.
- Wrong indentation might not be obvious, with or without space characters toggled on.
- The editor is not configured to or did not automatically detect a file's indentation style.
- Reusing code templates from previous projects or copying code from external sources.
- Interference with local formatter settings.For all these and similar occasions, this tool shall serve as a guide.
## Installation
E.g., using a plugin manager like [packer.nvim][10]
```lua
use "tenxsoydev/tabs-vs-spaces.nvim"-- ..
-- Then load it in a preferred location.
require("tabs-vs-spaces").setup()
```When using [lazy.nvim][20] it suffices to add this line to your `lazy.setup()` to use the plugin with it's default config.
```lua
{ "tenxsoydev/tabs-vs-spaces.nvim", config = true },
```## âïļ Config
```lua
require("tabs-vs-spaces").setup {
-- Preferred indentation. Possible values: "auto"|"tabs"|"spaces".
-- "auto" detects the dominant indentation style in a buffer and highlights deviations.
indentation = "auto",
-- Use a string like "DiagnosticUnderlineError" to link the `TabsVsSpace` highlight to another highlight.
-- Or a table valid for `nvim_set_hl` - e.g. { fg = "MediumSlateBlue", undercurl = true }.
highlight = "DiagnosticUnderlineHint",
-- Priority of highight matches.
priority = 20,
ignore = {
filetypes = {},
-- Works for normal buffers by default.
buftypes = {
"acwrite",
"help",
"nofile",
"nowrite",
"quickfix",
"terminal",
"prompt",
},
},
standartize_on_save = false,
-- Enable or disable user commands see Readme.md/#Commands for more info.
user_commands = true,
}
```##  âšÂ Commands
- `:TabsVsSpacesToggle` optional args `on` | `buf_on` | `off` | `buff_off`
- `:TabsVsSpacesStandardize` works for current buffer or selected range `:'<,'>TabsVsSpacesStandardize`
- `:TabsVsSpacesConvert` args `spaces_to_tabs` | `tabs_to_spaces` for current buffer or range.Command args work with completion.
## ðĪ Complementary Tools
- [mini.trailspace][30]
- [guess-indent][40][10]: https://github.com/wbthomason/packer.nvim
[20]: https://github.com/folke/lazy.nvim
[30]: https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-trailspace.md
[40]: https://github.com/nmac427/guess-indent.nvim