mluders/comfy-line-numbers.nvim

github github
utility
stars 21
issues 3
subscribers 1
forks 0
CREATED

2024-06-21

UPDATED

4 days ago


Comfy Line Numbers

A Neovim plugin that makes vertical motions more comfortable.

comfy_demo

The problem

I love using relative line numbers for vertical movement. But I've noticed a problem...

  • 6j
  • 19k
  • 18j

What do these motions have in common? The right-hand fingers are overloaded, having to jump between numbers and letters.

It's too much movement.

The solution

Represent line numbers using left-hand digits:

1
2
3
4
5
11
12
13
14
15
21
22
...
55

This lets your left hand focus on digits, while your right hand focuses on j and k.

Less movement. More comfort.

How it works

  1. Relative line numbers are displayed in status column (with right-hand digits omitted).

  2. Vertical motions are re-mapped to their original meanings:

    • 11j becomes 6j
    • 34k becomes 19k
    • 33j becomes 18j
    • etc.

Installation

Using your plugin manager of choice (lazy.nvim in the example below):

return {
  'mluders/comfy-line-numbers.nvim'
}

Make sure line numbers are enabled:

vim.opt.number = true

Customization

require('comfy-line-numbers').setup({
  labels = {
    '1', '2', '3', '4', '5', '11', '12', '13', '14', '15',
    '21', '22', '23', '24', '25', '31', '32', '33', '34', '35',
    '41', '42', '43', '44', '45', '51', '52', '53', '54', '55',
  }
  up_key = 'j'
  down_key = 'k'
  enable_in_terminal = false
})

Limitations

  • When enable_in_terminal is false, an empty status column is still visible in the terminal (see a67c19e for more details).

Testing

The specs use plenary.nvim tests.

To run the spec in the current buffer:

:PlenaryBustedFile %

To run all of the specs:

:PlenaryBustedDirectory tests

Note: The tests run in a remote nvim instance and display output in a new window in terminal mode. You may need to C-\ C-n to switch back to NORMAL mode and close the window.

Optionally, you can run the tests from the command line. Here is an ex command that opens a new terminal in a split window and runs all the tests:

:split term://nvim --headless -c 'PlenaryBustedDirectory tests'