Skip to content

A Neovim plugin that makes vertical motions more comfortable

License

Notifications You must be signed in to change notification settings

mluders/comfy-line-numbers.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'
}

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', '111', '112', '113', '114', '115', '121',
    '122', '123', '124', '125', '131', '132', '133', '134', '135', '141',
    '142', '143', '144', '145', '151', '152', '153', '154', '155', '211',
    '212', '213', '214', '215', '221', '222', '223', '224', '225', '231',
    '232', '233', '234', '235', '241', '242', '243', '244', '245', '251',
    '252', '253', '254', '255',
  },
  up_key = 'j'
  down_key = 'k'

  -- Line numbers will be completely hidden for the following file/buffer types
  hidden_file_types = { 'undotree' },
  hidden_buffer_types = { 'terminal' }
})

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'

About

A Neovim plugin that makes vertical motions more comfortable

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages