Skip to content

Commit

Permalink
Breaking changes, and add g:ai_indicator_style.
Browse files Browse the repository at this point in the history
Breaking changes:
- Rename g:ai_sign_text to g:ai_indicator_text.
- Rename AISign hlgroup to AIIndicator.
  • Loading branch information
aduros committed Dec 16, 2022
1 parent d7f2571 commit 3700049
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
22 changes: 16 additions & 6 deletions doc/ai.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,26 @@ CUSTOMIZING

Example: `let g:ai_context_after=50`

*g:ai_sign_text* (default: "🤖")
*g:ai_indicator_style* (default: "sign")

The gutter sign text used to indicate a request in-progress. If your
terminal can't display emojis, you'll probably want to set this.
Controls where the progress indicator is displayed. Allowed values:

Example: `let g:ai_sign_text="A"`
- `sign`: Display indicator in the sign column.
- `virtual_text`: Display indicator as virtual text.
- `none`: Don't display any indicator.

*AISign* is the |:highlight| group to color the gutter sign text.
Example: `let g:ai_indicator_style="virtual_text"`

Example: `:highlight AISign ctermbg=red`
*g:ai_indicator_text* (default: "🤖")

The text used to indicate a request in-progress. If your terminal can't
display emojis, you'll probably want to set this.

Example: `let g:ai_indicator_text="A"`

*AIIndicator* is the |:highlight| group to color the indicator text.

Example: `:highlight AIIndicator ctermbg=red`

*AIHighlight* is the |:highlight| group to color the text being processed.

Expand Down
20 changes: 15 additions & 5 deletions lua/_ai/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,24 @@ function M.ai (args)
local end_line_length = vim.api.nvim_buf_get_lines(buffer, end_row, end_row+1, true)[1]:len()
end_col = math.min(end_col, end_line_length)

local mark_id = vim.api.nvim_buf_set_extmark(buffer, ns_id, start_row, start_col, {
local indicator_style = get_var("ai_indicator_style", "sign")
local indicator_text = get_var("ai_indicator_text", "🤖")
local extmark_opts = {
end_row = end_row,
end_col = end_col,
hl_group = "AIHighlight",
sign_text = get_var("ai_sign_text", "🤖"),
sign_hl_group = "AISign",
-- virt_text = {{"🤖", nil}},
})
}
if indicator_style == "sign" then
extmark_opts.sign_text = indicator_text
extmark_opts.sign_hl_group = "AIIndicator"
elseif indicator_style == "virtual_text" then
extmark_opts.virt_text = {{ indicator_text, "AIIndicator" }}
elseif indicator_style ~= "none" then
vim.api.nvim_err_writeln("ai.vim: Unsupported value for g:ai_indicator_style")
return
end

local mark_id = vim.api.nvim_buf_set_extmark(buffer, ns_id, start_row, start_col, extmark_opts)

local completions_model = get_var("ai_completions_model", "text-davinci-003")
local edits_model = get_var("ai_edits_model", "text-davinci-edit-001")
Expand Down

0 comments on commit 3700049

Please sign in to comment.