mui 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +13 -8
  3. data/CHANGELOG.md +99 -0
  4. data/README.md +309 -6
  5. data/docs/_config.yml +56 -0
  6. data/docs/configuration.md +301 -0
  7. data/docs/getting-started.md +140 -0
  8. data/docs/index.md +55 -0
  9. data/docs/jobs.md +297 -0
  10. data/docs/keybindings.md +229 -0
  11. data/docs/plugins.md +285 -0
  12. data/docs/syntax-highlighting.md +149 -0
  13. data/lib/mui/command_completer.rb +11 -2
  14. data/lib/mui/command_history.rb +89 -0
  15. data/lib/mui/command_line.rb +32 -2
  16. data/lib/mui/command_registry.rb +21 -2
  17. data/lib/mui/config.rb +3 -1
  18. data/lib/mui/editor.rb +78 -2
  19. data/lib/mui/handler_result.rb +13 -7
  20. data/lib/mui/highlighters/search_highlighter.rb +2 -1
  21. data/lib/mui/highlighters/syntax_highlighter.rb +3 -1
  22. data/lib/mui/key_handler/base.rb +87 -0
  23. data/lib/mui/key_handler/command_mode.rb +68 -0
  24. data/lib/mui/key_handler/insert_mode.rb +10 -41
  25. data/lib/mui/key_handler/normal_mode.rb +24 -51
  26. data/lib/mui/key_handler/operators/paste_operator.rb +9 -3
  27. data/lib/mui/key_handler/search_mode.rb +10 -7
  28. data/lib/mui/key_handler/visual_mode.rb +15 -10
  29. data/lib/mui/key_notation_parser.rb +152 -0
  30. data/lib/mui/key_sequence.rb +67 -0
  31. data/lib/mui/key_sequence_buffer.rb +85 -0
  32. data/lib/mui/key_sequence_handler.rb +163 -0
  33. data/lib/mui/key_sequence_matcher.rb +79 -0
  34. data/lib/mui/line_renderer.rb +52 -1
  35. data/lib/mui/mode_manager.rb +3 -2
  36. data/lib/mui/screen.rb +24 -6
  37. data/lib/mui/search_state.rb +61 -28
  38. data/lib/mui/syntax/language_detector.rb +33 -1
  39. data/lib/mui/syntax/lexers/css_lexer.rb +121 -0
  40. data/lib/mui/syntax/lexers/go_lexer.rb +205 -0
  41. data/lib/mui/syntax/lexers/html_lexer.rb +118 -0
  42. data/lib/mui/syntax/lexers/javascript_lexer.rb +197 -0
  43. data/lib/mui/syntax/lexers/markdown_lexer.rb +210 -0
  44. data/lib/mui/syntax/lexers/rust_lexer.rb +148 -0
  45. data/lib/mui/syntax/lexers/typescript_lexer.rb +203 -0
  46. data/lib/mui/terminal_adapter/curses.rb +13 -11
  47. data/lib/mui/version.rb +1 -1
  48. data/lib/mui/window.rb +83 -40
  49. data/lib/mui/window_manager.rb +7 -0
  50. data/lib/mui/wrap_cache.rb +40 -0
  51. data/lib/mui/wrap_helper.rb +84 -0
  52. data/lib/mui.rb +15 -0
  53. metadata +26 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9515ecfb14d1a9ea5422a842fd22911c303f2465f35827b879117e3cce4d1551
4
- data.tar.gz: e6daedc45ebb07f1e8b094f590ae9749bfae49e2ced12017cba16f1c1dc255c0
3
+ metadata.gz: f38d3d434535fc336c9b5394801e3fb49393f691b15878a1994758cfb73a6217
4
+ data.tar.gz: 220128d17afb0f711f2642cd7e64acc14364ca5e65de77c7130828e5a809796c
5
5
  SHA512:
