GithubHelp home page GithubHelp logo

hsi / numberly.nvim Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

Line numbers at will per filetype. ๐Ÿช„

License: Apache License 2.0

Lua 100.00%
filetype line-numbering neovim number nvim relativenumber line-number line-numbers

numberly.nvim's Introduction

โŒจ 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

numberly.nvim's People

Contributors

hsi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.