@icarusmx/creta 1.5.17 → 1.5.19

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.
@@ -0,0 +1,564 @@
1
+ # Understanding LazyVim Plugin Architecture
2
+
3
+ <!-- vim: set foldmethod=marker foldlevel=0: -->
4
+
5
+ ## 📖 LazyVim Reading Guide {{{
6
+
7
+ **Start with:** `zM` (close all folds) → Navigate with `za` (toggle fold)
8
+
9
+ **Keys for navigation:**
10
+ - `}` - Jump to next section
11
+ - `{` - Jump to previous section
12
+ - `zM` - Close all folds (overview mode)
13
+ - `zR` - Open all folds (detailed mode)
14
+
15
+ }}}
16
+
17
+ ## 🎯 Purpose {{{
18
+
19
+ **What:** Understand your LazyVim plugin configuration structure
20
+ **Why:** Know where to add/modify plugins without breaking your setup
21
+ **Time:** 20 minutes
22
+ **Level:** 🟡 Intermediate
23
+
24
+ **Entrypoint for ariadna nvim configuration:**
25
+ `~/.config/nvim/lua/plugins/`
26
+
27
+ Each `.lua` file = one plugin configuration (auto-loaded by LazyVim)
28
+
29
+ }}}
30
+
31
+ ## Plugin Configuration Locations {{{
32
+
33
+ ### Two Important Directories {{{
34
+
35
+ 1. **`~/.config/nvim/lua/config/`** - LazyVim core settings
36
+ - `lazy.lua` - Plugin manager setup
37
+ - `options.lua` - Vim options (tab width, line numbers, etc)
38
+ - `keymaps.lua` - Custom keybindings
39
+ - `autocmds.lua` - Auto-commands (events)
40
+
41
+ 2. **`~/.config/nvim/lua/plugins/`** - Your plugin overrides
42
+ - Each file adds/modifies plugins
43
+ - Auto-loaded alphabetically
44
+ - This is where YOU make changes
45
+
46
+ }}}
47
+
48
+ ### Current Plugin Files {{{
49
+
50
+ ```bash
51
+ ~/.config/nvim/lua/plugins/
52
+ ├── colorscheme.lua # Theme (Catppuccin Latte)
53
+ ├── example.lua # Reference examples (disabled)
54
+ ├── markdown.lua # Markdown rendering + Glow preview
55
+ ├── neo-tree.lua # File explorer filters
56
+ ├── svelte.lua # Svelte support
57
+ └── telescope_noignore.lua # Search hidden/ignored files
58
+ ```
59
+
60
+ }}}
61
+
62
+ }}}
63
+
64
+ ## Part 1: Color Scheme Configuration {{{
65
+
66
+ ### File: `colorscheme.lua` {{{
67
+
68
+ **Location:** `~/.config/nvim/lua/plugins/colorscheme.lua`
69
+
70
+ **Purpose:** Override LazyVim's default theme
71
+
72
+ **Current Setup:**
73
+ ```lua
74
+ return {
75
+ {
76
+ "catppuccin/nvim",
77
+ name = "catppuccin",
78
+ priority = 1000,
79
+ opts = {
80
+ flavour = "latte", -- Light theme
81
+ transparent_background = true, -- See terminal bg
82
+ color_overrides = {
83
+ latte = {
84
+ blue = "#1e66f5", -- Vibrant blues
85
+ },
86
+ },
87
+ },
88
+ },
89
+ {
90
+ "LazyVim/LazyVim",
91
+ opts = {
92
+ colorscheme = "catppuccin",
93
+ },
94
+ },
95
+ }
96
+ ```
97
+
98
+ **To change theme:**
99
+ 1. Edit this file
100
+ 2. Save
101
+ 3. Run `:Lazy sync` in nvim
102
+ 4. Restart nvim
103
+
104
+ }}}
105
+
106
+ ### Practice: Try Different Flavors {{{
107
+
108
+ Catppuccin has 4 flavors. Try changing `flavour = "latte"` to:
109
+
110
+ - `"latte"` - Light (current)
111
+ - `"frappe"` - Light-ish
112
+ - `"macchiato"` - Dark-ish
113
+ - `"mocha"` - Dark
114
+
115
+ **Exercise:**
116
+ 1. Open `~/.config/nvim/lua/plugins/colorscheme.lua`
117
+ 2. Change `flavour = "mocha"`
118
+ 3. Save (`:w`)
119
+ 4. Quit nvim (`:q`)
120
+ 5. Reopen nvim
121
+ 6. Notice the dark theme
122
+ 7. Change back to `"latte"` if you prefer light
123
+
124
+ }}}
125
+
126
+ }}}
127
+
128
+ ## Part 2: Markdown Workflow {{{
129
+
130
+ ### File: `markdown.lua` {{{
131
+
132
+ **Two plugins for different needs:**
133
+
134
+ 1. **render-markdown.nvim** - Inline preview
135
+ - Auto-renders when you open `.md` files
136
+ - Shows formatted headings, code blocks, bullets
137
+ - Works in normal mode (not insert)
138
+
139
+ 2. **glow.nvim** - Full preview
140
+ - Press `Shift+L` to open terminal preview
141
+ - Better for reviewing whole documents
142
+ - Dark theme, 120 char width
143
+
144
+ **When to use which:**
145
+ - Editing docs → render-markdown (always on)
146
+ - Reviewing docs → Shift+L for glow
147
+ - Presenting docs → Shift+L for clean view
148
+
149
+ }}}
150
+
151
+ ### Practice: Test Markdown Preview {{{
152
+
153
+ **Exercise:**
154
+ 1. Create a test markdown file: `nvim ~/test-doc.md`
155
+ 2. Type this content:
156
+
157
+ ```markdown
158
+ # Test Document
159
+
160
+ This is a **bold** paragraph with some *italic* text.
161
+
162
+ ## Code Example
163
+
164
+ ```javascript
165
+ console.log("Hello from markdown!");
166
+ ```
167
+
168
+ - Bullet one
169
+ - Bullet two
170
+ ```
171
+
172
+ 3. Save (`:w`) and notice render-markdown formatting
173
+ 4. Press `Shift+L` to see Glow preview
174
+ 5. Press `q` to exit Glow
175
+ 6. Delete the test file: `:!rm %`
176
+
177
+ }}}
178
+
179
+ }}}
180
+
181
+ ## Part 3: Project-Specific Configs {{{
182
+
183
+ ### File: `neo-tree.lua` {{{
184
+
185
+ **Hides config clutter from file explorer**
186
+
187
+ Files hidden:
188
+ - `eslint.config.js`
189
+ - `jsconfig.json`
190
+ - `vite.config.js`
191
+ - `svelte.config.js`
192
+ - `package-lock.json`
193
+ - `.prettierrc`, `.prettierignore`
194
+ - `.npmrc`, `.gitignore`
195
+
196
+ **Why:** Keep file tree focused on actual code
197
+
198
+ **To modify:**
199
+ Add filenames to the `hide_by_name` and `never_show` arrays.
200
+
201
+ }}}
202
+
203
+ ### File: `svelte.lua` {{{
204
+
205
+ **Sets up Svelte development:**
206
+
207
+ 1. Treesitter parsers: svelte, html, css, js, ts
208
+ 2. Svelte LSP with Svelte 5 support
209
+ 3. Disables annoying a11y warnings
210
+
211
+ **Critical for icarus.mx work**
212
+
213
+ **The config:**
214
+ ```lua
215
+ return {
216
+ -- Treesitter parsers
217
+ {
218
+ "nvim-treesitter/nvim-treesitter",
219
+ opts = function(_, opts)
220
+ vim.list_extend(opts.ensure_installed, {
221
+ "svelte", "html", "css", "javascript", "typescript",
222
+ })
223
+ end,
224
+ },
225
+ -- LSP support
226
+ {
227
+ "neovim/nvim-lspconfig",
228
+ opts = {
229
+ servers = {
230
+ svelte = {
231
+ settings = {
232
+ svelte = {
233
+ plugin = {
234
+ svelte = {
235
+ compilerWarnings = {
236
+ ["a11y-autofocus"] = "ignore",
237
+ ["a11y-click-events-have-key-events"] = "ignore",
238
+ },
239
+ },
240
+ },
241
+ },
242
+ },
243
+ },
244
+ },
245
+ },
246
+ },
247
+ }
248
+ ```
249
+
250
+ }}}
251
+
252
+ ### File: `telescope_noignore.lua` {{{
253
+
254
+ **Overrides LazyVim defaults to search EVERYTHING:**
255
+
256
+ - `--hidden` - Search dotfiles
257
+ - `--no-ignore` - Search node_modules, .git, etc.
258
+ - Shows gitignored files in neo-tree
259
+
260
+ **When you need it:**
261
+ - Finding files in node_modules
262
+ - Debugging .git issues
263
+ - Exploring hidden config files
264
+
265
+ **The config:**
266
+ ```lua
267
+ return {
268
+ {
269
+ "nvim-telescope/telescope.nvim",
270
+ opts = function(_, opts)
271
+ opts.defaults = vim.tbl_deep_extend("force", opts.defaults or {}, {
272
+ vimgrep_arguments = {
273
+ "rg", "--color=never", "--no-heading",
274
+ "--with-filename", "--line-number", "--column",
275
+ "--smart-case", "--hidden", "--no-ignore",
276
+ },
277
+ })
278
+ opts.pickers = vim.tbl_deep_extend("force", opts.pickers or {}, {
279
+ find_files = {
280
+ find_command = { "rg", "--files", "--hidden", "--no-ignore" },
281
+ },
282
+ })
283
+ end,
284
+ },
285
+ }
286
+ ```
287
+
288
+ }}}
289
+
290
+ }}}
291
+
292
+ ## Part 4: Adding New Plugins {{{
293
+
294
+ ### The Pattern {{{
295
+
296
+ **Create a new file:** `~/.config/nvim/lua/plugins/my-plugin.lua`
297
+
298
+ ```lua
299
+ return {
300
+ {
301
+ "author/plugin-name",
302
+ opts = {
303
+ -- plugin options here
304
+ },
305
+ },
306
+ }
307
+ ```
308
+
309
+ **LazyVim automatically loads it** - no imports needed!
310
+
311
+ }}}
312
+
313
+ ### Example: Add GitHub Copilot {{{
314
+
315
+ **File:** `~/.config/nvim/lua/plugins/copilot.lua`
316
+
317
+ ```lua
318
+ return {
319
+ {
320
+ "zbirenbaum/copilot.lua",
321
+ cmd = "Copilot",
322
+ event = "InsertEnter",
323
+ opts = {
324
+ suggestion = { enabled = true, auto_trigger = true },
325
+ panel = { enabled = true },
326
+ },
327
+ },
328
+ }
329
+ ```
330
+
331
+ Save → `:Lazy sync` → Restart → Done
332
+
333
+ }}}
334
+
335
+ ### Example: Add a File Icon Theme {{{
336
+
337
+ **File:** `~/.config/nvim/lua/plugins/devicons.lua`
338
+
339
+ ```lua
340
+ return {
341
+ {
342
+ "nvim-tree/nvim-web-devicons",
343
+ opts = {
344
+ override = {
345
+ md = {
346
+ icon = "📝",
347
+ color = "#519aba",
348
+ name = "Markdown",
349
+ },
350
+ },
351
+ },
352
+ },
353
+ }
354
+ ```
355
+
356
+ This changes the markdown file icon in neo-tree and telescope.
357
+
358
+ }}}
359
+
360
+ ### Practice: Add Your Own Plugin {{{
361
+
362
+ **Exercise: Add a TODO comment highlighter**
363
+
364
+ 1. Create the file:
365
+ ```bash
366
+ nvim ~/.config/nvim/lua/plugins/todo-comments.lua
367
+ ```
368
+
369
+ 2. Add this config:
370
+ ```lua
371
+ return {
372
+ {
373
+ "folke/todo-comments.nvim",
374
+ dependencies = { "nvim-lua/plenary.nvim" },
375
+ opts = {
376
+ signs = true,
377
+ keywords = {
378
+ TODO = { icon = "✓", color = "info" },
379
+ HACK = { icon = "⚠", color = "warning" },
380
+ WARN = { icon = "⚠", color = "warning" },
381
+ NOTE = { icon = "ℹ", color = "hint" },
382
+ },
383
+ },
384
+ },
385
+ }
386
+ ```
387
+
388
+ 3. Save and run `:Lazy sync`
389
+ 4. Restart nvim
390
+ 5. Try it in a JavaScript file:
391
+
392
+ ```javascript
393
+ // TODO: This will be highlighted
394
+ // HACK: So will this
395
+ // NOTE: And this too
396
+ ```
397
+
398
+ 6. Search todos with `:TodoTelescope`
399
+
400
+ }}}
401
+
402
+ }}}
403
+
404
+ ## Part 5: Understanding Plugin Loading {{{
405
+
406
+ ### How LazyVim Loads Plugins {{{
407
+
408
+ When nvim starts:
409
+
410
+ 1. Reads `~/.config/nvim/lua/config/lazy.lua`
411
+ 2. This file tells Lazy.nvim to load all files in `plugins/`
412
+ 3. Each `.lua` file returns a table of plugin specs
413
+ 4. Lazy.nvim merges all specs together
414
+ 5. Plugins install/load based on events (`VeryLazy`, `InsertEnter`, etc.)
415
+
416
+ **Key insight:** Files in `plugins/` don't need to import each other. They're all loaded automatically.
417
+
418
+ }}}
419
+
420
+ ### Plugin Loading Events {{{
421
+
422
+ Common events you'll see:
423
+
424
+ - `VeryLazy` - Load after startup (most plugins)
425
+ - `InsertEnter` - Load when entering insert mode
426
+ - `BufRead` - Load when reading a buffer
427
+ - `FileType` - Load for specific file types
428
+ - `cmd` - Load when command is run
429
+
430
+ **Example:**
431
+ ```lua
432
+ return {
433
+ {
434
+ "ellisonleao/glow.nvim",
435
+ cmd = "Glow", -- Only loads when :Glow is run
436
+ ft = { "markdown" }, -- Only for .md files
437
+ },
438
+ }
439
+ ```
440
+
441
+ This keeps nvim startup fast!
442
+
443
+ }}}
444
+
445
+ ### Overriding vs Extending {{{
446
+
447
+ **Overriding** - Replace default config:
448
+ ```lua
449
+ opts = {
450
+ theme = "latte", -- Replaces entire opts table
451
+ }
452
+ ```
453
+
454
+ **Extending** - Add to default config:
455
+ ```lua
456
+ opts = function(_, opts)
457
+ vim.list_extend(opts.ensure_installed, {
458
+ "svelte", -- Adds to existing list
459
+ })
460
+ end
461
+ ```
462
+
463
+ **Use `opts = function` when you want to keep LazyVim defaults.**
464
+
465
+ }}}
466
+
467
+ }}}
468
+
469
+ ## Part 6: Debugging Plugin Issues {{{
470
+
471
+ ### Common Issues {{{
472
+
473
+ **1. Plugin not loading**
474
+ ```vim
475
+ :Lazy " Open Lazy.nvim UI
476
+ :Lazy log " Check for errors
477
+ :Lazy sync " Force re-sync
478
+ ```
479
+
480
+ **2. Config not applying**
481
+ - Did you save the file?
482
+ - Did you restart nvim?
483
+ - Did you run `:Lazy sync`?
484
+
485
+ **3. Conflicting configs**
486
+ - Check if another file overrides the same plugin
487
+ - LazyVim loads files alphabetically
488
+ - Later files can override earlier ones
489
+
490
+ }}}
491
+
492
+ ### Useful Commands {{{
493
+
494
+ ```vim
495
+ :Lazy " Open plugin manager UI
496
+ :Lazy update " Update all plugins
497
+ :Lazy sync " Install/update/clean plugins
498
+ :Lazy clean " Remove unused plugins
499
+ :Lazy profile " See plugin load times
500
+ :Lazy log " View error logs
501
+
502
+ :checkhealth " Check nvim health
503
+ :LspInfo " Check LSP status
504
+ :Mason " Manage LSP/formatters
505
+ ```
506
+
507
+ }}}
508
+
509
+ ### Practice: Debug a Plugin {{{
510
+
511
+ **Exercise:**
512
+
513
+ 1. Open Lazy UI: `:Lazy`
514
+ 2. Press `p` to see profile (load times)
515
+ 3. Press `l` to see logs
516
+ 4. Find the `catppuccin` plugin
517
+ 5. Press `?` to see help
518
+ 6. Press `q` to close
519
+
520
+ This UI shows you:
521
+ - Which plugins are installed
522
+ - Load order and timing
523
+ - Error messages
524
+ - Update status
525
+
526
+ }}}
527
+
528
+ }}}
529
+
530
+ ## 🎯 Outcomes {{{
531
+
532
+ After this exercise, you can:
533
+
534
+ ✅ Find where your plugins are configured
535
+ ✅ Modify existing plugin settings
536
+ ✅ Add new plugins without breaking LazyVim
537
+ ✅ Understand the difference between `config/` and `plugins/`
538
+ ✅ Know your Neovim ariadna entrypoint: `~/.config/nvim/lua/plugins/`
539
+ ✅ Debug plugin issues using `:Lazy` commands
540
+ ✅ Extend vs override plugin configs
541
+ ✅ Use lazy loading for fast startup
542
+
543
+ **Next Steps:**
544
+ - Explore `example.lua` for more patterns
545
+ - Try adding a plugin you've been wanting
546
+ - Customize keybindings in a new plugin file
547
+ - Browse LazyVim extras: `:LazyExtras`
548
+
549
+ }}}
550
+
551
+ ## 🧭 Reference Links {{{
552
+
553
+ - LazyVim docs: https://lazyvim.org
554
+ - Lazy.nvim plugin manager: https://github.com/folke/lazy.nvim
555
+ - Catppuccin theme: https://github.com/catppuccin/nvim
556
+ - Plugin examples: `~/.config/nvim/lua/plugins/example.lua`
557
+ - LazyVim plugins list: https://www.lazyvim.org/plugins
558
+
559
+ **Your actual config:**
560
+ - Main directory: `~/.config/nvim/`
561
+ - Plugin configs: `~/.config/nvim/lua/plugins/`
562
+ - Core settings: `~/.config/nvim/lua/config/`
563
+
564
+ }}}
@@ -0,0 +1,310 @@
1
+ # Exercise 16: Customizing Fold Keymaps in Neovim (zN instead of zR)
2
+
3
+ **Objective:** Replace the default `zR` (unfold all) mapping with `zN` so you can unfold all folds with a more intuitive keymap that aligns with your nvim muscle memory.
4
+
5
+ **Time to complete:** 15 minutes
6
+
7
+ ---
8
+
9
+ ## Why This Matters
10
+
11
+ Neovim's default fold keymaps follow traditional Vi conventions:
12
+ - `zR` = unfold all (Reduce folds)
13
+ - `zM` = fold all (More folds)
14
+
15
+ The letter choices are cryptic. If you prefer mnemonics like:
16
+ - `zN` = unfold all (N for "opeN")
17
+ - `zM` = fold all (M stays the same - "More folds" works)
18
+
19
+ ...then this exercise shows you how to map them in your `init.lua`.
20
+
21
+ ---
22
+
23
+ ## Step 1: Understand the Default Fold Keymaps
24
+
25
+ First, let's see what fold mappings exist by default.
26
+
27
+ Open your Neovim and check the current mappings:
28
+
29
+ ```vim
30
+ :help fold-commands
31
+ ```
32
+
33
+ The key ones are:
34
+ | Mapping | Action | Default |
35
+ |---------|--------|---------|
36
+ | `zR` | Unfold all | Open all folds in buffer |
37
+ | `zM` | Fold all | Close all folds in buffer |
38
+ | `zr` | Unfold one level | Open one level of folds |
39
+ | `zm` | Fold one level | Close one level of folds |
40
+ | `za` | Toggle fold | Toggle fold at cursor |
41
+
42
+ ---
43
+
44
+ ## Step 2: Locate Your init.lua
45
+
46
+ Your Neovim configuration file is typically at one of these locations:
47
+
48
+ ```bash
49
+ # Check which one exists
50
+ ls ~/.config/nvim/init.lua
51
+ ls ~/AppData/Local/nvim/init.lua # Windows
52
+ ls ~/.config/nvim/init.vim # Old init.vim (less common now)
53
+ ```
54
+
55
+ The standard location on macOS/Linux:
56
+
57
+ ```bash
58
+ ~/.config/nvim/init.lua
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Step 3: Add the Custom Keymap
64
+
65
+ Open your `init.lua` in Neovim:
66
+
67
+ ```bash
68
+ nvim ~/.config/nvim/init.lua
69
+ ```
70
+
71
+ Add these lines to create the `zN` mapping:
72
+
73
+ ```lua
74
+ -- Fold keymaps customization
75
+ -- Use zN to unfold all (instead of zR)
76
+ vim.keymap.set('n', 'zN', 'zR', { noremap = true, silent = true, desc = 'Unfold all' })
77
+
78
+ -- Optional: keep zR as a backup
79
+ -- (Remove this line if you want to completely replace zR with zN)
80
+ -- vim.keymap.set('n', 'zR', 'zN', { noremap = true, silent = true, desc = 'Unfold all (backup)' })
81
+ ```
82
+
83
+ **What each part does:**
84
+ - `'n'` - Normal mode only
85
+ - `'zN'` - The new key you want to press
86
+ - `'zR'` - The command it executes (the built-in unfold all)
87
+ - `noremap = true` - Don't remap recursively
88
+ - `silent = true` - Don't show the command in status line
89
+ - `desc` - Help text when you do `:map zN`
90
+
91
+ ---
92
+
93
+ ## Step 4: Remove or Remap zR
94
+
95
+ If you want `zR` to stop working (force yourself to use `zN`), add this:
96
+
97
+ ```lua
98
+ -- Disable zR so only zN works
99
+ vim.keymap.set('n', 'zR', '<nop>', { noremap = true, silent = true, desc = 'Disabled - use zN instead' })
100
+ ```
101
+
102
+ Or remap `zR` to something else:
103
+
104
+ ```lua
105
+ -- Remap zR to unfold one level (what zr does)
106
+ vim.keymap.set('n', 'zR', 'zr', { noremap = true, silent = true, desc = 'Unfold one level' })
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Step 5: Save and Reload
112
+
113
+ In Neovim:
114
+
115
+ ```vim
116
+ :w " Save the file
117
+ :source % " Reload the configuration
118
+ ```
119
+
120
+ Or exit and restart Neovim:
121
+
122
+ ```bash
123
+ exit
124
+ nvim
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Step 6: Test Your New Mapping
130
+
131
+ 1. Open any file with folds (or create one with folds using `:set foldmethod=syntax`)
132
+ 2. Press `zM` to fold all
133
+ 3. Press `zN` to unfold all
134
+ 4. Verify it works!
135
+
136
+ ---
137
+
138
+ ## Complete Configuration Example
139
+
140
+ Here's what your `~/.config/nvim/init.lua` fold section should look like:
141
+
142
+ ```lua
143
+ -- ============================================================================
144
+ -- FOLD KEYMAPS
145
+ -- ============================================================================
146
+
147
+ -- Custom fold mappings for better muscle memory
148
+ vim.keymap.set('n', 'zN', 'zR', { noremap = true, silent = true, desc = 'Unfold all (zN)' })
149
+ vim.keymap.set('n', 'zM', 'zM', { noremap = true, silent = true, desc = 'Fold all (zM)' })
150
+
151
+ -- Optional: Disable zR to force zN usage
152
+ -- vim.keymap.set('n', 'zR', '<nop>', { noremap = true, silent = true })
153
+
154
+ -- Optional: Map for one-level fold/unfold with intuitive keys
155
+ -- vim.keymap.set('n', 'zn', 'zr', { noremap = true, silent = true, desc = 'Unfold one level' })
156
+ -- vim.keymap.set('n', 'zm', 'zm', { noremap = true, silent = true, desc = 'Fold one level' })
157
+
158
+ -- ============================================================================
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Verification: Check Your Mapping
164
+
165
+ After reloading, verify the mapping exists:
166
+
167
+ ```vim
168
+ :map zN
169
+ ```
170
+
171
+ You should see:
172
+ ```
173
+ n zN zR
174
+ ```
175
+
176
+ This confirms `zN` now executes `zR` (unfold all).
177
+
178
+ ---
179
+
180
+ ## Advanced: Create a Fold Mode Function
181
+
182
+ If you want even more control, create a function:
183
+
184
+ ```lua
185
+ -- Function-based fold toggle
186
+ local function toggle_fold_level()
187
+ -- Get current fold level
188
+ local fold_level = vim.fn.foldlevel(vim.fn.line('.'))
189
+
190
+ if fold_level > 0 then
191
+ vim.cmd('zN') -- Unfold all
192
+ else
193
+ vim.cmd('zM') -- Fold all
194
+ end
195
+ end
196
+
197
+ vim.keymap.set('n', 'z<Space>', toggle_fold_level, { noremap = true, silent = true, desc = 'Toggle fold state' })
198
+ ```
199
+
200
+ Then pressing `z<Space>` intelligently toggles between fold all and unfold all.
201
+
202
+ ---
203
+
204
+ ## Troubleshooting
205
+
206
+ ### Mapping doesn't work
207
+ **Problem:** You press `zN` and nothing happens.
208
+
209
+ **Solution:**
210
+ 1. Verify the mapping was loaded: `:map zN`
211
+ 2. Check for conflicts: `:verbose map zN`
212
+ 3. Make sure you're in Normal mode (press `Esc` first)
213
+ 4. Reload config: `:source %`
214
+
215
+ ### Old mapping still works
216
+ **Problem:** `zR` still unfolds even though you wanted to disable it.
217
+
218
+ **Solution:**
219
+ - Make sure you added the `<nop>` mapping for `zR`
220
+ - Restart Neovim completely (`:q!` then `nvim`)
221
+ - Check if another plugin is defining `zR`: `:verbose map zR`
222
+
223
+ ### Fold commands not working
224
+ **Problem:** `zN` executes but nothing happens.
225
+
226
+ **Solution:**
227
+ - Make sure the buffer has folds: `:set foldmethod=syntax` or `:set foldmethod=manual`
228
+ - The buffer must have fold markers (depends on `foldmethod`)
229
+ - Check the file type supports folding
230
+
231
+ ---
232
+
233
+ ## Related Keymaps Worth Adding
234
+
235
+ While you're customizing folds, consider these related mappings:
236
+
237
+ ```lua
238
+ -- Complete fold mapping suite
239
+ vim.keymap.set('n', 'zN', 'zR', { noremap = true, silent = true, desc = 'Unfold all' })
240
+ vim.keymap.set('n', 'zM', 'zM', { noremap = true, silent = true, desc = 'Fold all' })
241
+ vim.keymap.set('n', 'zn', 'zr', { noremap = true, silent = true, desc = 'Unfold one level' })
242
+ vim.keymap.set('n', 'zm', 'zm', { noremap = true, silent = true, desc = 'Fold one level' })
243
+ vim.keymap.set('n', 'zc', 'zc', { noremap = true, silent = true, desc = 'Close fold' })
244
+ vim.keymap.set('n', 'zo', 'zo', { noremap = true, silent = true, desc = 'Open fold' })
245
+ vim.keymap.set('n', 'za', 'za', { noremap = true, silent = true, desc = 'Toggle fold' })
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Pro Tips
251
+
252
+ 1. **Use modelines** - Add to the top of files you edit frequently:
253
+ ```vim
254
+ " vim: set foldmethod=syntax foldlevel=1 :
255
+ ```
256
+
257
+ 2. **Set default foldlevel** - Add to `init.lua`:
258
+ ```lua
259
+ vim.opt.foldlevel = 1 -- Start with one level of folds open
260
+ ```
261
+
262
+ 3. **Use with LazyVim** - If using LazyVim, add to `~/.config/nvim/lua/config/keymaps.lua`:
263
+ ```lua
264
+ -- Already might have keymaps there
265
+ vim.keymap.set('n', 'zN', 'zR', { desc = 'Unfold all' })
266
+ ```
267
+
268
+ 4. **Vim muscle memory** - Remember: `z` is for "**z**ones" (folds), then:
269
+ - `N` = ope**N** all
270
+ - `M` = **M**ore closed
271
+ - `C` = **C**lose
272
+ - `O` = **O**pen
273
+ - `A` = **A**lternate (toggle)
274
+
275
+ ---
276
+
277
+ ## Summary
278
+
279
+ You've successfully:
280
+ - ✅ Understood Neovim's default fold keymaps
281
+ - ✅ Located your `init.lua` configuration
282
+ - ✅ Created a custom `zN` mapping for unfold all
283
+ - ✅ Optionally disabled the old `zR` mapping
284
+ - ✅ Tested your new configuration
285
+ - ✅ Verified the mapping is active
286
+
287
+ Your new `zN` keymap is now part of your Neovim muscle memory. Use it consistently in your workflow.
288
+
289
+ ---
290
+
291
+ ## Next Steps
292
+
293
+ 1. Create this mapping in your actual `init.lua` right now
294
+ 2. Test it for the next week in your daily editing
295
+ 3. If you like it, consider adding the one-level mappings (`zn` and `zm`)
296
+ 4. Move on to Exercise 17 when you're comfortable with fold navigation
297
+
298
+ ---
299
+
300
+ ## Resources
301
+
302
+ - `:help fold-commands` - Full fold command documentation
303
+ - `:help mapping` - Full mapping documentation
304
+ - `:help option-window` - View all fold-related options
305
+ - `:map` - List all current mappings
306
+ - `:verbose map zN` - See where a mapping is defined
307
+
308
+ ---
309
+
310
+ **Keep it simple.** Just two lines for the basic mapping. Everything else is optional optimization.
@@ -0,0 +1,373 @@
1
+ # Customizing Fold Keymaps in Ariadna (zN instead of zR)
2
+
3
+ <!-- vim: set foldmethod=marker foldlevel=0: -->
4
+
5
+ ## 📖 Ariadna Reading Guide {{{
6
+
7
+ **Start with:** `zM` (close all folds) → Navigate with `za` (toggle fold under cursor)
8
+
9
+ **Keys for navigation:**
10
+ - `}` - Jump to next section
11
+ - `{` - Jump to previous section
12
+ - `zM` - Close all folds (overview mode)
13
+ - `zN` - Open all folds (will use this after implementing!)
14
+
15
+ }}}
16
+
17
+ ## 🎯 Purpose {{{
18
+
19
+ **What:** Replace Neovim's default fold keymaps with more intuitive ones
20
+ **Why:** The default `zR` is cryptic; `zN` (for "opeN") is more memorable
21
+ **Time:** 10 minutes
22
+ **Level:** 🟢 Beginner
23
+ **Entrypoint for ariadna setup:** `~/.config/nvim/lua/plugins/`
24
+
25
+ }}}
26
+
27
+ ## Part 1: Understanding Default Fold Commands {{{
28
+
29
+ ### Why Fold Commands Matter {{{
30
+
31
+ Ariadna uses fold markers (`{{{` and `}}}`) throughout documentation to create navigable sections. But the default Neovim keymaps are cryptic:
32
+
33
+ - `zR` = unfold all (Reduce? No one knows...)
34
+ - `zM` = fold all (More folds? Still confusing!)
35
+ - `zr` = unfold one level
36
+ - `zm` = fold one level
37
+
38
+ These follow old Vi conventions, not modern mnemonics.
39
+
40
+ }}}
41
+
42
+ ### The Better Alternative {{{
43
+
44
+ We want:
45
+ - `zN` = unfold all (N for "**opeN**")
46
+ - `zM` = fold all (M for "**More** closed" - keep this)
47
+ - `zn` = unfold one level (lowercase n)
48
+ - `zm` = fold one level (lowercase m)
49
+
50
+ This is much more memorable and aligns with your muscle memory.
51
+
52
+ }}}
53
+
54
+ }}}
55
+
56
+ ## Part 2: Creating the Plugin File {{{
57
+
58
+ ### Step 1: Create the Folds Plugin {{{
59
+
60
+ Create a new file in Ariadna's plugin directory:
61
+
62
+ ```bash
63
+ nvim ~/.config/nvim/lua/plugins/folds.lua
64
+ ```
65
+
66
+ This is where all Ariadna plugins live. LazyVim auto-loads every `.lua` file in this directory.
67
+
68
+ }}}
69
+
70
+ ### Step 2: Add the Configuration {{{
71
+
72
+ Add this to `folds.lua`:
73
+
74
+ ```lua
75
+ -- Custom fold keymaps for Ariadna
76
+ -- Replace cryptic zR/zM with intuitive zN/zM
77
+
78
+ return {
79
+ {
80
+ "fold-keymaps/custom",
81
+ init = function()
82
+ local map = vim.keymap.set
83
+
84
+ -- Main fold commands
85
+ map("n", "zN", "zR", { desc = "Unfold all (zN = opeN)" })
86
+ map("n", "zM", "zM", { desc = "Fold all (zM = More closed)" })
87
+
88
+ -- Optional: One-level fold/unfold
89
+ map("n", "zn", "zr", { desc = "Unfold one level" })
90
+ map("n", "zm", "zm", { desc = "Fold one level" })
91
+
92
+ -- Optional: Disable zR to force zN usage
93
+ -- Uncomment if you want to completely replace zR
94
+ -- map("n", "zR", "<nop>", { desc = "Use zN instead (unfold all)" })
95
+ end,
96
+ },
97
+ }
98
+ ```
99
+
100
+ **What each mapping does:**
101
+ - `map("n", "zN", "zR", ...)` - In Normal mode, pressing `zN` executes `zR` (unfold all)
102
+ - `desc` - Help text for `:map zN` or which-key
103
+
104
+ }}}
105
+
106
+ ### Step 3: Save and Reload {{{
107
+
108
+ In Neovim:
109
+
110
+ ```vim
111
+ :w " Save folds.lua
112
+ :source % " Reload configuration
113
+ ```
114
+
115
+ Or exit and restart Neovim - LazyVim will auto-load the new plugin.
116
+
117
+ }}}
118
+
119
+ }}}
120
+
121
+ ## Part 3: Testing Your Custom Keymaps {{{
122
+
123
+ ### Test Zone: Try Your New Keymaps {{{
124
+
125
+ Now that you've created `folds.lua`, test it:
126
+
127
+ 1. **Fold all content:**
128
+ Press `zM` (or `zm zm zm...` to fold level by level)
129
+
130
+ 2. **Unfold all content:**
131
+ Press `zN` (this is your new mapping!)
132
+
133
+ 3. **Verify it works:**
134
+ Check the output shows all sections visible again
135
+
136
+ 4. **One-level folds:**
137
+ Try `zn` (unfold one level) and `zm` (fold one level)
138
+
139
+ The keymaps should respond immediately. If they don't:
140
+ - Did you save `folds.lua`?
141
+ - Did you reload nvim?
142
+ - Check: `:map zN` should show the mapping
143
+
144
+ }}}
145
+
146
+ ### Advanced: Verify the Mapping {{{
147
+
148
+ In Neovim, run:
149
+
150
+ ```vim
151
+ :map zN
152
+ ```
153
+
154
+ You should see output like:
155
+
156
+ ```
157
+ n zN zR
158
+ ```
159
+
160
+ This confirms `zN` is mapped to `zR` (unfold all). If nothing shows, the mapping didn't load.
161
+
162
+ }}}
163
+
164
+ }}}
165
+
166
+ ## Part 4: Ariadna-Specific Context {{{
167
+
168
+ ### Why This Matters for Ariadna Users {{{
169
+
170
+ Ariadna documents are built with fold markers for optimal navigation:
171
+
172
+ ```lua
173
+ -- These fold markers structure everything
174
+ -- {{{ = start fold
175
+ -- }}} = end fold
176
+ ```
177
+
178
+ When you're reading Ariadna docs or editing structured Lua files, you'll:
179
+
180
+ 1. Start with `zM` (fold all) to see structure
181
+ 2. Navigate with `}` to jump sections
182
+ 3. Use `za` to toggle individual folds
183
+ 4. Use `zN` to unfold everything when you need full content
184
+
185
+ This is the "Ariadna way" of reading documentation.
186
+
187
+ }}}
188
+
189
+ ### Where You'll Use This {{{
190
+
191
+ Every Ariadna document uses this pattern:
192
+
193
+ - `01-developing-muscle-for-nvim.md` - Has fold markers
194
+ - `15-nvim-plugin-architecture.md` - Heavily folded
195
+ - Your own `.md` files - You'll add fold markers too
196
+
197
+ Plus any Lua files you write in `~/.config/nvim/lua/` will benefit from custom fold navigation.
198
+
199
+ }}}
200
+
201
+ }}}
202
+
203
+ ## Part 5: Optional Customizations {{{
204
+
205
+ ### Option 1: Disable Old zR Mapping {{{
206
+
207
+ If you want to completely replace `zR` with `zN` (force new muscle memory):
208
+
209
+ **Edit** `~/.config/nvim/lua/plugins/folds.lua`:
210
+
211
+ ```lua
212
+ -- Disable zR to force zN usage
213
+ map("n", "zR", "<nop>", { desc = "Use zN instead" })
214
+ ```
215
+
216
+ This makes `zR` do nothing, so you're forced to use `zN`.
217
+
218
+ }}}
219
+
220
+ ### Option 2: Add Custom Fold Default Level {{{
221
+
222
+ You can set the default fold level when opening files:
223
+
224
+ ```lua
225
+ vim.opt.foldlevel = 1 -- Start with one level open
226
+ ```
227
+
228
+ Add this to `~/.config/nvim/lua/config/options.lua` (or create a new section in folds.lua):
229
+
230
+ ```lua
231
+ init = function()
232
+ -- Set default fold behavior
233
+ vim.opt.foldlevel = 1
234
+ vim.opt.foldmethod = "marker" -- Use {{{ }}} markers
235
+ end
236
+ ```
237
+
238
+ }}}
239
+
240
+ ### Option 3: Add Smart Fold Toggle {{{
241
+
242
+ Create a function that intelligently toggles between fold all/unfold all:
243
+
244
+ ```lua
245
+ local function smart_fold_toggle()
246
+ local fold_level = vim.fn.foldlevel(vim.fn.line('.'))
247
+ if fold_level > 0 then
248
+ vim.cmd('zN') -- Unfold all
249
+ else
250
+ vim.cmd('zM') -- Fold all
251
+ end
252
+ end
253
+
254
+ map("n", "z<Space>", smart_fold_toggle, { desc = "Smart fold toggle" })
255
+ ```
256
+
257
+ Now `z<Space>` intelligently switches between folded/unfolded state.
258
+
259
+ }}}
260
+
261
+ }}}
262
+
263
+ ## Part 6: Troubleshooting {{{
264
+
265
+ ### Mapping Doesn't Work {{{
266
+
267
+ **Problem:** You press `zN` and nothing happens.
268
+
269
+ **Solutions:**
270
+ 1. Verify mapping loaded: `:map zN` (should show output)
271
+ 2. Reload config: `:source %` or restart nvim
272
+ 3. Check you're in Normal mode (press `Esc` first)
273
+ 4. Verify `folds.lua` file exists: `ls ~/.config/nvim/lua/plugins/folds.lua`
274
+
275
+ }}}
276
+
277
+ ### Old zR Mapping Still Works {{{
278
+
279
+ **Problem:** `zR` still unfolds even though you wanted to disable it.
280
+
281
+ **Solutions:**
282
+ 1. Make sure you added the `<nop>` mapping in `folds.lua`
283
+ 2. Restart Neovim completely (`:q!` then `nvim`)
284
+ 3. Check for conflicts: `:verbose map zR`
285
+
286
+ }}}
287
+
288
+ ### File Has No Folds {{{
289
+
290
+ **Problem:** `zM` doesn't do anything.
291
+
292
+ **Solutions:**
293
+ 1. File must use fold markers: `{{{` and `}}}`
294
+ 2. Set foldmethod: `:set foldmethod=marker`
295
+ 3. Try on an Ariadna document that has fold markers
296
+
297
+ }}}
298
+
299
+ }}}
300
+
301
+ ## 🎯 Outcomes {{{
302
+
303
+ After this exercise, you can:
304
+
305
+ ✅ Create custom Neovim keymaps in Ariadna plugin files
306
+ ✅ Replace cryptic default keymaps with intuitive ones
307
+ ✅ Use `zN` instead of `zR` for "open" all folds
308
+ ✅ Structure your Lua files with fold markers for navigation
309
+ ✅ Read Ariadna documentation using fold navigation
310
+ ✅ Customize Ariadna's behavior without forking the repo
311
+ ✅ Debug and verify custom keymaps with `:map`
312
+
313
+ **Your new workflow:**
314
+ - `zM` - Fold all (see structure)
315
+ - `}` - Jump to next section
316
+ - `za` - Toggle individual fold
317
+ - `zN` - Unfold all (see content)
318
+
319
+ **Next Steps:**
320
+ - Try the custom `zN` mapping in actual Ariadna files
321
+ - Add fold markers to your own documentation
322
+ - Experiment with one-level folds (`zn`/`zm`)
323
+ - Move on to Exercise 18 when comfortable
324
+
325
+ }}}
326
+
327
+ ## 🧭 Reference Links {{{
328
+
329
+ **Ariadna Locations:**
330
+ - Plugin files: `~/.config/nvim/lua/plugins/`
331
+ - Core settings: `~/.config/nvim/lua/config/`
332
+ - Your config: `~/.config/nvim/init.lua`
333
+
334
+ **Neovim Documentation:**
335
+ - `:help fold-commands` - Full fold documentation
336
+ - `:help map` - Mapping documentation
337
+ - `:help foldmethod` - Fold detection options
338
+
339
+ **Vim Mnemonics:**
340
+ - `z` = zones (folds)
341
+ - `N` = ope**N** (unfold all)
342
+ - `M` = **M**ore folds (fold all)
343
+ - `n` = ope**n** (unfold one level)
344
+ - `m` = **m**ore folds (fold one level)
345
+
346
+ **Related Exercises:**
347
+ - Exercise 01 - Developing Muscle Memory (uses fold navigation)
348
+ - Exercise 15 - LazyVim Plugin Architecture (plugin structure)
349
+
350
+ }}}
351
+
352
+ ## 📝 Quick Reference: What You Just Created {{{
353
+
354
+ **File:** `~/.config/nvim/lua/plugins/folds.lua`
355
+
356
+ **What it does:**
357
+ 1. Maps `zN` to `zR` (unfold all)
358
+ 2. Maps `zM` to `zM` (fold all - no change needed)
359
+ 3. Maps `zn` to `zr` (unfold one level - optional)
360
+ 4. Maps `zm` to `zm` (fold one level - optional)
361
+
362
+ **How to modify:**
363
+ - Edit the file and save
364
+ - Reload: `:source %` or restart nvim
365
+ - Verify: `:map zN`
366
+
367
+ **How to remove:**
368
+ ```bash
369
+ rm ~/.config/nvim/lua/plugins/folds.lua
370
+ # Then restart nvim
371
+ ```
372
+
373
+ }}}
@@ -112,6 +112,12 @@ Each phase builds on knowledge from previous phases.
112
112
  **Time:** Design exercise
113
113
  **Level:** 🔴 Advanced
114
114
 
115
+ ### 15. [Understanding LazyVim Plugin Architecture](./15-nvim-plugin-architecture.md)
116
+ **What:** Master your Neovim plugin configuration structure
117
+ **Why:** Add/modify plugins without breaking your setup
118
+ **Time:** 20 minutes
119
+ **Level:** 🟡 Intermediate
120
+
115
121
  ---
116
122
 
117
123
  ## 🎯 How to Use These Guides
@@ -153,6 +159,10 @@ Prefer to browse by subject?
153
159
  - [Shell Aliases](./13-shell-aliases.md)
154
160
  - [curl + Pipes](./06-curl-and-pipes.md)
155
161
 
162
+ ### Neovim Configuration
163
+ - [Developing Muscle Memory for Neovim](./01-developing-muscle-for-nvim.md)
164
+ - [Understanding LazyVim Plugin Architecture](./15-nvim-plugin-architecture.md)
165
+
156
166
  ### JavaScript & Development
157
167
  - [Array & Object Manipulation](./04-array-object-manipulation.md)
158
168
  - [SvelteKit First Steps](./05-svelte-first-steps.md)
@@ -170,6 +180,7 @@ Prefer to browse by subject?
170
180
 
171
181
  ### Meta/Tooling
172
182
  - [Install Skills Command](./12-install-skills.md)
183
+ - [Understanding LazyVim Plugin Architecture](./15-nvim-plugin-architecture.md)
173
184
 
174
185
  ---
175
186
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icarusmx/creta",
3
- "version": "1.5.17",
3
+ "version": "1.5.19",
4
4
  "description": "Salgamos de este laberinto.",
5
5
  "type": "module",
6
6
  "bin": {