diff --git a/.gitignore b/.gitignore index a52bd495579..1b987d7e7bf 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,10 @@ nvim spell/ # In your personal fork, you likely want to comment this, since it's recommended to track -# nvim-pack-lock.json in version control - see :help vim.pack-lockfile +# lazy-lock.json in version control - see https://lazy.folke.io/usage/lockfile # For the official `nvim-lua/kickstart.nvim` git repository, we leave it ignored to avoid unneeded # merge conflicts. -nvim-pack-lock.json +lazy-lock.json +.nvimlog .DS_Store diff --git a/AVANTE_SETUP.md b/AVANTE_SETUP.md new file mode 100644 index 00000000000..251e17ff6c2 --- /dev/null +++ b/AVANTE_SETUP.md @@ -0,0 +1,273 @@ +# Avante.nvim Multi-Provider Setup + +Avante.nvim now supports **both Claude (Anthropic) and OpenAI**! Switch between them seamlessly. + +--- + +## ๐Ÿ”‘ API Key Setup + +### Option 1: Scoped Keys (Recommended) + +Set provider-specific keys that only Avante uses: + +```bash +# Add to ~/.zshrc or ~/.bashrc + +# Claude (Anthropic) +export AVANTE_ANTHROPIC_API_KEY="your-claude-api-key" + +# OpenAI (GPT-4) +export AVANTE_OPENAI_API_KEY="your-openai-api-key" +``` + +### Option 2: Global Keys (Legacy) + +Use keys shared across all applications: + +```bash +# Claude +export ANTHROPIC_API_KEY="your-claude-api-key" + +# OpenAI +export OPENAI_API_KEY="your-openai-api-key" +``` + +**After adding keys:** +```bash +source ~/.zshrc # or ~/.bashrc +``` + +--- + +## ๐Ÿ”„ Switching Between Providers + +### Method 1: Keybinding (Easiest) +```vim +as " Switch provider (Claude โ†” OpenAI) +``` + +### Method 2: Command +```vim +:AvanteSwitchProvider +``` + +### Method 3: Change Default +Edit `lua/custom/plugins/avante.lua`: +```lua +provider = 'claude', -- Change to 'openai' +``` + +--- + +## ๐ŸŽฏ Current Configuration + +### Default Provider +**Claude (Sonnet 4)** - Best for: +- Code generation +- Deep reasoning +- Long context understanding + +### Alternative Provider +**OpenAI (GPT-4o)** - Best for: +- Fast responses +- General tasks +- When you want variety + +--- + +## ๐Ÿ“‹ Getting API Keys + +### Claude (Anthropic) +1. Go to: https://console.anthropic.com/settings/keys +2. Create new key +3. Copy and set as `AVANTE_ANTHROPIC_API_KEY` + +**Models available:** +- `claude-sonnet-4-20250514` (default - balanced) +- `claude-opus-4-20250514` (most capable) +- `claude-3-5-sonnet-20241022` (fast) + +### OpenAI +1. Go to: https://platform.openai.com/api-keys +2. Create new key +3. Copy and set as `AVANTE_OPENAI_API_KEY` + +**Models available:** +- `gpt-4o` (default - multimodal) +- `gpt-4-turbo` (faster) +- `gpt-4` (most capable) + +--- + +## ๐Ÿš€ Usage + +### Basic Workflow + +1. **Open Avante sidebar:** + ```vim + aa + ``` + +2. **Ask a question:** + - Type your prompt + - Press `` to submit + +3. **Edit code with AI:** + - Visual select code: `V` + movement + - Press `ae` (edit selection) + - Describe changes + - Apply diff: `a` or `A` + +4. **Switch providers if needed:** + ```vim + as " Claude โ†” OpenAI + ``` + +--- + +## ๐Ÿ’ก When to Use Which Provider + +### Use Claude for: +- โœ… Complex code generation +- โœ… Architecture decisions +- โœ… Deep debugging +- โœ… Long context (100k+ tokens) +- โœ… Precise code modifications + +### Use OpenAI for: +- โœ… Quick questions +- โœ… General programming help +- โœ… Faster responses +- โœ… When Claude is busy/rate-limited +- โœ… Image understanding (gpt-4o) + +--- + +## ๐Ÿ”ง Advanced Configuration + +### Change Models + +Edit `lua/custom/plugins/avante.lua`: + +```lua +providers = { + claude = { + model = 'claude-opus-4-20250514', -- More powerful + }, + openai = { + model = 'gpt-4-turbo', -- Faster + }, +} +``` + +### Adjust Temperature + +```lua +extra_request_body = { + temperature = 0.7, -- 0 = deterministic, 1 = creative +} +``` + +### Change Max Tokens + +```lua +extra_request_body = { + max_tokens = 8000, -- Longer responses +} +``` + +--- + +## ๐Ÿ†˜ Troubleshooting + +### "API key not found" +**Solution:** Set environment variable and restart terminal +```bash +export AVANTE_ANTHROPIC_API_KEY="your-key" +source ~/.zshrc +``` + +### "Rate limit exceeded" +**Solution:** Switch providers +```vim +as " Switch to alternative provider +``` + +### "Invalid API key" +**Solution:** Check key is correct +```bash +echo $AVANTE_ANTHROPIC_API_KEY # Should show your key +echo $AVANTE_OPENAI_API_KEY +``` + +### Provider not switching +**Solution:** Restart Neovim +```bash +:qa! +nvim +``` + +--- + +## ๐Ÿ“Š Cost Comparison + +### Claude Pricing +- Sonnet 4: $3/million input, $15/million output tokens +- Opus 4: $15/million input, $75/million output tokens +- Very cost-effective for code tasks + +### OpenAI Pricing +- GPT-4o: $2.50/million input, $10/million output tokens +- GPT-4 Turbo: $10/million input, $30/million output tokens +- Good for quick tasks + +**Tip:** Use Claude as default, OpenAI as backup for rate limits. + +--- + +## ๐ŸŽŠ All Keybindings + +```vim +aa " Toggle Avante sidebar +ar " Refresh Avante +ae " Edit selection with AI (visual mode) +ac " Clear Avante +as " Switch provider (Claude โ†” OpenAI) +``` + +**In Avante window:** +```vim + " Submit prompt + " Submit prompt (insert mode) +a " Apply suggestion to cursor +A " Apply all suggestions + " Switch windows +``` + +--- + +## ๐ŸŒŸ Pro Tips + +1. **Use both providers:** + - Claude for complex tasks + - OpenAI for quick questions + +2. **Set scoped keys:** + - Keeps Avante keys separate from other tools + - Easier to manage + +3. **Monitor usage:** + - Check API dashboards regularly + - Set spending limits + +4. **Switch on rate limits:** + - Hit Claude limit? `as` to OpenAI + - Hit OpenAI limit? `as` to Claude + +5. **Experiment with models:** + - Try different models for different tasks + - Adjust temperature for creativity + +--- + +Enjoy your multi-provider AI coding experience! ๐Ÿš€๐Ÿค– diff --git a/JUPYTER_SETUP.md b/JUPYTER_SETUP.md new file mode 100644 index 00000000000..55f294bfdb6 --- /dev/null +++ b/JUPYTER_SETUP.md @@ -0,0 +1,175 @@ +# Jupyter Notebook Setup Guide + +Your Neovim is now configured with **Molten.nvim** for full interactive Jupyter notebook support! + +## Prerequisites + +### 1. Install Python Packages + +```bash +# Required packages +pip install jupyter ipython pynvim + +# Optional but recommended for full functionality +pip install cairosvg plotly kaleido pnglatex pyperclip +pip install jupyter-console # For better REPL experience +``` + +### 2. Terminal Requirements + +For inline image rendering, you need a terminal that supports the Kitty graphics protocol: + +**Fully Supported Terminals:** +- **Ghostty** โœ… (you're using this - perfect!) +- **Kitty** - `brew install --cask kitty` +- **WezTerm** +- **iTerm2** with imgcat + +**Note:** Ghostty implements the Kitty graphics protocol, so inline images will work perfectly with your current terminal setup! + +If using macOS Terminal or other terminals, images will open in external viewers instead. + +### 3. Verify Installation + +```bash +# Check jupyter is installed +jupyter --version + +# Check ipython is installed +ipython --version + +# Check pynvim is available +python -c "import pynvim; print('pynvim OK')" +``` + +## Usage + +### Starting a Kernel + +1. Open a Python file or Jupyter notebook (`.ipynb`) +2. Press `mi` to initialize a kernel +3. Select kernel (usually "python3") + +### Working with Notebooks + +**Evaluate code:** +- `me` - Evaluate current line +- Visual mode + `me` - Evaluate selection +- `mr` - Re-evaluate current cell + +**Navigate cells:** +- `]c` - Next cell +- `[c` - Previous cell + +**Manage outputs:** +- `mo` - Show output +- `mh` - Hide output +- `md` - Delete cell + +**Kernel control:** +- `mx` - Interrupt kernel (stop execution) +- `mX` - Restart kernel +- `mq` - Quit/deinit kernel +- `mI` - Show kernel info + +**Import/Export:** +- `ms` - Save session +- `ml` - Load session +- `mE` - Export output + +### Working with .ipynb Files + +Molten works directly with `.ipynb` files. When you open a notebook: + +1. `:MoltenInit` to start a kernel +2. Navigate cells with `]c` and `[c` +3. Execute cells with `me` +4. View outputs inline or in floating windows + +### Working with Regular Python Files + +You can use Molten with regular `.py` files by marking code cells: + +```python +# %% +import numpy as np +import matplotlib.pyplot as plt + +# %% +x = np.linspace(0, 10, 100) +y = np.sin(x) +plt.plot(x, y) +plt.show() + +# %% +print("Results:", y.mean()) +``` + +The `# %%` markers define cells that can be executed independently. + +### Jupytext Integration + +Edit notebooks as Python files using Jupytext: + +```bash +# Open a notebook as Python file +nvim notebook.ipynb # Will open as .py file automatically +``` + +Jupytext syncs changes between `.ipynb` and `.py` formats. + +## Tips + +1. **Start simple:** Begin with `:MoltenInit` in a Python file +2. **Check output:** Use `mo` if output doesn't appear automatically +3. **Restart kernel:** Use `mX` if kernel gets stuck +4. **Cell markers:** Use `# %%` to create cells in `.py` files +5. **Virtual text:** Outputs can appear as virtual text inline (configurable) + +## Troubleshooting + +**"No kernel found" error:** +```bash +# Reinstall jupyter +pip install --upgrade jupyter ipython pynvim +``` + +**Images not showing:** +- Check you're using Kitty or supported terminal +- Set `vim.g.molten_image_provider = 'none'` to use external viewer +- Install image dependencies: `pip install cairosvg pillow` + +**Slow execution:** +- Interrupt kernel: `mx` +- Restart kernel: `mX` +- Check kernel process: `:MoltenInfo` + +**Plugin not loading:** +```bash +# In Neovim, update remote plugins +:UpdateRemotePlugins + +# Restart Neovim +``` + +## Advanced Configuration + +The configuration is in `lua/custom/plugins/molten.lua`. Key options: + +- `vim.g.molten_auto_open_output` - Auto-show output (default: false) +- `vim.g.molten_image_location` - 'float' or 'buffer' +- `vim.g.molten_output_win_max_height` - Max output window height + +## Integration with Neotest + +Molten works alongside neotest. Use: +- Neotest for running unit tests (`tt`) +- Molten for interactive data science work (`me`) + +## Resources + +- [Molten.nvim Documentation](https://github.com/benlubas/molten-nvim) +- [Image.nvim Documentation](https://github.com/3rd/image.nvim) +- [Jupytext Documentation](https://github.com/mwouts/jupytext) + +Enjoy your interactive Python notebooks in Neovim! ๐Ÿš€ diff --git a/LEARNING_GUIDE.md b/LEARNING_GUIDE.md new file mode 100644 index 00000000000..397eb4febcd --- /dev/null +++ b/LEARNING_GUIDE.md @@ -0,0 +1,411 @@ +# Vim/Neovim Learning Guide + +Your Neovim is now equipped with **learning-focused plugins** that will accelerate your Vim journey! This guide will help you master Vim efficiently. + +--- + +## ๐ŸŽฏ Learning Philosophy + +These plugins work together to teach you Vim the right way: +1. **Precognition** - Shows you what's possible +2. **Hardtime** - Prevents bad habits +3. **Flash** - Makes navigation intuitive +4. **Treesitter Textobjects** - Teaches code-aware editing + +--- + +## ๐Ÿ“š The Plugins + +### 1. Precognition - Your Motion Teacher + +**What it does:** Shows ghost hints for available motions as you navigate. + +**You'll see hints like:** +``` +function calculateTotal(items) { + ^ w w w e e +``` + +**Common hints you'll learn:** +- `w` = next word start +- `b` = previous word start +- `e` = end of word +- `^` = first non-blank character +- `$` = end of line +- `{` = previous paragraph +- `}` = next paragraph + +**Keybindings:** +- `tp` - Toggle precognition on/off +- `pp` - Peek at available motions + +**Learning tip:** Don't ignore the hints! When you see a hint, try using that motion. + +--- + +### 2. Hardtime - Break Bad Habits + +**What it does:** Gently reminds you to use better motions instead of repeating `hjkl`. + +**How it works:** +- Press `jjjjj` โ†’ Get hint: "Use } or 5j instead" +- Press `llllll` โ†’ Get hint: "Use w or 6l instead" +- After 4 repetitions, you'll see suggestions + +**Configuration:** +- **Currently set to:** Hint mode (gentle) +- **Max repetitions:** 4 (beginner-friendly) +- **Does NOT block** - just reminds you + +**Keybindings:** +- `th` - Toggle hardtime on/off +- `hr` - View hardtime report (see your patterns) + +**Learning tip:** Read the hints! They tell you exactly what motion to use instead. + +--- + +### 3. Flash - Enhanced Navigation + +**What it does:** Jump anywhere on screen with 2-3 keystrokes using labeled jumps. + +#### Basic Usage + +**Jump to any location:** +1. Press `s` +2. Type 2 characters (e.g., `fu` for "function") +3. Labels appear: `a`, `b`, `c`, etc. +4. Press the label letter to jump there + +**Example:** +``` +Before: +function calculateTotal(items) { + const total = items.reduce() +} + +Type: s + fu +Shows: +a +function calculateTotal(items) { + const total = items.reduce() +} + +Press: a +Cursor jumps to "function"! +``` + +#### Keybindings + +**Navigation:** +- `s` - Flash jump (2 chars + label) +- `S` - Treesitter jump (select function/class) +- `r` - Remote flash (use with operators like `d`, `c`) + +**In search:** +- `/search` then `` - Toggle flash in search results + +**With operators:** +- `dsfu` - Delete from cursor to "fu" match +- `csfu` - Change from cursor to "fu" match +- `ysfu` - Yank from cursor to "fu" match + +**Learning tip:** Use `s` instead of counting (`5w`) or searching (`/term`). It's faster once you get used to it! + +--- + +### 4. Treesitter Textobjects - Code-Aware Editing + +**What it does:** Adds code structure text objects (functions, classes, parameters). + +#### Text Object Selections + +**Functions:** +- `vaf` - Select entire function (including definition) +- `vif` - Select inside function (body only) +- `daf` - Delete entire function +- `yif` - Yank function body +- `cif` - Change function body + +**Classes:** +- `vac` - Select entire class +- `vic` - Select inside class + +**Parameters/Arguments:** +- `via` - Select inside parameter +- `vaa` - Select parameter including comma +- `cia` - Change parameter +- `daa` - Delete parameter + +**Conditionals (if/else):** +- `vii` - Select inside if block +- `vai` - Select entire if statement + +**Loops:** +- `vil` - Select inside loop +- `val` - Select entire loop + +**Comments:** +- `va/` - Select comment + +#### Navigation + +**Jump to next/previous:** +- `]f` / `[f` - Next/Previous function +- `]c` / `[c` - Next/Previous class +- `]a` / `[a` - Next/Previous parameter +- `]i` / `[i` - Next/Previous conditional +- `]l` / `[l` - Next/Previous loop + +**Jump to end:** +- `]F` - Next function end +- `[F` - Previous function end + +#### Parameter Swapping + +- `sn` - Swap parameter with next +- `sp` - Swap parameter with previous + +**Example:** +```javascript +function foo(first, second, third) { + // ^^^^^^ + // Cursor here, press sn +} + +// Becomes: +function foo(first, third, second) { +} +``` + +#### Incremental Selection + +- `` - Start/expand selection +- `` - Expand to scope +- `` - Shrink selection + +**Learning tip:** These become second nature after a week. Start with `vif`, `daf`, `]f`, `[f`. + +--- + +## ๐Ÿš€ Learning Path (Week-by-Week) + +### Week 1: Basic Motions +**Focus:** Learn to use `w`, `b`, `e`, `{`, `}` + +**Practice:** +1. Watch Precognition hints - try every motion you see +2. Let Hardtime remind you when you use `hjkl` too much +3. Don't disable anything yet! + +**Goals:** +- Stop using arrow keys +- Use `w` instead of `lllll` +- Use `{`/`}` instead of `jjjjj` + +### Week 2: Flash Navigation +**Focus:** Master Flash for quick jumps + +**Practice:** +1. Use `s` + 2 chars to jump around +2. Try `S` to select functions/classes +3. Use Flash with operators: `dsfu` (delete to "fu") + +**Goals:** +- Jump to any visible text in 3 keystrokes +- Stop using `/search` for short jumps + +### Week 3: Text Objects +**Focus:** Learn function/class operations + +**Practice:** +1. Use `vif` to select function body +2. Use `daf` to delete entire functions +3. Navigate with `]f` and `[f` + +**Goals:** +- Think in code structures, not lines +- Delete/change functions without counting lines + +### Week 4: Advanced Combinations +**Focus:** Combine everything + +**Practice:** +1. `s` + label + `vif` - Jump and select function +2. `]f` then `daf` - Jump to next function and delete it +3. `via` + `cia` - Select and change parameters + +**Goals:** +- Edit code at the speed of thought +- Rarely use `hjkl` anymore + +--- + +## ๐Ÿ’ก Quick Reference Card + +### Essential Motions (Learn These First) +``` +w - Next word start ]f - Next function +b - Previous word start [f - Previous function +e - End of word vif - Select in function +{ - Previous paragraph daf - Delete function +} - Next paragraph s - Flash jump +^ - Line start (non-blank) S - Treesitter select +$ - Line end +``` + +### Practice Exercises + +**Exercise 1: Navigation** +```javascript +function calculateTotal(items) { + const total = items.reduce((sum, item) => { + return sum + item.price + }, 0) + return total +} + +Tasks: +1. Jump to "reduce" using: sre