fix: improve code prompts to output only raw code

Add explicit instruction to all code generation prompts to return
only raw code without explanations, markdown, or code fences.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-11 19:48:17 -05:00
parent 9d52b9364f
commit 29f321995d
8 changed files with 172 additions and 19 deletions

View File

@@ -18,17 +18,32 @@ if fn.has("nvim-0.8.0") == 0 then
return
end
--- Initialize codetyper plugin fully
--- Creates .coder folder, settings.json, tree.log, .gitignore
--- Also registers autocmds for /@ @/ prompt detection
---@return boolean success
local function init_coder_files()
local ok, err = pcall(function()
-- Full plugin initialization (includes config, commands, autocmds, tree, gitignore)
local codetyper = require("codetyper")
if not codetyper.is_initialized() then
codetyper.setup()
end
end)
if not ok then
vim.notify("[Codetyper] Failed to initialize: " .. tostring(err), vim.log.levels.ERROR)
return false
end
return true
end
-- Initialize .coder folder and tree.log on project open
api.nvim_create_autocmd("VimEnter", {
callback = function()
-- Delay slightly to ensure cwd is set
vim.defer_fn(function()
local tree = require("codetyper.tree")
tree.setup()
-- Also ensure gitignore is updated
local gitignore = require("codetyper.gitignore")
gitignore.ensure_ignored()
init_coder_files()
end, 100)
end,
desc = "Initialize Codetyper .coder folder on startup",
@@ -38,11 +53,7 @@ api.nvim_create_autocmd("VimEnter", {
api.nvim_create_autocmd("DirChanged", {
callback = function()
vim.defer_fn(function()
local tree = require("codetyper.tree")
tree.setup()
local gitignore = require("codetyper.gitignore")
gitignore.ensure_ignored()
init_coder_files()
end, 100)
end,
desc = "Initialize Codetyper .coder folder on directory change",