in lua/llm/completion.lua [70:98]
function M.lsp_suggest()
M.request_id = llm_ls.get_completions(function(err, result, context, _conf)
if err ~= nil then
vim.notify("[LLM] " .. err.message, vim.log.levels.ERROR)
return
end
local completions = result.completions
local generated_text = llm_ls.extract_generation(completions)
local lines = utils.split_str(generated_text, "\n")
if lines == nil then
return
end
M.suggestion = lines
local col = context.params.position.character
local line = context.params.position.line
local extmark = {
virt_text_win_col = col,
virt_text = { { lines[1], M.hl_group } },
}
if #lines > 1 then
extmark.virt_lines = {}
for i = 2, #lines do
extmark.virt_lines[i - 1] = { { lines[i], M.hl_group } }
end
end
api.nvim_buf_set_extmark(0, M.ns_id, line, col, extmark)
M.shown_suggestion = result
end)
end