goui-sourceview

module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT

README

GOUI SourceView

A native code editor for Go applications

中文

GOUI SourceView brings source code editing to GOUI applications, with syntax highlighting, completion, matching brackets, and Modern light/dark appearances. It supports both imperative and declarative integration.

The project is under active development. The v0.6.0 release notes describe the prepared, unreleased changes and migration.

Installation

Requires Go 1.24 or newer and GOUI v0.8.0, which Go downloads automatically. A separate GOUI checkout or workspace is optional for development. The dependency includes the typed input, Surface and shared transient contracts used here; see the upgrade record.

This checkout uses a new, unreleased package layout. The imperative entry is:

import source "github.com/golang-gui/goui-sourceview/sourceview"

To integrate this checkout into another application, include the application and SourceView modules in a local Go workspace. Published v0.5.0 uses the previous root import path and does not contain the new subpackage. The ui, language and scheme paths are unchanged. See the package migration notes for the layout and validation scope.

This checkout also owns its text model, history and paragraph caches. Use Document directly in place of Document.Model() / NewDocumentWithModel; use SourceView TextRange, TextSelection, TextEdit and TextChange (also available in ui). These changes are unreleased. See the editor core migration.

Features

  • Syntax highlighting for JSON/JSONC, JSON Lines, XML, HTML, Markdown, TOML, YAML, Shell, HTTP, Protobuf, Makefile, CMake, Nginx, INI, Dockerfile, SQL, Go, Python, JavaScript, TypeScript, JSX, TSX, CSS, C, C++, Java, Rust, C#, Lua, PowerShell, Ruby, PHP, Kotlin, Swift, Dart, R, Zig, Objective-C, Objective-C++, Scala, Perl, Diff/Patch, Windows Batch, HCL/Terraform, GraphQL, SCSS, Less, Dotenv, Java Properties, Git Ignore/Attributes, Starlark, Groovy, Go Template, Jinja2, systemd unit, Desktop Entry, Nix, jq, PromQL, F#, Elixir, Erlang, Julia, Clojure, Haskell, OCaml, CSV, TSV, AsciiDoc, reStructuredText, TeX/LaTeX, BibTeX, gettext PO/POT, EditorConfig, JSON5, EDN, Git config, SSH config, crontab, Mermaid, Graphviz DOT and Go module/workspace/checksum files.
  • Mixed documents with highlighted Markdown metadata and code fences, plus HTML, XML, YAML and TOML template hosts.
  • Folding and navigation for structured documents, common code languages, Markdown headings and code fences, with independent external fold snapshots.
  • Editing assistance with smart indentation, whitespace markers, indent guides and rulers.
  • Multiple cursors and column selection with configurable mouse/keyboard gestures, occurrence commands and selection undo.
  • Save points and view states with document modified notifications and same-revision selection/viewport restoration.
  • Special characters with optional native-cluster markers and Unicode tooltips.
  • Code editing with Unicode and structural selection, word-part navigation, clipboard, undo/redo, reindentation and cleanup commands.
  • Line marks and minimap with breakpoint/bookmark presentation, execution lines and color-block navigation.
  • External analysis with independent highlight/fold snapshots and completion refresh.
  • Inline suggestions with optional host-provided single-line/multiline ghost text, Tab acceptance, Escape dismissal and single-edit undo.
  • Completion and brackets with suggestions, automatic pairs, matching-bracket navigation and linked tag names.
  • Custom languages with application-defined highlighting, editing rules and completion.
  • Find and replace in a floating panel, with multiline queries, regular expressions, capture replacements and selection scopes.
  • Light and dark appearances with syntax colors preserved in selections.
  • Multilingual controls with editor menus and find/replace available in eight languages.

Screenshots

Modern Light — JSON

GOUI SourceView editing JSON in Modern Light

Modern Dark — HTML

GOUI SourceView editing HTML in Modern Dark

Screenshots from the example running on Linux.

Build with an AI coding assistant

The SourceView application development Skill helps your AI integrate the editor and customize highlighting, editing rules, and completion. To install it, tell your AI:

Install the SourceView application development skill following https://github.com/golang-gui/goui-sourceview/blob/main/skills/INSTALL.md.

The installation guide uses your tool's native skill mechanism. Tools without Skill support can read the development guide directly. Installing the Skill does not install or upgrade your application's Go dependencies.

Try the example

Requires Go 1.24 or newer. Follow the example guide to prepare the development environment, then run from the repository root:

go run ./example/editor

The example includes editable samples for every built-in language, search and completion, and lets you switch between light and dark appearances. A declarative example and a custom Markdown editor are also available.

License

MIT

Directories

