@icarusmx/creta 1.5.6 → 1.5.7
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,367 @@
|
|
|
1
|
+
import { createInterface } from 'readline'
|
|
2
|
+
import { execSync } from 'child_process'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
|
|
5
|
+
export class VimSetupTutorial {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.rl = null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async start() {
|
|
11
|
+
this.rl = createInterface({
|
|
12
|
+
input: process.stdin,
|
|
13
|
+
output: process.stdout
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
await this.showWelcome()
|
|
18
|
+
await this.checkPrerequisites()
|
|
19
|
+
await this.showFeatures()
|
|
20
|
+
await this.showInstallationOptions()
|
|
21
|
+
await this.showEssentialKeybindings()
|
|
22
|
+
await this.showFirstWorkflow()
|
|
23
|
+
await this.showHelpResources()
|
|
24
|
+
await this.completion()
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('\n❌ Error en el tutorial:', error.message)
|
|
27
|
+
} finally {
|
|
28
|
+
this.rl.close()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async showWelcome() {
|
|
33
|
+
console.clear()
|
|
34
|
+
console.log(chalk.cyan('\n🏛️ Creta Vim - Configuración Oficial de Neovim'))
|
|
35
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
36
|
+
console.log('\nCreta Vim es una distribución de LazyVim optimizada para')
|
|
37
|
+
console.log('el stack de Icarus, con tema personalizado, plugins esenciales')
|
|
38
|
+
console.log('y documentación en español.')
|
|
39
|
+
console.log('\n' + chalk.italic('"Salgamos de este laberinto" 🏛️'))
|
|
40
|
+
|
|
41
|
+
await this.pressEnter('\nPresiona Enter para comenzar...')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async checkPrerequisites() {
|
|
45
|
+
console.clear()
|
|
46
|
+
console.log(chalk.cyan('\n📋 Verificando Requisitos'))
|
|
47
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
48
|
+
console.log('\nCreta Vim requiere las siguientes herramientas:\n')
|
|
49
|
+
|
|
50
|
+
const checks = []
|
|
51
|
+
|
|
52
|
+
// Check Neovim
|
|
53
|
+
try {
|
|
54
|
+
const nvimVersion = execSync('nvim --version 2>/dev/null | head -n1', { encoding: 'utf8' }).trim()
|
|
55
|
+
checks.push({
|
|
56
|
+
name: 'Neovim',
|
|
57
|
+
status: 'ok',
|
|
58
|
+
version: nvimVersion.replace('NVIM v', ''),
|
|
59
|
+
required: '>= 0.10.0'
|
|
60
|
+
})
|
|
61
|
+
} catch (error) {
|
|
62
|
+
checks.push({
|
|
63
|
+
name: 'Neovim',
|
|
64
|
+
status: 'missing',
|
|
65
|
+
required: '>= 0.10.0',
|
|
66
|
+
install: 'macOS: brew install neovim | Linux: https://github.com/neovim/neovim/releases'
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Check Git
|
|
71
|
+
try {
|
|
72
|
+
const gitVersion = execSync('git --version 2>/dev/null', { encoding: 'utf8' }).trim()
|
|
73
|
+
checks.push({
|
|
74
|
+
name: 'Git',
|
|
75
|
+
status: 'ok',
|
|
76
|
+
version: gitVersion.replace('git version ', ''),
|
|
77
|
+
required: '>= 2.19.0'
|
|
78
|
+
})
|
|
79
|
+
} catch (error) {
|
|
80
|
+
checks.push({
|
|
81
|
+
name: 'Git',
|
|
82
|
+
status: 'missing',
|
|
83
|
+
required: '>= 2.19.0',
|
|
84
|
+
install: 'https://git-scm.com/downloads'
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Check Node.js
|
|
89
|
+
try {
|
|
90
|
+
const nodeVersion = execSync('node --version 2>/dev/null', { encoding: 'utf8' }).trim()
|
|
91
|
+
checks.push({
|
|
92
|
+
name: 'Node.js',
|
|
93
|
+
status: 'ok',
|
|
94
|
+
version: nodeVersion,
|
|
95
|
+
required: '>= 18.0.0'
|
|
96
|
+
})
|
|
97
|
+
} catch (error) {
|
|
98
|
+
checks.push({
|
|
99
|
+
name: 'Node.js',
|
|
100
|
+
status: 'warning',
|
|
101
|
+
required: '>= 18.0.0',
|
|
102
|
+
note: 'Necesario para LSP servers (autocompletado, errores, etc.)',
|
|
103
|
+
install: 'https://nodejs.org'
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Check Nerd Font (optional but recommended)
|
|
108
|
+
checks.push({
|
|
109
|
+
name: 'Nerd Font',
|
|
110
|
+
status: 'recommended',
|
|
111
|
+
note: 'Necesario para iconos en la interfaz',
|
|
112
|
+
install: 'https://www.nerdfonts.com/font-downloads (recomendado: JetBrains Mono)'
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
// Display results
|
|
116
|
+
checks.forEach(check => {
|
|
117
|
+
if (check.status === 'ok') {
|
|
118
|
+
console.log(chalk.green('✓') + ` ${check.name}: ${check.version}`)
|
|
119
|
+
} else if (check.status === 'missing') {
|
|
120
|
+
console.log(chalk.red('✗') + ` ${check.name}: No instalado`)
|
|
121
|
+
console.log(chalk.gray(` Requerido: ${check.required}`))
|
|
122
|
+
console.log(chalk.gray(` Instalar: ${check.install}`))
|
|
123
|
+
} else if (check.status === 'warning') {
|
|
124
|
+
console.log(chalk.yellow('⚠') + ` ${check.name}: No instalado (opcional pero recomendado)`)
|
|
125
|
+
console.log(chalk.gray(` ${check.note}`))
|
|
126
|
+
console.log(chalk.gray(` Instalar: ${check.install}`))
|
|
127
|
+
} else if (check.status === 'recommended') {
|
|
128
|
+
console.log(chalk.yellow('💡') + ` ${check.name}: Recomendado`)
|
|
129
|
+
console.log(chalk.gray(` ${check.note}`))
|
|
130
|
+
console.log(chalk.gray(` Instalar: ${check.install}`))
|
|
131
|
+
}
|
|
132
|
+
console.log()
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const missingRequired = checks.filter(c => c.status === 'missing')
|
|
136
|
+
if (missingRequired.length > 0) {
|
|
137
|
+
console.log(chalk.red('\n⚠️ Instala las herramientas requeridas antes de continuar.'))
|
|
138
|
+
console.log(chalk.gray(' Una vez instaladas, vuelve a ejecutar: creta'))
|
|
139
|
+
process.exit(1)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
await this.pressEnter('Presiona Enter para continuar...')
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async showFeatures() {
|
|
146
|
+
console.clear()
|
|
147
|
+
console.log(chalk.cyan('\n✨ Características de Creta Vim'))
|
|
148
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
149
|
+
|
|
150
|
+
console.log('\n' + chalk.bold('🎨 Estética Icarus'))
|
|
151
|
+
console.log(' • Tema: Kanagawa Wave (modo transparente)')
|
|
152
|
+
console.log(' • Welcome screen personalizada de Creta')
|
|
153
|
+
console.log(' • Iconos con Nerd Fonts')
|
|
154
|
+
|
|
155
|
+
console.log('\n' + chalk.bold('🚀 Optimizado para el Stack de Icarus'))
|
|
156
|
+
console.log(' • SvelteKit 5: Syntax highlighting, LSP, snippets')
|
|
157
|
+
console.log(' • Tailwind CSS 4: Autocompletado, preview de colores')
|
|
158
|
+
console.log(' • JavaScript/Node.js: ESLint, Prettier, debugging')
|
|
159
|
+
|
|
160
|
+
console.log('\n' + chalk.bold('📦 Plugins Pre-configurados'))
|
|
161
|
+
console.log(' • Telescope: Búsqueda rápida de archivos')
|
|
162
|
+
console.log(' • Neotree: Explorador de archivos')
|
|
163
|
+
console.log(' • Gitsigns: Indicadores de Git')
|
|
164
|
+
console.log(' • Markdown: Renderizado inline + preview')
|
|
165
|
+
console.log(' • LSP: TypeScript, Svelte, Tailwind, Lua')
|
|
166
|
+
|
|
167
|
+
console.log('\n' + chalk.bold('📚 Documentación en Español'))
|
|
168
|
+
console.log(' • Cheatsheet de keybindings')
|
|
169
|
+
console.log(' • Tutoriales integrados')
|
|
170
|
+
console.log(' • Mensajes de ayuda traducidos')
|
|
171
|
+
|
|
172
|
+
await this.pressEnter('\nPresiona Enter para ver opciones de instalación...')
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async showInstallationOptions() {
|
|
176
|
+
console.clear()
|
|
177
|
+
console.log(chalk.cyan('\n🚀 Opciones de Instalación'))
|
|
178
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
179
|
+
|
|
180
|
+
console.log('\n' + chalk.bold('Opción 1: Instalación Limpia') + chalk.gray(' (Recomendado para nuevos estudiantes)'))
|
|
181
|
+
console.log('\n' + chalk.gray('# Respaldar configuración actual (si existe)'))
|
|
182
|
+
console.log(chalk.yellow('mv ~/.config/nvim ~/.config/nvim.backup'))
|
|
183
|
+
console.log(chalk.yellow('mv ~/.local/share/nvim ~/.local/share/nvim.backup'))
|
|
184
|
+
console.log('\n' + chalk.gray('# Clonar Creta Vim'))
|
|
185
|
+
console.log(chalk.yellow('git clone https://github.com/icarusmx/creta-vim.git ~/.config/nvim'))
|
|
186
|
+
console.log('\n' + chalk.gray('# Abrir Neovim (instalará plugins automáticamente)'))
|
|
187
|
+
console.log(chalk.yellow('nvim'))
|
|
188
|
+
|
|
189
|
+
console.log('\n' + chalk.bold('Primera vez:'))
|
|
190
|
+
console.log(' • Lazy.nvim instalará todos los plugins (~2 minutos)')
|
|
191
|
+
console.log(' • Mason instalará LSP servers automáticamente')
|
|
192
|
+
console.log(' • Presiona `q` cuando termine')
|
|
193
|
+
console.log(' • Reinicia Nvim: `:q` y vuelve a abrir `nvim`')
|
|
194
|
+
|
|
195
|
+
console.log('\n' + chalk.gray('─'.repeat(60)))
|
|
196
|
+
|
|
197
|
+
console.log('\n' + chalk.bold('Opción 2: Probar sin Afectar tu Configuración'))
|
|
198
|
+
console.log('\n' + chalk.gray('# Clonar en directorio temporal'))
|
|
199
|
+
console.log(chalk.yellow('git clone https://github.com/icarusmx/creta-vim.git ~/creta-vim-test'))
|
|
200
|
+
console.log('\n' + chalk.gray('# Abrir con configuración aislada'))
|
|
201
|
+
console.log(chalk.yellow('NVIM_APPNAME=creta-vim-test nvim'))
|
|
202
|
+
console.log('\n' + chalk.gray('Esto no toca tu configuración actual de Nvim.'))
|
|
203
|
+
|
|
204
|
+
await this.pressEnter('\nPresiona Enter para ver keybindings esenciales...')
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async showEssentialKeybindings() {
|
|
208
|
+
console.clear()
|
|
209
|
+
console.log(chalk.cyan('\n⌨️ Keybindings Esenciales'))
|
|
210
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
211
|
+
|
|
212
|
+
console.log('\n' + chalk.bold('General'))
|
|
213
|
+
const generalBindings = [
|
|
214
|
+
['<leader>', 'Space (tecla líder)'],
|
|
215
|
+
['<leader><leader>', 'Buscar archivos (Telescope)'],
|
|
216
|
+
['<leader>e', 'Toggle explorador de archivos'],
|
|
217
|
+
['<leader>ff', 'Buscar archivos por nombre'],
|
|
218
|
+
['<leader>fg', 'Buscar texto en proyecto (grep)'],
|
|
219
|
+
]
|
|
220
|
+
this.displayTable(generalBindings)
|
|
221
|
+
|
|
222
|
+
console.log('\n' + chalk.bold('Navegación'))
|
|
223
|
+
const navBindings = [
|
|
224
|
+
['Ctrl+h/j/k/l', 'Navegar entre ventanas'],
|
|
225
|
+
['<leader>sv', 'Split vertical'],
|
|
226
|
+
['<leader>sh', 'Split horizontal'],
|
|
227
|
+
['gd', 'Ir a definición'],
|
|
228
|
+
['gr', 'Ver referencias'],
|
|
229
|
+
['K', 'Mostrar documentación (hover)'],
|
|
230
|
+
]
|
|
231
|
+
this.displayTable(navBindings)
|
|
232
|
+
|
|
233
|
+
console.log('\n' + chalk.bold('Edición'))
|
|
234
|
+
const editBindings = [
|
|
235
|
+
['gcc', 'Comentar/descomentar línea'],
|
|
236
|
+
['gc (visual)', 'Comentar selección'],
|
|
237
|
+
['<leader>ca', 'Code actions (refactors)'],
|
|
238
|
+
['<leader>rn', 'Renombrar símbolo'],
|
|
239
|
+
]
|
|
240
|
+
this.displayTable(editBindings)
|
|
241
|
+
|
|
242
|
+
console.log('\n' + chalk.bold('Git'))
|
|
243
|
+
const gitBindings = [
|
|
244
|
+
['<leader>gg', 'Abrir Lazygit'],
|
|
245
|
+
[']h', 'Siguiente cambio (hunk)'],
|
|
246
|
+
['[h', 'Anterior cambio (hunk)'],
|
|
247
|
+
['<leader>gp', 'Preview cambio'],
|
|
248
|
+
]
|
|
249
|
+
this.displayTable(gitBindings)
|
|
250
|
+
|
|
251
|
+
await this.pressEnter('\nPresiona Enter para ver tu primer flujo de trabajo...')
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async showFirstWorkflow() {
|
|
255
|
+
console.clear()
|
|
256
|
+
console.log(chalk.cyan('\n🎓 Tu Primer Flujo de Trabajo'))
|
|
257
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
258
|
+
|
|
259
|
+
console.log('\n' + chalk.bold('1. Familiarízate con los modos:'))
|
|
260
|
+
console.log(' • ' + chalk.yellow('Normal') + ' - Navegación (ESC para volver aquí)')
|
|
261
|
+
console.log(' • ' + chalk.yellow('Insert') + ' - Edición (i, a, o para entrar)')
|
|
262
|
+
console.log(' • ' + chalk.yellow('Visual') + ' - Selección (v para entrar)')
|
|
263
|
+
console.log(' • ' + chalk.yellow('Command') + ' - Comandos (: para entrar)')
|
|
264
|
+
|
|
265
|
+
console.log('\n' + chalk.bold('2. Practica navegación básica:'))
|
|
266
|
+
console.log(' • ' + chalk.yellow('h j k l') + ' → ← ↓ ↑')
|
|
267
|
+
console.log(' • ' + chalk.yellow('w b') + ' → Siguiente/anterior palabra')
|
|
268
|
+
console.log(' • ' + chalk.yellow('gg G') + ' → Inicio/fin de archivo')
|
|
269
|
+
console.log(' • ' + chalk.yellow('Ctrl+d/u') + ' → Media página abajo/arriba')
|
|
270
|
+
|
|
271
|
+
console.log('\n' + chalk.bold('3. Flujo completo de edición:'))
|
|
272
|
+
const workflow = [
|
|
273
|
+
['1.', 'nvim', 'Abrir Nvim'],
|
|
274
|
+
['2.', 'Space Space', 'Buscar archivo'],
|
|
275
|
+
['3.', 'Type filename', 'Escribir nombre'],
|
|
276
|
+
['4.', 'Enter', 'Abrir archivo'],
|
|
277
|
+
['5.', 'i', 'Entrar a modo Insert'],
|
|
278
|
+
['6.', '(editar código)', ''],
|
|
279
|
+
['7.', 'Esc', 'Volver a Normal'],
|
|
280
|
+
['8.', ':w', 'Guardar'],
|
|
281
|
+
['9.', 'Space e', 'Ver archivos'],
|
|
282
|
+
['10.', ':q', 'Salir'],
|
|
283
|
+
]
|
|
284
|
+
|
|
285
|
+
console.log()
|
|
286
|
+
workflow.forEach(([step, command, description]) => {
|
|
287
|
+
const stepStr = chalk.gray(step.padEnd(4))
|
|
288
|
+
const cmdStr = chalk.yellow(command.padEnd(20))
|
|
289
|
+
const descStr = description
|
|
290
|
+
console.log(` ${stepStr}${cmdStr}${descStr}`)
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
await this.pressEnter('\nPresiona Enter para ver recursos de ayuda...')
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
async showHelpResources() {
|
|
297
|
+
console.clear()
|
|
298
|
+
console.log(chalk.cyan('\n🆘 Recursos de Ayuda'))
|
|
299
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
300
|
+
|
|
301
|
+
console.log('\n' + chalk.bold('Dentro de Nvim:'))
|
|
302
|
+
console.log(' ' + chalk.yellow(':help creta') + ' - Ayuda de Creta Vim')
|
|
303
|
+
console.log(' ' + chalk.yellow(':Lazy') + ' - Ver/actualizar plugins')
|
|
304
|
+
console.log(' ' + chalk.yellow(':Mason') + ' - Ver/instalar LSP servers')
|
|
305
|
+
console.log(' ' + chalk.yellow(':checkhealth') + ' - Diagnosticar problemas')
|
|
306
|
+
console.log(' ' + chalk.yellow(':LspInfo') + ' - Ver LSP servers activos')
|
|
307
|
+
|
|
308
|
+
console.log('\n' + chalk.bold('Tutoriales integrados:'))
|
|
309
|
+
console.log(' ' + chalk.yellow(':Tutor') + ' - Tutorial oficial de Vim (español)')
|
|
310
|
+
console.log(' ' + chalk.yellow(':CretaBasics') + ' - Básicos de Creta Vim')
|
|
311
|
+
console.log(' ' + chalk.yellow(':CretaGit') + ' - Flujo de Git con Lazygit')
|
|
312
|
+
console.log(' ' + chalk.yellow(':CretaSvelte') + ' - Editar SvelteKit como pro')
|
|
313
|
+
|
|
314
|
+
console.log('\n' + chalk.bold('Problemas Comunes:'))
|
|
315
|
+
|
|
316
|
+
console.log('\n ' + chalk.red('LSP no funciona:'))
|
|
317
|
+
console.log(' ' + chalk.yellow(':Mason'))
|
|
318
|
+
console.log(' ' + chalk.gray('Buscar e instalar: vtsls, svelte-language-server, tailwindcss-language-server'))
|
|
319
|
+
|
|
320
|
+
console.log('\n ' + chalk.red('Iconos no se ven bien:'))
|
|
321
|
+
console.log(' ' + chalk.gray('Instala una Nerd Font: https://www.nerdfonts.com'))
|
|
322
|
+
console.log(' ' + chalk.gray('Configura tu terminal para usarla'))
|
|
323
|
+
|
|
324
|
+
console.log('\n ' + chalk.red('Plugins no cargan:'))
|
|
325
|
+
console.log(' ' + chalk.yellow(':Lazy sync') + ' ' + chalk.gray('- Sincronizar plugins'))
|
|
326
|
+
console.log(' ' + chalk.yellow(':Lazy clean') + ' ' + chalk.gray('- Limpiar plugins no usados'))
|
|
327
|
+
|
|
328
|
+
await this.pressEnter('\nPresiona Enter para finalizar...')
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async completion() {
|
|
332
|
+
console.clear()
|
|
333
|
+
console.log(chalk.cyan('\n🎉 ¡Listo para comenzar!'))
|
|
334
|
+
console.log(chalk.gray('═'.repeat(60)))
|
|
335
|
+
|
|
336
|
+
console.log('\n' + chalk.bold('Próximos pasos:'))
|
|
337
|
+
console.log(' 1. Elige una opción de instalación (arriba)')
|
|
338
|
+
console.log(' 2. Sigue los comandos de instalación')
|
|
339
|
+
console.log(' 3. Abre Neovim: ' + chalk.yellow('nvim'))
|
|
340
|
+
console.log(' 4. Espera a que Mason instale LSP servers (~1 min)')
|
|
341
|
+
console.log(' 5. Reinicia Neovim')
|
|
342
|
+
console.log(' 6. ¡Comienza a programar!')
|
|
343
|
+
|
|
344
|
+
console.log('\n' + chalk.bold('Enlaces útiles:'))
|
|
345
|
+
console.log(' • README completo: https://github.com/icarusmx/creta-vim')
|
|
346
|
+
console.log(' • Creta CLI: ' + chalk.yellow('creta') + ' (este programa)')
|
|
347
|
+
console.log(' • Comunidad Icarus: https://icarus.mx')
|
|
348
|
+
|
|
349
|
+
console.log('\n' + chalk.gray('Hecho con <3 por icarus.mx') + ' - Salgamos de este laberinto 🏛️')
|
|
350
|
+
console.log()
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
displayTable(rows) {
|
|
354
|
+
const maxKeyLength = Math.max(...rows.map(([key]) => key.length))
|
|
355
|
+
rows.forEach(([key, value]) => {
|
|
356
|
+
console.log(' ' + chalk.yellow(key.padEnd(maxKeyLength + 2)) + value)
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async pressEnter(message = '\nPresiona Enter para continuar...') {
|
|
361
|
+
return new Promise((resolve) => {
|
|
362
|
+
this.rl.question(chalk.gray(message), () => {
|
|
363
|
+
resolve()
|
|
364
|
+
})
|
|
365
|
+
})
|
|
366
|
+
}
|
|
367
|
+
}
|