SkillAgentSearch skills...

Focus.nvim

Auto-Focusing and Auto-Resizing Splits/Windows for Neovim written in Lua. A full suite of window management enhancements. Vim splits on steroids!

Install / Use

/learn @nvim-focus/Focus.nvim
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

focus.nvim

GitHub stars Requires Neovim 0.9+ GitHub contributors PRs Welcome GitHub issues GitHub issues-closed

Always have a nice view over your split windows

Preview

screencast

Note: For reference this screencast features dimensions set to 40 rows and 120 columns.

See a visual demonstration of each focus feature here.

Features

  • 👌 Resizes split windows automatically based on golden ratio
  • ⚙️ Enables cursorline/signcolumn/numbers on focus window only
  • 🙌 Window creation or switch by direction
  • 🖥 Equalise splits or maximise focused splits, and toggle between the two
  • 🔌 Option to open tmux windows instead of creating new splits

Installation

Here are code snippets for some common installation methods (use only one):

<details> <summary>With <a href="https://github.com/folke/lazy.nvim">folke/lazy.nvim</a></summary> <table> <thead> <tr> <th>Github repo</th> <th>Branch</th> <th>Code snippet</th> </tr> </thead> <tbody> <tr> <td rowspan=2>'focus.nvim' library</td> <td>Main</td> <td><code>{ 'nvim-focus/focus.nvim', version = false },</code></td> </tr> <tr> <td>Stable</td> <td><code>{ 'nvim-focus/focus.nvim', version = '*' },</code></td> </tr> </tbody> </table> </details> <details> <summary>With <a href="https://github.com/wbthomason/packer.nvim">wbthomason/packer.nvim</a></summary> <table> <thead> <tr> <th>Github repo</th> <th>Branch</th> <th>Code snippet</th> </tr> </thead> <tbody> <tr> <td rowspan=2>'focus.nvim' library</td> <td>Main</td> <td><code>use 'nvim-focus/focus.nvim'</code></td> </tr> <tr> <td>Stable</td> <td><code>use { 'nvim-focus/focus.nvim', branch = 'stable' }</code></td> </tr> </tbody> </table> </details> <details> <summary>With <a href="https://github.com/junegunn/vim-plug">junegunn/vim-plug</a></summary> <table> <thead> <tr> <th>Github repo</th> <th>Branch</th> <th>Code snippet</th> </tr> </thead> <tbody> <tr> <td rowspan=2>'focus.nvim' library</td> <td>Main</td> <td><code>Plug 'nvim-focus/focus.nvim'</code></td> </tr> <tr> <td>Stable</td> <td><code>Plug("nvim-focus/focus.nvim", {["tag"]="stable"}) -- stable should be the latest stable version, as of 16th july 2024, it's v1.0.0</code></td> </tr> </tbody> </table> </details> <br>

Configuration

For basic setup with all batteries included:

require("focus").setup()

Configuration can be passed to the setup function. Here is an example with the default settings:

require("focus").setup({
    enable = true, -- Enable module
    commands = true, -- Create Focus commands
    autoresize = {
        enable = true, -- Enable or disable auto-resizing of splits
        width = 0, -- Force width for the focused window
        height = 0, -- Force height for the focused window
        minwidth = 0, -- Force minimum width for the unfocused window
        minheight = 0, -- Force minimum height for the unfocused window
        focusedwindow_minwidth = 0, --Force minimum width for the focused window
        focusedwindow_minheight = 0, --Force minimum height for the focused window
        height_quickfix = 10, -- Set the height of quickfix panel
        equalise_min_cols = 0, -- Use equal splits when columns >= this value (0 = ignore)
        equalise_min_rows = 0, -- Use equal splits when rows >= this value (0 = ignore)
    },
    split = {
        bufnew = false, -- Create blank buffer for new split windows
        tmux = false, -- Create tmux splits instead of neovim splits
    },
    ui = {
        number = false, -- Display line numbers in the focussed window only
        relativenumber = false, -- Display relative line numbers in the focussed window only
        hybridnumber = false, -- Display hybrid line numbers in the focussed window only
        absolutenumber_unfocussed = false, -- Preserve absolute numbers in the unfocussed windows

        cursorline = true, -- Display a cursorline in the focussed window only
        cursorcolumn = false, -- Display cursorcolumn in the focussed window only
        colorcolumn = {
            enable = false, -- Display colorcolumn in the foccused window only
            list = '+1', -- Set the comma-saperated list for the colorcolumn
        },
        signcolumn = true, -- Display signcolumn in the focussed window only
        winhighlight = false, -- Auto highlighting for focussed/unfocussed windows
    }
})

