Skip to content

tuffgniuz/simplezen.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simplezen

GitHub code size in bytes GitHub commit activity

Summary

simplezen.nvim is a lightweight Neovim plugin for distraction-free editing. It centers the current buffer, hides UI chrome, and creates seamless side margins for a minimal writing or coding layout. It restores the original UI state when Zen Mode is toggled off, even when multiple tabs are using Zen Mode at the same time.

Features:

  • Content Centering: Creates dynamic side margins around the active buffer.
  • Distraction-Free UI: Hides laststatus, showmode, ruler, and showtabline.
  • Configurable Layout: Lets you control content width and window-local editing options.
  • State Restoration: Restores original global and window-local settings on exit.
  • Tab-Aware Behavior: Supports Zen Mode in multiple tabs at once.
  • Safe Window Cleanup: Closing the centered window tears down the Zen layout for that tab.
  • Auto-Resizing: Recomputes margin widths when Neovim is resized.

Demo

simplezen in action

Installation

lazy.nvim

return {
    "tuffgniuz/simplezen.nvim",
    config = function()
      require("simplezen").setup({
        text_width = 100, -- Optional: Customize your preferred text width
        number = true, -- Optional: Keep absolute line numbers visible in Zen Mode
        signcolumn = "yes", -- Optional: Preserve sign column space in Zen Mode
      })
    end,
    keys = {
      { "<leader>zz", "<cmd>lua require('simplezen').toggle()<CR>", desc = "Toggle Zen Mode" },
    },
}

Usage

Once installed, you can toggle Zen Mode on and off using require("simplezen").toggle(). setup() is optional; if you do not call it, the plugin uses sane defaults. If you've set up the keybinding as shown in the installation example, simply press <leader>zz (or your chosen keybind).

Zen Mode supports multiple tabs at once. Global UI settings stay hidden until the last Zen tab exits, and closing the centered Zen window automatically cleans up the layout for that tab.

  • <leader>zz: Toggle Zen Mode.

Configuration

Configure simplezen.nvim with require("simplezen").setup({...}). Available options:

  • text_width (number, default: 110): Maximum width of the centered content area.
  • laststatus (number, default: 0): Value applied to laststatus while Zen Mode is active.
  • showmode (boolean, default: false): Value applied to showmode while Zen Mode is active.
  • ruler (boolean, default: false): Value applied to ruler while Zen Mode is active.
  • showtabline (number, default: 0): Value applied to showtabline while Zen Mode is active.
  • number (boolean, default: false): Whether to show absolute line numbers in the focused Zen window.
  • relativenumber (boolean, default: false): Whether to show relative line numbers in the focused Zen window.
  • signcolumn (string, default: "no"): Value applied to signcolumn in the focused Zen window.
  • wrap (boolean, default: true): Whether long lines wrap in the focused Zen window.
  • linebreak (boolean, default: true): Whether wrapping happens at convenient breakpoints in the focused Zen window.

Default Configuration:

require("simplezen").setup({
  text_width = 110,
  laststatus = 0,
  showmode = false,
  ruler = false,
  showtabline = 0,
  number = false,
  relativenumber = false,
  signcolumn = "no",
  wrap = true,
  linebreak = true,
})

Example Configuration:

require("simplezen").setup({
  text_width = 90, -- Set content width to 90 characters
  number = true, -- Keep absolute line numbers visible in Zen Mode
  signcolumn = "yes", -- Preserve space for signs and diagnostics
})

About

Distraction free writing / coding in neovim

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages