Skip to content

hsi/numberly.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⌨ numberly.nvim

Set the desired line numbering quickly, even if it differs by filetype.

✨ Features

  • Fast switching among line numbering combinations at will via a hotkey.
  • Freely combine absolute/relative line numbering options in ordered sets.
  • Ability to use different line numbering sets per filetype.
  • Each window respects others' line numbering order for the same buffer too.
  • Can define a default line numbering set for unknown filetypes.

⚑ Requirements

  • Neovim 0.7.0

πŸ’Ύ Installation

Using lazy.nvim

-- ~/.config/nvim/lua/plugins/numberly.lua
return {
    'hsi/numberly.nvim',
    tag = 'stable',
}

or

-- ~/.config/nvim/init.lua
{
    'hsi/numberly.nvim',
    tag = 'stable',
}
use {
    'hsi/numberly.nvim',
    tag = 'stable',
}

Using dein.vim

call dein#add('hsi/numberly.nvim', { 'rev': 'stable' })

Using vim-plug

Plug 'hsi/numberly.nvim', { 'tag': 'stable' }

πŸš€ Usage

Per filetype (optional)

The following code makes numberly to use both relative and absolute line numberings in Python files after opening them, since n.BOTH is the first item in the passed table. Hitting the mapped hotkey (F6 in the example below) disables any line numbering via the n.NONE setting. Pressing the hotkey again jumps to n.BOTH setting, then n.NONE, and so forth.

-- ~/.config/nvim/after/ftplugin/python.lua
local numberly = require('numberly')
local n = numberly.Numberings

numberly.setup({
    n.BOTH,
    n.NONE,
})

Default (optional)

It's possible to set a default order of line numberings for unknown filetypes as well. Here when Neovim opens a file without any filetype, the n.NONE setting is activated first. By hitting the hotkey, it'll set relative line numbering only, then absolute line numbering only, and on the third hotkey hit it jumps back to the n.NONE setting, where we started.

-- ~/.config/nvim/init.lua
local numberly = require('numberly')
local n = numberly.Numberings

numberly.setup({
    n.NONE,
    n.RELATIVE,
    n.ABSOLUTE,
})

Key mappings

-- ~/.config/nvim/init.lua
vim.keymap.set('n', '<F6>', require('numberly').next)
vim.keymap.set('n', '<M-F6>', require('numberly').prev)

βš– License

Apache-2.0