Skip to content

ruinivist/loc.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loc.nvim

Entirely GPT 5.5 generated

A tiny Neovim plugin that tracks characters added and deleted while you are in insert mode.

It keeps daily totals:

  • added: characters inserted
  • deleted: characters removed
  • net: added - deleted

The statusline text shows today's net, for example:

LOC +123

Install

With lazy.nvim:

{
  "your-name/loc.nvim",
  config = function()
    require("loc").setup()
  end,
}

Statusline

loc.nvim does not overwrite your statusline. Add the exposed function wherever you want it.

Built-in statusline:

vim.o.statusline = vim.o.statusline .. " %{v:lua.require'loc'.statusline()}"

With lualine.nvim:

require("lualine").setup({
  sections = {
    lualine_x = {
      function()
        return require("loc").statusline()
      end,
    },
  },
})

Commands

The plugin defines these commands when it is on your runtimepath:

  • :LocEnable starts tracking.
  • :LocDisable stops tracking.
  • :LocReset clears today's counters.
  • :LocStats prints today's counters.

Calling require("loc").setup() enables tracking by default. Use this if you want to configure the plugin but start it manually:

require("loc").setup({ auto_enable = false })

Configuration

Defaults:

require("loc").setup({
  auto_enable = true,
  persist = true,
  data_path = nil,
  save_delay_ms = 1000,
  statusline_prefix = "LOC",
})

When data_path is nil, stats are stored at:

stdpath("data")/loc.nvim/stats.json

Stats are stored by local date:

{
  "2026-04-30": {
    "added": 123,
    "deleted": 45
  }
}

With persist = false, daily counters stay in memory only for the current Neovim process.

API

require("loc").enable()
require("loc").disable()
require("loc").reset()
require("loc").save()
require("loc").statusline()
require("loc").stats()

stats() returns today's counters:

{
  added = 123,
  deleted = 45,
  net = 78,
}

Test

From the repository root:

nvim --headless -u NONE -i NONE -l test/loc_spec.lua

About

lines of code tracker based on insert mode character changes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages