### Added
- **Smart Scope Resolution** — Tree-sitter + indentation context for
selections
- `resolve_selection_context()` in `scope/init.lua` handles partial
functions,
whole functions, multi-function spans, indent blocks, and whole-file
selections
- Enclosing function automatically sent as context when selecting code
inside one
- Whole-file selection (>=80% of lines) triggers project tree as
context
- Indentation-based fallback when Tree-sitter is unavailable
- **Explain-to-Document Intent** — "explain" prompts generate
documentation
- Detects prompts like "explain this", "tell me about", "what does",
"question"
- Generates documentation comments and inserts them above selected
code
- Shows notification if nothing is selected
- Updated intent action from "none" to "insert" for explain intent
- **Granular LLM Status Notifications** — Real-time progress reporting
- Inline virtual text and floating status window show current stage
- Stages: "Reading context...", "Searching index...", "Gathering
context...",
"Recalling patterns...", "Building prompt...", "Sending to
[provider]...",
"Processing response...", "Generating patch...", "Applying code..."
- `update_inline_status()` in `thinking_placeholder.lua`
- `update_stage()` in `thinking.lua`
- **Thinking Placeholder Positioning** — "Implementing..." appears above
selection
- Uses `virt_lines_above = true` on extmark at selection start line
- Dynamic status text updates during LLM processing
### Changed
- **Providers reduced to Copilot and Ollama only**
- Removed Claude, OpenAI, and Gemini provider integrations
- Deleted `llm/openai.lua` and `llm/gemini.lua`
- Cleaned `llm/init.lua`, `config/defaults.lua`, `types.lua`,
`credentials.lua`,
`cost/init.lua`, and `events/queue.lua` of all references
- `valid_providers` now only includes "copilot" and "ollama"
- **Removed timer-based delayed processing** — Prompts are processed
instantly
- Removed `timer` field, `timeout_ms`, and timer setup/cancellation
from `worker.lua`
- **Removed chat/agent/split window UI**
- Deleted `ui/chat.lua`, `windows.lua`, `ui/switcher.lua`
- Removed `CoderOpen`, `CoderClose`, `CoderToggle` commands
- Removed window management from `autocmds.lua`, `inject.lua`,
`executor.lua`
- Removed auto-open companion file logic
- **Commands removed from menu** (code retained with TODOs for
re-enabling)
- `CoderAddApiKey`, `CoderRemoveApiKey`, `CoderBrain`,
`CoderFeedback`,
`CoderMemories`, `CoderForget`, `CoderProcess`
- Subcommands `process`, `status`, `memories`, `forget`,
`llm-feedback-good`,
`llm-feedback-bad`, `add-api-key`, `remove-api-key` removed from
completion
### Fixed
- Fixed `patch.lua` syntax error — missing `if` wrapper around
SEARCH/REPLACE block
- Fixed `CoderModel` require path typo
(`codetyper.adapters.config.credentials`
→ `codetyper.config.credentials`)
- Fixed `thinking_placeholder` extmark placement appearing after
selection
instead of above it
104 lines
2.5 KiB
Lua
104 lines
2.5 KiB
Lua
-- Codetyper.nvim - AI-powered coding partner for Neovim
|
|
-- Plugin loader
|
|
|
|
local g = vim.g
|
|
local fn = vim.fn
|
|
local api = vim.api
|
|
local cmd = vim.cmd
|
|
|
|
-- Prevent loading twice
|
|
if g.loaded_codetyper then
|
|
return
|
|
end
|
|
g.loaded_codetyper = true
|
|
|
|
-- Minimum Neovim version check
|
|
if fn.has("nvim-0.8.0") == 0 then
|
|
api.nvim_err_writeln("Codetyper.nvim requires Neovim 0.8.0 or higher")
|
|
return
|
|
end
|
|
|
|
--- Initialize codetyper plugin fully
|
|
--- Creates .codetyper 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 .codetyper 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()
|
|
init_coder_files()
|
|
end, 100)
|
|
end,
|
|
desc = "Initialize Codetyper .codetyper folder on startup",
|
|
})
|
|
|
|
-- Also initialize on directory change
|
|
api.nvim_create_autocmd("DirChanged", {
|
|
callback = function()
|
|
vim.defer_fn(function()
|
|
init_coder_files()
|
|
end, 100)
|
|
end,
|
|
desc = "Initialize Codetyper .codetyper folder on directory change",
|
|
})
|
|
|
|
-- Auto-initialize when opening a coder file (for nvim-tree, telescope, etc.)
|
|
api.nvim_create_autocmd({ "BufRead", "BufNewFile", "BufEnter" }, {
|
|
pattern = "*.codetyper/*",
|
|
callback = function()
|
|
-- Initialize plugin if not already done
|
|
local codetyper = require("codetyper")
|
|
if not codetyper.is_initialized() then
|
|
codetyper.setup()
|
|
end
|
|
end,
|
|
desc = "Auto-initialize Codetyper when opening coder files",
|
|
})
|
|
|
|
-- Lazy-load the plugin on first command usage
|
|
api.nvim_create_user_command("Coder", function(opts)
|
|
require("codetyper").setup()
|
|
cmd("Coder " .. (opts.args or ""))
|
|
end, {
|
|
nargs = "?",
|
|
complete = function()
|
|
return {
|
|
"tree",
|
|
"tree-view",
|
|
"reset",
|
|
"gitignore",
|
|
}
|
|
end,
|
|
desc = "Codetyper.nvim commands",
|
|
})
|
|
|
|
-- Lazy-load aliases
|
|
api.nvim_create_user_command("CoderTree", function()
|
|
require("codetyper").setup()
|
|
cmd("CoderTree")
|
|
end, { desc = "Refresh tree.log" })
|
|
|
|
api.nvim_create_user_command("CoderTreeView", function()
|
|
require("codetyper").setup()
|
|
cmd("CoderTreeView")
|
|
end, { desc = "View tree.log" })
|
|
|
|
|