Skip to content

Commit cde4c8b

Browse files
committed
feat: improve sessions panel with date grouping and visible icons
- Group sessions by date (Today, Yesterday, This Week, This Month, Older) - Add date group headers with separator lines - Replace Nerd Font icons with Unicode symbols (●, ○, ▸) - Add ChatGPTSessionHeader and ChatGPTSessionCursor highlight groups - Skip header lines when selecting/renaming/deleting sessions - Maintain existing navigation and keymap behavior
1 parent 017158e commit cde4c8b

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

lua/chatgpt/context/project.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ function M.generate_summary()
140140
local content = read_file(root .. "/Cargo.toml")
141141
if content then
142142
-- Simple pattern matching for common crates
143-
if content:match('%[dependencies%][^%[]*tokio') then
143+
if content:match("%[dependencies%][^%[]*tokio") then
144144
table.insert(details, "Tokio")
145145
end
146-
if content:match('%[dependencies%][^%[]*actix') then
146+
if content:match("%[dependencies%][^%[]*actix") then
147147
table.insert(details, "Actix")
148148
end
149149
end

lua/chatgpt/flows/chat/base.lua

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,17 @@ function Chat:highlight_message_content(lines, start_line)
540540
local header_text = {}
541541
if code_lang then
542542
table.insert(header_text, { " LANGUAGE: " .. string.upper(code_lang) .. " ", "ChatGPTCodeLang" })
543-
table.insert(header_text, { " ────────────────── ", "ChatGPTCodeBlockHeader" })
543+
table.insert(
544+
header_text,
545+
{ " ────────────────── ", "ChatGPTCodeBlockHeader" }
546+
)
544547
table.insert(header_text, { "[y] copy", "Comment" })
545548
else
546549
table.insert(header_text, { " CODE ", "ChatGPTCodeLang" })
547-
table.insert(header_text, { " ────────────────── ", "ChatGPTCodeBlockHeader" })
550+
table.insert(
551+
header_text,
552+
{ " ────────────────── ", "ChatGPTCodeBlockHeader" }
553+
)
548554
table.insert(header_text, { "[y] copy", "Comment" })
549555
end
550556
vim.api.nvim_buf_set_extmark(bufnr, Config.namespace_id, line_num, 0, {
@@ -614,7 +620,9 @@ function Chat:highlight_message_content(lines, start_line)
614620
local col = 1
615621
while true do
616622
local s, e = line:find("`[^`]+`", col)
617-
if not s then break end
623+
if not s then
624+
break
625+
end
618626
vim.api.nvim_buf_add_highlight(bufnr, Config.namespace_id, "ChatGPTInlineCode", line_num, s - 1, e)
619627
col = e + 1
620628
end
@@ -623,7 +631,9 @@ function Chat:highlight_message_content(lines, start_line)
623631
col = 1
624632
while true do
625633
local s, e = line:find("%*%*[^%*]+%*%*", col)
626-
if not s then break end
634+
if not s then
635+
break
636+
end
627637
vim.api.nvim_buf_add_highlight(bufnr, Config.namespace_id, "ChatGPTBold", line_num, s - 1, e)
628638
col = e + 1
629639
end
@@ -632,7 +642,9 @@ function Chat:highlight_message_content(lines, start_line)
632642
col = 1
633643
while true do
634644
local s, e = line:find("%*[^%*]+%*", col)
635-
if not s then break end
645+
if not s then
646+
break
647+
end
636648
-- Skip if it's actually bold (**)
637649
if line:sub(s, s + 1) ~= "**" and (s == 1 or line:sub(s - 1, s - 1) ~= "*") then
638650
vim.api.nvim_buf_add_highlight(bufnr, Config.namespace_id, "ChatGPTItalic", line_num, s - 1, e)
@@ -644,7 +656,9 @@ function Chat:highlight_message_content(lines, start_line)
644656
col = 1
645657
while true do
646658
local s, e = line:find("https?://[^%s%)%]]+", col)
647-
if not s then break end
659+
if not s then
660+
break
661+
end
648662
vim.api.nvim_buf_add_highlight(bufnr, Config.namespace_id, "ChatGPTLink", line_num, s - 1, e)
649663
col = e + 1
650664
end
@@ -663,7 +677,9 @@ function Chat:highlight_message_content(lines, start_line)
663677
col = 1
664678
while true do
665679
local s, e = line:find("~~[^~]+~~", col)
666-
if not s then break end
680+
if not s then
681+
break
682+
end
667683
vim.api.nvim_buf_add_highlight(bufnr, Config.namespace_id, "ChatGPTStrikethrough", line_num, s - 1, e)
668684
col = e + 1
669685
end
@@ -672,7 +688,9 @@ function Chat:highlight_message_content(lines, start_line)
672688
col = 1
673689
while true do
674690
local s, e = line:find("%[[^%]]+%]%([^%)]+%)", col)
675-
if not s then break end
691+
if not s then
692+
break
693+
end
676694
-- Find the split between text and url
677695
local text_end = line:find("%]%(", s)
678696
if text_end then

lua/chatgpt/flows/chat/sessions.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ M.render_list = function()
155155
local is_current = (M.line_to_session[line_num] == M.line_to_session[M.current_line])
156156

157157
local cursor = is_current and Config.options.chat.sessions_window.current_line_sign or " "
158-
local icon = is_active and Config.options.chat.sessions_window.active_sign or Config.options.chat.sessions_window.inactive_sign
158+
local icon = is_active and Config.options.chat.sessions_window.active_sign
159+
or Config.options.chat.sessions_window.inactive_sign
159160
local cls = is_active and Config.options.highlights.active_session or "Comment"
160161
local name = Utils.trimText(session.name, 28)
161162

0 commit comments

Comments
 (0)