Files
tools/ved/WORKPLAN.md
T
2026-04-08 16:37:32 +02:00

2.5 KiB

Vi-style Editor with Ollama Code Prediction

Overview

Terminal-based code editor written in C with nvi-style modal editing and local LLM-powered code completion via Ollama. For Linux CLI. Target users: personal + colleagues.

Editor Scope (nvi-style)

Modal Editing

  • Normal, Insert, Command-line (:) modes

Navigation

  • h/j/k/l — basic movement
  • w/b/e — word movement
  • 0/$ — line start/end
  • ^f/^b — page up/down
  • G/gg — file start/end
  • f/t/F/T — find char on line, with counts

Operators + Motions

  • d, y, c combined with any motion (e.g. c3td, d$, y2w)
  • Single unnamed buffer for yank/delete
  • p/P — paste after/before

Other

  • . — repeat last command
  • u — undo
  • :w, :q, :wq, :e — file commands
  • :/regex — search
  • :%s/pat/rep/g — substitution

Out of Scope

  • Macros, named registers, splits, tabs

Language Support

  • C
  • Assembly

Ollama Integration

Models (user-configurable)

  • gemma2:2b
  • deepseek-r1:1.5b
  • qwen2.5-coder:3b
  • gemma3:4b

Completion Behavior

  • Idle timer in insert mode (~300ms) triggers completion request
  • Tab to accept ghost text (rendered dim)
  • Context sent: current function/block (enclosing {}) + current line
  • Endpoint: POST http://localhost:11434/api/generate (streaming JSON)

Architecture

src/
  main.c          — entry point, arg parsing
  terminal.c      — raw mode, ncurses screen management
  buffer.c        — gap buffer or piece table, line indexing
  editor.c        — editor state, viewport, cursor
  input.c         — keypress reading, modal dispatch
  normal.c        — normal mode commands, operator-motion parsing
  insert.c        — insert mode, char input, trigger completion
  command.c       — : command line parsing and execution
  search.c        — regex search (POSIX regex.h)
  undo.c          — undo list
  ollama.c        — HTTP client (libcurl), prompt building, response parsing
  syntax.c        — minimal scope detection for C/asm (brace matching)
  config.c        — runtime config (~/.editorrc or similar)

Dependencies

  • ncurses — terminal UI
  • libcurl — Ollama HTTP communication
  • POSIX regex.h — search/replace (libc)
  • cJSON (or hand-rolled) — parse Ollama JSON responses

Design Decisions to Finalize

  • Text buffer: gap buffer (simpler) vs piece table (better for large files)
  • Visual mode: include char/line visual mode?
  • Config file format and location