Path Synopsis
example
debug command
Run: go run ./example/debug [-dark].
Run: go run ./example/debug [-dark].
declarative command
Run: go run ./example/declarative.
Run: go run ./example/declarative.
editor command
Run: go run ./example/editor [-theme system|light|dark] [file].
Run: go run ./example/editor [-theme system|light|dark] [file].
markdown command
Run: go run ./example/markdown [-dark].
Run: go run ./example/markdown [-dark].
markdown/markdown
Package markdown demonstrates an application-owned SourceView language.
Package markdown demonstrates an application-owned SourceView language.
semantic command
Run: go run ./example/semantic [-dark].
Run: go run ./example/semantic [-dark].
semantic/analysis
Package analysis is an application-owned, single-file Go analysis service.
Package analysis is an application-owned, single-file Go analysis service.
internal
editor
Package editor plans source edits without depending on Widgets or native resources.
Package editor plans source edits without depending on Widgets or native resources.
folding
Package folding contains detached snapshots, change mapping and visible-line indexes.
Package folding contains detached snapshots, change mapping and visible-line indexes.
highlight
Package highlight implements SourceView lexical and foreground indexes.
Package highlight implements SourceView lexical and foreground indexes.
resource
Package resource contains SourceView-owned presentation text.
Package resource contains SourceView-owned presentation text.
text
Package text owns SourceView text storage, edit transactions, history, preedit projection, metric snapshots and editor geometry.
Package text owns SourceView text storage, edit transactions, history, preedit projection, metric snapshots and editor geometry.
view
Package view contains view-local indexes and native presentation resources.
Package view contains view-local indexes and native presentation resources.
Package language describes the languages and lexical styles supported by SourceView.
Package language describes the languages and lexical styles supported by SourceView.
Package scheme provides immutable source-code color schemes.
Package scheme provides immutable source-code color schemes.
Package sourceview provides a native GOUI code editor.
Package sourceview provides a native GOUI code editor.
tests
window/editor command
SourceView desktop verification.
SourceView desktop verification.
window/editor/assistance command
编辑辅助和空白外观的原生窗口验证,需要桌面及窗口管理器。
编辑辅助和空白外观的原生窗口验证,需要桌面及窗口管理器。
window/editor/binding command
SourceView 选区属性绑定与局部更新验收,需要桌面、原生排版和字体。
SourceView 选区属性绑定与局部更新验收,需要桌面、原生排版和字体。
window/editor/brackets command
Bracket decoration visual verification.
Bracket decoration visual verification.
window/editor/completion command
Completion panel verification.
Completion panel verification.
window/editor/corpus command
Downloaded-corpus verification.
Downloaded-corpus verification.
window/editor/extensions command
Public extension verification.
Public extension verification.
window/editor/find command
内置查找、替换和声明式生命周期验证。
内置查找、替换和声明式生命周期验证。
window/editor/find_appearance command
Find overlay appearance and isolation verification.
Find overlay appearance and isolation verification.
window/editor/fold_preview command
Unified gutter folding.
Unified gutter folding.
window/editor/folding command
Folding integration verification.
Folding integration verification.
window/editor/folding_config command
Config folding verification in an independent native desktop/WM.
Config folding verification in an independent native desktop/WM.
window/editor/folding_data command
Structured-language folding verification in an independent native desktop/WM.
Structured-language folding verification in an independent native desktop/WM.
window/editor/folding_diff command
DOT and ordinary Git/unified Diff folding in an independent native desktop/WM.
DOT and ordinary Git/unified Diff folding in an independent native desktop/WM.
window/editor/folding_docker command
Dockerfile folding verification in an independent native desktop/WM.
Dockerfile folding verification in an independent native desktop/WM.
window/editor/folding_functional command
Functional folding verification in an independent native desktop/WM.
Functional folding verification in an independent native desktop/WM.
window/editor/folding_keywords command
Keyword-block folding verification in an independent native desktop/WM.
Keyword-block folding verification in an independent native desktop/WM.
window/editor/folding_languages command
Built-in code folding verification.
Built-in code folding verification.
window/editor/folding_layout command
Layout folding verification in an independent native desktop/WM.
Layout folding verification in an independent native desktop/WM.
window/editor/folding_mixed command
Mixed JSX/TSX/PHP folding verification in a native desktop/window manager.
Mixed JSX/TSX/PHP folding verification in a native desktop/window manager.
window/editor/folding_profiles command
Language-profile folding verification in an independent native desktop/WM.
Language-profile folding verification in an independent native desktop/WM.
window/editor/folding_query command
Query/reader folding verification in an independent native desktop/WM.
Query/reader folding verification in an independent native desktop/WM.
window/editor/folding_remaining command
Remaining-language folding in an independent native desktop/WM.
Remaining-language folding in an independent native desktop/WM.
window/editor/folding_requests command
SSH sections and HTTP request folding in an independent native desktop/WM.
SSH sections and HTTP request folding in an independent native desktop/WM.
window/editor/frame command
编辑器外框与滚动条组合验证。
编辑器外框与滚动条组合验证。
window/editor/goui_integration command
本地 GOUI 接入验收,需要桌面、原生字体和窗口管理器。
本地 GOUI 接入验收,需要桌面、原生字体和窗口管理器。
window/editor/highlight command
连续输入的着色稳定性,需要桌面、原生排版及正常事件循环。
连续输入的着色稳定性,需要桌面、原生排版及正常事件循环。
window/editor/horizontal_scroll command
Horizontal scrollbar after typing past the viewport.
Horizontal scrollbar after typing past the viewport.
window/editor/inline_multiline command
Multiline host-provided inline suggestions.
Multiline host-provided inline suggestions.
window/editor/inline_suggestion command
Host-provided inline suffix verification.
Host-provided inline suffix verification.
window/editor/interaction command
Real desktop input verification; requires a desktop and native typography.
Real desktop input verification; requires a desktop and native typography.
window/editor/keybindings command
Command binding integration verification.
Command binding integration verification.
window/editor/languages command
内置语言集成验证,需要桌面、窗口管理器、原生排版及字体。
内置语言集成验证,需要桌面、窗口管理器、原生排版及字体。
window/editor/largefiles command
Medium/large-file functional verification.
Medium/large-file functional verification.
window/editor/line_collapse command
Manual long-line collapse.
Manual long-line collapse.
window/editor/line_marks command
行标记窗口验收,需要桌面、窗口管理器、原生排版与字体。
行标记窗口验收,需要桌面、窗口管理器、原生排版与字体。
window/editor/lines command
Logical line editing verification.
Logical line editing verification.
window/editor/localization command
Eight-language editor UI verification.
Eight-language editor UI verification.
window/editor/longlines command
Long-line rasterization regression.
Long-line rasterization regression.
window/editor/markup command
Native markup verification; desktop/window manager required.
Native markup verification; desktop/window manager required.
window/editor/menus command
Menu command/hint integration.
Menu command/hint integration.
window/editor/minimap command
色块地图窗口验收:go run ./tests/window/editor/minimap [-theme basic|light|dark]。
色块地图窗口验收:go run ./tests/window/editor/minimap [-theme basic|light|dark]。
window/editor/multibinding command
多选区绑定的独立窗口验收,需要原生桌面/字体;运行 go run ./tests/window/editor/multibinding。
多选区绑定的独立窗口验收,需要原生桌面/字体;运行 go run ./tests/window/editor/multibinding。
window/editor/multiselection command
多选区独立窗口验收,需要桌面、原生排版和字体。
多选区独立窗口验收,需要桌面、原生排版和字体。
window/editor/paragraph command
超大单行文本交互验证,需要独立桌面、原生排版和字体,不使用 DevServer。
超大单行文本交互验证,需要独立桌面、原生排版和字体,不使用 DevServer。
window/editor/resize_cache command
Recent-width layout cache verification.
Recent-width layout cache verification.
window/editor/savepoint command
保存点窗口验收:需要桌面、原生排版与字体;不使用真实剪贴板或磁盘文件。
保存点窗口验收:需要桌面、原生排版与字体;不使用真实剪贴板或磁盘文件。
window/editor/search command
Native search enhancements verification; desktop/window manager required.
Native search enhancements verification; desktop/window manager required.
window/editor/selection command
Syntax-preserving selection verification.
Syntax-preserving selection verification.
window/editor/semantic command
外部语义分析验收:go run ./tests/window/editor/semantic [-dark]。
外部语义分析验收:go run ./tests/window/editor/semantic [-dark]。
window/editor/settext command
Full-text replacement without blank transition frames.
Full-text replacement without blank transition frames.
window/editor/shortcuts command
Editor shortcut verification.
Editor shortcut verification.
window/editor/special_characters command
特殊字符窗口验收,需要桌面、原生排版和字体。
特殊字符窗口验收,需要桌面、原生排版和字体。
window/editor/structural command
P0 编辑辅助与大折叠结果的窗口验证。
P0 编辑辅助与大折叠结果的窗口验证。
window/editor/view_state command
视图状态的独立原生窗口验收。
视图状态的独立原生窗口验收。
window/experience command
Editor experience verification.
Editor experience verification.
Package ui provides thin GOUI declarative bindings for SourceView.
Package ui provides thin GOUI declarative bindings for SourceView.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL