FFFF
Skip to content

Repository files navigation

tiny-cloak.nvim

tiny-cloak logo

License Stars Issues

A lightweight Neovim plugin that masks sensitive data (API keys, secrets, tokens) in .env, JSON, and YAML files. Prevents accidental exposure of credentials during screen sharing, demos, or pair programming.

Demo

✨ Features

  • 🔒 Automatically cloak sensitive values in .env, .json, .yaml, and .yml files
  • 🎯 Masks common patterns: API_KEY, SECRET, PASSWORD, TOKEN, CREDENTIAL, AUTH
  • ⚡ Zero configuration required for common use cases
  • 🪶 Minimal footprint with no external dependencies
  • 👁️ Toggle commands to temporarily reveal values

⚡️ Requirements

  • Neovim >= 0.11.0

📦 Installation

{
  "jellydn/tiny-cloak.nvim",
  event = { "BufReadPre", "BufNewFile" },
  opts = {},
}
use {
  "jellydn/tiny-cloak.nvim",
  config = function()
    require("tiny-cloak").setup()
  end,
}

🚀 Usage

The plugin works automatically once installed. Open any .env, .json, .yaml, or .yml file and sensitive values will be masked:

# Before                          # After (displayed)
API_KEY=sk-example                API_KEY=***************
SECRET_TOKEN=example-secret       SECRET_TOKEN=************

⌨️ Commands

Command Description
:CloakToggle Toggle cloaking on/off globally
:CloakEnable Enable cloaking (no-op if already enabled)
:CloakDisable Disable cloaking (no-op if already disabled)
:CloakPreviewToggle Toggle preview on current line

Recommended Keymaps

-- Toggle cloaking globally
vim.keymap.set("n", "<leader>ct", "<cmd>CloakToggle<cr>", { desc = "Toggle cloak" })

-- Preview current line (toggle reveal/cloak)
vim.keymap.set("n", "<leader>cp", "<cmd>CloakPreviewToggle<cr>", { desc = "Preview line" })

👁️ Preview Feature

The plugin automatically reveals cloaked values when you enter insert mode for seamless editing:

  • Auto-reveal on Insert: Enter insert mode on a cloaked line → value is revealed
  • Auto-recloak on Exit: Press Escape → value is automatically re-cloaked
  • Manual Toggle: :CloakPreviewToggle to reveal/hide in normal mode without editing

Example Workflow

  1. Navigate to a line with cloaked content
  2. Press i to enter insert mode → value auto-reveals
  3. Edit the value
  4. Press Escape → value auto-recloaks

⚙️ Configuration

require("tiny-cloak").setup({
  -- Masking character
  cloak_character = "*", -- default

  -- File patterns to cloak
  file_patterns = { ".env*", "*.json", "*.yaml", "*.yml" }, -- default

  -- Key patterns to match for cloaking
  key_patterns = { "API_KEY", "SECRET", "PASSWORD", "TOKEN", "CREDENTIAL", "AUTH" }, -- default
})

🔧 How It Works

Uses Neovim's extmarks API to overlay text without modifying buffer content. Your files remain unchanged—only the visual display is masked.

👤 Author

Huynh Duc Dung

Show Your Support

If this plugin has been helpful, please give it a ⭐️.

Ko-fi PayPal Buy Me A Coffee

Star History

Star History Chart

📝 License

MIT

About

A lightweight Neovim plugin that masks sensitive data (API keys, secrets, tokens) in .env, JSON, and YAML files

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0