Skip to content

Commit 40a84b4

Browse files
grok-nvim v0.1.0
grok-nvim v0.1.0 release
2 parents 89d6611 + 5f7deee commit 40a84b4

File tree

9 files changed

+334
-232
lines changed

9 files changed

+334
-232
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ return {
3535
{
3636
"acris-software/grok-nvim",
3737
dependencies = { "nvim-lua/plenary.nvim" },
38-
branch = "dev",
38+
branch = "master",
3939
config = function()
4040
require("grok").setup({
4141
model = "grok-3-mini",
@@ -52,7 +52,7 @@ return {
5252
## Usage
5353

5454
Chat: **`:Grok`** "Explain my Hyprland config" or <leader>gg to open a floating chat window.
55-
Code Analysis: In visual mode, select code and press <leader>gg to get explanations orಯ
55+
Code Analysis: In visual mode, select code and press <leader>gg to get explanations.
5656
Customize: Adjust model, temperature, or max_tokens in the setup function.
5757

5858
Requirements

issue_tracker.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Issue Tracker
2+
## Issue 1: Chat Persistence Doesn’t Work When Tabbing Out of Tab 1 (Grok)
3+
- **Problem:** The conversation history is reset or not maintained when switching away from the Grok tab (tab 1) to Keymaps or Config tabs and back.
4+
- **Analysis:** The history table is currently local to the async.run scope in chat.lua, which may cause it to reset or lose scope when the UI re-renders or tabs switch. To fix, move history to a module-level scope in chat.lua to persist across tab switches within a session.
5+
- **Solution:** Move the history table to the top of chat.lua and ensure it’s only cleared by :GrokClear. Update tab-switching logic to preserve the chat buffer’s content.
6+
- **Version:** Critical bug for multi-turn chat persistence, a core v0.1.0 feature.
7+
8+
*Changes:*
9+
- Move history to module scope in chat.lua.
10+
- Update ui/render.lua to restore chat history content when returning to tab 1.
11+
12+
## Issue 2: Navigation Bar Should Remain Fixed Regardless of Tab
13+
- **Problem:** The navigation bar may not stay fixed or visible consistently across all tabs.
14+
- **Analysis:** The render_tab_header function in ui/render.lua is called correctly, but the buffer’s content clearing in render_tab_content might affect the header’s persistence. Ensure the header is always rendered at the top and not overwritten, regardless of tab.
15+
- **Solution:** Modify render_tab_content to preserve the header line and ensure it’s always visible.
16+
- **Version:** UI polish issue for v0.1.1.
17+
18+
*Changes:*
19+
- Update ui/render.lua to avoid clearing the header line when rendering tab content.
20+
21+
## Issue 3: Grok’s Responses Should Be Read-Only
22+
- **Problem:** In the Grok tab, user can edit Grok’s responses, which is incorrect. Assistant responses should be read-only, while user input areas remain editable.
23+
- **Analysis:** The chat tab is kept modifiable (vim.api.nvim_buf_set_option(buf, "modifiable", true)) in ui/render.lua to allow user input, but this allows editing of all content, including Grok’s responses. We need to make assistant responses read-only while keeping the input area modifiable.
24+
- **Solution:** Use buffer extmarks to mark assistant response lines as read-only, and update ui/render.lua to enforce this. Allow only the last line to be modifiable.
25+
- **Version:** Critical UI bug affecting usability and data integrity for v0.1.0’s UI requirements.
26+
27+
*Changes:*
28+
29+
- Modify ui/render.lua to apply extmarks to assistant response lines.
30+
- Update ui/keymaps.lua to prevent editing on protected lines.
31+
32+
## Issue 4: Chat box needs to pop up in the center; possibly make the location configurable
33+
- **Problem:** In the Grok tab, user chat box input pops up in a weird space and cutting off everything the user has typed. We need to clean this up.
34+
- **Analysis:** The Grok tab works and allows user to make prompts, read the history, and not write-over Grok rresponses. UI/UX needs to be improved as the prompt box is bare minimal. User should be able to see everything they type and be able to scroll up/down after the prompt box has hit it's max height/width. Determine prompt character count based off Grok and what it currently will allow for the versoin the user is using.
35+
- **Solution:** Update UI to include configurable location, allowing user to change in real-time and have the update applied in real-time via the config tab.
36+
- **Version:** UI polish affecting usability for v0.1.1’s UI requirements.
37+
38+
*Changes:*
39+
40+
- Add config location for prompt box (3 settings, left, center, right)
41+
- Clean up UI/UX and ensure user prompt scales with the users typing.
42+
43+

lua/grok/chat.lua

Lines changed: 0 additions & 172 deletions
This file was deleted.

lua/grok/chat/history.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- ~/github.com/acris-software/grok-nvim/lua/grok/chat/history.lua
2+
3+
local M = {}
4+
5+
M.history = {}
6+
7+
function M.add(role, content)
8+
table.insert(M.history, { role = role, content = content })
9+
end
10+
11+
function M.get()
12+
return M.history
13+
end
14+
15+
function M.clear()
16+
M.history = {}
17+
end
18+
19+
return M

lua/grok/chat/init.lua

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
-- ~/github.com/acris-software/grok-nvim/lua/grok/chat/init.lua
2+
3+
local M = {}
4+
local async = require("plenary.async")
5+
local ui = require("grok.ui")
6+
local log = require("grok.log")
7+
local request = require("grok.chat.request")
8+
9+
function M.chat(prompt)
10+
local config = require("grok").config
11+
if not config.api_key then
12+
vim.notify("GROK_KEY not set!", vim.log.levels.ERROR)
13+
log.error("API key not set")
14+
return
15+
end
16+
async.run(function()
17+
ui.open_chat_window(function(input)
18+
local ok, err = pcall(function()
19+
vim.api.nvim_buf_set_option(ui.current_buf, "modifiable", true)
20+
vim.api.nvim_buf_set_lines(ui.current_buf, -1, -1, false, { "", "You: " .. input, "" })
21+
vim.api.nvim_buf_set_option(ui.current_buf, "modifiable", false)
22+
end)
23+
if not ok then
24+
log.error("Failed to append user input: " .. vim.inspect(err))
25+
end
26+
request.send_request(input)
27+
end)
28+
if prompt and prompt ~= "" then
29+
vim.schedule(function()
30+
local ok, err = pcall(function()
31+
vim.api.nvim_buf_set_option(ui.current_buf, "modifiable", true)
32+
vim.api.nvim_buf_set_lines(ui.current_buf, -1, -1, false, { "", "You: " .. prompt, "" })
33+
vim.api.nvim_buf_set_option(ui.current_buf, "modifiable", false)
34+
end)
35+
if not ok then
36+
log.error("Failed to append initial prompt: " .. vim.inspect(err))
37+
end
38+
request.send_request(prompt)
39+
end)
40+
end
41+
end)
42+
end
43+
44+
function M.clear_history()
45+
require("grok.chat.history").clear()
46+
log.info("Conversation history cleared")
47+
end
48+
49+
return M

0 commit comments

Comments
 (0)