Skip to content

Buffer Local Config

Ahmet Zeybek edited this page Sep 27, 2026 · 3 revisions

Buffer-Local Configuration

You can override global settings for specific buffers using Neovim buffer variables (vim.b). This is the highest-priority configuration layer.

Supported Variables

Variable Type Description
vim.b.camouflage_enabled boolean Enable/disable masking for this buffer
vim.b.camouflage_style string Masking style: 'stars', 'dotted', 'text', 'scramble'
vim.b.camouflage_mask_char string Mask character for the stars style (dotted always uses •)
vim.b.camouflage_mask_length number Fixed mask length (overrides actual value length)
vim.b.camouflage_highlight_group string Highlight group for masked text
vim.b.camouflage_terminal boolean Set to false to skip a single terminal buffer, see Terminal Masking

Examples

Disable for a specific buffer

vim.b.camouflage_enabled = false

Use a different style

vim.b.camouflage_style = 'scramble'

Custom mask character

vim.b.camouflage_mask_char = '#'

Fixed mask length

vim.b.camouflage_mask_length = 8

Different highlight group

vim.b.camouflage_highlight_group = 'NonText'

Using with Autocommands

The most common use case is setting buffer-local overrides via autocommands for specific file patterns or directories:

Production files hide the length too

vim.api.nvim_create_autocmd('BufEnter', {
  pattern = '*/production/.env*',
  callback = function()
    vim.b.camouflage_style = 'text'
  end,
})

text draws the same fixed text over every value, so not even the length shows. Don't use scramble for this: it shuffles the real characters and leaks the length and character set.

Disable masking for example files

vim.api.nvim_create_autocmd('BufEnter', {
  pattern = { '*.example', '*.sample', '*.template' },
  callback = function()
    vim.b.camouflage_enabled = false
  end,
})

Longer masks for staging configs

vim.api.nvim_create_autocmd('BufEnter', {
  pattern = '*/staging/*',
  callback = function()
    vim.b.camouflage_mask_length = 16
    vim.b.camouflage_mask_char = 'X'
  end,
})

Important Notes

  • Set buffer variables before entering the buffer, or call :CamouflageRefresh after setting them
  • Use the exact variable names: vim.b.camouflage_enabled (not vim.b.camouflage.enabled)
  • Buffer-local settings override all other configuration layers (defaults, setup, project config)
  • Presentation Mode masks a buffer even when vim.b.camouflage_enabled = false, and puts the variable back when it ends

Configuration Precedence

1. Defaults (lowest priority)
2. setup() options
3. Project config (.camouflage.yaml)
4. Buffer-local overrides (highest priority, this page)

See Also

Clone this wiki locally