irongit

My nvim configuration

feat: history limit in claude plugin

huncholanehuncholaneauthored
parent 7076faecommit 6c0bb61213de92070659519fa7d1df0e03ff888fBrowse files

4 files changed, +33 -2

+5-0claude-nvim/lua/claude/init.lua
@@ -7,6 +7,7 @@ local edit = require("claude.edit")
77 local timetravel = require("claude.timetravel")
88 local commit = require("claude.commit")
99 local find = require("claude.find")
10+local store = require("claude.store")
1011
1112 ---@class ClaudeConfig
1213 local defaults = {
@@ -16,12 +17,16 @@ local defaults = {
1617 skip_permissions = false,
1718 --- Write raw stream events + cmd + exit codes to <data>/claude-nvim/debug.log
1819 debug = false,
20+ --- Max number of history entries surfaced by the prompts/sessions pickers.
21+ --- nil or 0 means unlimited (default: nil).
22+ history_limit = nil,
1923 }
2024
2125 --- Setup the Claude CLI wrapper plugin.
2226 ---@param opts? ClaudeConfig
2327 function M.setup(opts)
2428 opts = vim.tbl_deep_extend("force", defaults, opts or {})
29+ store.setup(opts)
2530 ui.setup(opts)
2631 runner.setup(opts)
2732 edit.setup(opts)
+1-1claude-nvim/lua/claude/pickers.lua
@@ -176,7 +176,7 @@ local function list_sessions()
176176 end
177177 end
178178 table.sort(out, function(a, b) return a.mtime > b.mtime end)
179- return out
179+ return store.apply_history_limit(out)
180180 end
181181
182182 function M.sessions_picker()
+26-1claude-nvim/lua/claude/store.lua
@@ -1,5 +1,30 @@
11 local M = {}
22
3+--- Runtime config (populated by M.setup from the plugin's options).
4+M.config = {
5+ --- Max number of history entries to surface; nil/0 = unlimited.
6+ history_limit = nil,
7+}
8+
9+function M.setup(opts)
10+ M.config.history_limit = opts and opts.history_limit or nil
11+end
12+
13+--- Truncate a newest-first list to the configured history limit.
14+---@param list table
15+---@return table
16+function M.apply_history_limit(list)
17+ local limit = M.config.history_limit
18+ if not limit or limit <= 0 or #list <= limit then
19+ return list
20+ end
21+ local out = {}
22+ for i = 1, limit do
23+ out[i] = list[i]
24+ end
25+ return out
26+end
27+
328 local function data_dir()
429 local d = vim.fn.stdpath("data") .. "/claude-nvim"
530 vim.fn.mkdir(d, "p")
@@ -90,7 +115,7 @@ function M.all_prompts(cwd)
90115 end
91116 end
92117 table.sort(out, function(a, b) return (a.ts or 0) > (b.ts or 0) end)
93- return out
118+ return M.apply_history_limit(out)
94119 end
95120
96121 function M.uuid()
+1-0lua/plugins/claude.lua
@@ -5,6 +5,7 @@ return {
55 event = "VeryLazy",
66 config = function()
77 require("claude").setup({
8+ history_limit = 20,
89 width = 100,
910 skip_permissions = true
1011 })