docs: statusline integration recipes in vimdoc #263

Closed
opened 2026-02-27 00:21:29 +00:00 by barrettruth · 0 comments
barrettruth commented 2026-02-27 00:21:29 +00:00

Problem

cp.nvim has rich state (platform, contest_id, problem_id, language) but no documented path for surfacing it in statusline plugins like lualine, heirline, or feline. Users who want to display "CF/1234/A [cpp]" in their statusline have no documented approach and must discover require('cp.state') themselves.

Proposed solution

Add a Recipes or Integrations section to the vimdoc covering statusline usage, e.g.:

-- lualine
require('lualine').setup({
  sections = {
    lualine_x = {
      {
        function()
          local state = require('cp.state')
          local platform = state.get_platform()
          if not platform then return '' end
          return table.concat({
            platform,
            state.get_contest_id() or '?',
            state.get_problem_id() or '?',
            '[' .. (state.get_language() or '?') .. ']',
          }, ' ')
        end,
        cond = function() return require('cp.state').get_platform() ~= nil end,
      },
    },
  },
})

This requires zero new Lua code — only documentation. require('cp.state') is already the stable internal module and is unlikely to move. A dedicated public API module would add unnecessary surface area.

Alternatives considered

Adding a require('cp').statusline public module. Rejected as unnecessary complexity — documenting the existing require('cp.state') API is sufficient and avoids maintaining a separate abstraction.

## Problem cp.nvim has rich state (`platform`, `contest_id`, `problem_id`, `language`) but no documented path for surfacing it in statusline plugins like lualine, heirline, or feline. Users who want to display "CF/1234/A [cpp]" in their statusline have no documented approach and must discover `require('cp.state')` themselves. ## Proposed solution Add a **Recipes** or **Integrations** section to the vimdoc covering statusline usage, e.g.: ```lua -- lualine require('lualine').setup({ sections = { lualine_x = { { function() local state = require('cp.state') local platform = state.get_platform() if not platform then return '' end return table.concat({ platform, state.get_contest_id() or '?', state.get_problem_id() or '?', '[' .. (state.get_language() or '?') .. ']', }, ' ') end, cond = function() return require('cp.state').get_platform() ~= nil end, }, }, }, }) ``` This requires zero new Lua code — only documentation. `require('cp.state')` is already the stable internal module and is unlikely to move. A dedicated public API module would add unnecessary surface area. ## Alternatives considered Adding a `require('cp').statusline` public module. Rejected as unnecessary complexity — documenting the existing `require('cp.state')` API is sufficient and avoids maintaining a separate abstraction.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
barrettruth/cp.nvim#263
No description provided.