Skip to content
sand4rtPublic

About

Centers the main buffer to reduce neck strain and improve focus

Topics

Resources

Stars

20 stars

Watchers

0 watching

Forks

Repository files navigation

🧘🏼‍♂️ zen.nvim

zen mode by https://github.com/alex35mil/dotfiles

Capabilities

  • Simple plugin that centers the main buffer.
  • Compatible with side buffer plugins (like neo-tree.nvim).
  • Automatically toggles side buffers whenever a side buffer is opened/closed without flickering.
  • Responsive during resizing.
  • Supports tabs, horizontal and vertical splits.
  • Layout and positioning options.
  • Removes the need for a visual guide showing the maximum line width (ColorColumn).
  • Reduces neck strain and improves focus.

Usage

Using Lazy.nvim
return {
  "sand4rt/zen.nvim",
  lazy = false,
  opts = {
    main = {
      width = 148, -- or vim.wo.colorcolumn

      -- Or compute a responsive width with any local command. Hyprland example:
      -- width = function()
      --   local command = "hyprctl monitors -j" -- use a platform-specific command on macOS or Windows
      --   local monitors = vim.json.decode(vim.fn.system(command))
      --   for _, monitor in ipairs(monitors) do
      --     if monitor.width == 3840 then return 198 end
      --     if monitor.width == 2880 then return 148 end
      --   end
      -- end,
    },

    -- TIP: find a buffer's filetype with :lua print(vim.bo.filetype)
    top = {
      { filetype = "gitcommit", replace = false },
      { filetype = "fugitive" },
      { filetype = "man" },
      { filetype = "help" },
    },
    right = {
      { filetype = "*", min_width = 46 },
      { filetype = "copilot-chat", min_width = 60 },
      { filetype = "neotest-summary" },
      { filetype = { "dapui_watches", "dapui_scopes", "dapui_stacks", "dapui_breakpoints" } },
    },
    bottom = {
      { filetype = "dap-repl" },
      { filetype = "qf" },
      { filetype = "trouble" },
      { filetype = "noice" }, -- noice opens large notifications in a buffer
    },
    left = {
      { filetype = "*", min_width = 46 },
      { filetype = "fugitiveblame" },
      { filetype = "fyler_finder" },
      { filetype = "neotree" },
      { filetype = "dbui" },
      { filetype = { "undotree", "diff" } },
    },
  },
}
Using Nix NVF
vim.ui.zen-nvim.enable = true;
vim.ui.zen-nvim.setupOpts = {
  main.width = 148;

  # Or compute a responsive width with any local command. Hyprland example:
  # main.width = lib.mkLuaInline ''
  #   function()
  #     local command = "hyprctl monitors -j" -- use a platform-specific command on macOS or Windows
  #     local monitors = vim.json.decode(vim.fn.system(command))
  #     for _, monitor in ipairs(monitors) do
  #       if monitor.width == 3840 then return 198 end
  #       if monitor.width == 2880 then return 148 end
  #     end
  #   end
  # '';

  # TIP: find a buffer's filetype with :lua print(vim.bo.filetype)
  top = [
    { filetype = "gitcommit"; replace = false; }
    { filetype = "fugitive"; }
    { filetype = "man"; }
    { filetype = "help"; }
  ];
  right = [
    { filetype = "*"; min_width = 46; }
    { filetype = "copilot-chat"; min_width = 60; }
    { filetype = "neotest-summary"; }
    { filetype = [ "dapui_watches" "dapui_scopes" "dapui_stacks" "dapui_breakpoints" ]; }
  ];
  bottom = [
    { filetype = "dap-repl"; }
    { filetype = "qf"; }
    { filetype = "trouble"; }
    { filetype = "noice"; }
  ];
  left = [
    { filetype = "*"; min_width = 46; }
    { filetype = "fugitiveblame"; }
    { filetype = "neotree"; }
    { filetype = [ "undotree" "diff" ]; }
  ];
};

Nix users not using NVF can install the plugin with pkgs.vimPlugins.zen-nvim.

Credits to other plugins for inspiration

About

Centers the main buffer to reduce neck strain and improve focus

Topics

Resources

Stars

20 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages