Skip to content

atiladefreitas/tinyunit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TinyUnit

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.

demo.mp4

🚀 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

  1. Press <leader>tc to open the converter window
  2. Enter a value with unit (e.g., "16px")
  3. Press <CR> to see all possible conversions
  4. Select a converted value and press <CR> to replace the original value

Visual Selection

  1. Select a value in your code (e.g., "16px")
  2. Press <leader>tc
  3. The converter will automatically convert the selected value
  4. 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 Stars
Dooing A Minimalist Todo List Manager Stars
TinyUnit A Practical CSS Unit Converter Stars

About

A minimalist CSS unit converter for Neovim

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •