Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions lua/CopilotChat/ui/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,22 @@ function Chat:render()
end
end

-- Keywords
if current_message and current_message.role == 'user' then
-- FIXME: This is not optimal, but i cant figure out how to do it better as treesitter keeps overriding it
local patterns = {
'()#?#[^ ]+()',
'()@[^ ]+()',
'()%$[^ ]+()',
'()/[^ ]+()',
}
for _, pattern in ipairs(patterns) do
for s, e in line:gmatch(pattern) do
vim.api.nvim_buf_add_highlight(self.bufnr, highlight_ns, 'CopilotChatKeyword', l - 1, s - 1, e - 1)
end
end
end

-- If last line, finish last message
if l == #lines and current_message then
current_message.section.end_line = l
Expand All @@ -695,20 +711,6 @@ function Chat:render()
end
end
end

-- Highlight keywords
-- FIXME: This is not optimal, but i cant figure out how to do it better as treesitter keeps overriding it
local patterns = {
'()#?#[^ ]+()',
'()@[^ ]+()',
'()%$[^ ]+()',
'()/[^ ]+()',
}
for _, pattern in ipairs(patterns) do
for s, e in line:gmatch(pattern) do
vim.api.nvim_buf_add_highlight(self.bufnr, highlight_ns, 'CopilotChatKeyword', l - 1, s - 1, e - 1)
end
end
end

-- Replace self.messages with new_messages (preserving tool_calls, etc.)
Expand Down
Loading