Documentation
¶
Overview ¶
Package nvim runs an embedded Neovim for the split view's source pane: nvim --embed with the ext_linegrid UI, editing a buffer kept in step with the notebook's text. The page draws the grid; this package passes its redraw events on and the page's keys back.
Index ¶
- Variables
- type Editor
- func (e *Editor) ApplyLines(seq int, edits []LineEdit) (bool, error)
- func (e *Editor) Call(fn, args string) (string, error)
- func (e *Editor) Close() error
- func (e *Editor) Input(keys string) error
- func (e *Editor) Mouse(button, action, mod string, row, col int) error
- func (e *Editor) Paste(text string) error
- func (e *Editor) Resize(cols, rows int) error
- func (e *Editor) Saved() error
- func (e *Editor) Snapshot() (string, int, error)
- type Found
- type LineEdit
- type Lines
- type Options
- type Version
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("nvim not found")
ErrNotFound is Find's error when there is no nvim to use.
var MinVersion = Version{0, 10, 0}
MinVersion is the oldest Neovim that works: 0.9 has no inline virtual text.
var StartTimeout = 5 * time.Second
StartTimeout is how long Start waits for Neovim and the user's config.
Functions ¶
This section is empty.
Types ¶
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor is one running Neovim.
func (*Editor) ApplyLines ¶
ApplyLines makes edits on the buffer, in order and not overlapping, made against its text as of seq. If the buffer has typing since that wasn't sent, or seq isn't the buffer's, it changes nothing and reports false; the typing is then sent, as Lines, to fold in before trying again. Done, it moves the buffer's seq on one.
func (*Editor) Call ¶
Call calls the function called fn in the buffer's mdsh side with args, a JSON array, and returns what it returns, as JSON.
func (*Editor) Mouse ¶
Mouse passes on a mouse event: button is "left", "right", "middle" or "wheel"; action is "press", "drag" or "release", or for the wheel "up", "down", "left" or "right"; mod is like "C" or "S-A" or "".
type Lines ¶
type Lines struct {
Seq int `json:"seq"`
First int `json:"first"`
Last int `json:"last"`
Text string `json:"text"`
}
Lines says lines [First, Last) of the buffer's text, counted from 0, became Text, whole lines each ending with a newline. Seq counts what changed the text, as the buffer sends it: what was typed, and each ApplyLines.
type Options ¶
type Options struct {
Path string
Cols, Rows int
// Name is the buffer's name, such as mdsh://notes.md.
Name string
Text string
// Clean starts Neovim without the user's config.
Clean bool
// Dark sets 'background' to dark, else light, before the config
// runs, which may set it again.
Dark bool
// LSP is the command that starts mdsh's language server, which the
// buffer attaches to for completion, hover help and diagnostics.
// Empty starts none.
LSP []string
// Redraw gets the redraw events up to each flush, as Neovim sent
// them: each is the event's name and then one argument list for
// each time it happened.
Redraw func(events [][]any)
// Lines gets what was typed in the buffer, a moment after: the lines
// that changed.
Lines func(Lines)
// Write is called for :w, with the Seq of the last Lines it follows.
Write func(seq int)
// Event gets what the buffer's mdsh side reports, such as the
// cursor moving or :RunBlock: the event's name and its data as JSON.
Event func(name, data string)
// Exit is called once Neovim has quit, with why if it failed.
Exit func(err error)
}
Options are how to start an Editor.
type Version ¶
type Version struct {
Major, Minor, Patch int
}
Version is a Neovim version.
func ReadVersion ¶
ReadVersion runs nvim --version, which reads no config.