-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimtea.go
74 lines (56 loc) · 1.73 KB
/
vimtea.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Package vimtea provides a Vim-like text editor component for terminal applications
built with Bubble Tea (github.com/charmbracelet/bubbletea).
# Features
- Vim-like modal editing with normal, insert, visual, and command modes
- Familiar key bindings for Vim users (h,j,k,l navigation, d/y/p for delete/yank/paste, etc.)
- Command mode with colon commands
- Visual mode for selecting text
- Undo/redo functionality
- Line numbers (regular and relative)
- Syntax highlighting
- Customizable styles and themes
- Extensible key binding system
# Getting Started
Create a new editor with default settings:
editor := vimtea.NewEditor()
Or customize it with options:
editor := vimtea.NewEditor(
vimtea.WithContent("Initial content"),
vimtea.WithEnableStatusBar(true),
vimtea.WithDefaultSyntaxTheme("catppuccin-macchiato"),
vimtea.WithRelativeNumbers(true),
)
Use it in a Bubble Tea application:
p := tea.NewProgram(editor)
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
# Extending Functionality
Add custom key bindings:
editor.AddBinding(vimtea.KeyBinding{
Key: "ctrl+s",
Mode: vimtea.ModeNormal,
Description: "Save file",
Handler: func(buf vimtea.Buffer) tea.Cmd {
// Your save logic here
return nil
},
})
Add custom command:
editor.AddCommand("write", func(buf vimtea.Buffer, args []string) tea.Cmd {
// Your save logic here
return nil
})
# Styling
Customize the appearance with style options:
customStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("#FFFFFF")).
Background(lipgloss.Color("#333333"))
editor := vimtea.NewEditor(
vimtea.WithTextStyle(customStyle),
vimtea.WithLineNumberStyle(numberStyle),
vimtea.WithCursorStyle(cursorStyle),
)
*/
package vimtea