Note To manage window views when resizing, see :h splitkeep.<br> For users of Neovim >= 0.10, it is recommended to use splitkeep=cursor.<br> For users of lazyvim, they set opt.winminwidth = 5 in default options may cause conflict with session manage plugins.

Setup options

Enable/Disable Focus

-- Completely disable this plugin
-- Default: true
require("focus").setup({enable = false})

Enable/Disable Focus Commands

-- This not export :Focus* commands
-- Default: true
require("focus").setup({commands = false})

Enable/Disable Focus Window Autoresizing

--The focussed window will no longer automatically resize. Other focus features are still available
-- Default: true
require("focus").setup({ autoresize = { enable = false } })

Set Focus Width

-- Force width for the focused window
-- Default: Calculated based on golden ratio
require("focus").setup({ autoresize = { width = 120 } })

Set Focus Minimum Width

-- Force minimum width for the unfocused window
-- Default: Calculated based on golden ratio
require("focus").setup({ autoresize = { minwidth = 80} })

Set Focus Minimum Width for Focused Window

-- Force minimum width for the focused window
-- Default: Calculated based on golden ratio
require("focus").setup({ autoresize = { focusedwindow_minwidth = 80} })

Set Focus Height

-- Force height for the focused window
-- Default: Calculated based on golden ratio
require("focus").setup({ autoresize = { height = 40 } })

Set Focus Minimum Height

-- Force minimum height for the unfocused window
-- Default: 0
require("focus").setup({ autoresize = { minheight = 10} })

Set Focus Minimum Height for Focused Window

-- Force minimum height for the focused window
-- Default: Calculated based on golden ratio
require("focus").setup({ autoresize = { focusedwindow_minheight = 80} })

Set Focus Quickfix Height

-- Sets the height of quickfix panel, in case you pass the height to
-- `:copen <height>`
-- Default: 10
require("focus").setup({ autoresize = { height_quickfix = 10 })

Set Minimum Terminal Size for Equal Splits

-- Use equal-size splits when terminal has sufficient columns and/or rows
-- When thresholds are met: all splits are equal size (via wincmd =)
-- When thresholds are not met: use golden ratio autoresize (focused window larger)
-- Useful for large terminals where equal splits are preferred
-- Default: 0 (always use golden ratio autoresize)

-- Equal splits on wide terminals (120+ columns)
require("focus").setup({ autoresize = { equalise_min_cols = 120 })

-- Equal splits on tall terminals (40+ rows)
require("focus").setup({ autoresize = { equalise_min_rows = 40 })

-- Equal splits only when BOTH wide AND tall (120+ columns AND 40+ rows)
require("focus").setup({ autoresize = { equalise_min_cols = 120, equalise_min_rows = 40 })

When creating a new split window, do/don't initialise it as an empty buffer

-- True: When a :Focus.. command creates a new split window, initialise it as a new blank buffer
-- False: When a :Focus.. command creates a new split, retain a copy of the current window in the new window
-- Default: false
require("focus").setup({ split = { bufnew = true } })

Set Focus Auto Numbers

-- Displays line numbers in the focussed window only
-- Not displayed in unfocussed windows
-- Default: true
require("focus").setup({ui = { number = false } })

Set Focus Auto Relative Numbers

-- Displays relative line numbers in the focussed window only
-- Not displayed in unfocussed windows
-- See :help relativenumber
-- Default: false
require("focus").setup({ ui = { relativenumber = true } })

Set Focus Auto Hybrid Numbers

-- Displays hybrid line numbers in the focussed window only
-- Not displayed in unfocussed windows
-- Combination of :help relativenumber, but also displays the line number of the
-- current line only
-- Default: false
require("focus").setup({ ui = { hybridnumber = true} })

Set Preserve Absolute Numbers

-- Preserve absolute numbers in the unfocussed windows
-- Works in combination with relativenumber or hybridnumber
-- Default: false
require("focus").setup({ ui = { absolutenumber_unfocussed = true } })

**When creating a new split window, use tmux s

Related Skills

View on GitHub
GitHub Stars809
CategoryDevelopment
Updated7d ago
Forks38

Languages

Lua

Security Score

100/100

Audited on Mar 29, 2026

No findings