Skip to content

Commit 2fa3bd0

Browse files
committed
feat(plugin): port neotree look and theme colors
Render the file tree with segmented rows, Nerd Font icons, git badges, and panel actions that match the Neo-tree workflow more closely. Add filesystem git status access so the plugin can keep badges current. Expose raw VS Code workbench colors through `theme.colors` so plugins can borrow existing theme keys without inventing new Red theme variables. NeoTree uses those colors for folders, guides, ignored files, and status badges while preserving fallbacks.
1 parent 8703f93 commit 2fa3bd0

12 files changed

Lines changed: 1063 additions & 77 deletions

File tree

docs/PLUGIN_SYSTEM.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ Returns an object containing:
142142
- `buffers` - Array of buffer information (id, name, path, language_id)
143143
- `current_buffer_index` - Index of the active buffer
144144
- `size` - Editor dimensions (rows, cols)
145-
- `theme` - Current theme information
145+
- `theme` - Current theme information. `theme.colors` contains parsed VS Code
146+
workbench colors keyed by their original names, such as
147+
`gitDecoration.modifiedResourceForeground` or `list.highlightForeground`.
146148
147149
#### Session State
148150
```javascript
@@ -176,20 +178,27 @@ red.openBuffer(name: string)
176178
red.drawText(x: number, y: number, text: string, style?: object)
177179

178180
// Create and update a persistent side panel
179-
red.createPanel("tree", { side: "left", width: 32, title: "Files" })
181+
red.createPanel("tree", { side: "left", width: 32 })
180182
red.updatePanel("tree", [{
181183
id: "/repo/src",
182-
label: "src",
183184
path: "/repo/src",
184-
depth: 0,
185185
expanded: true,
186-
kind: "directory"
186+
kind: "directory",
187+
segments: [
188+
{ text: "", style: mutedStyle },
189+
{ text: "", style: directoryStyle },
190+
{ text: "src", style: directoryStyle }
191+
],
192+
right_segments: [
193+
{ text: "", style: modifiedStyle }
194+
]
187195
}])
188196
red.focusPanel("tree")
189197
red.focusEditor()
190198
red.closePanel("tree")
191199
red.onPanelEvent("tree", (event) => {
192-
// event.action is "up", "down", "expand", "collapse", or "activate"
200+
// event.action is "up", "down", "expand", "collapse", "activate",
201+
// "toggle", "close", or "refresh"
193202
})
194203
```
195204
@@ -198,9 +207,14 @@ while the panel is active. Plugins can call `focusEditor()` to return input
198207
to the editor after handling a panel action. Pressing `Esc` also returns
199208
focus to the editor.
200209
210+
Rows are segment-based: `segments` render from the left, and
211+
`right_segments` render flush-right when space allows. Segment text is clipped
212+
by terminal display width, so plugins can use Unicode/Nerd Font glyphs safely.
213+
201214
#### Filesystem
202215
```javascript
203216
const { entries, error } = await red.listDirectory(".")
217+
const git = await red.getGitStatus(".")
204218
const watchId = red.watchDirectory(".", async (snapshot) => {
205219
// snapshot has the same shape as listDirectory()
206220
})
@@ -212,6 +226,10 @@ red.openFile("src/main.rs")
212226
do not receive arbitrary filesystem access; they request directory listings
213227
and directory watches through editor-owned APIs.
214228
229+
`getGitStatus` returns `{ root, statuses, error }` for the Git repository that
230+
contains the requested path. Each status has `path`, `absolute_path`, and a
231+
normalized `status` such as `modified`, `untracked`, `ignored`, or `conflict`.
232+
215233
#### Buffer Manipulation
216234
```javascript
217235
// Insert text at position

0 commit comments

Comments
 (0)