TinyUnit
December 5, 2024 ยท View on GitHub
TinyUnit is a minimalist unit converter for Neovim, designed to seamlessly convert between different CSS units directly within your editor. Perfect for frontend developers who want to quickly convert measurements without leaving their editor.
https://github.com/user-attachments/assets/451ed70b-f771-447a-8186-d2cba03b32ee
๐ Features
- ๐ช Convert units in a clean floating window
- ๐ Support for common CSS units (px, rem, em, vh, vw, mm, cm, in, pt)
- ๐ฏ Visual selection support for direct conversion
- โก Fast and lightweight
- ๐จ Adapts to your Neovim colorscheme
- ๐ ๏ธ Compatible with Lazy.nvim for effortless installation
๐ฆ Installation
Prerequisites
- Neovim >= 0.8.0
- Lazy.nvim as your plugin manager
Using Lazy.nvim
return {
"atiladefreitas/tinyunit",
config = function()
require("tinyunit").setup({
-- your custom config here (optional)
})
end,
}
Default Configuration
TinyUnit comes with sensible defaults that you can override:
{
window = {
width = 30, -- Width of the floating window
height = 15, -- Height of the floating window
border = "rounded", -- Border style
input_title = "Enter Value",
},
keymap = {
open = "tc", -- Toggle converter window
close = "q", -- Close window
convert = "", -- Convert value
escape = "", -- Close window
},
units = {
"px",
"rem",
"em",
"vh",
"vw",
"mm",
"cm",
"in",
"pt",
},
font = {
base_size = 16, -- Base font size in pixels (default: 16)
},
}
๐ Usage
Basic Usage
- Press
<leader>tcto open the converter window - Enter a value with unit (e.g., "16px")
- Press
<CR>to see all possible conversions - Select a converted value and press
<CR>to replace the original value
Visual Selection
- Select a value in your code (e.g., "16px")
- Press
<leader>tc - The converter will automatically convert the selected value
- Choose a conversion and press
<CR>to replace the selected text
๐ Supported Conversions
TinyUnit supports conversions between the following units:
- px (pixels)
- rem (root em)
- em (relative to parent font size)
- vh (viewport height)
- vw (viewport width)
- mm (millimeters)
- cm (centimeters)
- in (inches)
- pt (points)
๐ฅ Roadmap
- Custom conversion formulas
- More unit types (deg, rad, etc.)
- Configuration for base font size
- Support for calc() expressions
- Unit conversion history
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Contributing
Contributions are welcome! Feel free to:
- Submit issues for bugs or feature requests
- Create pull requests with improvements
- Share feedback and suggestions
๐ Acknowledgments
Special thanks to:
- The Neovim community
- Lazy.nvim
- All contributors and users
All my plugins
| Repository | Description | Stars |
|---|---|---|
| LazyClip | A Simple Clipboard Manager | |
| Dooing | A Minimalist Todo List Manager | |
| TinyUnit | A Practical CSS Unit Converter |