Minga.Buffer (minga_sdk v0.1.2)

Copy Markdown View Source

Public API for buffer operations.

Extensions use this module to read buffer content, query cursor position, check file paths, and manage decorations.

This is a compile-time stub. At runtime, the real module in Minga's BEAM VM provides the implementation.

Summary

Functions

Returns the cursor, inclusive conflict regions, and their shared buffer version.

Returns content and its mutation version from the same buffer state.

Replaces the content only at the observed version, returning the new version.

Resolves one conflict at the observed version without saving.

Saves the file only when the buffer is still at the requested version.

Types

position()

@type position() :: {line :: non_neg_integer(), col :: non_neg_integer()}

t()

@type t() :: GenServer.server()

Functions

batch_decorations(server, fun)

@spec batch_decorations(t(), (term() -> term())) :: :ok

conflict_count(server)

@spec conflict_count(t()) :: non_neg_integer()

conflict_snapshot(server)

@spec conflict_snapshot(t()) :: {String.t(), position(), [term()]}

conflict_view(server)

@spec conflict_view(t()) :: Minga.Buffer.Conflict.view()

Returns the cursor, inclusive conflict regions, and their shared buffer version.

conflicts(server)

@spec conflicts(t()) :: [term()]

content(server)

@spec content(t()) :: String.t()

content_with_version(server)

@spec content_with_version(t()) :: {String.t(), non_neg_integer()}

Returns content and its mutation version from the same buffer state.

cursor(server)

@spec cursor(t()) :: position()

decorations(server)

@spec decorations(t()) :: term()

dirty?(server)

@spec dirty?(t()) :: boolean()

file_path(server)

@spec file_path(t()) :: String.t() | nil

filetype(server)

@spec filetype(t()) :: atom()

get_option(server, name)

@spec get_option(t(), atom()) :: term()

line_count(server)

@spec line_count(t()) :: pos_integer()

lines(server, start, count)

@spec lines(t(), non_neg_integer(), non_neg_integer()) :: [String.t()]

move_to(server, pos)

@spec move_to(t(), position()) :: :ok

read_only?(server)

@spec read_only?(t()) :: boolean()

replace_content_if_version(server, expected_version, new_content)

@spec replace_content_if_version(t(), non_neg_integer(), String.t()) ::
  {:ok, non_neg_integer()} | {:error, :read_only | :stale}

Replaces the content only at the observed version, returning the new version.

resolve_conflict(server, expected_version, target, choice)

Resolves one conflict at the observed version without saving.

save_if_version(server, expected_version)

@spec save_if_version(t(), non_neg_integer()) :: :ok | {:error, term()}

Saves the file only when the buffer is still at the requested version.