6
- metadata.gz: 4f493037291b8801dd2fc8a6101fb714110c12653ebb432900eebaa8f135d91597c8c862d5cf2b380e332d689decbada6d06f406e7f8c8eae859819d63887845
7
- data.tar.gz: de2b83ea5a999760a171bb037bc264035ef1b43878b806a2b0577099b5601e6e94bdbf6d711604fd9d5a7df01d381665ed734526e1d0f643f896b40e89954604
6
+ metadata.gz: 82468df468d286b1b672b4c47257565f348661cf38633fdabfdc021cf42639d3637f1b6a1b233bd7af65b47fa426b15da2cd52e270cbe7be987dd071e4d785db
7
+ data.tar.gz: dbf19ebadd262acc004320ebcf55d25f404ce22ad7a77beb08f4363d5154dc2f9241834f531fa15b4b953d8768bc3c1ec8213441d3150ec803081b1be32590b0
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-12-11 15:57:29 UTC using RuboCop version 1.81.7.
3
+ # on 2025-12-14 12:18:50 UTC using RuboCop version 1.81.7.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -12,10 +12,11 @@ Gemspec/RequiredRubyVersion:
12
12
  Exclude:
13
13
  - 'test/fixtures/mui-test-plugin/mui-test-plugin.gemspec'
14
14
 
15
- # Offense count: 3
15
+ # Offense count: 4
16
16
  # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
17
17
  Lint/DuplicateBranch:
18
18
  Exclude:
19
+ - 'lib/mui/editor.rb'
19
20
  - 'lib/mui/key_handler/command_mode.rb'
20
21
  - 'lib/mui/plugin_manager.rb'
21
22
  - 'lib/mui/register.rb'
@@ -33,25 +34,26 @@ Lint/MissingSuper:
33
34
  Exclude:
34
35
  - 'test/test_helper.rb'
35
36
 
36
- # Offense count: 2
37
+ # Offense count: 3
37
38
  # This cop supports safe autocorrection (--autocorrect).
38
39
  # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
39
40
  # NotImplementedExceptions: NotImplementedError
40
41
  Lint/UnusedMethodArgument:
41
42
  Exclude:
42
43
  - 'lib/mui/terminal_adapter/base.rb'
44
+ - 'test/mui/highlighters/test_search_highlighter.rb'
43
45
 
44
46
  # Offense count: 1
45
47
  Lint/UselessConstantScoping:
46
48
  Exclude:
47
49
  - 'lib/mui/buffer_word_cache.rb'
48
50
 
49
- # Offense count: 32
51
+ # Offense count: 33
50
52
  # Configuration parameters: AllowedMethods, AllowedPatterns.
51
53
  Metrics/CyclomaticComplexity:
52
54
  Max: 49
53
55
 
54
- # Offense count: 1
56
+ # Offense count: 2
55
57
  # Configuration parameters: CountComments, CountAsOne.
56
58
  Metrics/ModuleLength:
57
59
  Max: 284
@@ -61,7 +63,7 @@ Metrics/ModuleLength:
61
63
  Metrics/ParameterLists:
62
64
  Max: 9
63
65
 
64
- # Offense count: 12
66
+ # Offense count: 14
65
67
  # Configuration parameters: AllowedMethods, AllowedPatterns.
66
68
  Metrics/PerceivedComplexity:
67
69
  Max: 19
@@ -90,7 +92,7 @@ Naming/MethodName:
90
92
  - 'test/mui/key_handler/test_visual_mode.rb'
91
93
  - 'test/mui/key_handler/test_window_command.rb'
92
94
 
93
- # Offense count: 41
95
+ # Offense count: 45
94
96
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
95
97
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
96
98
  Naming/MethodParameterName:
@@ -108,13 +110,16 @@ Naming/MethodParameterName:
108
110
  - 'test/e2e/test_helper.rb'
109
111
  - 'test/test_helper.rb'
110
112
 
111
- # Offense count: 6
113
+ # Offense count: 11
112
114
  # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
113
115
  # AllowedMethods: call
114
116
  # WaywardPredicates: nonzero?
115
117
  Naming/PredicateMethod:
116
118
  Exclude:
119
+ - 'lib/mui/command_line.rb'
120
+ - 'lib/mui/editor.rb'
117
121
  - 'lib/mui/key_handler/insert_mode.rb'
122
+ - 'lib/mui/key_sequence_buffer.rb'
118
123
  - 'lib/mui/undo_manager.rb'
119
124
  - 'lib/mui/window_manager.rb'
