{"id":50373144,"url":"https://github.com/lancekrogers/nvim-token-counter","last_synced_at":"2026-05-30T08:04:10.764Z","repository":{"id":338891147,"uuid":"1133813125","full_name":"lancekrogers/nvim-token-counter","owner":"lancekrogers","description":"Neovim plugin: real-time LLM token counts in your status line. Supports Claude, GPT, Llama, DeepSeek \u0026 Qwen. Async, non-blocking, powered by tcount.","archived":false,"fork":false,"pushed_at":"2026-02-24T23:20:38.000Z","size":146,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-25T04:33:14.499Z","etag":null,"topics":["ai","claude","developer-tools","llm","lua","lualine","neovim","neovim-plugin","openai","statusline","tcount","tokens"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lancekrogers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-13T21:14:49.000Z","updated_at":"2026-02-24T23:22:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lancekrogers/nvim-token-counter","commit_stats":null,"previous_names":["lancekrogers/nvim-token-counter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lancekrogers/nvim-token-counter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancekrogers%2Fnvim-token-counter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancekrogers%2Fnvim-token-counter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancekrogers%2Fnvim-token-counter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancekrogers%2Fnvim-token-counter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lancekrogers","download_url":"https://codeload.github.com/lancekrogers/nvim-token-counter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancekrogers%2Fnvim-token-counter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33684419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","claude","developer-tools","llm","lua","lualine","neovim","neovim-plugin","openai","statusline","tcount","tokens"],"created_at":"2026-05-30T08:04:09.027Z","updated_at":"2026-05-30T08:04:10.752Z","avatar_url":"https://github.com/lancekrogers.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nvim-token-counter\n\nA Neovim plugin that displays token counts in your status line using [tcount](https://github.com/lancekrogers/tcount), a fast zero-network token counter for LLM workflows.\n\n![nvim-token-counter](docs/images/nvim-token-counter.png)\n\n## Features\n\n- Displays token count in lualine status line\n- Async execution (non-blocking, ~73ms per file)\n- Per-buffer caching (no redundant calls)\n- Updates on save (BufWritePost)\n- Supports multiple tokenizer models (Claude, GPT, Llama, DeepSeek, Qwen)\n- Exact BPE tokenization for OpenAI models, calibrated approximation for Claude\n- Formatted numbers with commas (1,234)\n\n## Requirements\n\n- Neovim \u003e= 0.9.0\n- [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim)\n- [tcount](https://github.com/lancekrogers/tcount) installed and in PATH\n\n## Installing tcount\n\nThe plugin requires the `tcount` binary. Install it using one of these methods:\n\n### Homebrew (macOS \u0026 Linux)\n\n```bash\nbrew install lancekrogers/tap/tcount\n```\n\n### Go Install\n\n```bash\ngo install github.com/lancekrogers/tcount/cmd/tcount@latest\n```\n\n### Pre-built Binaries\n\nDownload from the [releases page](https://github.com/lancekrogers/tcount/releases) for macOS, Linux, and Windows.\n\n### From Source\n\n```bash\ngit clone https://github.com/lancekrogers/tcount.git\ncd tcount\ngo build -o bin/tcount ./cmd/tcount\n# Copy bin/tcount to somewhere in your PATH\n```\n\nVerify the installation:\n\n```bash\ntcount --help\n```\n\n## Installation\n\n### lazy.nvim\n\n```lua\nreturn {\n  \"lancekrogers/nvim-token-counter\",\n  -- Or for local development:\n  -- dir = \"~/path/to/nvim-token-counter\",\n\n  dependencies = { \"nvim-lualine/lualine.nvim\" },\n  event = \"BufReadPost\",\n\n  opts = {\n    model = \"claude-4.5-sonnet\",  -- Tokenizer model\n    icon = \"󰊄\",                   -- Display icon (nerd font)\n    tcount_path = \"tcount\",       -- Path to tcount binary (auto-detected)\n  },\n\n  config = function(_, opts)\n    require(\"nvim-token-counter\").setup(opts)\n\n    -- Add to lualine\n    local lualine = require(\"lualine\")\n    local tc = require(\"nvim-token-counter\")\n    local config = lualine.get_config()\n\n    table.insert(config.sections.lualine_x, 1, {\n      tc.lualine_component(),\n      cond = tc.lualine_cond(),\n    })\n\n    lualine.setup(config)\n  end,\n}\n```\n\n### LazyVim (lualine override method)\n\nIf you prefer to keep the lualine configuration separate:\n\n```lua\n-- lua/plugins/token-counter.lua\nreturn {\n  {\n    \"lancekrogers/nvim-token-counter\",\n    dependencies = { \"nvim-lualine/lualine.nvim\" },\n    event = \"BufReadPost\",\n    opts = {\n      model = \"claude-4.5-sonnet\",\n      icon = \"󰊄\",\n    },\n  },\n  {\n    \"nvim-lualine/lualine.nvim\",\n    opts = function(_, opts)\n      local tc = require(\"nvim-token-counter\")\n      table.insert(opts.sections.lualine_x, 1, {\n        tc.lualine_component(),\n        cond = tc.lualine_cond(),\n      })\n      return opts\n    end,\n  },\n}\n```\n\n## Configuration\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `model` | string | `\"claude-4.5-sonnet\"` | Tokenizer model (see supported models below) |\n| `icon` | string | `\"󰊄\"` | Icon displayed before token count |\n| `tcount_path` | string | `\"tcount\"` | Path to tcount binary (auto-detected if in PATH) |\n| `format` | string | `\"%s %s\"` | Display format (icon, count) |\n| `enabled` | boolean | `true` | Enable/disable the plugin |\n| `filetypes_exclude` | table | `{...}` | Filetypes to skip (neo-tree, help, etc.) |\n\n### Supported Models\n\n**Anthropic:** `claude-4-opus`, `claude-4-sonnet`, `claude-4.5-sonnet`, `claude-3.7-sonnet`, `claude-3.5-sonnet`, `claude-3-opus`, `claude-3-sonnet`, `claude-3-haiku`\n\n**OpenAI:** `gpt-5`, `gpt-5-mini`, `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano`, `gpt-4o`, `gpt-4o-mini`, `o3`, `o3-mini`, `o4-mini`, `gpt-4`, `gpt-4-turbo`, `gpt-3.5-turbo`\n\n**Meta:** `llama-3.1-8b`, `llama-3.1-70b`, `llama-3.1-405b`, `llama-4-scout`, `llama-4-maverick`\n\n**DeepSeek:** `deepseek-v2`, `deepseek-v3`, `deepseek-coder-v2`\n\n**Qwen:** `qwen-2.5-7b`, `qwen-2.5-14b`, `qwen-2.5-72b`, `qwen-3-72b`\n\n**Phi:** `phi-3-mini`, `phi-3-small`, `phi-3-medium`\n\n## Commands\n\n| Command | Description |\n|---------|-------------|\n| `:TokenCounterRecount` | Force recount for current buffer |\n| `:TokenCounterEnable` | Enable the plugin |\n| `:TokenCounterDisable` | Disable the plugin |\n| `:TokenCounterToggle` | Toggle enable/disable |\n| `:TokenCounterShow` | Show detailed count (tokens, chars, words, lines) |\n\n## API\n\n```lua\nlocal tc = require(\"nvim-token-counter\")\n\n-- Setup with options\ntc.setup({ model = \"claude-4.5-sonnet\", icon = \"󰊄\" })\n\n-- Get lualine component and condition functions\ntc.lualine_component()  -- Returns the component function\ntc.lualine_cond()       -- Returns the condition function\n\n-- Manual control\ntc.recount()            -- Force recount current buffer\ntc.enable()             -- Enable plugin\ntc.disable()            -- Disable plugin\ntc.toggle()             -- Toggle enabled state\n\n-- Get raw count data\nlocal count = tc.get_count()\nif count then\n  print(count.tokens)      -- Token count\n  print(count.characters)  -- Character count\n  print(count.words)       -- Word count\n  print(count.lines)       -- Line count\nend\n```\n\n## How It Works\n\n1. On buffer enter (first time) or save, the plugin runs `tcount --json --model \u003cmodel\u003e \u003cfilepath\u003e`\n2. The command executes asynchronously using `vim.fn.jobstart()` (~73ms)\n3. Results are cached per-buffer until the next save\n4. The lualine component reads from cache and displays formatted count\n5. Cache is cleaned up when buffers are deleted\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancekrogers%2Fnvim-token-counter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flancekrogers%2Fnvim-token-counter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancekrogers%2Fnvim-token-counter/lists"}