Editor Integration

Lectic is designed to work with your editor, not replace it. The core workflow is: edit a file, press a key, watch the response stream in. No mode switching, no separate chat window—you stay in your editor the whole time.

This page covers setup for several editors. If you just want to get started quickly:

  • Neovim: Install the plugin from extra/lectic.nvim, add the LSP config below, and use <localleader>l to submit.
  • VS Code: Install the extension from releases and use Cmd+L / Alt+L.
  • Other editors: Run lectic -if file.lec from a keybinding.

The LSP Server

Lectic includes a Language Server Protocol (LSP) server. You don’t strictly need it—Lectic works fine as a command-line tool—but the LSP makes editing .lec files much more pleasant:

  • Completions for directives, macro names, YAML fields, model names, and tool types. Start typing and the LSP suggests what comes next.
  • Diagnostics that catch YAML errors, missing configuration, and duplicate names before you run the file.
  • Folding for tool-call blocks. Tool output can be verbose; folding keeps the conversation readable.
  • Hover information showing what a directive does or what a macro expands to.
  • Go to definition for macros, kits, and interlocutors defined in config files.

Start it with:

lectic lsp

The server uses stdio transport and works with any LSP-capable editor.

Neovim

The repository includes a full-featured plugin at extra/lectic.nvim.

Installation

lazy.nvim:

{
  'gleachkr/lectic',
  name = 'lectic.nvim',
  config = function(plugin)
    vim.opt.rtp:append(plugin.dir .. "/extra/lectic.nvim")
  end
}

vim-plug:

Plug 'gleachkr/lectic', { 'rtp': 'extra/lectic.nvim' }

Features

  • Filetype detection for .lec and .lectic files
  • Async submission — send conversations without blocking
  • Streaming responses — watch the response appear in real-time
  • Visual feedback — spinner while processing
  • Response highlighting — distinguish LLM blocks from your text
  • Tool call folding — collapsed by default, showing tool name
  • Selection explanation — select text, ask for elaboration

Default Keybindings

Key Mode Action
<localleader>l Normal Submit conversation
<localleader>c Normal Cancel generation
<localleader>e Visual Explain selection

Customize with:

vim.g.lectic_key_submit = '<Leader>l'
vim.g.lectic_key_cancel_submit = '<Leader>c'
vim.g.lectic_key_explain = '<Leader>e'

LSP Setup

The plugin handles filetype detection. For LSP features, add:

vim.api.nvim_create_autocmd("FileType", {
  pattern = { "lectic", "markdown.lectic", "lectic.markdown" },
  callback = function(args)
    vim.lsp.start({
      name = "lectic",
      cmd = { "lectic", "lsp" },
      root_dir = vim.fs.root(args.buf, { ".git", "lectic.yaml" })
                 or vim.fn.getcwd(),
      single_file_support = true,
    })
  end,
})

For LSP-based folding:

vim.opt.foldexpr = 'vim.lsp.foldexpr()'

VS Code

An extension is available at extra/lectic.vscode. VSIX files are distributed with releases.

Features

  • Generate Next Response — stream LLM output into the editor
  • Explain Selection — rewrite selected text with more detail
  • Block highlighting — visual distinction for response blocks
  • Tool call folding — collapse verbose tool output
  • LSP integration — completions, diagnostics, and hovers

Default Keybindings

Key Action
Alt+L (Cmd+L on macOS) Generate next response
Alt+C (Cmd+C on macOS) Consolidate
Alt+E (Cmd+E on macOS) Explain selection

Configuration

  • lectic.executablePath: Path to lectic if not in PATH
  • lectic.blockBackgroundColor: Background color for ::: blocks

Other Editors

Any editor that can run an external command on the current buffer works with Lectic. The basic pattern:

cat file.lec | lectic > file.lec

Or use -i with -f for in-place updates:

lectic -if file.lec

Emacs

A minimal setup using shell-command-on-region:

(defun lectic-submit ()
  "Send the buffer to lectic and replace with output."
  (interactive)
  (shell-command-on-region
   (point-min) (point-max)
   "lectic"
   nil t))

(add-to-list 'auto-mode-alist '("\\.lec\\'" . markdown-mode))
(add-hook 'markdown-mode-hook
          (lambda ()
            (when (string-match-p "\\.lec\\'" (buffer-file-name))
              (local-set-key (kbd "C-c C-l") 'lectic-submit))))

For LSP support, use eglot or lsp-mode:

;; With eglot
(add-to-list 'eglot-server-programs
             '((markdown-mode :language-id "lectic")
               . ("lectic" "lsp")))

Helix

Add to languages.toml:

[[language]]
name = "lectic"
scope = "source.lectic"
file-types = ["lec", "lectic"]
language-servers = ["lectic-lsp"]
grammar = "markdown"

[language-server.lectic-lsp]
command = "lectic"
args = ["lsp"]

Sublime Text

Install the LSP package, then add to LSP settings:

{
  "clients": {
    "lectic": {
      "command": ["lectic", "lsp"],
      "selector": "text.html.markdown",
      "file_patterns": ["*.lec"]
    }
  }
}

Tips

  • Working directory matters. When you run lectic -if file.lec, tools and file references resolve relative to the file’s directory. Most editor plugins handle this automatically.

  • Use the LSP for header editing. Completions for model names, tool types, and interlocutor properties save time and catch typos.

  • Fold tool calls. Long tool outputs can obscure the conversation. Both the Neovim and VS Code plugins fold these by default.

  • Stream for long responses. Use --format block to output just the new assistant block, which editor plugins can stream incrementally.