120
125
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,104 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2025-12-15
4
+
5
+ ### Added
6
+ - Additional syntax highlighting for 7 languages:
7
+ - Go: keywords, types, constants, raw strings (backtick), block comments
8
+ - Rust: macros (`println!`), lifetimes (`'a`), attributes (`#[derive]`), doc comments (`///`), raw strings (`r#"..."#`)
9
+ - JavaScript: template literals, regex literals, BigInt (`123n`), ES6+ keywords (`const`, `let`, `async`, `await`)
10
+ - TypeScript: extends JavaScript with type keywords (`interface`, `type`, `enum`, `declare`, `abstract`)
11
+ - Markdown: headings, emphasis (`*italic*`, `**bold**`), code blocks, links, lists, blockquotes
12
+ - HTML: tags, attributes, comments (`<!-- -->`), DOCTYPE, entities (`&amp;`)
13
+ - CSS: selectors (`.class`, `#id`, `:pseudo`), properties, hex colors, @rules, functions (`calc`, `rgb`, `var`)
14
+ - Supported extensions: `.go`, `.rs`, `.js`/`.mjs`/`.cjs`/`.jsx`, `.ts`/`.tsx`/`.mts`/`.cts`, `.md`/`.markdown`, `.html`/`.htm`/`.xhtml`, `.css`/`.scss`/`.sass`
15
+ - Multi-key sequence and leader key support (Vim-compatible):
16
+ - Leader key: `Mui.set :leader, "\\"` (default: backslash)
17
+ - `<Leader>` notation: `Mui.keymap :normal, "<Leader>gd" do ... end`
18
+ - Multi-key sequences: `<Leader>ff`, `<C-x><C-s>`, etc.
19
+ - Special key notation: `<Space>`, `<Tab>`, `<CR>`, `<Enter>`, `<Esc>`, `<BS>`
20
+ - Control key notation: `<C-x>`, `<Ctrl-x>`, `<C-S-x>` (Ctrl+Shift)
21
+ - Shift key notation: `<S-x>`, `<Shift-x>`
22
+ - Timeout setting: `Mui.set :timeoutlen, 1000` (milliseconds)
23
+ - All modes supported: Normal, Insert, Visual, Command, Search
24
+ - Built-in commands (dd, dw, gg, etc.) take priority over plugin keymaps
25
+ - Partial match waiting: typing `<Leader>g` waits for more keys if `<Leader>gd` is registered
26
+ - Exact match with longer possibilities: waits for timeout before executing
27
+ - Backward compatible with single-key keymaps
28
+ - External shell command execution (`:!cmd`):
29
+ - `:!echo hello` to run shell commands asynchronously
30
+ - Output displayed in `[Shell Output]` scratch buffer (readonly)
31
+ - stdout/stderr/exit status formatted and displayed
32
+ - "Running: cmd" message shown during execution
33
+ - Subsequent `:!cmd` updates existing scratch buffer (doesn't create new windows)
34
+ - Supports pipes, redirects, and all shell features via Open3
35
+ - Empty command (`:!` or `:! `) shows error: "E471: Argument required"
36
+ - Case-insensitive command completion:
37
+ - `:git` now matches `:Git`, `:lsp` matches `:LspHover`, `:LspDefinition`, etc.
38
+ - Original command case is preserved in completion results
39
+ - Only applies to command completion (file path completion remains case-sensitive)
40
+ - Command history with persistence:
41
+ - Up/Down arrow keys navigate through command history in command mode
42
+ - History saved to `~/.mui_history` (persists across sessions)
43
+ - Maximum 100 entries stored
44
+ - Duplicate commands move to most recent position
45
+ - Empty commands are not added to history
46
+ - Current input is preserved when browsing history (restored with Down at end)
47
+
48
+ ### Fixed
49
+ - Fixed long lines not displaying correctly by implementing line wrapping
50
+ - Lines exceeding screen width are now automatically wrapped to next screen line
51
+ - Unicode width aware wrapping (Japanese characters count as 2 width)
52
+ - Removed broken horizontal scrolling (`scroll_col`) in favor of wrap mode
53
+ - Cursor position correctly calculated across wrapped lines
54
+ - Selection and search highlights work correctly across wrap boundaries
55
+ - Added `WrapCache` for performance optimization (content-based caching)
56
+ - Added `WrapHelper` module for wrap calculations
57
+ - Fixed search returning "Pattern not found" after switching buffers via `:e`
58
+ - `execute_search` was using `@buffer` (initial buffer) instead of `buffer` method (current buffer)
59
+ - Now correctly searches in the current buffer after buffer switch
60
+ - Search highlight now recalculates correctly when switching buffers via `:e`
61
+ - Previously, search highlight from old buffer remained visible in new buffer
62
+ - Now calls `find_all_matches` on buffer switch to recalculate matches (Vim-compatible behavior)
63
+ - Search pattern is preserved, only match positions are updated for new buffer content
64
+ - Search highlight now recalculates correctly when opening files via `:sp`, `:vs`, `:tabnew`
65
+ - Previously, search highlight was not calculated for new buffers opened with split/tab commands
66
+ - Now calls `find_all_matches` when path is specified, consistent with `:e` behavior
67
+ - Improved Escape key response time in Insert mode
68
+ - Set `ESCDELAY = 10` to reduce escape sequence detection delay from 1000ms to 10ms
69
+ - Use `timeout = 0` instead of `nodelay` for `getch_nonblock`
70
+ - Insert mode completion now closes when pressing Left/Right arrow keys
71
+ - Previously, arrow keys would move cursor but completion popup remained open
72
+ - Now matches Vim behavior: completion closes on cursor movement
73
+ - Undo/Redo now works correctly for buffers opened via `:e`, `:sp`, `:vs`, `:tabnew`
74
+ - Previously, buffers opened with these commands had no UndoManager set
75
+ - Each buffer now gets its own UndoManager (Vim-compatible: independent undo history per buffer)
76
+ - Handlers now use dynamic `undo_manager` reference to support buffer switching
77
+ - Fixed screen remnants after `:e` command when new file has fewer lines
78
+ - Previously, lines from the old buffer would remain visible below the new content
79
+ - Now explicitly clears lines beyond buffer content during render
80
+ - Fixed background color not applied to lines beyond buffer content
81
+ - Previously, when opening a file with fewer lines than the visible height, lines beyond buffer were rendered without background color (transparent)
82
+ - Now uses `put_with_style` with `:normal` color scheme to ensure consistent background color
83
+ - Plugin commands now appear in command completion suggestions
84
+ - Previously, commands registered via `Mui.command` were not shown in Tab completion
85
+ - `CommandCompleter` now includes plugin commands from `Mui.config.commands`
86
+ - Multi-line paste now undos as a single action (Vim-compatible)
87
+ - Previously, pasting multiple lines would undo one line at a time
88
+ - Now uses `begin_group`/`end_group` to group all paste operations into a single undo unit
89
+ - Fixed direct array assignment to use `replace_line` for proper undo recording
90
+ - Search highlight now works correctly per buffer when switching tabs/windows
91
+ - Previously, search matches from old buffer remained when using `gt`/`gT` or `Ctrl+W` commands
92
+ - `SearchState` now caches matches per buffer (keyed by `object_id`) with lazy evaluation
93
+ - Each buffer maintains its own match positions while sharing the global search pattern
94
+ - Cache automatically invalidates when pattern changes or buffer content is modified
95
+ - Vim-compatible behavior: search pattern is global, highlights are buffer-specific
96
+ - Plugin commands now recognized by CommandRegistry for alias configuration
97
+ - Previously, `CommandRegistry#exists?` and `#find` only checked built-in commands
98
+ - Now also checks `Mui.config.commands` for plugin-registered commands
99
+ - Enables setting command aliases for plugin commands without errors
100
+ - Built-in commands take precedence over plugin commands with the same name
101
+
3
102
  ## [0.2.0] - 2025-12-12
4
103
 
5
104
  ### Added
data/README.md CHANGED
@@ -17,13 +17,316 @@ gem install mui
17
17
  mui [file]
18
18
  ```
19
19
 
20
- ## Features (Planned)
20
+ ## Features
21
21
 
22
- - Vim-like modal editing (Normal, Insert, Visual, Command modes)
23
- - Plugin system via gems
24
- - LSP support (via `mui-lsp` gem)
25
- - Git integration (via `mui-git` gem)
26
- - Configurable via `.muirc`
22
+ ### Modal Editing
23
+
24
+ Vim-like modal editing with five modes:
25
+
26
+ - **Normal mode**: Navigation and text manipulation
27
+ - **Insert mode**: Text input with auto-completion
28
+ - **Command mode**: Ex commands (`:w`, `:q`, `:e`, etc.)
29
+ - **Visual mode** (`v`): Character-wise selection
30
+ - **Visual Line mode** (`V`): Line-wise selection
31
+
32
+ ### Tab Pages and Window Splits
33
+
34
+ - **Tab pages**: `:tabnew`, `:tabclose`, `gt`/`gT` to switch
35
+ - **Horizontal split**: `:sp [file]`
36
+ - **Vertical split**: `:vs [file]`
37
+ - **Window navigation**: `Ctrl-w h/j/k/l` or `Ctrl-w w`
38
+
39
+ ### Syntax Highlighting
40
+
41
+ Supports 9 languages:
42
+
43
+ - Ruby (`.rb`, `.rake`, `.gemspec`)
44
+ - C (`.c`, `.h`, `.y`)
45
+ - Go (`.go`)
46
+ - Rust (`.rs`)
47
+ - JavaScript (`.js`, `.mjs`, `.cjs`, `.jsx`)
48
+ - TypeScript (`.ts`, `.tsx`, `.mts`, `.cts`)
49
+ - Markdown (`.md`, `.markdown`)
50
+ - HTML (`.html`, `.htm`, `.xhtml`)
51
+ - CSS (`.css`, `.scss`, `.sass`)
52
+
53
+ ### Search
54
+
55
+ - Forward search: `/pattern`
56
+ - Backward search: `?pattern`
57
+ - Next/previous match: `n`/`N`
58
+ - Word under cursor: `*` (forward), `#` (backward)
59
+ - Incremental search with real-time highlighting
60
+
61
+ ### Undo/Redo
62
+
63
+ - Undo: `u`
64
+ - Redo: `Ctrl-r`
65
+ - Insert mode changes grouped as single undo unit
66
+
67
+ ### Named Registers
68
+
69
+ - Named registers: `"a` - `"z`
70
+ - Unnamed register: `""`
71
+ - Yank register: `"0`
72
+ - Delete history: `"1` - `"9`
73
+ - Black hole register: `"_`
74
+
75
+ ### Completion
76
+
77
+ - Command-line completion with popup
78
+ - Buffer word completion in Insert mode (`Ctrl-n`/`Ctrl-p`)
79
+ - LSP completion support (via [mui-lsp](https://github.com/S-H-GAMELINKS/mui-lsp) gem)
80
+
81
+ ### Multi-key Sequences and Leader Key
82
+
83
+ ```ruby
84
+ # Set leader key (default: backslash)
85
+ Mui.set :leader, " " # Space as leader
86
+
87
+ # Define multi-key mappings
88
+ Mui.keymap :normal, "<Leader>ff" do |ctx|
89
+ # Find file
90
+ end
91
+ ```
92
+
93
+ Supports:
94
+ - `<Leader>` notation
95
+ - Control keys: `<C-x>`, `<C-S-x>`
96
+ - Special keys: `<Space>`, `<Tab>`, `<CR>`, `<Esc>`, `<BS>`
97
+
98
+ ### Other Features
99
+
100
+ - Japanese and multibyte character support (UTF-8)
101
+ - Floating windows for hover info
102
+ - Asynchronous job execution
103
+ - External shell command execution (`:!cmd`)
104
+ - Command history with persistence
105
+
106
+ ## Key Bindings
107
+
108
+ ### Normal Mode
109
+
110
+ | Key | Action |
111
+ |-----|--------|
112
+ | `h`, `j`, `k`, `l` | Cursor movement |
113
+ | `w`, `b`, `e` | Word movement |
114
+ | `0`, `^`, `$` | Line movement |
115
+ | `gg`, `G` | File start/end |
116
+ | `f{char}`, `t{char}` | Find character |
117
+ | `i`, `a`, `o`, `O` | Enter Insert mode |
118
+ | `v`, `V` | Enter Visual mode |
119
+ | `d`, `c`, `y` | Delete/Change/Yank operators |
120
+ | `p`, `P` | Paste after/before |
121
+ | `u`, `Ctrl-r` | Undo/Redo |
122
+ | `/`, `?` | Search forward/backward |
123
+ | `n`, `N` | Next/previous match |
124
+ | `*`, `#` | Search word under cursor |
125
+ | `gt`, `gT` | Next/previous tab |
126
+ | `gv` | Reselect last visual selection |
127
+ | `Ctrl-w` + `h/j/k/l` | Window navigation |
128
+
129
+ ### Visual Mode
130
+
131
+ | Key | Action |
132
+ |-----|--------|
133
+ | `d` | Delete selection |
134
+ | `c` | Change selection |
135
+ | `y` | Yank selection |
136
+ | `>`, `<` | Indent/unindent |
137
+ | `Esc` | Exit to Normal mode |
138
+
139
+ ### Command Mode
140
+
141
+ | Command | Action |
142
+ |---------|--------|
143
+ | `:w` | Save file |
144
+ | `:q` | Quit |
145
+ | `:wq` | Save and quit |
146
+ | `:e <file>` | Open file |
147
+ | `:sp [file]` | Horizontal split |
148
+ | `:vs [file]` | Vertical split |
149
+ | `:tabnew [file]` | New tab |
150
+ | `:!cmd` | Run shell command |
151
+
152
+ ## Configuration
153
+
154
+ Mui can be configured via `~/.muirc` (global) or `.lmuirc` (project-local).
155
+
156
+ ```ruby
157
+ # ~/.muirc
158
+
159
+ # Color scheme
160
+ Mui.set :colorscheme, "tokyo_night"
161
+
162
+ # Editor settings
163
+ Mui.set :tabstop, 4
164
+ Mui.set :shiftwidth, 4
165
+ Mui.set :expandtab, true
166
+ Mui.set :syntax, true
167
+
168
+ # Leader key
169
+ Mui.set :leader, " "
170
+
171
+ # Custom keymaps
172
+ Mui.keymap :normal, "<Leader>w" do |ctx|
173
+ ctx.editor.execute_command("w")
174
+ end
175
+
176
+ # Custom commands
177
+ Mui.command :hello do |ctx|
178
+ ctx.set_message("Hello, World!")
179
+ end
180
+
181
+ # Autocmd
182
+ Mui.autocmd :BufWritePre, pattern: "*.rb" do |ctx|
183
+ # Before saving Ruby files
184
+ end
185
+ ```
186
+
187
+ ### Available Themes
188
+
189
+ - `mui` (default)
190
+ - `solarized_dark`
191
+ - `solarized_light`
192
+ - `monokai`
193
+ - `nord`
194
+ - `gruvbox_dark`
195
+ - `dracula`
196
+ - `tokyo_night`
197
+
198
+ ## Plugin System
199
+
200
+ Mui supports plugins via Ruby gems.
201
+
202
+ ### Official Plugins
203
+
204
+ - [mui-lsp](https://github.com/S-H-GAMELINKS/mui-lsp) - LSP (Language Server Protocol) support
205
+ - [mui-git](https://github.com/S-H-GAMELINKS/mui-git) - Git integration
206
+ - [mui-fzf](https://github.com/S-H-GAMELINKS/mui-fzf) - Fuzzy finder integration with fzf
207
+
208
+ ### Using Plugins
209
+
210
+ ```ruby
211
+ # ~/.muirc
212
+ Mui.use "mui-lsp"
213
+ Mui.use "mui-git"
214
+ Mui.use "mui-fzf"
215
+ ```
216
+
217
+ ### Creating Plugins
218
+
219
+ ```ruby
220
+ # Class-based plugin
221
+ class MyPlugin < Mui::Plugin
222
+ name :my_plugin
223
+
224
+ def setup
225
+ command :greet do |ctx|
226
+ ctx.set_message("Hello from MyPlugin!")
227
+ end
228
+
229
+ keymap :normal, "<Leader>g" do |ctx|
230
+ ctx.editor.execute_command("greet")
231
+ end
232
+
233
+ autocmd :BufEnter, pattern: "*.txt" do |ctx|
234
+ ctx.set_message("Opened a text file")
235
+ end
236
+ end
237
+ end
238
+ ```
239
+
240
+ ### Asynchronous Job Execution
241
+
242
+ Plugins can run background tasks without blocking the editor:
243
+
244
+ ```ruby
245
+ class MyAsyncPlugin < Mui::Plugin
246
+ name :my_async_plugin
247
+
248
+ def setup
249
+ # Run a shell command asynchronously
250
+ command :run_tests do |ctx|
251
+ ctx.run_shell_command("bundle exec rake test") do |result|
252
+ if result[:success]
253
+ ctx.open_scratch_buffer("[Test Results]", result[:stdout])
254
+ else
255
+ ctx.set_error("Tests failed: #{result[:stderr]}")
256
+ end
257
+ end
258
+ end
259
+
260
+ # Run a Ruby block asynchronously
261
+ command :fetch_data do |ctx|
262
+ ctx.run_async do
263
+ # This runs in a background thread
264
+ sleep 2 # Simulate long operation
265
+ "Data fetched!"
266
+ end
267
+ end
268
+
269
+ # Check if jobs are running
270
+ command :job_status do |ctx|
271
+ if ctx.jobs_running?
272
+ ctx.set_message("Jobs are running...")
273
+ else
274
+ ctx.set_message("No jobs running")
275
+ end
276
+ end
277
+ end
278
+ end
279
+ ```
280
+
281
+ Available job methods:
282
+ - `ctx.run_async { ... }` - Run a Ruby block in background
283
+ - `ctx.run_shell_command(cmd) { |result| ... }` - Run shell command asynchronously
284
+ - `ctx.jobs_running?` - Check if any jobs are active
285
+ - `ctx.cancel_job(id)` - Cancel a running job
286
+ - `ctx.open_scratch_buffer(name, content)` - Display results in a scratch buffer
287
+
288
+ Autocmd events for jobs:
289
+ - `JobStarted` - When a job begins
290
+ - `JobCompleted` - When a job finishes successfully
291
+ - `JobFailed` - When a job fails
292
+ - `JobCancelled` - When a job is cancelled
293
+
294
+ ### Interactive Command Execution
295
+
296
+ Plugins can run interactive external commands:
297
+
298
+ ```ruby
299
+ class FzfPlugin < Mui::Plugin
300
+ name :fzf
301
+
302
+ def setup
303
+ command :Files do |ctx|
304
+ if ctx.command_exists?("fzf")
305
+ result = ctx.run_interactive_command("fzf")
306
+ ctx.editor.execute_command("e #{result}") if result && !result.empty?
307
+ else
308
+ ctx.set_error("fzf is not installed")
309
+ end
310
+ end
311
+ end
312
+ end
313
+ ```
314
+
315
+ ### LSP Configuration
316
+
317
+ ```ruby
318
+ # ~/.muirc
319
+ Mui.use "mui-lsp"
320
+
321
+ Mui.lsp do
322
+ use :ruby # Use preset configuration
323
+
324
+ # Or custom server
325
+ server :custom_lsp,
326
+ command: ["my-lsp", "--stdio"],
327
+ filetypes: ["mylang"]
328
+ end
329
+ ```
27
330
 
28
331
  ## Development
29
332
 
data/docs/_config.yml ADDED
@@ -0,0 +1,56 @@
1
+ title: Mui(無為) Documentation
2
+ description: A Vim-like TUI text editor written in Ruby
3
+ baseurl: "/mui"
4
+ url: "https://s-h-gamelinks.github.io"
5
+
6
+ remote_theme: just-the-docs/just-the-docs
7
+
8
+ color_scheme: dark
9
+
10
+ permalink: pretty
11
+
12
+ aux_links:
13
+ GitHub: https://github.com/S-H-GAMELINKS/mui
14
+ RubyGems: https://rubygems.org/gems/mui
15
+
16
+ nav_external_links:
17
+ - title: GitHub
18
+ url: https://github.com/S-H-GAMELINKS/mui
19
+
20
+ search_enabled: true
21
+ search:
22
+ heading_level: 2
23
+ previews: 3
24
+ preview_words_before: 5
25
+ preview_words_after: 10
26
+ tokenizer_separator: /[\s/]+/
27
+ rel_url: true
28
+ button: false
29
+
30
+ heading_anchors: true
31
+
32
+ back_to_top: true
33
+ back_to_top_text: "Back to top"
34
+
35
+ footer_content: "Copyright &copy; 2025 S-H-GAMELINKS. Distributed under the <a href=\"https://opensource.org/licenses/MIT\">MIT License</a>."
36
+
37
+ last_edit_timestamp: true
38
+ last_edit_time_format: "%Y-%m-%d"
39
+
40
+ gh_edit_link: true
41
+ gh_edit_link_text: "Edit this page on GitHub"
42
+ gh_edit_repository: "https://github.com/S-H-GAMELINKS/mui"
43
+ gh_edit_branch: "master"
44
+ gh_edit_source: docs
45
+ gh_edit_view_mode: "edit"
46
+
47
+ callouts:
48
+ warning:
49
+ title: Warning
50
+ color: yellow
51
+ note:
52
+ title: Note
53
+ color: blue
54
+ tip:
55
+ title: Tip
56
+ color: green