diff --git a/.gitignore b/.gitignore index 005b535b606..8a192cab54d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ test.sh nvim spell/ -lazy-lock.json diff --git a/README.md b/README.md index 4113950550d..42920514f81 100644 --- a/README.md +++ b/README.md @@ -1,241 +1,263 @@ -# kickstart.nvim - -## Introduction - -A starting point for Neovim that is: - -* Small -* Single-file -* Completely Documented - -**NOT** a Neovim distribution, but instead a starting point for your configuration. - -## Installation - -### Install Neovim - -Kickstart.nvim targets *only* the latest -['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest -['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. -If you are experiencing issues, please make sure you have the latest versions. - -### Install External Dependencies - -External Requirements: -- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) -- [ripgrep](https://github.com/BurntSushi/ripgrep#installation), - [fd-find](https://github.com/sharkdp/fd#installation) -- Clipboard tool (xclip/xsel/win32yank or other depending on the platform) -- A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons - - if you have it set `vim.g.have_nerd_font` in `init.lua` to true -- Emoji fonts (Ubuntu only, and only if you want emoji!) `sudo apt install fonts-noto-color-emoji` -- Language Setup: - - If you want to write Typescript, you need `npm` - - If you want to write Golang, you will need `go` - - etc. - -> [!NOTE] -> See [Install Recipes](#Install-Recipes) for additional Windows and Linux specific notes -> and quick install snippets - -### Install Kickstart - -> [!NOTE] -> [Backup](#FAQ) your previous configuration (if any exists) - -Neovim's configurations are located under the following paths, depending on your OS: - -| OS | PATH | -| :- | :--- | -| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| Windows (cmd)| `%localappdata%\nvim\` | -| Windows (powershell)| `$env:LOCALAPPDATA\nvim\` | - -#### Recommended Step - -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo -so that you have your own copy that you can modify, then install by cloning the -fork to your machine using one of the commands below, depending on your OS. - -> [!NOTE] -> Your fork's URL will be something like this: -> `https://github.com//kickstart.nvim.git` - -You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file -too - it's ignored in the kickstart repo to make maintenance easier, but it's -[recommended to track it in version control](https://lazy.folke.io/usage/lockfile). - -#### Clone kickstart.nvim - -> [!NOTE] -> If following the recommended step above (i.e., forking the repo), replace -> `nvim-lua` with `` in the commands below - -
Linux and Mac - -```sh -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim -``` - -
- -
Windows - -If you're using `cmd.exe`: - +# ๐Ÿš€ Kickstart.nvim - Professional Edition + +> A powerful, modular Neovim configuration built on kickstart.nvim, enhanced with LazyVim-style organization and comprehensive language support. + +[![Neovim](https://img.shields.io/badge/Neovim-0.11.4+-57A143?style=for-the-badge&logo=neovim&logoColor=white)](https://neovim.io/) +[![Lua](https://img.shields.io/badge/Lua-5.1+-2C2D72?style=for-the-badge&logo=lua&logoColor=white)](https://www.lua.org/) +[![License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](./LICENSE.md) + +--- + +## โœจ Features + +### ๐ŸŽจ **LazyVim-Style Interface** +- Beautiful which-key menu with icons and intuitive groupings +- Consistent keybindings across all plugins (Telescope, Neo-tree, etc.) +- Comprehensive searchable cheatsheet with 200+ keymaps (`sc`) + +### ๐Ÿ› ๏ธ **Language Support** +- **Flutter/Dart**: Full Flutter tools integration with device management +- **Rust**: rust-analyzer + Crates.io integration for dependency management +- **Python**: Pyright LSP with virtual environment support +- **Svelte**: Complete web development setup +- **Go, TypeScript, Lua**: Pre-configured LSP servers + +### ๐Ÿ” **Advanced Tooling** +- **Telescope**: Fuzzy finder for files, git, LSP, and more +- **Neo-tree**: File explorer with git integration +- **nvim-dap**: Full debugging support for all languages +- **Gitsigns**: Git integration with blame, hunk navigation, and staging +- **Mini.nvim**: Surround, autopairs, comments, and more + +### ๐Ÿ“š **Comprehensive Documentation** +- In-editor cheatsheet accessible anytime +- Progressive learning path from basics to advanced +- Vim mastery tips to build your skills over time + +--- + +## ๐Ÿ“‹ Requirements + +### Core Dependencies +- **Neovim** 0.11.4+ (stable or nightly) +- **Git** for plugin management +- **C Compiler** (gcc/clang) for TreeSitter +- **Make** and **unzip** + +### Recommended Tools +- **ripgrep** - Fast file searching (required for Telescope) +- **fd** - Fast file finding +- **Nerd Font** - Icons support (set `vim.g.have_nerd_font = true`) +- **Clipboard tool** - xclip (Linux), pbcopy (macOS), win32yank (Windows) + +### Language-Specific +- **Node.js** & **npm** - TypeScript, Svelte, web development +- **Python 3** - Python development +- **Rust** & **Cargo** - Rust development +- **Flutter SDK** - Flutter/Dart development +- **Go** - Go development + +--- + +## ๐Ÿš€ Quick Start + +### 1. Backup Existing Config +```bash +# macOS/Linux +mv ~/.config/nvim ~/.config/nvim.backup +mv ~/.local/share/nvim ~/.local/share/nvim.backup +mv ~/.local/state/nvim ~/.local/state/nvim.backup +mv ~/.cache/nvim ~/.cache/nvim.backup ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim" -``` - -If you're using `powershell.exe` -``` -git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim" +### 2. Clone This Configuration +```bash +git clone https://github.com/anupjsebastian/kickstart.nvim.git ~/.config/nvim +cd ~/.config/nvim ``` -
+### 3. Install Dependencies +```bash +# macOS (using Homebrew) +brew install neovim ripgrep fd -### Post Installation +# Ubuntu/Debian +sudo apt install neovim ripgrep fd-find -Start Neovim +# Arch Linux +sudo pacman -S neovim ripgrep fd +``` -```sh +### 4. Launch Neovim +```bash nvim ``` -That's it! Lazy will install all the plugins you have. Use `:Lazy` to view -the current plugin status. Hit `q` to close the window. +On first launch: +- Lazy.nvim will automatically install all plugins +- TreeSitter will compile language parsers +- LSP servers will be installed via Mason +- Wait for all installations to complete (check bottom right) -#### Read The Friendly Documentation +### 5. Verify Installation +```vim +:checkhealth +``` -Read through the `init.lua` file in your configuration folder for more -information about extending and exploring Neovim. That also includes -examples of adding popularly requested plugins. +--- + +## ๐Ÿ“– Documentation + +### Essential Reading +- **[Getting Started](docs/getting-started/README.md)** - First-time setup and orientation +- **[Installation Guide](docs/getting-started/installation.md)** - Detailed installation steps +- **[Quick Reference](docs/getting-started/quick-reference.md)** - Most common commands + +### Core Guides +- **[Keymaps Reference](docs/keymaps/README.md)** - Complete keymap documentation + - [Core Keymaps](docs/keymaps/core.md) - Leader key organization + - [LSP Keymaps](docs/keymaps/lsp.md) - Language Server Protocol commands + - [Plugin Keymaps](docs/keymaps/plugins.md) - Telescope, Neo-tree, etc. + - [Duplicates Guide](docs/keymaps/duplicates.md) - Understanding multiple keys for same action + +- **[Plugins Guide](docs/plugins/README.md)** - Plugin documentation + - [Core Plugins](docs/plugins/core.md) - Essential plugins (Telescope, Neo-tree, which-key) + - [Editor Plugins](docs/plugins/editor.md) - Editing enhancements + - [LSP & Completion](docs/plugins/lsp.md) - Language features + - [Debug Adapter](docs/plugins/debug.md) - Debugging setup + +- **[Language Setup](docs/languages/README.md)** - Language-specific configuration + - [Flutter/Dart](docs/languages/flutter.md) + - [Rust](docs/languages/rust.md) + - [Python](docs/languages/python.md) + - [Svelte](docs/languages/svelte.md) + - [Other Languages](docs/languages/others.md) + +### Advanced Topics +- **[Vim Mastery](docs/vim-mastery/README.md)** - Progressive skill building + - [Week 1: Motion Basics](docs/vim-mastery/week-01-motions.md) + - [Week 2: Text Objects](docs/vim-mastery/week-02-text-objects.md) + - [Week 3: Advanced Editing](docs/vim-mastery/week-03-advanced.md) + - [Week 4: Macros & Registers](docs/vim-mastery/week-04-macros.md) + - [Tips & Tricks](docs/vim-mastery/tips-and-tricks.md) + - [Workflow Optimization](docs/vim-mastery/workflows.md) + +- **[Customization](docs/customization.md)** - Making it your own +- **[Troubleshooting](docs/troubleshooting.md)** - Common issues and solutions +- **[FAQ](docs/faq.md)** - Frequently asked questions + +--- + +## ๐ŸŽฏ Quick Access Cheatsheet + +### In-Editor Help +- `sc` - Open comprehensive cheatsheet (searchable!) +- `sk` - Search all keymaps with Telescope +- `?` - Quick keymap search +- `sK` - Which-key command palette + +### Essential Keymaps +| Keymap | Action | Category | +|--------|--------|----------| +| `sf` | Find files | Search | +| `sg` | Live grep | Search | +| `bb` | List buffers | Buffer | +| `\` | Toggle Neo-tree | Files | +| `gg` | LazyGit | Git | +| `dc` or `F5` | Start debugging | Debug | +| `K` | Hover documentation | LSP | +| `gra` | Code actions | LSP | + +> **Pro Tip**: Press `` and wait - which-key will show you all available keymaps! + +--- + +## ๐Ÿ—๏ธ Project Structure -> [!NOTE] -> For more information about a particular plugin check its repository's documentation. +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua # Entry point +โ”œโ”€โ”€ lua/ +โ”‚ โ”œโ”€โ”€ config/ +โ”‚ โ”‚ โ”œโ”€โ”€ keymaps.lua # Global keymaps +โ”‚ โ”‚ โ”œโ”€โ”€ lazy.lua # Plugin manager setup +โ”‚ โ”‚ โ””โ”€โ”€ options.lua # Neovim options +โ”‚ โ”œโ”€โ”€ plugins/ +โ”‚ โ”‚ โ”œโ”€โ”€ core/ # Essential plugins +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ editor.lua # Telescope, which-key +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ neo-tree.lua # File explorer +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ debug.lua # Debug adapter +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ cheatsheet.lua # In-editor help +โ”‚ โ”‚ โ””โ”€โ”€ lang/ # Language-specific +โ”‚ โ”‚ โ”œโ”€โ”€ flutter.lua +โ”‚ โ”‚ โ”œโ”€โ”€ rust.lua +โ”‚ โ”‚ โ”œโ”€โ”€ python.lua +โ”‚ โ”‚ โ””โ”€โ”€ svelte.lua +โ”‚ โ””โ”€โ”€ kickstart/ +โ”‚ โ””โ”€โ”€ plugins/ # Additional plugins +โ””โ”€โ”€ docs/ # Documentation + โ”œโ”€โ”€ getting-started/ + โ”œโ”€โ”€ keymaps/ + โ”œโ”€โ”€ plugins/ + โ”œโ”€โ”€ languages/ + โ””โ”€โ”€ vim-mastery/ +``` +--- -### Getting Started +## ๐ŸŽจ Philosophy -[The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o) +This configuration follows these principles: -### FAQ +1. **Modular**: Each plugin in its own file, easy to enable/disable +2. **Discoverable**: Comprehensive which-key menus and cheatsheet +3. **Consistent**: Same keys work the same way across plugins +4. **Progressive**: Learn at your own pace with structured guides +5. **Documented**: Every keymap and feature explained +6. **Extensible**: Easy to customize and add your own plugins -* What should I do if I already have a pre-existing Neovim configuration? - * You should back it up and then delete all associated files. - * This includes your existing init.lua and the Neovim files in `~/.local` - which can be deleted with `rm -rf ~/.local/share/nvim/` -* Can I keep my existing configuration in parallel to kickstart? - * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` - to maintain multiple configurations. For example, you can install the kickstart - configuration in `~/.config/nvim-kickstart` and create an alias: - ``` - alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' - ``` - When you run Neovim using `nvim-kickstart` alias it will use the alternative - config directory and the matching local directory - `~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim - distribution that you would like to try out. -* What if I want to "uninstall" this configuration: - * See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information -* Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? - * The main purpose of kickstart is to serve as a teaching tool and a reference - configuration that someone can easily use to `git clone` as a basis for their own. - As you progress in learning Neovim and Lua, you might consider splitting `init.lua` - into smaller parts. A fork of kickstart that does this while maintaining the - same functionality is available here: - * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) - * Discussions on this topic can be found here: - * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) - * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) +--- -### Install Recipes +## ๐Ÿค Contributing -Below you can find OS specific install instructions for Neovim and dependencies. +Found a bug? Have a suggestion? Contributions are welcome! -After installing all the dependencies continue with the [Install Kickstart](#Install-Kickstart) step. +1. Fork the repository +2. Create a feature branch (`git checkout -b feature/amazing-feature`) +3. Commit your changes (`git commit -m 'Add amazing feature'`) +4. Push to the branch (`git push origin feature/amazing-feature`) +5. Open a Pull Request -#### Windows Installation +--- -
Windows with Microsoft C++ Build Tools and CMake -Installation may require installing build tools and updating the run command for `telescope-fzf-native` +## ๐Ÿ“ License -See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. -This requires: +--- -- Install CMake and the Microsoft C++ Build Tools on Windows +## ๐Ÿ™ Acknowledgments -```lua -{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } -``` -
-
Windows with gcc/make using chocolatey -Alternatively, one can install gcc and make which don't require changing the config, -the easiest way is to use choco: - -1. install [chocolatey](https://chocolatey.org/install) -either follow the instructions on the page or use winget, -run in cmd as **admin**: -``` -winget install --accept-source-agreements chocolatey.chocolatey -``` +- **[kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim)** - The foundation of this config +- **[LazyVim](https://www.lazyvim.org/)** - Inspiration for keybinding organization +- **[AstroVim](https://astronvim.com/)** - Cheatsheet inspiration +- **Neovim Community** - Amazing plugins and support -2. install all requirements using choco, exit the previous cmd and -open a new one so that choco path is set, and run in cmd as **admin**: -``` -choco install -y neovim git ripgrep wget fd unzip gzip mingw make -``` -
-
WSL (Windows Subsystem for Linux) - -``` -wsl --install -wsl -sudo add-apt-repository ppa:neovim-ppa/unstable -y -sudo apt update -sudo apt install make gcc ripgrep unzip git xclip neovim -``` -
+--- -#### Linux Install -
Ubuntu Install Steps +## ๐Ÿ“š Learn More -``` -sudo add-apt-repository ppa:neovim-ppa/unstable -y -sudo apt update -sudo apt install make gcc ripgrep unzip git xclip neovim -``` -
-
Debian Install Steps +- [Neovim Documentation](https://neovim.io/doc/) +- [Lua Guide for Neovim](https://github.com/nanotee/nvim-lua-guide) +- [Awesome Neovim Plugins](https://github.com/rockerBOO/awesome-neovim) +- [This Configuration's Full Documentation](docs/README.md) -``` -sudo apt update -sudo apt install make gcc ripgrep unzip git xclip curl - -# Now we install nvim -curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz -sudo rm -rf /opt/nvim-linux-x86_64 -sudo mkdir -p /opt/nvim-linux-x86_64 -sudo chmod a+rX /opt/nvim-linux-x86_64 -sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz - -# make it available in /usr/local/bin, distro installs to /usr/bin -sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/ -``` -
-
Fedora Install Steps +--- -``` -sudo dnf install -y gcc make git ripgrep fd-find unzip neovim -``` -
+
-
Arch Install Steps +**Built with โค๏ธ using Neovim** -``` -sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim -``` -
+[Get Started](docs/getting-started/README.md) โ€ข [Keymaps](docs/keymaps/README.md) โ€ข [Plugins](docs/plugins/README.md) โ€ข [Languages](docs/languages/README.md) +
diff --git a/archive/CONSISTENCY.md b/archive/CONSISTENCY.md new file mode 100644 index 00000000000..a57c2c52558 --- /dev/null +++ b/archive/CONSISTENCY.md @@ -0,0 +1,82 @@ +# Keymap Consistency Guide + +> **Last Updated:** November 1, 2025 +> **Purpose:** Document consistent keymaps across Telescope and Neo-tree + +## ๐ŸŽฏ Consistent Actions + +The following keymaps work **identically** in both Telescope and Neo-tree: + +### File Opening Actions + +| Key | Action | Telescope | Neo-tree | +|-----|--------|-----------|----------| +| `` or `o` | Open in current window | โœ… | โœ… | +| `` | Open in horizontal split | โœ… | โœ… | +| `` | Open in vertical split | โœ… | โœ… | +| `` | Open in new tab | โœ… | โœ… | + +### Navigation + +| Key | Action | Telescope | Neo-tree | +|-----|--------|-----------|----------| +| `` | Next item/source | โœ… | โœ… | +| `` | Previous item/source | โœ… | โœ… | +| `j/k` (normal mode) | Down/Up | โœ… | โœ… | +| `gg/G` (normal mode) | First/Last | โœ… | โœ… | + +### Utility + +| Key | Action | Telescope | Neo-tree | +|-----|--------|-----------|----------| +| `?` | Show help | โœ… | โœ… | +| `` or `q` | Close | โœ… | โœ… (`\\` for Neo-tree) | + +### Cross-Plugin Integration + +| Key | Action | Context | +|-----|--------|---------| +| `sf` | Telescope find files | Works in both editor and Neo-tree | +| `sg` | Telescope live grep | Works in both editor and Neo-tree | + +When used in Neo-tree, these commands search from the currently selected directory! + +## ๐Ÿ“š Complete Cheatsheet Access + +Access the comprehensive cheatsheet with: + +``` +sc - Complete cheatsheet (vim, plugins, language-specific) +sk - Search keymaps (Telescope) +sK - All keymaps (which-key) +? - Quick keymap search +``` + +## ๐ŸŽจ Visual Consistency + +Both Telescope and Neo-tree now follow the same pattern: +- **Same keys** for same actions +- **Predictable behavior** across interfaces +- **Integrated workflows** (use Telescope from Neo-tree) +- **Help always available** with `?` + +## ๐Ÿ“ Quick Reference + +### In Telescope: +1. `` to navigate +2. `` to open in split/vsplit/tab +3. `` to open in current window +4. `?` for help + +### In Neo-tree: +1. `` to switch sources +2. `` to open in split/vsplit/tab +3. `` or `o` to open file +4. `?` for help +5. `sf/sg` to launch Telescope from current directory + +### Both Share: +- Consistent split/tab opening +- Same navigation philosophy +- Integrated search capabilities +- Help on demand diff --git a/archive/DUPLICATES.md b/archive/DUPLICATES.md new file mode 100644 index 00000000000..0406cae9c1a --- /dev/null +++ b/archive/DUPLICATES.md @@ -0,0 +1,90 @@ +# Duplicate Keymaps Reference + +This document lists all keymaps where the same action can be performed using multiple key combinations. + +## Philosophy + +Having duplicate keymaps is **intentional and beneficial**: +- **Vim defaults + Modern alternatives**: Keep familiar vim keys while adding intuitive modern ones +- **Consistency across plugins**: Same keys work the same way in Telescope and Neo-tree +- **Ergonomics**: Function keys (F5-F12) AND leader keys for debugging +- **Context switching**: Use what feels natural in different workflows + +## Debug Actions + +| Action | Keys | Notes | +|--------|------|-------| +| Continue | `F5` or `dc` | F5 is standard in many IDEs | +| Step over | `F10` or `dO` | Uppercase O for over | +| Step into | `F11` or `di` | | +| Step out | `F12` or `do` | Lowercase o for out | + +**Why duplicates?** Function keys are muscle memory from other IDEs. Leader keys are more discoverable via which-key and don't conflict with terminal function keys. + +## Neo-tree vs Consistent Actions + +| Action | Neo-tree Default | Consistent Alternative | Notes | +|--------|------------------|------------------------|-------| +| Vertical split | `s` | `Ctrl-v` | Matches Telescope | +| Horizontal split | `S` | `Ctrl-x` | Matches Telescope | +| New tab | `t` | `Ctrl-t` | Matches Telescope | +| Next source | `>` | `Ctrl-j` | Matches Telescope navigation | +| Previous source | `<` | `Ctrl-k` | Matches Telescope navigation | +| Close window | `q` | `\` or `Esc` | Backslash mirrors toggle | +| Open file | `` | `o` | Two ways to open | + +**Why duplicates?** Neo-tree defaults are efficient single-key presses. Consistent alternatives (`Ctrl-x/v/t/j/k`) work the same way in Telescope, reducing cognitive load when switching between file finder and file tree. + +## Flutter Code Actions + +| Action | Keys | Notes | +|--------|------|-------| +| Code actions | `.` or `gra` | Period mimics Cmd+. in IDEs, gra is standard LSP | + +**Why duplicates?** Flutter developers coming from IDEs expect `.` (like Cmd+.). `gra` is the standard LSP keymap used everywhere else. + +## Telescope Navigation + +| Action | Keys | Notes | +|--------|------|-------| +| Next/prev item | `Ctrl-j/k` or `j/k` (normal) | Insert mode uses Ctrl, normal mode uses plain | +| Close | `Ctrl-c` or `Esc` or `q` (normal) | Three ways to exit | + +**Why duplicates?** `Ctrl-j/k` work in insert mode without switching modes. In normal mode, plain `j/k` are more natural. + +## Vim Defaults + +| Action | Keys | Notes | +|--------|------|-------| +| Save and quit | `:wq` or `ZZ` | ZZ is faster | +| Quit without save | `:q!` or `ZQ` | ZQ is faster | + +**Why duplicates?** Both are vim defaults. ZZ/ZQ are faster but less discoverable. + +## Summary of Duplicate Patterns + +1. **Debug**: F-keys + Leader keys (muscle memory from IDEs + discoverability) +2. **Splits/Tabs**: Single keys + Ctrl combos (efficiency + consistency) +3. **Navigation**: Plain + Ctrl variants (context-dependent ergonomics) +4. **Close/Exit**: Multiple keys (q, Esc, Ctrl-c, \\) (different mental models) + +## Design Principles + +1. **Never remove defaults** unless they conflict +2. **Add consistent alternatives** that work across plugins +3. **Document all options** so users can choose their preferred style +4. **Optimize for discoverability** (leader keys show in which-key) +5. **Respect muscle memory** (keep vim and IDE conventions) + +## Quick Reference: Cross-Plugin Consistency + +These keys work the same way in **both Telescope and Neo-tree**: + +- `Ctrl-x` โ†’ Horizontal split +- `Ctrl-v` โ†’ Vertical split +- `Ctrl-t` โ†’ New tab +- `Ctrl-j` โ†’ Next/down +- `Ctrl-k` โ†’ Previous/up +- `?` โ†’ Show help + +This consistency means once you learn these in one plugin, they work the same everywhere. diff --git a/archive/INSTALLATION.md b/archive/INSTALLATION.md new file mode 100644 index 00000000000..df60e556dbf --- /dev/null +++ b/archive/INSTALLATION.md @@ -0,0 +1,527 @@ +# Complete Installation Guide - Neovim Profile Setup + +This guide documents all the tools and setup steps needed to replicate this VS Code-like Neovim configuration on a new computer. + +## ๐Ÿ“‹ Prerequisites + +### Required Software +- **macOS** (this guide is for macOS, adapt for Linux/Windows) +- **Homebrew** - Package manager for macOS +- **Neovim v0.10+** - Text editor +- **Git** - Version control + +## ๐Ÿ› ๏ธ Installation Steps + +### 1. Install Homebrew (if not already installed) +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +### 2. Install Neovim +```bash +brew install neovim +``` + +Verify installation: +```bash +nvim --version +# Should show v0.10.0 or higher +``` + +### 3. Install Node.js via fnm (Fast Node Manager) + +#### Why fnm? +- Fast and simple Node.js version manager +- Written in Rust (very fast) +- Better than nvm for switching Node.js versions +- Required for GitHub Copilot and some LSP servers + +#### Install fnm +```bash +brew install fnm +``` + +#### Configure fnm in your shell +Add to `~/.zshrc`: +```bash +# fnm (Fast Node Manager) - for managing Node.js versions +eval "$(fnm env --use-on-cd)" +``` + +Reload your shell: +```bash +source ~/.zshrc +``` + +#### Install Node.js LTS +```bash +# Install latest LTS version +fnm install --lts + +# Set it as default +fnm default lts-latest + +# Verify installation +node --version +# Should show v24.x.x or similar + +npm --version +# Should show 11.x.x or similar +``` + +#### fnm Directory Structure +fnm stores Node.js versions here: +- **Versions**: `~/.local/share/fnm/node-versions/` +- **Default alias**: `~/.local/share/fnm/aliases/default/bin/` + +The default alias automatically points to your default Node.js version, so you don't need to update paths when upgrading Node.js. + +### 4. Install Bun (Fast JavaScript Runtime) + +#### Why Bun? +- Faster than Node.js for development +- Great for running Svelte/TypeScript projects +- Built-in bundler and test runner +- Compatible with Node.js packages + +#### Install Bun +```bash +curl -fsSL https://bun.sh/install | bash +``` + +This installs Bun to `~/.bun/bin/bun` + +#### Configure Bun in your shell +Add to `~/.zshrc` (should be added automatically, but verify): +```bash +# Bun - Fast JavaScript runtime +export BUN_INSTALL="$HOME/.bun" +export PATH="$BUN_INSTALL/bin:$PATH" +``` + +Reload your shell: +```bash +source ~/.zshrc +``` + +Verify installation: +```bash +bun --version +# Should show 1.3.x or similar +``` + +### 5. Clone Kickstart.nvim Configuration + +#### Backup existing config (if you have one) +```bash +mv ~/.config/nvim ~/.config/nvim.backup +mv ~/.local/share/nvim ~/.local/share/nvim.backup +mv ~/.local/state/nvim ~/.local/state/nvim.backup +``` + +#### Clone Kickstart.nvim +```bash +git clone https://github.com/nvim-lua/kickstart.nvim.git ~/.config/nvim +``` + +### 6. Apply Custom Profile Configuration + +You need to copy these custom files to your new machine: + +#### Required Custom Files +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua (modified from kickstart) +โ””โ”€โ”€ lua/custom/plugins/ + โ”œโ”€โ”€ init.lua # Common plugins (Copilot, Neo-tree) + โ”œโ”€โ”€ flutter.lua # Flutter/Dart profile + โ”œโ”€โ”€ python.lua # Python profile + โ””โ”€โ”€ svelte.lua # Svelte/Web profile +``` + +#### Copy from this repository +If you've pushed your config to GitHub: +```bash +cd ~/.config/nvim +git remote set-url origin YOUR_FORK_URL +git pull +``` + +Or manually copy the `lua/custom/` directory from your current setup. + +### 7. Configure Node.js Path in Neovim + +This is **critical** for GitHub Copilot to work! + +The `init.lua` file should have this configuration (around lines 96-110): + +```lua +-- ======================================================================== +-- NODE.JS PATH CONFIGURATION (for GitHub Copilot and LSP servers) +-- ======================================================================== +-- GitHub Copilot and some LSP servers require Node.js to be in PATH. +-- fnm doesn't add Node.js to Neovim's PATH automatically, so we do it here. +-- Using fnm aliases ensures this works even when Node.js version changes. +-- ======================================================================== + +-- Add fnm Node.js to PATH for Copilot and other Node.js-dependent plugins +local fnm_default_path = vim.fn.expand '~/.local/share/fnm/aliases/default/bin' +local fnm_multishells_path = vim.fn.expand '~/.local/share/fnm/node-versions/*/installation/bin' + +if vim.fn.isdirectory(fnm_default_path) == 1 then + vim.env.PATH = fnm_default_path .. ':' .. vim.env.PATH +elseif vim.fn.glob(fnm_multishells_path) ~= '' then + local node_path = vim.fn.glob(fnm_multishells_path) + vim.env.PATH = node_path .. ':' .. vim.env.PATH +end +``` + +This ensures Neovim can find Node.js even when it's not in the shell PATH. + +### 8. First Launch - Install Plugins + +#### Open Neovim +```bash +nvim +``` + +On first launch: +1. **lazy.nvim** will automatically install all plugins +2. Wait for plugins to finish installing (watch the bottom of the screen) +3. You may see some errors - this is normal on first launch + +#### Manually sync plugins (if needed) +```vim +:Lazy sync +``` + +Wait for completion, then restart Neovim: +```vim +:qa +nvim +``` + +### 9. Install LSP Servers and Tools via Mason + +#### Open Mason +```vim +nvim +:Mason +``` + +#### Required Tools +These should auto-install via `mason-tool-installer`, but verify: + +**Common:** +- `lua-language-server` (lua_ls) +- `stylua` + +**Flutter:** +- `dart-language-server` (dartls) + +**Python:** +- `pyright` +- `ruff` + +**Svelte/Web:** +- `svelte-language-server` +- `typescript-language-server` (ts_ls) +- `tailwindcss-language-server` +- `prettier` + +#### Manual Installation (if needed) +In Mason, navigate to a tool and press: +- `i` - Install +- `U` - Update +- `X` - Uninstall +- `g?` - Help + +### 10. Setup GitHub Copilot + +#### Authenticate Copilot +```vim +nvim +:Copilot setup +``` + +Follow the prompts: +1. It will give you a code +2. Open the URL in your browser +3. Enter the code +4. Authorize GitHub Copilot + +#### Verify Copilot works +```vim +:Copilot status +``` + +Should show: "Copilot: Ready" + +### 11. Install Treesitter Parsers + +Parsers should auto-install when you open files, but you can manually install: + +```vim +:TSInstall dart python svelte typescript tsx javascript css html json lua vim vimdoc +``` + +Verify: +```vim +:TSInstallInfo +``` + +## ๐Ÿ”ง Configuration Summary + +### Shell Configuration (~/.zshrc) + +Your `~/.zshrc` should have these additions: + +```bash +# fnm (Fast Node Manager) - for managing Node.js versions +eval "$(fnm env --use-on-cd)" + +# Bun - Fast JavaScript runtime +export BUN_INSTALL="$HOME/.bun" +export PATH="$BUN_INSTALL/bin:$PATH" +``` + +### Directory Structure After Installation + +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua # Main Kickstart config (modified with Node.js PATH) +โ”œโ”€โ”€ lazy-lock.json # Plugin versions (auto-generated) +โ”œโ”€โ”€ LICENSE.md +โ”œโ”€โ”€ README.md +โ”œโ”€โ”€ SETUP-GUIDE.md # Profile setup guide +โ”œโ”€โ”€ INSTALLATION.md # This file +โ”œโ”€โ”€ doc/ +โ”‚ โ””โ”€โ”€ kickstart.txt +โ””โ”€โ”€ lua/ + โ”œโ”€โ”€ custom/ + โ”‚ โ””โ”€โ”€ plugins/ + โ”‚ โ”œโ”€โ”€ init.lua # Common plugins (Copilot, Neo-tree) + โ”‚ โ”œโ”€โ”€ flutter.lua # Flutter profile + โ”‚ โ”œโ”€โ”€ python.lua # Python profile + โ”‚ โ””โ”€โ”€ svelte.lua # Svelte profile + โ””โ”€โ”€ kickstart/ + โ””โ”€โ”€ plugins/ + โ”œโ”€โ”€ autopairs.lua + โ”œโ”€โ”€ debug.lua + โ”œโ”€โ”€ gitsigns.lua + โ”œโ”€โ”€ indent_line.lua + โ”œโ”€โ”€ lint.lua + โ””โ”€โ”€ neo-tree.lua + +~/.local/share/fnm/ +โ”œโ”€โ”€ aliases/ +โ”‚ โ””โ”€โ”€ default/ # Default Node.js version +โ”‚ โ””โ”€โ”€ bin/ +โ”‚ โ”œโ”€โ”€ node +โ”‚ โ””โ”€โ”€ npm +โ””โ”€โ”€ node-versions/ + โ””โ”€โ”€ v24.11.0/ # Actual Node.js installation + +~/.bun/ +โ””โ”€โ”€ bin/ + โ””โ”€โ”€ bun # Bun executable + +~/.local/share/nvim/ +โ”œโ”€โ”€ lazy/ # lazy.nvim plugin installations +โ””โ”€โ”€ mason/ # Mason LSP/tool installations +``` + +## ๐Ÿงช Verification Checklist + +After installation, verify everything works: + +### Check Node.js Setup +```bash +# Should all work: +which node +node --version +which npm +npm --version +which fnm +fnm list +``` + +### Check Bun Setup +```bash +which bun +bun --version +``` + +### Check Neovim +```bash +nvim --version +# Should be v0.10.0+ +``` + +### Test in Neovim +```vim +# Open Neovim +nvim + +# Check Node.js is in PATH +:echo $PATH +# Should include: /Users/YOUR_USERNAME/.local/share/fnm/aliases/default/bin + +# Check Copilot +:Copilot status +# Should show: Ready + +# Check plugins +:Lazy +# All plugins should be loaded or available + +# Check Mason +:Mason +# All tools should be installed + +# Check LSP +:checkhealth lsp +# Should show no errors +``` + +## ๐Ÿ”„ Updating Tools + +### Update Node.js +```bash +# Install new LTS version +fnm install --lts + +# Set as default +fnm default lts-latest + +# Old versions are kept, you can switch back: +fnm use 22 # if you need an older version +``` + +The fnm alias system means Neovim automatically uses the new version without config changes! + +### Update Bun +```bash +bun upgrade +``` + +### Update Neovim Plugins +```vim +:Lazy update +``` + +### Update Mason Tools +```vim +:Mason +# Press 'U' to update all tools +``` + +### Update Neovim +```bash +brew upgrade neovim +``` + +## ๐Ÿ› Troubleshooting + +### Copilot says "Node.js not found" +1. Check Node.js is installed: `which node` +2. Check fnm is in PATH: `which fnm` +3. Verify init.lua has Node.js PATH configuration (see step 7) +4. Restart Neovim completely + +### LSP not loading +```vim +:LspInfo # Check if attached +:checkhealth lsp # Check for issues +:Mason # Verify tool is installed +``` + +### Plugins not loading +```vim +:Lazy check +:Lazy clean +:Lazy sync +``` + +### Format-on-save not working +```vim +:ConformInfo # Check formatter config +:Mason # Verify formatter installed +``` + +### Treesitter syntax highlighting broken +```vim +:TSUpdate # Update all parsers +:checkhealth nvim-treesitter +``` + +## ๐Ÿš€ Platform-Specific Notes + +### Linux +- Use your package manager instead of Homebrew +- fnm install: `curl -fsSL https://fnm.vercel.app/install | bash` +- Bun works the same way +- Shell config goes in `~/.bashrc` or `~/.zshrc` + +### Windows (WSL) +- Use WSL2 with Ubuntu/Debian +- Follow Linux instructions above +- Make sure Neovim is installed in WSL, not Windows + +### Windows (Native) +- Use Scoop or Chocolatey instead of Homebrew +- fnm Windows install: `winget install Schniz.fnm` +- Bun: `powershell -c "irm bun.sh/install.ps1 | iex"` +- Config goes in `~\AppData\Local\nvim\` + +## ๐Ÿ“š Additional Resources + +- **Kickstart.nvim**: https://github.com/nvim-lua/kickstart.nvim +- **fnm**: https://github.com/Schniz/fnm +- **Bun**: https://bun.sh +- **Mason**: https://github.com/williamboman/mason.nvim +- **lazy.nvim**: https://github.com/folke/lazy.nvim +- **Neovim**: https://neovim.io + +## ๐Ÿ“ Quick Setup Script + +For experienced users, here's a one-liner (review before running!): + +```bash +# Install Homebrew (if needed) +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + +# Install all tools +brew install neovim fnm && \ +fnm install --lts && \ +fnm default lts-latest && \ +curl -fsSL https://bun.sh/install | bash + +# Add to ~/.zshrc +echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc +echo 'export BUN_INSTALL="$HOME/.bun"' >> ~/.zshrc +echo 'export PATH="$BUN_INSTALL/bin:$PATH"' >> ~/.zshrc + +# Clone Kickstart +git clone https://github.com/nvim-lua/kickstart.nvim.git ~/.config/nvim + +# Copy your custom plugins +# (You need to do this manually from your backup/repo) + +# Launch Neovim +source ~/.zshrc +nvim +``` + +Then in Neovim: +1. Wait for plugins to install +2. Run `:Copilot setup` +3. Restart Neovim +4. Done! ๐ŸŽ‰ + +--- + +**Last Updated**: October 29, 2025 +**Neovim Version**: v0.11.4 +**Node.js Version**: v24.11.0 LTS +**Bun Version**: 1.3.1 diff --git a/archive/KEYMAPS.md b/archive/KEYMAPS.md new file mode 100644 index 00000000000..95c02a83652 --- /dev/null +++ b/archive/KEYMAPS.md @@ -0,0 +1,422 @@ +# Neovim Keymap Reference + +> **Last Updated:** November 1, 2025 +> **Organization Status:** โš ๏ธ NEEDS CLEANUP - Duplicates and conflicts identified + +## Table of Contents +- [Global Keymaps](#global-keymaps) +- [LSP Keymaps](#lsp-keymaps) +- [Language-Specific Keymaps](#language-specific-keymaps) +- [Conflicts & Duplicates](#conflicts--duplicates) +- [Proposed Organization](#proposed-organization) + +--- + +## Global Keymaps + +### Window Navigation +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `` | n | Move to left window | โœ… Keep | +| `` | n | Move to right window | โœ… Keep | +| `` | n | Move to lower window | โš ๏ธ **CONFLICT** with Telescope | +| `` | n | Move to upper window | โš ๏ธ **CONFLICT** with Telescope | + +### Quit Commands +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `Q` | n | Quit all | โœ… Keep | +| `q` | n | Open diagnostic quickfix | โœ… Keep | + +### File Explorer +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `\` | n | Toggle Neo-tree | โœ… Keep (user requested) | + +### Terminal +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `` | t | Exit terminal mode | โœ… Keep | + +### Escape/Clear +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `` | n | Clear highlights + close floats | โœ… Keep | + +--- + +## Search/Telescope (`s`) + +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `sh` | n | Search Help | โœ… Keep | +| `sk` | n | Search Keymaps | โœ… Keep | +| `sf` | n | Search Files | โœ… Keep | +| `ss` | n | Search Select Telescope | โœ… Keep | +| `sw` | n | Search current Word | โœ… Keep | +| `sg` | n | Search by Grep | โœ… Keep | +| `sd` | n | Search Diagnostics | โœ… Keep | +| `sr` | n | Search Resume | โœ… Keep | +| `s.` | n | Search Recent Files | โœ… Keep | +| `s/` | n | Search in open files | โœ… Keep | +| `sn` | n | Search Neovim config | โœ… Keep | +| `/` | n | Fuzzy search in buffer | โœ… Keep | +| `` | n | Find buffers | โœ… Keep | + +### Telescope Navigation (Within Telescope) +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `` | i | Next item | โš ๏ธ **CONFLICT** with window nav | +| `` | i | Previous item | โš ๏ธ **CONFLICT** with window nav | + +--- + +## Session (`S`) + +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `Ss` | n | Session save | โœ… Keep | +| `Sr` | n | Session restore | โœ… Keep | +| `Sd` | n | Session delete | โœ… Keep | + +--- + +## LSP Keymaps (All Languages) + +### Go-to Commands (`gr*`) +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `grd` | n | Go to Definition | โœ… Keep | +| `grD` | n | Go to Declaration | โœ… Keep | +| `gri` | n | Go to Implementation | โœ… Keep | +| `grr` | n | Go to References | โœ… Keep | +| `grt` | n | Go to Type Definition | โœ… Keep | +| `grn` | n | Rename | โœ… Keep | +| `gra` | n,v | Code Action | โš ๏ธ **DUPLICATE** (also `.` in Flutter) | + +### Other LSP +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `K` | n | Hover Documentation | โœ… Keep | +| `gO` | n | Document Symbols | โœ… Keep | +| `gW` | n | Workspace Symbols | โœ… Keep | + +--- + +## Toggle (`t`) + +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `th` | n | Toggle Inlay Hints | โœ… Keep | + +--- + +## Diagnostics/Quickfix (`x`) + +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `xx` | n | Toggle diagnostics list (Trouble) | โœ… Keep | +| `xX` | n | Toggle buffer diagnostics (Trouble) | โœ… Keep | +| `xs` | n | Toggle symbols (Trouble) | โœ… Keep | + +--- + +## Git Hunks (`h`) + +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `hs` | n,v | Stage hunk | โœ… Keep | +| `hr` | n,v | Reset hunk | โœ… Keep | +| `hS` | n | Stage buffer | โœ… Keep | +| `hu` | n | Undo stage hunk | โœ… Keep | +| `hR` | n | Reset buffer | โœ… Keep | +| `hp` | n | Preview hunk | โœ… Keep | +| `hb` | n | Blame line | โœ… Keep | +| `hd` | n | Diff this | โœ… Keep | +| `hD` | n | Diff this ~ | โœ… Keep | + +--- + +## Language-Specific Keymaps + +### Flutter/Dart (`f`, `d`) + +#### Flutter Workflow +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `fr` | n | Flutter Run | โœ… Keep | +| `fR` | n | Flutter Hot Restart | โœ… Keep | +| `fq` | n | Flutter Quit | โœ… Keep | +| `fd` | n | Flutter Devices (select) | โœ… Keep | +| `fe` | n | Flutter Emulators | โœ… Keep | +| `fo` | n | Flutter Outline Toggle | โœ… Keep | +| `fc` | n | Flutter Copy Profiler URL | โœ… Keep | +| `fl` | n | Flutter LSP Restart | โœ… Keep | + +#### Flutter Code Actions +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `.` | n,v | Code Actions (Cmd+.) | โš ๏ธ **DUPLICATE** with `gra` | +| `gra` | n,v | Code Action | โš ๏ธ **DUPLICATE** with `.` | + +#### Debug (Flutter/Dart) +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `` | n | Debug: Start/Continue | โœ… Keep | +| `` | n | Debug: Step Over | โœ… Keep | +| `` | n | Debug: Step Into | โœ… Keep | +| `` | n | Debug: Step Out | โœ… Keep | +| `db` | n | Debug: Toggle Breakpoint | โœ… Keep | +| `dB` | n | Debug: Conditional Breakpoint | โœ… Keep | +| `dc` | n | Debug: Continue | โš ๏ธ **DUPLICATE** with `` | +| `dt` | n | Debug: Terminate | โœ… Keep | +| `du` | n | Debug: Toggle UI | โœ… Keep | + +### Rust (`r`, `c`) + +#### Rust Tools +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `rh` | n | Rust Hover Actions | โœ… Keep | +| `ra` | n | Rust Code Actions | โœ… Keep | +| `re` | n | Rust Explain Error | โœ… Keep | +| `rc` | n | Rust Open Cargo.toml | โš ๏ธ **CONFLICT** with Crates (in Cargo.toml) | +| `rp` | n | Rust Parent Module | โœ… Keep | +| `rj` | n | Rust Join Lines | โœ… Keep | + +#### Crates (Cargo.toml only) +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| `ct` | n | Crates Toggle | โœ… Keep | +| `cr` | n | Crates Reload | โš ๏ธ **CONFLICT** with `rc` in .rs files | +| `cv` | n | Crates Show Versions | โœ… Keep | +| `cf` | n | Crates Show Features | โœ… Keep | +| `cd` | n | Crates Show Dependencies | โœ… Keep | +| `cu` | n,v | Crates Update | โœ… Keep | +| `ca` | n | Crates Update All | โœ… Keep | +| `cU` | n,v | Crates Upgrade | โœ… Keep | +| `cA` | n | Crates Upgrade All | โœ… Keep | +| `ce` | n | Crates Expand to inline | โœ… Keep | +| `cE` | n | Crates Extract to table | โœ… Keep | +| `cH` | n | Crates Open Homepage | โœ… Keep | +| `cR` | n | Crates Open Repository | โœ… Keep | +| `cD` | n | Crates Open Documentation | โœ… Keep | +| `cC` | n | Crates Open Crates.io | โœ… Keep | + +### Python (`p`) +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| (No keymaps defined yet) | - | - | โš ๏ธ Need to add | + +### Svelte (`v`) +| Key | Mode | Action | Status | +|-----|------|--------|--------| +| (No keymaps defined yet) | - | - | โš ๏ธ Need to add | + +--- + +## Conflicts & Duplicates + +### ๐Ÿ”ด Critical Conflicts + +1. **Window Navigation vs Telescope Navigation** + - `` and `` used for BOTH window navigation AND Telescope item navigation + - **Impact:** Medium - Can't navigate windows while Telescope is open + - **Resolution:** Telescope should use different keys or remain as-is (works in insert mode) + +2. **Code Actions: `gra` vs `.`** + - Both do the same thing in Flutter/Dart files + - **Impact:** Low - Just redundant + - **Resolution:** Keep both (muscle memory from different editors) + +3. **Debug Continue: `` vs `dc`** + - Both do the same thing + - **Impact:** Low - Just redundant + - **Resolution:** Keep both (F5 is standard, leader-based for discoverability) + +4. **Rust Cargo.toml conflicts** + - `rc` means different things in `.rs` vs `Cargo.toml` files + - `cr` means different things in `.rs` vs `Cargo.toml` files + - **Impact:** High - Same key does different things based on filename + - **Resolution:** This is acceptable since they're context-dependent (filetype-specific) + +### ๐ŸŸก Minor Issues + +1. **No Python or Svelte keymaps** + - Missing language-specific shortcuts + - **Resolution:** Add `p` for Python, `v` for Svelte + +2. **No unified debug keymaps** + - Debug keys only in Flutter, not available globally + - **Resolution:** Move debug keymaps to global scope if DAP is loaded + +--- + +## Proposed Organization + +### Leader Key Groups (LazyVim-style with Icons) + +``` + +โ”œโ”€โ”€ โ†’ Buffers +โ”œโ”€โ”€ / โ†’ Search in buffer +โ”œโ”€โ”€ . โ†’ Code action (Flutter/Dart specific) +โ”œโ”€โ”€ Q โ†’ Quit all +โ”œโ”€โ”€ q โ†’ Quickfix diagnostics +โ”‚ +โ”œโ”€โ”€ ๓ฐŠ„ b โ†’ [B]uffer operations (NEW) +โ”‚ โ”œโ”€โ”€ bd โ†’ Delete buffer +โ”‚ โ”œโ”€โ”€ bD โ†’ Delete buffer (force) +โ”‚ โ”œโ”€โ”€ bn โ†’ Next buffer +โ”‚ โ”œโ”€โ”€ bp โ†’ Previous buffer +โ”‚ โ””โ”€โ”€ bP โ†’ Pin buffer +โ”‚ +โ”œโ”€โ”€ c โ†’ [C]ode operations (NEW - UNIFY CODE ACTIONS) +โ”‚ โ”œโ”€โ”€ ca โ†’ Code action +โ”‚ โ”œโ”€โ”€ cf โ†’ Format +โ”‚ โ”œโ”€โ”€ cr โ†’ Rename +โ”‚ โ””โ”€โ”€ cs โ†’ Symbol search +โ”‚ +โ”œโ”€โ”€ d โ†’ [D]ebug (GLOBAL - move from Flutter-only) +โ”‚ โ”œโ”€โ”€ db โ†’ Toggle breakpoint +โ”‚ โ”œโ”€โ”€ dB โ†’ Conditional breakpoint +โ”‚ โ”œโ”€โ”€ dc โ†’ Continue +โ”‚ โ”œโ”€โ”€ di โ†’ Step into +โ”‚ โ”œโ”€โ”€ do โ†’ Step out +โ”‚ โ”œโ”€โ”€ dO โ†’ Step over +โ”‚ โ”œโ”€โ”€ dt โ†’ Terminate +โ”‚ โ””โ”€โ”€ du โ†’ Toggle UI +โ”‚ +โ”œโ”€โ”€ f โ†’ [F]lutter (Dart files only) +โ”‚ โ”œโ”€โ”€ fr โ†’ Run +โ”‚ โ”œโ”€โ”€ fR โ†’ Hot restart +โ”‚ โ”œโ”€โ”€ fq โ†’ Quit +โ”‚ โ”œโ”€โ”€ fd โ†’ Devices +โ”‚ โ”œโ”€โ”€ fe โ†’ Emulators +โ”‚ โ”œโ”€โ”€ fo โ†’ Outline toggle +โ”‚ โ”œโ”€โ”€ fc โ†’ Copy profiler URL +โ”‚ โ””โ”€โ”€ fl โ†’ LSP restart +โ”‚ +โ”œโ”€โ”€ g โ†’ [G]it (RENAME from h) +โ”‚ โ”œโ”€โ”€ gs โ†’ Stage hunk +โ”‚ โ”œโ”€โ”€ gr โ†’ Reset hunk +โ”‚ โ”œโ”€โ”€ gS โ†’ Stage buffer +โ”‚ โ”œโ”€โ”€ gu โ†’ Undo stage +โ”‚ โ”œโ”€โ”€ gR โ†’ Reset buffer +โ”‚ โ”œโ”€โ”€ gp โ†’ Preview hunk +โ”‚ โ”œโ”€โ”€ gb โ†’ Blame line +โ”‚ โ”œโ”€โ”€ gd โ†’ Diff this +โ”‚ โ””โ”€โ”€ gD โ†’ Diff this ~ +โ”‚ +โ”œโ”€โ”€ p โ†’ [P]ython (Python files only) (NEW) +โ”‚ โ”œโ”€โ”€ pr โ†’ Run file +โ”‚ โ”œโ”€โ”€ pR โ†’ Run with args +โ”‚ โ”œโ”€โ”€ pi โ†’ Import sort +โ”‚ โ”œโ”€โ”€ pe โ†’ Select environment +โ”‚ โ””โ”€โ”€ pt โ†’ Run tests +โ”‚ +โ”œโ”€โ”€ r โ†’ [R]ust (Rust files only) +โ”‚ โ”œโ”€โ”€ rh โ†’ Hover actions +โ”‚ โ”œโ”€โ”€ ra โ†’ Code actions +โ”‚ โ”œโ”€โ”€ re โ†’ Explain error +โ”‚ โ”œโ”€โ”€ rc โ†’ Open Cargo.toml +โ”‚ โ”œโ”€โ”€ rp โ†’ Parent module +โ”‚ โ”œโ”€โ”€ rj โ†’ Join lines +โ”‚ โ”œโ”€โ”€ rt โ†’ Runnables +โ”‚ โ””โ”€โ”€ rr โ†’ Run (NEW) +โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€ rc โ†’ [C]rates (Cargo.toml only) +โ”‚ โ”œโ”€โ”€ rct โ†’ Toggle +โ”‚ โ”œโ”€โ”€ rcr โ†’ Reload +โ”‚ โ”œโ”€โ”€ rcv โ†’ Show versions +โ”‚ โ”œโ”€โ”€ rcf โ†’ Show features +โ”‚ โ”œโ”€โ”€ rcd โ†’ Show dependencies +โ”‚ โ”œโ”€โ”€ rcu โ†’ Update crate +โ”‚ โ”œโ”€โ”€ rca โ†’ Update all +โ”‚ โ”œโ”€โ”€ rcU โ†’ Upgrade crate +โ”‚ โ””โ”€โ”€ rcA โ†’ Upgrade all +โ”‚ +โ”œโ”€โ”€ s โ†’ [S]earch +โ”‚ โ”œโ”€โ”€ sh โ†’ Help +โ”‚ โ”œโ”€โ”€ sk โ†’ Keymaps +โ”‚ โ”œโ”€โ”€ sf โ†’ Files +โ”‚ โ”œโ”€โ”€ ss โ†’ Select Telescope +โ”‚ โ”œโ”€โ”€ sw โ†’ Current word +โ”‚ โ”œโ”€โ”€ sg โ†’ Grep +โ”‚ โ”œโ”€โ”€ sd โ†’ Diagnostics +โ”‚ โ”œโ”€โ”€ sr โ†’ Resume +โ”‚ โ”œโ”€โ”€ s. โ†’ Recent files +โ”‚ โ”œโ”€โ”€ s/ โ†’ Open files +โ”‚ โ”œโ”€โ”€ sn โ†’ Neovim config +โ”‚ โ””โ”€โ”€ sc โ†’ Cheatsheet (NEW) +โ”‚ +โ”œโ”€โ”€ S โ†’ [S]ession +โ”‚ โ”œโ”€โ”€ Ss โ†’ Save +โ”‚ โ”œโ”€โ”€ Sr โ†’ Restore +โ”‚ โ””โ”€โ”€ Sd โ†’ Delete +โ”‚ +โ”œโ”€โ”€ t โ†’ [T]oggle +โ”‚ โ”œโ”€โ”€ th โ†’ Inlay hints +โ”‚ โ”œโ”€โ”€ td โ†’ Diagnostics +โ”‚ โ”œโ”€โ”€ tl โ†’ Line numbers +โ”‚ โ”œโ”€โ”€ tr โ†’ Relative numbers +โ”‚ โ”œโ”€โ”€ ts โ†’ Spell check +โ”‚ โ”œโ”€โ”€ tw โ†’ Wrap +โ”‚ โ””โ”€โ”€ tc โ†’ Conceallevel +โ”‚ +โ”œโ”€โ”€ u โ†’ [U]I (NEW) +โ”‚ โ”œโ”€โ”€ un โ†’ Noice dismiss +โ”‚ โ”œโ”€โ”€ ul โ†’ Lazy +โ”‚ โ”œโ”€โ”€ um โ†’ Mason +โ”‚ โ””โ”€โ”€ ui โ†’ Inspect tree +โ”‚ +โ”œโ”€โ”€ v โ†’ S[v]elte (Svelte files only) (NEW) +โ”‚ โ””โ”€โ”€ (TBD) +โ”‚ +โ”œโ”€โ”€ w โ†’ [W]indow operations (NEW) +โ”‚ โ”œโ”€โ”€ ww โ†’ Other window +โ”‚ โ”œโ”€โ”€ wd โ†’ Delete window +โ”‚ โ”œโ”€โ”€ ws โ†’ Split below +โ”‚ โ”œโ”€โ”€ wv โ†’ Split right +โ”‚ โ””โ”€โ”€ wm โ†’ Maximize toggle +โ”‚ +โ””โ”€โ”€ x โ†’ Diagnostics/quickfi[X] + โ”œโ”€โ”€ xx โ†’ Toggle diagnostics + โ”œโ”€โ”€ xX โ†’ Buffer diagnostics + โ””โ”€โ”€ xs โ†’ Symbols +``` + +### Non-Leader Keys + +``` +\ โ†’ Toggle Neo-tree (file explorer) +K โ†’ Hover documentation (LSP) + โ†’ Clear highlights + close floats + +gr* โ†’ LSP "go to" commands +โ”œโ”€โ”€ grd โ†’ Definition +โ”œโ”€โ”€ grD โ†’ Declaration +โ”œโ”€โ”€ gri โ†’ Implementation +โ”œโ”€โ”€ grr โ†’ References +โ”œโ”€โ”€ grt โ†’ Type definition +โ”œโ”€โ”€ grn โ†’ Rename +โ””โ”€โ”€ gra โ†’ Code action + +gO โ†’ Document symbols +gW โ†’ Workspace symbols + + โ†’ Window navigation + โ†’ Debug keys (when available) +``` + +--- + +## Next Steps + +1. โœ… **Document current state** (this file) +2. โณ **Clean up duplicates** - Remove redundant keymaps +3. โณ **Reorganize which-key** - Add icons, proper groups, submenus +4. โณ **Add missing keymaps** - Python, Svelte, Buffer, Window, UI operations +5. โณ **Update language configs** - Move Crates under `rc`, standardize patterns +6. โณ **Implement cheatsheet** - Telescope-based searchable keymap reference +7. โณ **Test everything** - Ensure no conflicts, all descriptions visible diff --git a/archive/MIGRATION.md b/archive/MIGRATION.md new file mode 100644 index 00000000000..50205cb82aa --- /dev/null +++ b/archive/MIGRATION.md @@ -0,0 +1,156 @@ +# Migration Checklist - Neovim Config Refactor + +## Current State โœ… +- [x] Working Python LSP (pyright) +- [x] Working Flutter LSP (dartls) +- [x] Lazy-loaded language profiles +- [x] Common plugins loaded globally +- [x] ~1200 line init.lua (needs refactoring) + +## Phase 1: Understand Your Config (Before Refactoring) +- [ ] Read through entire `init.lua` - understand every line +- [ ] List all plugins you actually use (vs installed) +- [ ] Identify startup bottlenecks: `nvim --startuptime startup.log` +- [ ] Document your most-used keybindings +- [ ] Run `:checkhealth` to verify everything works + +## Phase 2: Extract Configuration (Low Risk) +- [ ] Create `lua/config/options.lua` - Move all `vim.opt` settings +- [ ] Create `lua/config/keymaps.lua` - Move global keymaps +- [ ] Create `lua/config/autocmds.lua` - Move global autocmds +- [ ] Update `init.lua` to require these modules +- [ ] Test: Restart nvim, verify everything works + +## Phase 3: Reorganize Plugins (Medium Risk) +- [ ] Create `lua/plugins/core/` directory structure +- [ ] Move UI plugins to `core/ui.lua` +- [ ] Move editor plugins to `core/editor.lua` +- [ ] Move git plugins to `core/git.lua` +- [ ] Move completion to `core/completion.lua` +- [ ] Test after EACH move - don't batch them! + +## Phase 4: Refactor LSP (High Risk - Do Last!) +- [ ] Create `lua/plugins/lsp/init.lua` for mason setup +- [ ] Create `lua/plugins/lsp/servers.lua` for general servers (lua_ls) +- [ ] Move language-specific LSP to their lang files +- [ ] Create `lua/util/lsp.lua` for shared utilities +- [ ] Test each language: Python, Flutter, Svelte + +## Phase 5: Cleanup +- [ ] Remove unused plugins (check with `:Lazy`) +- [ ] Remove duplicate code +- [ ] Add comments explaining WHY, not WHAT +- [ ] Update README.md with your structure +- [ ] Profile startup time - compare before/after + +## Testing Checklist (Run After Each Phase) +- [ ] Python: Open .py file, verify pyright loads, test completion +- [ ] Flutter: Open .dart file, verify dartls loads, test completion +- [ ] Svelte: Open .svelte file, verify svelte-ls loads +- [ ] Git: Open a git repo, test gitsigns +- [ ] Telescope: Test fuzzy finding (sf) +- [ ] LSP: Test go-to-definition, hover, rename +- [ ] Formatting: Test format-on-save +- [ ] Sessions: Test session save/restore + +## Rollback Plan +```bash +# Before starting, create a backup branch +cd ~/.config/nvim +git checkout -b refactor-backup +git checkout -b refactor-attempt + +# If something breaks: +git checkout refactor-backup +``` + +## Performance Targets +| Metric | Before | Target | After | +|--------|--------|--------|-------| +| Startup time | ? ms | <100ms | ? ms | +| Plugins loaded on startup | ? | <30 | ? | +| Time to first edit | ? ms | <200ms | ? ms | + +Measure with: +```bash +nvim --startuptime startup.log +# Check the last line for total time +``` + +## When NOT to Refactor +- [ ] You don't understand why your current config works +- [ ] You're in the middle of a project deadline +- [ ] Your startup time is already <50ms +- [ ] You haven't backed up your config + +## When TO Refactor +- [x] Your init.lua is >500 lines (yours is 1200!) +- [x] You have duplicate code across files +- [x] You're adding a 4th+ language (you have 3) +- [x] Startup time is >200ms +- [x] You want to understand how Neovim works + +## Expected Benefits +- Faster startup (lazy-loading) +- Easier to add new languages (template) +- Easier to debug (modular) +- Easier to share/document +- Better understanding of Neovim + +## Expected Challenges +- LSP loading timing issues (we already solved this!) +- Plugin dependency conflicts +- Breaking changes in lazy.nvim API +- Time investment (plan 4-6 hours) + +--- + +## Quick Win: Do This First (30 minutes) + +1. **Extract options** (lowest risk, immediate clarity): +```lua +-- lua/config/options.lua +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' +vim.g.have_nerd_font = true +vim.opt.number = true +vim.opt.relativenumber = true +-- ... all your vim.opt settings +``` + +2. **Extract keymaps**: +```lua +-- lua/config/keymaps.lua +-- Escape closes floating windows +vim.keymap.set('n', '', function() + -- ... your escape logic +end) +``` + +3. **Update init.lua**: +```lua +-- NEW init.lua (first 3 lines!) +require('config.options') +require('config.keymaps') +-- ... rest stays the same for now +``` + +This alone will make your init.lua 200 lines shorter and much clearer! + +--- + +## Resources to Keep Handy +- [Lazy.nvim Spec](https://lazy.folke.io/spec) +- [:help lua-guide](https://neovim.io/doc/user/lua-guide.html) +- [Your ORGANIZATION.md](./ORGANIZATION.md) +- [Kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) (reference only) + +--- + +**Remember:** Refactoring is optional. Your current setup WORKS. Only refactor if: +1. You want to learn more about Neovim +2. You want to add many more languages +3. Your startup time bothers you +4. You enjoy organizing code + +Good luck! ๐Ÿš€ diff --git a/archive/NEO-TREE-CHEATSHEET.md b/archive/NEO-TREE-CHEATSHEET.md new file mode 100644 index 00000000000..95ecdafbb98 --- /dev/null +++ b/archive/NEO-TREE-CHEATSHEET.md @@ -0,0 +1,77 @@ +# Neo-tree File Explorer Cheat Sheet + +## Opening/Closing +- `\` - Toggle Neo-tree reveal (show tree with current file highlighted) +- `q` - Close Neo-tree window +- `` - Cancel/close preview or Neo-tree window + +## Navigation +- `j` / `k` - Move down/up in the file list +- `l` - Focus preview window +- `` (Enter) - Open file or toggle directory expand/collapse +- `` - Toggle directory expand/collapse +- `` - Navigate up one directory level +- `.` - Set current directory as root + +## Directory Expand/Collapse +- `` - Toggle expand/collapse directory +- `` (Enter) - Open file OR toggle directory +- `C` - Close node (collapse directory) +- `z` - Close all nodes (collapse all directories) + +## File Operations +- `a` - Add new file (prompts for name) +- `A` - Add new directory +- `d` - Delete file/directory +- `r` - Rename file/directory +- `c` - Copy (prompts for destination path) +- `m` - Move (prompts for destination path) +- `y` - Copy to clipboard +- `x` - Cut to clipboard +- `p` - Paste from clipboard +- `b` - Rename basename only (keep path) + +## File Opening +- `` - Open in current window +- `s` - Open in vertical split +- `S` - Open in horizontal split +- `t` - Open in new tab +- `w` - Open with window picker + +## Display & Navigation +- `H` - Toggle hidden files +- `/` - Fuzzy finder (search files in tree) +- `f` - Filter on submit +- `` - Clear filter +- `i` - Show file details +- `R` - Refresh tree +- `?` - Show help (displays all available mappings) + +## Git Navigation +- `[g` - Previous git modified file +- `]g` - Next git modified file + +## Sorting +Press `o` to show the order by menu, then: +- `oc` - Order by created date +- `od` - Order by diagnostics +- `og` - Order by git status +- `om` - Order by modified date +- `on` - Order by name +- `os` - Order by size +- `ot` - Order by type + +## Custom Mappings (from your config) +- `sf` - Telescope find files in current directory +- `sg` - Telescope live grep in current directory + +## Preview Window +- `P` - Toggle preview window +- `` - Scroll preview down +- `` - Scroll preview up + +## Tips +- Use `?` inside Neo-tree to see all available commands and their keybindings +- The tree follows your current file automatically (if `follow_current_file` is enabled) +- Hidden files (dotfiles) are toggled with `H` +- Most operations can be cancelled with `` diff --git a/archive/ORGANIZATION.md b/archive/ORGANIZATION.md new file mode 100644 index 00000000000..debe876380c --- /dev/null +++ b/archive/ORGANIZATION.md @@ -0,0 +1,389 @@ +# Neovim Configuration Organization Guide + +## Current Structure (What You Have) + +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua # Main entry point (1200 lines - TOO LARGE!) +โ”œโ”€โ”€ lua/ +โ”‚ โ”œโ”€โ”€ custom/ +โ”‚ โ”‚ โ””โ”€โ”€ plugins/ +โ”‚ โ”‚ โ”œโ”€โ”€ init.lua # Common plugins (all filetypes) +โ”‚ โ”‚ โ”œโ”€โ”€ flutter.lua # Flutter-specific (lazy-loaded) +โ”‚ โ”‚ โ”œโ”€โ”€ python.lua # Python-specific (lazy-loaded) +โ”‚ โ”‚ โ”œโ”€โ”€ svelte.lua # Svelte-specific (lazy-loaded) +โ”‚ โ”‚ โ””โ”€โ”€ session.lua # Session management +โ”‚ โ””โ”€โ”€ kickstart/ +โ”‚ โ”œโ”€โ”€ health.lua +โ”‚ โ””โ”€โ”€ plugins/ +โ”‚ โ”œโ”€โ”€ autopairs.lua +โ”‚ โ”œโ”€โ”€ debug.lua +โ”‚ โ”œโ”€โ”€ gitsigns.lua +โ”‚ โ”œโ”€โ”€ indent_line.lua +โ”‚ โ”œโ”€โ”€ lint.lua +โ”‚ โ””โ”€โ”€ neo-tree.lua +``` + +## Problems with Current Setup + +1. **`init.lua` is massive (1200 lines)** - Should be split into modules +2. **LSP setup is duplicated** - Language-specific LSP code is in `init.lua` instead of language files +3. **Unclear separation** - What belongs in `custom/` vs `kickstart/`? +4. **No clear loading strategy** - Which plugins load when? + +--- + +## Recommended Structure (Optimal Organization) + +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua # THIN entry point (~50 lines) +โ”‚ +โ”œโ”€โ”€ lua/ +โ”‚ โ”œโ”€โ”€ config/ +โ”‚ โ”‚ โ”œโ”€โ”€ options.lua # Vim options (set, opt) +โ”‚ โ”‚ โ”œโ”€โ”€ keymaps.lua # Global keymaps +โ”‚ โ”‚ โ”œโ”€โ”€ autocmds.lua # Global autocmds +โ”‚ โ”‚ โ””โ”€โ”€ lazy.lua # Lazy.nvim bootstrap +โ”‚ โ”‚ +โ”‚ โ”œโ”€โ”€ plugins/ +โ”‚ โ”‚ โ”œโ”€โ”€ core/ +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ui.lua # UI plugins (always loaded) +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ editor.lua # Editor enhancements (always loaded) +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ git.lua # Git tools (always loaded) +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ completion.lua # Completion engine (always loaded) +โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ โ”œโ”€โ”€ lsp/ +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ init.lua # LSP infrastructure (mason, lspconfig) +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ servers.lua # General LSP servers (lua_ls, etc.) +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ keymaps.lua # LSP keymaps (shared) +โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ โ””โ”€โ”€ lang/ +โ”‚ โ”‚ โ”œโ”€โ”€ python.lua # Python: LSP + formatters + linters +โ”‚ โ”‚ โ”œโ”€โ”€ flutter.lua # Flutter: LSP + debugging + tools +โ”‚ โ”‚ โ”œโ”€โ”€ svelte.lua # Svelte: LSP + formatters +โ”‚ โ”‚ โ”œโ”€โ”€ go.lua # Future: Go support +โ”‚ โ”‚ โ””โ”€โ”€ rust.lua # Future: Rust support +โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€ util/ +โ”‚ โ”œโ”€โ”€ lsp.lua # Shared LSP utilities +โ”‚ โ””โ”€โ”€ init.lua # Shared helper functions +``` + +--- + +## How This Works: Lazy-Loading Strategy + +### 1. **Core Plugins (Always Loaded)** +```lua +-- lua/plugins/core/editor.lua +return { + { 'echasnovski/mini.pairs' }, -- Autopairs + { 'folke/which-key.nvim' }, -- Keybinding helper + { 'nvim-telescope/telescope.nvim' }, -- Fuzzy finder +} +``` + +### 2. **LSP Infrastructure (Loaded Early)** +```lua +-- lua/plugins/lsp/init.lua +return { + 'neovim/nvim-lspconfig', + dependencies = { 'mason.nvim', 'mason-lspconfig.nvim' }, + config = function() + -- Setup mason, but don't configure language servers here + require('mason').setup() + require('mason-lspconfig').setup() + end, +} +``` + +### 3. **Language-Specific (Lazy-Loaded by FileType)** +```lua +-- lua/plugins/lang/python.lua +return { + -- Mason tools + { + 'WhoIsSethDaniel/mason-tool-installer.nvim', + ft = 'python', + config = function() + require('mason-tool-installer').setup({ + ensure_installed = { 'pyright', 'ruff' } + }) + end, + }, + + -- LSP setup + { + 'neovim/nvim-lspconfig', + ft = 'python', + config = function() + -- Start pyright via autocmd + vim.api.nvim_create_autocmd('FileType', { + pattern = 'python', + callback = function(args) + local capabilities = require('blink.cmp').get_lsp_capabilities() + vim.lsp.start({ + name = 'pyright', + cmd = { vim.fn.stdpath('data') .. '/mason/bin/pyright-langserver', '--stdio' }, + root_dir = vim.fs.root(args.buf, { 'pyproject.toml', 'setup.py', '.git' }), + capabilities = capabilities, + }) + end, + }) + end, + }, + + -- Formatters + { + 'stevearc/conform.nvim', + ft = 'python', + config = function() + require('conform').formatters_by_ft.python = { 'ruff_format', 'ruff_organize_imports' } + end, + }, +} +``` + +--- + +## Migration Plan (Step-by-Step) + +### Phase 1: Extract Configuration from init.lua +```lua +-- NEW init.lua (50 lines instead of 1200!) +require('config.options') -- Vim settings +require('config.keymaps') -- Global keymaps +require('config.autocmds') -- Global autocmds +require('config.lazy') -- Bootstrap lazy.nvim and load plugins +``` + +### Phase 2: Organize Plugins by Loading Strategy + +**Always Loaded (Core):** +- `lua/plugins/core/ui.lua` - colorscheme, statusline, bufferline +- `lua/plugins/core/editor.lua` - telescope, which-key, autopairs, neo-tree +- `lua/plugins/core/git.lua` - gitsigns, fugitive +- `lua/plugins/core/completion.lua` - blink.cmp + +**Lazy-Loaded by FileType:** +- `lua/plugins/lang/python.lua` - ft = 'python' +- `lua/plugins/lang/flutter.lua` - ft = { 'dart', 'flutter' } +- `lua/plugins/lang/svelte.lua` - ft = 'svelte' + +**Lazy-Loaded by Command:** +- Debugging tools - cmd = { 'DapContinue', 'DapToggleBreakpoint' } +- Session management - cmd = { 'SessionSave', 'SessionLoad' } + +### Phase 3: Fix LSP Loading Issue + +**Problem:** You discovered that language-specific LSP configs in lazy-loaded files don't work because `nvim-lspconfig` is already loaded by `init.lua`. + +**Solution:** Two approaches: + +#### Option A: Centralized LSP Setup (Simpler) +```lua +-- lua/plugins/lsp/servers.lua +local M = {} + +M.setup_python = function() + -- Python LSP setup +end + +M.setup_flutter = function() + -- Flutter LSP setup +end + +-- Autocmds to trigger setup +vim.api.nvim_create_autocmd('FileType', { + pattern = 'python', + once = true, + callback = M.setup_python, +}) +``` + +#### Option B: Per-Language Setup (Cleaner but Complex) +```lua +-- lua/plugins/lang/python.lua +return { + { + 'WhoIsSethDaniel/mason-tool-installer.nvim', + ft = 'python', + config = function() + -- Install tools + require('mason-tool-installer').setup({ ensure_installed = { 'pyright', 'ruff' }}) + + -- Setup LSP via autocmd (since lspconfig is already loaded) + vim.api.nvim_create_autocmd('FileType', { + pattern = 'python', + callback = function(args) + require('util.lsp').start_server('pyright', args.buf, { + settings = { python = { analysis = { typeCheckingMode = 'basic' }}} + }) + end, + }) + end, + }, +} + +-- lua/util/lsp.lua (shared utility) +local M = {} + +M.start_server = function(name, bufnr, opts) + local clients = vim.lsp.get_clients({ bufnr = bufnr, name = name }) + if #clients > 0 then return end + + local capabilities = require('blink.cmp').get_lsp_capabilities() + vim.lsp.start(vim.tbl_deep_extend('force', { + name = name, + capabilities = capabilities, + }, opts)) +end + +return M +``` + +--- + +## Loading Performance Best Practices + +### 1. Use Lazy-Loading Triggers + +```lua +-- โŒ BAD: Loads immediately on startup +{ 'some/plugin' } + +-- โœ… GOOD: Loads only when needed +{ 'some/plugin', ft = 'python' } -- When opening .py files +{ 'some/plugin', cmd = 'SomeCommand' } -- When running :SomeCommand +{ 'some/plugin', keys = 'x' } -- When pressing x +{ 'some/plugin', event = 'VeryLazy' } -- After startup (low priority) +``` + +### 2. Profile Your Startup Time + +```bash +# Measure startup time +nvim --startuptime startup.log + +# Find slow plugins +grep "sourcing" startup.log | sort -k2 -n +``` + +### 3. Use `:Lazy` to Monitor Loading + +- Green plugins = loaded +- Gray plugins = not loaded yet (lazy) +- See what triggered loading + +--- + +## Recommended Final Structure + +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua # ~50 lines: require config modules +โ”‚ +โ”œโ”€โ”€ lua/ +โ”‚ โ”œโ”€โ”€ config/ +โ”‚ โ”‚ โ”œโ”€โ”€ options.lua # set.number, opt.clipboard, etc. +โ”‚ โ”‚ โ”œโ”€โ”€ keymaps.lua # Global keymaps only +โ”‚ โ”‚ โ”œโ”€โ”€ autocmds.lua # Global autocmds only +โ”‚ โ”‚ โ””โ”€โ”€ lazy.lua # Bootstrap lazy.nvim +โ”‚ โ”‚ +โ”‚ โ”œโ”€โ”€ plugins/ +โ”‚ โ”‚ โ”œโ”€โ”€ core/ +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ui.lua # Colorscheme, statusline, etc. +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ editor.lua # Telescope, which-key, autopairs +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ git.lua # Gitsigns, fugitive +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ completion.lua # blink.cmp +โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ โ”œโ”€โ”€ lsp/ +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ init.lua # Mason, lspconfig setup +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ servers.lua # lua_ls and other general servers +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ keymaps.lua # LSP keymaps (on_attach) +โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ โ””โ”€โ”€ lang/ +โ”‚ โ”‚ โ”œโ”€โ”€ python.lua # ft = 'python' +โ”‚ โ”‚ โ”œโ”€โ”€ flutter.lua # ft = 'dart' +โ”‚ โ”‚ โ””โ”€โ”€ svelte.lua # ft = 'svelte' +โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€ util/ +โ”‚ โ”œโ”€โ”€ lsp.lua # Shared LSP helpers +โ”‚ โ””โ”€โ”€ init.lua # Shared utility functions +โ”‚ +โ”œโ”€โ”€ ORGANIZATION.md # This file +โ”œโ”€โ”€ MIGRATION.md # Step-by-step migration guide +โ””โ”€โ”€ README.md # Your custom README +``` + +--- + +## Key Principles + +1. **Thin `init.lua`** - Just require modules, no logic +2. **Separate concerns** - Options, keymaps, autocmds, plugins +3. **Lazy-load everything possible** - Use `ft`, `cmd`, `keys`, `event` +4. **Language files are independent** - Each lang/ file is self-contained +5. **Share common code** - Use `util/` for helpers +6. **Profile regularly** - Use `:Lazy profile` and `--startuptime` + +--- + +## Learning Resources + +### Understanding Neovim Configuration +- `:help lua-guide` - Official Lua guide +- `:help options` - All vim options +- `:help api` - Lua API reference + +### Lazy-Loading +- `:help lazy.nvim` - Lazy.nvim documentation +- `:Lazy profile` - See what's slow +- `:Lazy` - Interactive plugin manager + +### LSP +- `:help lsp` - LSP overview +- `:help vim.lsp.start()` - Start LSP servers +- `:LspInfo` - See active LSP clients + +### Performance +- `nvim --startuptime startup.log` - Measure startup +- `:profile start profile.log | profile func * | profile file *` - Profile runtime + +--- + +## Next Steps + +1. **Commit current working state** โœ… (You're doing this now) +2. **Read through this guide** to understand the concepts +3. **Try the migration in a branch** (don't break your working config!) +4. **Migrate incrementally**: + - Step 1: Extract options/keymaps from init.lua + - Step 2: Move plugins to core/ structure + - Step 3: Refactor language-specific configs +5. **Test after each step** - Make sure everything still works +6. **Profile before and after** - Measure improvements + +--- + +## Questions to Consider + +1. **Do you need kickstart/ folder anymore?** + - If you understand the code, merge it into your own structure + +2. **How many languages will you support?** + - 3-5 languages: Current structure is fine + - 10+ languages: Consider more sophisticated loading + +3. **Do you want to share your config?** + - Yes: Document everything, make it modular + - No: Optimize for your own workflow + +4. **How often will you add new languages?** + - Frequently: Build a template system + - Rarely: Current per-file approach works + +--- + +**Remember:** This is YOUR config. Start with what works, refactor when you understand WHY you're refactoring. Don't cargo-cult someone else's structure! diff --git a/archive/README.old.md b/archive/README.old.md new file mode 100644 index 00000000000..4113950550d --- /dev/null +++ b/archive/README.old.md @@ -0,0 +1,241 @@ +# kickstart.nvim + +## Introduction + +A starting point for Neovim that is: + +* Small +* Single-file +* Completely Documented + +**NOT** a Neovim distribution, but instead a starting point for your configuration. + +## Installation + +### Install Neovim + +Kickstart.nvim targets *only* the latest +['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest +['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. +If you are experiencing issues, please make sure you have the latest versions. + +### Install External Dependencies + +External Requirements: +- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) +- [ripgrep](https://github.com/BurntSushi/ripgrep#installation), + [fd-find](https://github.com/sharkdp/fd#installation) +- Clipboard tool (xclip/xsel/win32yank or other depending on the platform) +- A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons + - if you have it set `vim.g.have_nerd_font` in `init.lua` to true +- Emoji fonts (Ubuntu only, and only if you want emoji!) `sudo apt install fonts-noto-color-emoji` +- Language Setup: + - If you want to write Typescript, you need `npm` + - If you want to write Golang, you will need `go` + - etc. + +> [!NOTE] +> See [Install Recipes](#Install-Recipes) for additional Windows and Linux specific notes +> and quick install snippets + +### Install Kickstart + +> [!NOTE] +> [Backup](#FAQ) your previous configuration (if any exists) + +Neovim's configurations are located under the following paths, depending on your OS: + +| OS | PATH | +| :- | :--- | +| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | +| Windows (cmd)| `%localappdata%\nvim\` | +| Windows (powershell)| `$env:LOCALAPPDATA\nvim\` | + +#### Recommended Step + +[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo +so that you have your own copy that you can modify, then install by cloning the +fork to your machine using one of the commands below, depending on your OS. + +> [!NOTE] +> Your fork's URL will be something like this: +> `https://github.com//kickstart.nvim.git` + +You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file +too - it's ignored in the kickstart repo to make maintenance easier, but it's +[recommended to track it in version control](https://lazy.folke.io/usage/lockfile). + +#### Clone kickstart.nvim + +> [!NOTE] +> If following the recommended step above (i.e., forking the repo), replace +> `nvim-lua` with `` in the commands below + +
Linux and Mac + +```sh +git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim +``` + +
+ +
Windows + +If you're using `cmd.exe`: + +``` +git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim" +``` + +If you're using `powershell.exe` + +``` +git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim" +``` + +
+ +### Post Installation + +Start Neovim + +```sh +nvim +``` + +That's it! Lazy will install all the plugins you have. Use `:Lazy` to view +the current plugin status. Hit `q` to close the window. + +#### Read The Friendly Documentation + +Read through the `init.lua` file in your configuration folder for more +information about extending and exploring Neovim. That also includes +examples of adding popularly requested plugins. + +> [!NOTE] +> For more information about a particular plugin check its repository's documentation. + + +### Getting Started + +[The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o) + +### FAQ + +* What should I do if I already have a pre-existing Neovim configuration? + * You should back it up and then delete all associated files. + * This includes your existing init.lua and the Neovim files in `~/.local` + which can be deleted with `rm -rf ~/.local/share/nvim/` +* Can I keep my existing configuration in parallel to kickstart? + * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` + to maintain multiple configurations. For example, you can install the kickstart + configuration in `~/.config/nvim-kickstart` and create an alias: + ``` + alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' + ``` + When you run Neovim using `nvim-kickstart` alias it will use the alternative + config directory and the matching local directory + `~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim + distribution that you would like to try out. +* What if I want to "uninstall" this configuration: + * See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information +* Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? + * The main purpose of kickstart is to serve as a teaching tool and a reference + configuration that someone can easily use to `git clone` as a basis for their own. + As you progress in learning Neovim and Lua, you might consider splitting `init.lua` + into smaller parts. A fork of kickstart that does this while maintaining the + same functionality is available here: + * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) + * Discussions on this topic can be found here: + * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) + * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) + +### Install Recipes + +Below you can find OS specific install instructions for Neovim and dependencies. + +After installing all the dependencies continue with the [Install Kickstart](#Install-Kickstart) step. + +#### Windows Installation + +
Windows with Microsoft C++ Build Tools and CMake +Installation may require installing build tools and updating the run command for `telescope-fzf-native` + +See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) + +This requires: + +- Install CMake and the Microsoft C++ Build Tools on Windows + +```lua +{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } +``` +
+
Windows with gcc/make using chocolatey +Alternatively, one can install gcc and make which don't require changing the config, +the easiest way is to use choco: + +1. install [chocolatey](https://chocolatey.org/install) +either follow the instructions on the page or use winget, +run in cmd as **admin**: +``` +winget install --accept-source-agreements chocolatey.chocolatey +``` + +2. install all requirements using choco, exit the previous cmd and +open a new one so that choco path is set, and run in cmd as **admin**: +``` +choco install -y neovim git ripgrep wget fd unzip gzip mingw make +``` +
+
WSL (Windows Subsystem for Linux) + +``` +wsl --install +wsl +sudo add-apt-repository ppa:neovim-ppa/unstable -y +sudo apt update +sudo apt install make gcc ripgrep unzip git xclip neovim +``` +
+ +#### Linux Install +
Ubuntu Install Steps + +``` +sudo add-apt-repository ppa:neovim-ppa/unstable -y +sudo apt update +sudo apt install make gcc ripgrep unzip git xclip neovim +``` +
+
Debian Install Steps + +``` +sudo apt update +sudo apt install make gcc ripgrep unzip git xclip curl + +# Now we install nvim +curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz +sudo rm -rf /opt/nvim-linux-x86_64 +sudo mkdir -p /opt/nvim-linux-x86_64 +sudo chmod a+rX /opt/nvim-linux-x86_64 +sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz + +# make it available in /usr/local/bin, distro installs to /usr/bin +sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/ +``` +
+
Fedora Install Steps + +``` +sudo dnf install -y gcc make git ripgrep fd-find unzip neovim +``` +
+ +
Arch Install Steps + +``` +sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim +``` +
+ diff --git a/archive/SETUP-GUIDE.md b/archive/SETUP-GUIDE.md new file mode 100644 index 00000000000..baafd0b2c34 --- /dev/null +++ b/archive/SETUP-GUIDE.md @@ -0,0 +1,307 @@ +# VS Code-like Profile Setup for Neovim + +This configuration implements a VS Code-like "profiles" system where language-specific plugins and tools only load when working with their respective file types. + +## ๐ŸŽฏ Architecture + +### File Structure +``` +~/.config/nvim/ +โ”œโ”€โ”€ init.lua # Main config with shared LSP, Treesitter, etc. +โ””โ”€โ”€ lua/ + โ””โ”€โ”€ custom/ + โ””โ”€โ”€ plugins/ + โ”œโ”€โ”€ init.lua # Common plugins (Copilot, Neo-tree) + โ”œโ”€โ”€ flutter.lua # Flutter/Dart profile + โ”œโ”€โ”€ python.lua # Python profile + โ””โ”€โ”€ svelte.lua # Svelte/Web profile +``` + +### How It Works +- **lazy.nvim** loads plugins based on file types (`ft = { 'dart', 'python', 'svelte' }`) +- When you open a `.dart` file โ†’ Flutter tools load +- When you open a `.py` file โ†’ Python tools load +- When you open a `.svelte` file โ†’ Svelte tools load +- Common plugins (Copilot, Neo-tree) are always available + +## ๐Ÿ“ฆ What's Included + +### Common (All Profiles) +- **GitHub Copilot**: AI pair programming +- **Neo-tree**: File explorer (commented out, enable if desired) +- **Telescope**: Fuzzy finder +- **Treesitter**: Syntax highlighting +- **blink.cmp**: Autocompletion engine +- **lua_ls**: LSP for Neovim config editing + +### Flutter Profile (`flutter.lua`) +**Loads on**: `.dart` files + +**Tools**: +- `flutter-tools.nvim`: Flutter development tools +- `dartls`: Dart LSP server +- Widget guides, closing tags, hot reload + +**Keymaps** (under `f`): +- `fr` - Flutter run +- `fq` - Flutter quit +- `fR` - Flutter restart +- `fd` - Flutter devices +- `fe` - Flutter emulators +- `fo` - Flutter outline +- `fc` - Copy profiler URL +- `fl` - Restart LSP + +### Python Profile (`python.lua`) +**Loads on**: `.py` files + +**Tools**: +- `pyright`: Python LSP server with type checking +- `ruff_format`: Fast Python formatter +- `ruff_organize_imports`: Import sorting +- Alternative: `black` + `isort` (commented out) + +**Format on save**: Enabled for Python files + +### Svelte Profile (`svelte.lua`) +**Loads on**: `.svelte`, `.ts`, `.js` files + +**Tools**: +- `svelte-language-server`: Svelte LSP +- `ts_ls`: TypeScript/JavaScript LSP +- `tailwindcss`: Tailwind CSS LSP with completions +- `prettier`: Code formatter for web files +- `emmet-vim`: HTML/CSS abbreviation expansion + +**Keymaps**: +- `,` - Expand Emmet abbreviation (e.g., `div.container` โ†’ full HTML) + +**Treesitter parsers**: svelte, typescript, tsx, javascript, css, html, json + +## ๐Ÿš€ Installation Steps + +### 1. Restart Neovim +```bash +nvim +``` + +### 2. Install Plugins +Once Neovim opens, lazy.nvim should automatically start installing plugins. If not: +```vim +:Lazy sync +``` + +Wait for all plugins to install. This may take a few minutes. + +### 3. Install LSP Servers & Tools +```vim +:Mason +``` + +Press `g?` for help. Verify these are installed: +- **Flutter**: `dart-language-server` (dartls) +- **Python**: `pyright`, `ruff`, `black` (optional), `isort` (optional) +- **Svelte**: `svelte-language-server`, `typescript-language-server`, `tailwindcss-language-server`, `prettier` +- **Common**: `lua-language-server`, `stylua` + +Mason will auto-install most of these via `mason-tool-installer`. + +### 4. Install Treesitter Parsers +Parsers should auto-install when you open files. To manually install: +```vim +:TSInstall dart python svelte typescript tsx javascript css html json +``` + +Check status: +```vim +:TSInstallInfo +``` + +### 5. Test Each Profile + +#### Test Flutter Profile +```bash +nvim test.dart +``` + +Inside Neovim: +- Type some Dart code (e.g., `void main() {`) +- Check LSP is active: `:LspInfo` +- Try hot reload keymaps if in a Flutter project: `fr` + +#### Test Python Profile +```bash +nvim test.py +``` + +Inside Neovim: +- Type some Python code (e.g., `def hello():`) +- Check LSP is active: `:LspInfo` +- Save file to trigger auto-formatting +- Try hover: `K` on a function/variable + +#### Test Svelte Profile +```bash +nvim test.svelte +``` + +Inside Neovim: +- Type Svelte component code +- Check LSP is active: `:LspInfo` +- Try Emmet: type `div.container>ul>li*3` then `,` +- Save file to trigger prettier formatting + +## ๐Ÿ”ง Configuration Details + +### Node.js for Copilot +Node.js is configured via fnm (Fast Node Manager): +- **Path**: `~/.local/share/fnm/aliases/default/bin` +- **Version**: Currently v24.11.0 LTS +- **Auto-update**: Using fnm aliases, so updating Node.js via `fnm install --lts` will automatically work + +To update Node.js: +```bash +fnm install --lts +fnm default lts-latest +``` + +### Shared LSP Capabilities +All language-specific LSPs use shared capabilities from `blink.cmp` for consistent completion behavior. This is configured automatically. + +### Format on Save +Enabled by default for all languages except C/C++. Language-specific formatters are defined in their respective profile files. + +To disable for a specific file type, edit `init.lua`: +```lua +local disable_filetypes = { c = true, cpp = true, python = true } -- example +``` + +## ๐Ÿ“ Customization + +### Adding a New Language Profile + +1. Create `lua/custom/plugins/mylang.lua`: +```lua +return { + { + 'neovim/nvim-lspconfig', + ft = { 'mylang' }, -- file type trigger + config = function() + local capabilities = require('blink.cmp').get_lsp_capabilities() + require('lspconfig').mylang_ls.setup { + capabilities = capabilities, + } + end, + }, + + { + 'stevearc/conform.nvim', + ft = { 'mylang' }, + opts = { + formatters_by_ft = { + mylang = { 'my_formatter' }, + }, + }, + }, + + { + 'nvim-treesitter/nvim-treesitter', + ft = { 'mylang' }, + opts = { + ensure_installed = { 'mylang' }, + }, + }, +} +``` + +2. Restart Neovim and open a `.mylang` file + +### Enabling Neo-tree +The file tree is currently commented out. To enable: + +Edit `lua/custom/plugins/init.lua` and uncomment the Neo-tree section: +```lua +return { + { + 'nvim-neo-tree/neo-tree.nvim', + -- ... (uncomment the entire block) + }, +} +``` + +Then `:Lazy sync` and use `e` to toggle the file tree. + +### Changing Keymaps +Edit the respective language file in `lua/custom/plugins/`. + +Example: Change Flutter hot reload from `fr` to `h`: +```lua +-- In lua/custom/plugins/flutter.lua +vim.keymap.set('n', 'h', 'FlutterRun', { desc = '[H]ot reload' }) +``` + +## ๐Ÿ› Troubleshooting + +### Plugins not loading +```vim +:Lazy check +:Lazy sync +``` + +### LSP not working +```vim +:LspInfo " Check if LSP is attached +:Mason " Verify servers are installed +:checkhealth lsp " Run LSP diagnostics +``` + +### Copilot not working +```vim +:Copilot setup " Initial setup (if not done) +:Copilot status " Check connection +``` + +If Node.js path issues: +```bash +# Verify Node.js is in fnm default alias +ls ~/.local/share/fnm/aliases/default/bin/node +``` + +### Formatter not running on save +Check if formatter is installed: +```vim +:Mason +``` + +Check if file type has formatter configured: +```vim +:ConformInfo +``` + +### Treesitter parsers missing +```vim +:TSInstall +# Or install all at once: +:TSInstall dart python svelte typescript tsx javascript css html json +``` + +## ๐Ÿ“š Resources + +- **Neovim LSP**: `:help lsp` +- **lazy.nvim**: `:help lazy.nvim` +- **Telescope**: `:help telescope.nvim` +- **Treesitter**: `:help nvim-treesitter` +- **conform.nvim**: `:help conform.nvim` +- **Mason**: `:help mason.nvim` + +## ๐ŸŽ‰ What's Next? + +Your setup is ready! Here are some next steps: + +1. **Explore Copilot**: Try getting AI suggestions as you code +2. **Learn Flutter Tools**: Use `fr` to run Flutter apps with hot reload +3. **Try Emmet**: Speed up HTML/Svelte writing with abbreviations +4. **Customize**: Add more keymaps, plugins, or language profiles as needed +5. **Consider Neo-tree**: Uncomment if you prefer a file explorer sidebar + +Enjoy your VS Code-like Neovim setup! ๐Ÿš€ diff --git a/archive/TESTING.md b/archive/TESTING.md new file mode 100644 index 00000000000..10335e4760d --- /dev/null +++ b/archive/TESTING.md @@ -0,0 +1,128 @@ +# Profile Testing Instructions + +## How to Test Each Profile + +### 1. Flutter Profile (test.dart) +```bash +nvim test.dart +``` + +**What to check:** +- [ ] LSP loads automatically (check with `:LspInfo`) +- [ ] You see dartls in the LSP list +- [ ] Hover over `StatelessWidget` and press `K` - should show documentation +- [ ] Try completion: type `Theme.of(` and see suggestions +- [ ] Check Flutter keymaps work: + - Press `` (space by default) and wait - should see Flutter commands + - Try `fl` to restart LSP +- [ ] Widget guides should show (vertical lines for nested widgets) +- [ ] Closing tags should appear (e.g., `// MyApp` after closing brace) + +### 2. Python Profile (test.py) +```bash +nvim test.py +``` + +**What to check:** +- [ ] LSP loads automatically (check with `:LspInfo`) +- [ ] You see pyright in the LSP list +- [ ] Hover over `calculate_fibonacci` and press `K` - should show type info +- [ ] Try completion: type `fib.` and see list methods +- [ ] **Test formatting on save:** + 1. Add some messy code: `x=1+2+3+4+5` + 2. Save the file (`:w`) + 3. Should auto-format to: `x = 1 + 2 + 3 + 4 + 5` +- [ ] Add an unused import at the top: `import os` + - Save the file - ruff should remove it or flag it +- [ ] Lint errors should appear (the f-string and unused sys import) + +### 3. Svelte Profile (test.svelte) +```bash +nvim test.svelte +``` + +**What to check:** +- [ ] LSP loads automatically (check with `:LspInfo`) +- [ ] You should see svelte-language-server +- [ ] Syntax highlighting works (script, template, style sections) +- [ ] **Test Emmet expansion:** + 1. In the `
` section, type: `div.test>ul>li*3` + 2. Press `,` (Ctrl+e then comma) + 3. Should expand to nested div/ul/li structure +- [ ] **Test formatting on save:** + 1. Mess up some HTML: `` + 2. Save the file (`:w`) + 3. Should auto-format with prettier +- [ ] Try completion on Tailwind classes: type `class="bg-` and see suggestions + +### 4. Test Lazy Loading +```bash +nvim test.lua # or init.lua +``` + +**What to check:** +- [ ] Open a Lua file +- [ ] Check `:LspInfo` - should only see lua_ls, NOT dartls, pyright, or svelte +- [ ] Check `:Lazy` - Flutter, Python, Svelte plugins should be "not loaded" +- [ ] Now open test.py in a split: `:split test.py` +- [ ] Check `:Lazy` again - Python plugins should now be "loaded" + +### 5. Verify Mason Tools +```bash +nvim +``` +Then run `:Mason` + +**Tools that should be installed:** +- [x] lua-language-server (lua_ls) +- [x] stylua +- [ ] dart-language-server (dartls) # For Flutter +- [ ] pyright # For Python +- [ ] ruff # For Python +- [ ] svelte-language-server +- [ ] typescript-language-server (tsserver/ts_ls) +- [ ] tailwindcss-language-server +- [ ] prettier + +**If any are missing:** +1. Highlight the missing tool in Mason +2. Press `i` to install +3. Or wait - mason-tool-installer should install them automatically + +## Common Issues + +### LSP not loading +```vim +:checkhealth lsp +:LspLog " Check for errors +``` + +### Formatter not working +```vim +:ConformInfo " Check formatter config +:Mason " Verify formatter is installed +``` + +### Plugins not loading +```vim +:Lazy check " Check plugin status +:Lazy sync " Re-sync plugins +``` + +### Node.js issues with Copilot +```vim +:echo $PATH " Should include fnm path +``` + +## Success Criteria + +โœ… All three language profiles should: +1. Load their respective LSP automatically on file open +2. Provide completions and hover info +3. Auto-format on save +4. NOT load when opening other file types (lazy loading works) + +โœ… Common plugins: +1. Copilot should work in all file types (`:Copilot status`) +2. Telescope should work (`:Telescope find_files`) +3. Which-key should show keymaps when pressing `` diff --git a/doc/kickstart.txt b/doc/kickstart.txt deleted file mode 100644 index cb87ac3f1de..00000000000 --- a/doc/kickstart.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================================ -INTRODUCTION *kickstart.nvim* - -Kickstart.nvim is a project to help you get started on your neovim journey. - - *kickstart-is-not* -It is not: -- Complete framework for every plugin under the sun -- Place to add every plugin that could ever be useful - - *kickstart-is* -It is: -- Somewhere that has a good start for the most common "IDE" type features: - - autocompletion - - goto-definition - - find references - - fuzzy finding - - and hinting at what more can be done :) -- A place to _kickstart_ your journey. - - You should fork this project and use/modify it so that it matches your - style and preferences. If you don't want to do that, there are probably - other projects that would fit much better for you (and that's great!)! - - vim:tw=78:ts=8:ft=help:norl: diff --git a/doc/tags b/doc/tags deleted file mode 100644 index 687ae7721d9..00000000000 --- a/doc/tags +++ /dev/null @@ -1,3 +0,0 @@ -kickstart-is kickstart.txt /*kickstart-is* -kickstart-is-not kickstart.txt /*kickstart-is-not* -kickstart.nvim kickstart.txt /*kickstart.nvim* diff --git a/docs/DOCUMENTATION-PLAN.md b/docs/DOCUMENTATION-PLAN.md new file mode 100644 index 00000000000..cfa5c7aa6b4 --- /dev/null +++ b/docs/DOCUMENTATION-PLAN.md @@ -0,0 +1,316 @@ +# ๐Ÿ“‹ Documentation Plan & Status + +## โœ… Completed + +### 1. Changed to in Cheatsheet +- Updated `lua/plugins/core/cheatsheet.lua` +- All 105 instances of `` changed to `` +- Ensures consistency with which-key display + +### 2. Created New Professional README.md +- Location: `README.new.md` (ready to replace README.md) +- Features: Badges, features list, requirements, quick start +- Links to comprehensive documentation structure +- Professional appearance with emojis and formatting + +### 3. Created Documentation Structure +``` +docs/ +โ”œโ”€โ”€ README.md # Main documentation index โœ… +โ”œโ”€โ”€ getting-started/ +โ”‚ โ”œโ”€โ”€ README.md # Getting started overview โœ… +โ”‚ โ”œโ”€โ”€ installation.md # Detailed install steps (TODO) +โ”‚ โ”œโ”€โ”€ first-steps.md # First hour tutorial (TODO) +โ”‚ โ”œโ”€โ”€ quick-reference.md # Essential commands (TODO) +โ”‚ โ””โ”€โ”€ philosophy.md # Design principles (TODO) +โ”œโ”€โ”€ keymaps/ +โ”‚ โ”œโ”€โ”€ README.md # Keymaps overview โœ… +โ”‚ โ”œโ”€โ”€ core.md # Leader key bindings (TODO) +โ”‚ โ”œโ”€โ”€ lsp.md # LSP commands (TODO) +โ”‚ โ”œโ”€โ”€ plugins.md # Plugin-specific (TODO) +โ”‚ โ”œโ”€โ”€ debug.md # Debug keymaps (TODO) +โ”‚ โ”œโ”€โ”€ consistency.md # Cross-plugin patterns โœ… (copied) +โ”‚ โ””โ”€โ”€ duplicates.md # Duplicate keys guide โœ… (copied) +โ”œโ”€โ”€ plugins/ +โ”‚ โ”œโ”€โ”€ README.md # Plugins overview (TODO) +โ”‚ โ”œโ”€โ”€ core.md # Telescope, Neo-tree, which-key (TODO) +โ”‚ โ”œโ”€โ”€ editor.md # TreeSitter, mini.nvim, etc (TODO) +โ”‚ โ”œโ”€โ”€ lsp.md # LSP & completion (TODO) +โ”‚ โ”œโ”€โ”€ debug.md # nvim-dap (TODO) +โ”‚ โ”œโ”€โ”€ git.md # Git integration (TODO) +โ”‚ โ””โ”€โ”€ ui.md # UI enhancements (TODO) +โ”œโ”€โ”€ languages/ +โ”‚ โ”œโ”€โ”€ README.md # Languages overview (TODO) +โ”‚ โ”œโ”€โ”€ flutter.md # Flutter/Dart guide (TODO) +โ”‚ โ”œโ”€โ”€ rust.md # Rust guide (TODO) +โ”‚ โ”œโ”€โ”€ python.md # Python guide (TODO) +โ”‚ โ”œโ”€โ”€ svelte.md # Svelte guide (TODO) +โ”‚ โ”œโ”€โ”€ typescript.md # TypeScript guide (TODO) +โ”‚ โ”œโ”€โ”€ go.md # Go guide (TODO) +โ”‚ โ””โ”€โ”€ others.md # Other languages (TODO) +โ”œโ”€โ”€ vim-mastery/ +โ”‚ โ”œโ”€โ”€ README.md # Vim mastery overview โœ… +โ”‚ โ”œโ”€โ”€ week-01-motions.md # Motion basics โœ… +โ”‚ โ”œโ”€โ”€ week-02-text-objects.md # Text objects (TODO) +โ”‚ โ”œโ”€โ”€ week-03-advanced.md # Advanced editing (TODO) +โ”‚ โ”œโ”€โ”€ week-04-macros.md # Macros & registers (TODO) +โ”‚ โ”œโ”€โ”€ week-05-cmdline.md # Command line (TODO) +โ”‚ โ”œโ”€โ”€ week-06-windows.md # Windows & tabs (TODO) +โ”‚ โ”œโ”€โ”€ week-07-search.md # Search & replace (TODO) +โ”‚ โ”œโ”€โ”€ week-08-marks.md # Marks & jumps (TODO) +โ”‚ โ”œโ”€โ”€ tips-and-tricks.md # Productivity tips (TODO) +โ”‚ โ”œโ”€โ”€ workflows.md # Real-world patterns (TODO) +โ”‚ โ””โ”€โ”€ advanced.md # Advanced topics (TODO) +โ”œโ”€โ”€ customization.md # Customization guide (TODO) +โ”œโ”€โ”€ plugin-development.md # Plugin dev (TODO) +โ”œโ”€โ”€ performance.md # Performance tuning (TODO) +โ”œโ”€โ”€ troubleshooting.md # Troubleshooting (TODO) +โ”œโ”€โ”€ migration.md # Migration guide (TODO) +โ””โ”€โ”€ faq.md # FAQ (TODO) +``` + +--- + +## ๐Ÿ“ Files to Remove/Consolidate + +### Remove (Redundant) +- `NEO-TREE-CHEATSHEET.md` - Incorporated into docs/keymaps/plugins.md +- `ORGANIZATION.md` - Internal planning doc, not needed for users + +### Move to Archive or Remove +- `TESTING.md` - Move to docs/development/ or remove +- `MIGRATION.md` - Move to docs/migration.md +- `SETUP-GUIDE.md` - Consolidate into docs/getting-started/installation.md +- `INSTALLATION.md` - Consolidate into docs/getting-started/installation.md + +### Keep but Update +- `LICENSE.md` - Keep at root +- `README.md` - Replace with README.new.md +- `lazy-lock.json` - Keep (Lazy.nvim uses this) + +--- + +## ๐ŸŽฏ Next Steps (Priority Order) + +### Phase 1: Core Documentation (High Priority) +1. **Replace README.md** with README.new.md +2. **Complete getting-started/** + - installation.md (consolidate INSTALLATION.md + SETUP-GUIDE.md) + - first-steps.md (interactive tutorial) + - quick-reference.md (one-page cheat sheet) + - philosophy.md (design decisions) + +3. **Complete keymaps/core.md** + - Consolidate KEYMAPS.md + - Organize by category + - Add examples + +4. **Complete keymaps/lsp.md** and **keymaps/plugins.md** + - Document all LSP keymaps + - Document Telescope, Neo-tree, Git, etc. + +### Phase 2: Plugin Documentation (Medium Priority) +5. **Create plugins/core.md** + - Telescope deep dive + - Neo-tree features + - which-key customization + +6. **Create plugins/lsp.md** and **plugins/debug.md** + - LSP configuration + - Mason setup + - Debug adapter setup + +### Phase 3: Language Guides (Medium Priority) +7. **Create language guides** + - flutter.md (full Flutter tools guide) + - rust.md (Crates.io integration) + - python.md (virtual envs, testing) + - Others as needed + +### Phase 4: Vim Mastery (Ongoing) +8. **Complete Vim mastery weeks 2-8** + - week-02-text-objects.md + - week-03-advanced.md + - week-04-macros.md + - week-05-cmdline.md + - week-06-windows.md + - week-07-search.md + - week-08-marks.md + +9. **Create supplementary guides** + - tips-and-tricks.md + - workflows.md + - advanced.md + +### Phase 5: Advanced Topics (Low Priority) +10. **Create advanced guides** + - customization.md + - plugin-development.md + - performance.md + - troubleshooting.md + - faq.md + +--- + +## ๐ŸŽจ Documentation Style Guide + +### Writing Principles +1. **Clear and Concise**: Get to the point quickly +2. **Example-Driven**: Show, don't just tell +3. **Progressive Disclosure**: Basic โ†’ Intermediate โ†’ Advanced +4. **Actionable**: Every guide includes exercises +5. **Searchable**: Good headers, keywords, cross-references + +### Formatting Standards +- **Emojis for visual hierarchy**: ๐ŸŽฏ ๐Ÿ”ฅ ๐Ÿ’ก โš ๏ธ ๐Ÿ“š +- **Code blocks with language**: ```vim, ```lua, ```bash +- **Tables for comparisons**: Keymap tables, feature matrices +- **Callouts**: Tips, Warnings, Notes +- **Navigation**: Links at top and bottom of every page + +### File Naming +- Use kebab-case: `week-01-motions.md` +- Be descriptive: `lsp-configuration.md` not `lsp.md` +- Group by prefix: `week-01-`, `week-02-`, etc. + +--- + +## ๐Ÿ“Š Estimated Completion Times + +### Already Done (4 hours) +- โœ… Cheatsheet โ†’ +- โœ… README.new.md +- โœ… docs/README.md +- โœ… docs/getting-started/README.md +- โœ… docs/keymaps/README.md +- โœ… docs/vim-mastery/README.md +- โœ… docs/vim-mastery/week-01-motions.md +- โœ… Copied consistency.md and duplicates.md + +### Phase 1 (8 hours) +- getting-started/ guides (4 hours) +- keymaps/core.md (2 hours) +- keymaps/lsp.md (1 hour) +- keymaps/plugins.md (1 hour) + +### Phase 2 (6 hours) +- plugins/ guides (6 hours total) + +### Phase 3 (8 hours) +- language guides (8 hours total) + +### Phase 4 (12 hours) +- Vim mastery weeks 2-8 (9 hours) +- tips/workflows/advanced (3 hours) + +### Phase 5 (6 hours) +- Advanced topics (6 hours) + +**Total Estimated**: ~44 hours of documentation writing + +--- + +## ๐ŸŽฏ Immediate Action Items + +### Right Now +1. **Backup old README.md** + ```bash + mv README.md README.old.md + mv README.new.md README.md + ``` + +2. **Remove redundant files** + ```bash + rm NEO-TREE-CHEATSHEET.md + rm ORGANIZATION.md + ``` + +3. **Clean up root directory** + ```bash + mkdir archive + mv KEYMAPS.md archive/ + mv CONSISTENCY.md archive/ # Now in docs/keymaps/ + mv DUPLICATES.md archive/ # Now in docs/keymaps/ + ``` + +### Next Session +4. **Write getting-started/installation.md** + - Consolidate INSTALLATION.md and SETUP-GUIDE.md + - Add macOS, Linux, Windows sections + - Include troubleshooting + +5. **Write getting-started/first-steps.md** + - Interactive 30-minute tutorial + - Essential keymaps only + - Real code examples + +6. **Write getting-started/quick-reference.md** + - One-page PDF-printable guide + - 50 most-used commands + - Organized by category + +--- + +## ๐Ÿ’ก Content Sources + +### From Existing Files +- KEYMAPS.md โ†’ docs/keymaps/core.md +- CONSISTENCY.md โ†’ docs/keymaps/consistency.md โœ… +- DUPLICATES.md โ†’ docs/keymaps/duplicates.md โœ… +- INSTALLATION.md + SETUP-GUIDE.md โ†’ docs/getting-started/installation.md +- lua/ plugin files โ†’ docs/plugins/ and docs/languages/ + +### From Configuration +- lua/config/keymaps.lua โ†’ keymap docs +- lua/plugins/ โ†’ plugin guides +- lua/plugins/lang/ โ†’ language guides +- Comments in code โ†’ feature documentation + +### Original Content Needed +- Vim mastery guides (weeks 2-8) +- Tips and tricks +- Workflows +- Troubleshooting +- FAQ +- Customization guide + +--- + +## ๐Ÿ”„ Maintenance Plan + +### Weekly +- Update any changed keymaps +- Add new plugin documentation +- Review and improve based on feedback + +### Monthly +- Check all links still work +- Update screenshots if needed +- Add new tips discovered + +### Per Release +- Update version numbers +- Document new features +- Archive old migration guides + +--- + +## ๐ŸŽŠ Success Criteria + +Documentation is complete when: +- โœ… New users can install and be productive in 1 hour +- โœ… All keymaps are documented with examples +- โœ… All plugins have usage guides +- โœ… Complete Vim mastery path (8 weeks) +- โœ… Troubleshooting covers common issues +- โœ… Users say "I found it in the docs" instead of asking + +--- + +
+ +**Documentation is a journey, not a destination!** + +This plan provides the structure. Now we execute, one file at a time. + +
diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000000..f69497a5c88 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,256 @@ +# ๐Ÿ“š Complete Documentation Guide + +Welcome to the comprehensive documentation for this Neovim configuration. This guide is organized to help you progress from beginner to advanced user. + +--- + +## ๐Ÿ—บ๏ธ Documentation Structure + +### ๐Ÿš€ Getting Started +**Start here if you're new or just installed the config** + +- [**Installation**](getting-started/installation.md) - Step-by-step setup guide +- [**First Steps**](getting-started/first-steps.md) - Your first hour with this config +- [**Quick Reference**](getting-started/quick-reference.md) - Essential commands cheat sheet +- [**Philosophy**](getting-started/philosophy.md) - Design principles and organization + +### โŒจ๏ธ Keymaps +**Complete keymap documentation with examples** + +- [**Overview**](keymaps/README.md) - Keymap organization philosophy +- [**Core Keymaps**](keymaps/core.md) - Leader key bindings (buffer, window, search, etc.) +- [**LSP Keymaps**](keymaps/lsp.md) - Language Server Protocol commands +- [**Plugin Keymaps**](keymaps/plugins.md) - Telescope, Neo-tree, Git, etc. +- [**Debug Keymaps**](keymaps/debug.md) - Debugging commands +- [**Duplicates Guide**](keymaps/duplicates.md) - Understanding multiple keys for same action +- [**Consistency Guide**](keymaps/consistency.md) - Cross-plugin key patterns + +### ๐Ÿ”Œ Plugins +**Understanding each plugin and how to use it** + +- [**Overview**](plugins/README.md) - All plugins explained +- [**Core Plugins**](plugins/core.md) - Telescope, Neo-tree, which-key, lazy.nvim +- [**Editor Plugins**](plugins/editor.md) - TreeSitter, mini.nvim, autopairs, etc. +- [**LSP & Completion**](plugins/lsp.md) - Language servers, nvim-cmp, snippets +- [**Debug Adapter**](plugins/debug.md) - nvim-dap setup and usage +- [**Git Integration**](plugins/git.md) - Gitsigns, LazyGit, fugitive +- [**UI Enhancements**](plugins/ui.md) - Colorscheme, statusline, bufferline + +### ๐Ÿ’ป Language Setup +**Language-specific configuration and features** + +- [**Overview**](languages/README.md) - All supported languages +- [**Flutter/Dart**](languages/flutter-dart.md) - Flutter tools, device management, hot reload +- [**Rust**](languages/rust.md) - rust-analyzer, Crates.io integration +- [**Python**](languages/python.md) - Pyright, virtual environments, testing +- [**Svelte**](languages/svelte.md) - Svelte LSP, web development +- [**TypeScript/JavaScript**](languages/typescript.md) - tsserver, ESLint, Prettier +- [**Go**](languages/go.md) - gopls, testing, debugging +- [**Other Languages**](languages/others.md) - Lua, JSON, YAML, Markdown, etc. + +### ๐ŸŽ“ Vim Mastery +**Progressive learning path to master Vim** + +- [**Overview**](vim-mastery/README.md) - Learning philosophy and roadmap +- [**Week 1: Motion Basics**](vim-mastery/week-01-motions.md) - hjkl, word motions, searching +- [**Week 2: Text Objects**](vim-mastery/week-02-text-objects.md) - iw, ap, at, etc. +- [**Week 3: Advanced Editing**](vim-mastery/week-03-advanced.md) - Visual mode, macros intro +- [**Week 4: Macros & Registers**](vim-mastery/week-04-macros.md) - Recording and replay +- [**Week 5: Command Line**](vim-mastery/week-05-cmdline.md) - Ex commands, ranges, substitution +- [**Week 6: Windows & Tabs**](vim-mastery/week-06-windows.md) - Managing your workspace +- [**Tips & Tricks**](vim-mastery/tips-and-tricks.md) - Productivity boosters +- [**Workflows**](vim-mastery/workflows.md) - Real-world editing patterns +- [**Advanced Topics**](vim-mastery/advanced.md) - Vim script, Lua, custom commands + +### ๐Ÿ› ๏ธ Advanced Topics + +- [**Customization**](customization.md) - Make this config your own +- [**Plugin Development**](plugin-development.md) - Create your own plugins +- [**Performance Tuning**](performance.md) - Optimize startup time +- [**Troubleshooting**](troubleshooting.md) - Common issues and solutions +- [**Migration Guide**](migration.md) - Coming from other configs +- [**FAQ**](faq.md) - Frequently asked questions + +--- + +## ๐Ÿ“– How to Use This Documentation + +### For Beginners +1. Start with [Getting Started](getting-started/README.md) +2. Learn [Quick Reference](getting-started/quick-reference.md) commands +3. Follow [Vim Mastery Week 1](vim-mastery/week-01-motions.md) +4. Use the [in-editor cheatsheet](#in-editor-help) constantly + +### For Intermediate Users +1. Review [Keymaps documentation](keymaps/README.md) to discover new commands +2. Explore [Plugin guides](plugins/README.md) for advanced features +3. Continue [Vim Mastery](vim-mastery/README.md) progression +4. Learn language-specific features in [Languages](languages/README.md) + +### For Advanced Users +1. Study [Customization](customization.md) to extend the config +2. Optimize with [Performance Tuning](performance.md) +3. Master [Advanced Topics](vim-mastery/advanced.md) +4. Contribute improvements back to the project + +--- + +## ๐ŸŽฏ In-Editor Help + +You don't need to leave Neovim to access help: + +### Built-in Cheatsheet +- `sc` - Comprehensive searchable cheatsheet (200+ keymaps) +- `sk` - Telescope keymap search +- `?` - Quick keymap fuzzy search +- `sK` - Which-key command palette + +### Context-Sensitive Help +- `K` - Hover documentation (LSP) +- `k` - Signature help +- `?` (in Telescope/Neo-tree) - Show plugin-specific help +- `:help ` - Vim's built-in help system + +### Discovery Tools +- Press `` and wait - which-key shows all available keymaps +- Press `g` and wait - see all "go to" commands +- Press `]` or `[` and wait - see all next/previous commands + +--- + +## ๐Ÿ’ก Learning Philosophy + +This documentation follows a **progressive disclosure** approach: + +1. **Start Simple**: Basic commands to be productive immediately +2. **Build Gradually**: Add one new technique per week +3. **Practice Deliberately**: Focus on mastering before moving on +4. **Apply Immediately**: Use new skills in real work +5. **Iterate**: Return to earlier topics with new understanding + +### The One-Trick-Per-Week Method + +Instead of trying to learn everything at once: +- Pick ONE new command/technique each week +- Use it consciously until it becomes muscle memory +- Track your progress in [Vim Mastery](vim-mastery/README.md) +- After a year, you'll have 52 new tricks! + +--- + +## ๐Ÿ—บ๏ธ Learning Paths + +### Path 1: Productive in One Day +*Goal: Get work done immediately* + +1. [Installation](getting-started/installation.md) - 30 min +2. [Quick Reference](getting-started/quick-reference.md) - 15 min +3. [Core Keymaps](keymaps/core.md) - Learn `sf`, `sg`, `bb` +4. Start coding with LSP features (K, gra, gd) + +### Path 2: Vim Proficiency in 6 Weeks +*Goal: Become efficient with Vim motions* + +1. Week 1: [Motion Basics](vim-mastery/week-01-motions.md) +2. Week 2: [Text Objects](vim-mastery/week-02-text-objects.md) +3. Week 3: [Advanced Editing](vim-mastery/week-03-advanced.md) +4. Week 4: [Macros & Registers](vim-mastery/week-04-macros.md) +5. Week 5: [Command Line](vim-mastery/week-05-cmdline.md) +6. Week 6: [Windows & Tabs](vim-mastery/week-06-windows.md) + +### Path 3: Master All Features +*Goal: Unlock the full power of this config* + +1. Complete Path 2 (Vim Proficiency) +2. Deep dive into [All Plugins](plugins/README.md) +3. Master your primary language setup +4. Learn [Advanced Workflows](vim-mastery/workflows.md) +5. Customize and extend ([Customization Guide](customization.md)) + +--- + +## ๐ŸŽ“ Recommended External Resources + +### Books +- **Practical Vim** by Drew Neil - The best Vim book +- **Modern Vim** by Drew Neil - Neovim-specific features +- **Learning the Vi and Vim Editors** - Comprehensive reference + +### Video Courses +- **ThePrimeagen's Vim Course** - Entertaining and informative +- **Vim Casts** - Short, focused video tutorials +- **TJ DeVries' Neovim YouTube** - Creator of kickstart.nvim + +### Interactive Learning +- **vimtutor** - Run `:Tutor` in Neovim +- **Vim Adventures** - Game to learn Vim +- **OpenVim** - Interactive tutorial + +### Community +- **r/neovim** - Reddit community +- **Neovim Discourse** - Official forum +- **Matrix/Discord** - Real-time chat + +--- + +## ๐Ÿ“ Documentation Conventions + +### Notation +- `` - Your leader key (default: Space) +- `` - Control + x +- `` - Alt/Meta + x +- `` - Enter/Return key +- `{motion}` - Any motion command (w, e, $, etc.) +- `[count]` - Optional number prefix + +### Visual Cues +- ๐Ÿ’ก **Tip** - Helpful suggestion +- โš ๏ธ **Warning** - Important caution +- ๐Ÿ“Œ **Note** - Additional information +- ๐ŸŽฏ **Pro Tip** - Advanced technique +- ๐Ÿ” **Example** - Practical demonstration + +--- + +## ๐Ÿ”„ Keeping Documentation Updated + +This documentation evolves with the configuration: + +- **Check for updates**: `git pull` in `~/.config/nvim` +- **Version**: Documentation matches config version +- **Feedback**: Open issues for unclear docs +- **Contribute**: Submit PRs for improvements + +--- + +## ๐ŸŽฏ Quick Navigation + +### By Topic +- **Need to find a file?** โ†’ [Telescope Guide](plugins/core.md#telescope) +- **Want to understand a keymap?** โ†’ [Keymaps Overview](keymaps/README.md) +- **LSP not working?** โ†’ [Troubleshooting LSP](troubleshooting.md#lsp-issues) +- **Adding a language?** โ†’ [Language Setup](languages/README.md) +- **Config too slow?** โ†’ [Performance Tuning](performance.md) + +### By Skill Level +- **Beginner** โ†’ [Getting Started](getting-started/README.md) +- **Intermediate** โ†’ [Vim Mastery](vim-mastery/README.md) +- **Advanced** โ†’ [Customization](customization.md) + +### By Plugin +- [Telescope](plugins/core.md#telescope) +- [Neo-tree](plugins/core.md#neo-tree) +- [which-key](plugins/core.md#which-key) +- [nvim-cmp](plugins/lsp.md#completion) +- [nvim-dap](plugins/debug.md) +- [Gitsigns](plugins/git.md) + +--- + +
+ +**Happy Coding! ๐Ÿš€** + +[Back to Main README](../README.md) | [Get Started โ†’](getting-started/README.md) + +
diff --git a/docs/getting-started/README.md b/docs/getting-started/README.md new file mode 100644 index 00000000000..558883238f2 --- /dev/null +++ b/docs/getting-started/README.md @@ -0,0 +1,195 @@ +# ๐Ÿš€ Getting Started + +Welcome! This guide will help you get up and running with this Neovim configuration. + +--- + +## ๐Ÿ“š Guide Structure + +1. **[Installation](installation.md)** - Set up Neovim and this configuration +2. **[First Steps](first-steps.md)** - Your first hour with the config +3. **[Quick Reference](quick-reference.md)** - Essential commands you'll use daily +4. **[Philosophy](philosophy.md)** - Understanding the design principles + +--- + +## โšก Quick Start (5 Minutes) + +### 1. Install Neovim 0.11.4+ +```bash +# macOS +brew install neovim + +# Ubuntu/Debian +sudo apt install neovim + +# Arch Linux +sudo pacman -S neovim +``` + +### 2. Backup Old Config +```bash +mv ~/.config/nvim ~/.config/nvim.backup +mv ~/.local/share/nvim ~/.local/share/nvim.backup +``` + +### 3. Clone This Config +```bash +git clone https://github.com/anupjsebastian/kickstart.nvim.git ~/.config/nvim +``` + +### 4. Install Dependencies +```bash +# macOS +brew install ripgrep fd + +# Ubuntu +sudo apt install ripgrep fd-find + +# Arch +sudo pacman -S ripgrep fd +``` + +### 5. Launch Neovim +```bash +nvim +``` + +Wait for all plugins to install (watch bottom right corner). + +### 6. Verify Everything Works +```vim +:checkhealth +``` + +--- + +## ๐ŸŽฏ What You'll Learn + +### Immediate (Day 1) +- Opening and editing files +- Basic navigation with Telescope +- Using LSP features (autocomplete, go to definition) +- Essential keymaps you'll use every day + +### Short Term (Week 1) +- Vim motion basics +- Using the file explorer (Neo-tree) +- Git integration +- Debugging basics + +### Medium Term (Month 1) +- Advanced Vim motions and text objects +- Customizing keymaps +- Language-specific features +- Efficient workflows + +### Long Term (Ongoing) +- Mastering Vim commands +- Building your own plugins +- Optimizing your workflow +- One new trick per week approach + +--- + +## ๐Ÿ—บ๏ธ Learning Path + +``` +Installation (15 min) + โ†“ +First Steps (30 min) - Learn the absolute basics + โ†“ +Quick Reference (ongoing) - Your daily command sheet + โ†“ +Week 1: Basic Motions - hjkl, word motions, searching + โ†“ +Week 2: Text Objects - iw, ap, it, edit intelligently + โ†“ +Week 3: Advanced Editing - Visual mode, macros + โ†“ +Continue with Vim Mastery guides... +``` + +--- + +## ๐Ÿ’ก Key Concepts + +### Leader Key = Space +Almost all custom keymaps start with `` (the Space key). Press Space and wait - you'll see a menu! + +### Which-key is Your Friend +When you press a key prefix (like `` or `g`), a menu appears showing all available commands. + +### Everything is Searchable +- Files: `sf` +- Text: `sg` +- Keymaps: `sc` +- Help: `sh` + +### LSP Powers Your Editing +- `K` - Documentation +- `gd` - Go to definition +- `gr` - Find references +- `gra` - Code actions + +--- + +## ๐Ÿ†˜ Getting Help + +### In-Editor +- `sc` - Comprehensive cheatsheet +- `sk` - Search all keymaps +- `` (wait) - Which-key menu +- `:help ` - Vim help + +### External +- [Full Documentation](../README.md) +- [Troubleshooting Guide](../troubleshooting.md) +- [FAQ](../faq.md) +- [GitHub Issues](https://github.com/anupjsebastian/kickstart.nvim/issues) + +--- + +## โš ๏ธ Common First-Day Issues + +### Plugins Not Installing +```vim +:Lazy sync +``` + +### LSP Not Working +```vim +:Mason +:LspInfo +:checkhealth +``` + +### Fonts Look Broken +Install a [Nerd Font](https://www.nerdfonts.com/) and set `vim.g.have_nerd_font = true` in `init.lua`. + +### Keymaps Not Working +Check your terminal doesn't intercept keys: +```vim +:checkhealth which-key +``` + +--- + +## ๐ŸŽ“ Next Steps + +1. Complete [Installation Guide](installation.md) +2. Follow [First Steps Tutorial](first-steps.md) +3. Bookmark [Quick Reference](quick-reference.md) +4. Start [Vim Mastery Week 1](../vim-mastery/week-01-motions.md) + +--- + +
+ +**Ready to dive in?** + +[Installation Guide โ†’](installation.md) + +[Back to Documentation](../README.md) | [Back to Main README](../../README.md) + +
diff --git a/docs/keymaps/README.md b/docs/keymaps/README.md new file mode 100644 index 00000000000..ff148291879 --- /dev/null +++ b/docs/keymaps/README.md @@ -0,0 +1,226 @@ +# โŒจ๏ธ Keymaps Reference + +Complete guide to all keymaps in this configuration, organized by category. + +--- + +## ๐Ÿ“‹ Quick Navigation + +- **[Core Keymaps](core.md)** - Leader-key organization (buffer, window, search, git, etc.) +- **[LSP Keymaps](lsp.md)** - Language Server Protocol commands +- **[Plugin Keymaps](plugins.md)** - Telescope, Neo-tree, Git, Debug +- **[Duplicates Guide](duplicates.md)** - Understanding multiple keys for same action +- **[Consistency Guide](consistency.md)** - Cross-plugin key patterns + +--- + +## ๐ŸŽฏ Keymap Philosophy + +### 1. Leader-Based Organization +Almost all custom keymaps start with `` (Space key): +- `b` - **Buffer** operations +- `s` - **Search** (Telescope) +- `f` - **Flutter** (Dart files) +- `r` - **Rust** operations +- `d` - **Debug** commands +- `g` - **Git** operations +- And more... + +### 2. Mnemonic Design +Keys are chosen to be memorable: +- `sf` = **S**earch **F**iles +- `bb` = **B**uffer **B**rowse +- `gg` = Open Lazy**G**it +- `db` = **D**ebug **B**reakpoint + +### 3. Which-key Discovery +Press `` and wait - a menu shows all available commands! + +### 4. Consistent Across Plugins +Same keys work the same way everywhere: +- `Ctrl-x` = Horizontal split (Telescope, Neo-tree) +- `Ctrl-v` = Vertical split (Telescope, Neo-tree) +- `Ctrl-t` = New tab (Telescope, Neo-tree) +- `?` = Show help (Telescope, Neo-tree) + +--- + +## ๐Ÿ—บ๏ธ Keymap Categories + +### Core Editor +| Prefix | Category | Example | +|--------|----------|---------| +| `b` | Buffer operations | `bd` = Delete buffer | +| `w` | Window operations | `wv` = Vertical split | +| `u` | UI toggles | `uw` = Toggle wrap | +| `s` | Search/Telescope | `sf` = Find files | +| `g` | Git operations | `gg` = LazyGit | + +### LSP (Language Features) +| Prefix | Category | Example | +|--------|----------|---------| +| `gr*` | Go to... | `grd` = Go to definition | +| `K` | Hover | `K` = Show documentation | +| `c` | Code | `ca` = Code actions | + +### Debug +| Prefix | Category | Example | +|--------|----------|---------| +| `d` | Debug commands | `db` = Breakpoint | +| `F5-F12` | Debug quick keys | `F5` = Continue | + +### Language-Specific +| Prefix | Language | Example | +|--------|----------|---------| +| `f` | Flutter/Dart | `fr` = Run app | +| `r` | Rust | `ra` = Code actions | +| `rc` | Rust Crates | `rct` = Toggle | +| `p` | Python | `pr` = Run | +| `v` | Svelte | `vf` = Format | + +--- + +## ๐Ÿ“š Detailed Documentation + +### [Core Keymaps](core.md) +Complete reference for all leader-key bindings: +- Buffer management +- Window operations +- Search/Telescope +- Git integration +- UI toggles +- Session management + +### [LSP Keymaps](lsp.md) +Language Server Protocol commands that work in all languages: +- Go to definition, references, implementation +- Hover documentation +- Rename symbol +- Code actions +- Signature help +- Diagnostics navigation + +### [Plugin Keymaps](plugins.md) +Plugin-specific keymaps: +- **Telescope**: Fuzzy finding, live grep, file browser +- **Neo-tree**: File explorer navigation and operations +- **Git**: Gitsigns hunks, staging, blame +- **Debug**: nvim-dap debugging commands +- **Mini.nvim**: Surround, comments, pairs + +### [Duplicates Guide](duplicates.md) +Understanding why some actions have multiple keymaps: +- Vim defaults + modern alternatives +- Function keys + leader keys for debugging +- Single keys + Ctrl combos for consistency +- Default plugin keys + consistent alternatives + +### [Consistency Guide](consistency.md) +Cross-plugin key patterns: +- Same split/tab keys in Telescope and Neo-tree +- Consistent navigation patterns +- Unified help access + +--- + +## ๐ŸŽ“ Learning Strategy + +### Week 1: Essential Commands +Focus on these 10 keymaps: +1. `sf` - Find files +2. `sg` - Search text (grep) +3. `bb` - Browse buffers +4. `\` - Toggle file explorer +5. `gd` - Go to definition +6. `K` - Show documentation +7. `ca` - Code actions +8. `gg` - Git interface +9. `` - Switch windows +10. `sc` - Open cheatsheet! + +### Week 2: Expand Your Arsenal +Add these: +- `s/` - Search in open files +- `bd` - Delete buffer +- `wv` - Split vertical +- `gr` - Find references +- `[d` / `]d` - Next/prev diagnostic + +### Ongoing: One Per Week +Pick ONE new keymap each week from the [full documentation](core.md) and practice it until it's muscle memory. + +--- + +## ๐Ÿ” Finding Keymaps + +### In-Editor Tools +```vim +" Comprehensive searchable cheatsheet +sc + +" Search all keymaps with Telescope +sk + +" Which-key command palette +sK + +" Quick fuzzy search +? + +" Press any prefix and wait + " Shows all leader keymaps +g " Shows all 'go to' commands +[ " Shows all 'next' commands +] " Shows all 'previous' commands +``` + +### By Category +- **Buffer commands**: `b` (then wait for menu) +- **Search commands**: `s` (then wait) +- **Git commands**: `g` (then wait) +- **Debug commands**: `d` (then wait) + +### By Plugin +Inside a plugin (like Telescope or Neo-tree), press `?` for help. + +--- + +## ๐Ÿ’ก Tips + +### Discovering Features +1. Press `` and wait - explore the which-key menu +2. Open cheatsheet with `sc` and search +3. Check plugin-specific help with `?` + +### Customizing Keymaps +See [Customization Guide](../customization.md) to: +- Change existing keymaps +- Add your own keymaps +- Disable unwanted keymaps + +### Resolving Conflicts +If a keymap doesn't work: +```vim +:verbose map sf +:checkhealth which-key +``` + +--- + +## ๐Ÿ“– External Resources + +- [Vim Cheat Sheet](https://vim.rtorr.com/) +- [Interactive Vim Tutorial](https://www.openvim.com/) +- [Practical Vim Book](https://pragprog.com/titles/dnvim2/practical-vim-second-edition/) + +--- + +
+ +**Master your keymaps, master your editor!** + +[Core Keymaps โ†’](core.md) | [LSP Keymaps โ†’](lsp.md) | [Plugin Keymaps โ†’](plugins.md) + +[Back to Documentation](../README.md) + +
diff --git a/docs/keymaps/consistency.md b/docs/keymaps/consistency.md new file mode 100644 index 00000000000..a57c2c52558 --- /dev/null +++ b/docs/keymaps/consistency.md @@ -0,0 +1,82 @@ +# Keymap Consistency Guide + +> **Last Updated:** November 1, 2025 +> **Purpose:** Document consistent keymaps across Telescope and Neo-tree + +## ๐ŸŽฏ Consistent Actions + +The following keymaps work **identically** in both Telescope and Neo-tree: + +### File Opening Actions + +| Key | Action | Telescope | Neo-tree | +|-----|--------|-----------|----------| +| `` or `o` | Open in current window | โœ… | โœ… | +| `` | Open in horizontal split | โœ… | โœ… | +| `` | Open in vertical split | โœ… | โœ… | +| `` | Open in new tab | โœ… | โœ… | + +### Navigation + +| Key | Action | Telescope | Neo-tree | +|-----|--------|-----------|----------| +| `` | Next item/source | โœ… | โœ… | +| `` | Previous item/source | โœ… | โœ… | +| `j/k` (normal mode) | Down/Up | โœ… | โœ… | +| `gg/G` (normal mode) | First/Last | โœ… | โœ… | + +### Utility + +| Key | Action | Telescope | Neo-tree | +|-----|--------|-----------|----------| +| `?` | Show help | โœ… | โœ… | +| `` or `q` | Close | โœ… | โœ… (`\\` for Neo-tree) | + +### Cross-Plugin Integration + +| Key | Action | Context | +|-----|--------|---------| +| `sf` | Telescope find files | Works in both editor and Neo-tree | +| `sg` | Telescope live grep | Works in both editor and Neo-tree | + +When used in Neo-tree, these commands search from the currently selected directory! + +## ๐Ÿ“š Complete Cheatsheet Access + +Access the comprehensive cheatsheet with: + +``` +sc - Complete cheatsheet (vim, plugins, language-specific) +sk - Search keymaps (Telescope) +sK - All keymaps (which-key) +? - Quick keymap search +``` + +## ๐ŸŽจ Visual Consistency + +Both Telescope and Neo-tree now follow the same pattern: +- **Same keys** for same actions +- **Predictable behavior** across interfaces +- **Integrated workflows** (use Telescope from Neo-tree) +- **Help always available** with `?` + +## ๐Ÿ“ Quick Reference + +### In Telescope: +1. `` to navigate +2. `` to open in split/vsplit/tab +3. `` to open in current window +4. `?` for help + +### In Neo-tree: +1. `` to switch sources +2. `` to open in split/vsplit/tab +3. `` or `o` to open file +4. `?` for help +5. `sf/sg` to launch Telescope from current directory + +### Both Share: +- Consistent split/tab opening +- Same navigation philosophy +- Integrated search capabilities +- Help on demand diff --git a/docs/keymaps/duplicates.md b/docs/keymaps/duplicates.md new file mode 100644 index 00000000000..0406cae9c1a --- /dev/null +++ b/docs/keymaps/duplicates.md @@ -0,0 +1,90 @@ +# Duplicate Keymaps Reference + +This document lists all keymaps where the same action can be performed using multiple key combinations. + +## Philosophy + +Having duplicate keymaps is **intentional and beneficial**: +- **Vim defaults + Modern alternatives**: Keep familiar vim keys while adding intuitive modern ones +- **Consistency across plugins**: Same keys work the same way in Telescope and Neo-tree +- **Ergonomics**: Function keys (F5-F12) AND leader keys for debugging +- **Context switching**: Use what feels natural in different workflows + +## Debug Actions + +| Action | Keys | Notes | +|--------|------|-------| +| Continue | `F5` or `dc` | F5 is standard in many IDEs | +| Step over | `F10` or `dO` | Uppercase O for over | +| Step into | `F11` or `di` | | +| Step out | `F12` or `do` | Lowercase o for out | + +**Why duplicates?** Function keys are muscle memory from other IDEs. Leader keys are more discoverable via which-key and don't conflict with terminal function keys. + +## Neo-tree vs Consistent Actions + +| Action | Neo-tree Default | Consistent Alternative | Notes | +|--------|------------------|------------------------|-------| +| Vertical split | `s` | `Ctrl-v` | Matches Telescope | +| Horizontal split | `S` | `Ctrl-x` | Matches Telescope | +| New tab | `t` | `Ctrl-t` | Matches Telescope | +| Next source | `>` | `Ctrl-j` | Matches Telescope navigation | +| Previous source | `<` | `Ctrl-k` | Matches Telescope navigation | +| Close window | `q` | `\` or `Esc` | Backslash mirrors toggle | +| Open file | `` | `o` | Two ways to open | + +**Why duplicates?** Neo-tree defaults are efficient single-key presses. Consistent alternatives (`Ctrl-x/v/t/j/k`) work the same way in Telescope, reducing cognitive load when switching between file finder and file tree. + +## Flutter Code Actions + +| Action | Keys | Notes | +|--------|------|-------| +| Code actions | `.` or `gra` | Period mimics Cmd+. in IDEs, gra is standard LSP | + +**Why duplicates?** Flutter developers coming from IDEs expect `.` (like Cmd+.). `gra` is the standard LSP keymap used everywhere else. + +## Telescope Navigation + +| Action | Keys | Notes | +|--------|------|-------| +| Next/prev item | `Ctrl-j/k` or `j/k` (normal) | Insert mode uses Ctrl, normal mode uses plain | +| Close | `Ctrl-c` or `Esc` or `q` (normal) | Three ways to exit | + +**Why duplicates?** `Ctrl-j/k` work in insert mode without switching modes. In normal mode, plain `j/k` are more natural. + +## Vim Defaults + +| Action | Keys | Notes | +|--------|------|-------| +| Save and quit | `:wq` or `ZZ` | ZZ is faster | +| Quit without save | `:q!` or `ZQ` | ZQ is faster | + +**Why duplicates?** Both are vim defaults. ZZ/ZQ are faster but less discoverable. + +## Summary of Duplicate Patterns + +1. **Debug**: F-keys + Leader keys (muscle memory from IDEs + discoverability) +2. **Splits/Tabs**: Single keys + Ctrl combos (efficiency + consistency) +3. **Navigation**: Plain + Ctrl variants (context-dependent ergonomics) +4. **Close/Exit**: Multiple keys (q, Esc, Ctrl-c, \\) (different mental models) + +## Design Principles + +1. **Never remove defaults** unless they conflict +2. **Add consistent alternatives** that work across plugins +3. **Document all options** so users can choose their preferred style +4. **Optimize for discoverability** (leader keys show in which-key) +5. **Respect muscle memory** (keep vim and IDE conventions) + +## Quick Reference: Cross-Plugin Consistency + +These keys work the same way in **both Telescope and Neo-tree**: + +- `Ctrl-x` โ†’ Horizontal split +- `Ctrl-v` โ†’ Vertical split +- `Ctrl-t` โ†’ New tab +- `Ctrl-j` โ†’ Next/down +- `Ctrl-k` โ†’ Previous/up +- `?` โ†’ Show help + +This consistency means once you learn these in one plugin, they work the same everywhere. diff --git a/docs/languages/flutter-dart.md b/docs/languages/flutter-dart.md new file mode 100644 index 00000000000..f21a17fac1f --- /dev/null +++ b/docs/languages/flutter-dart.md @@ -0,0 +1,295 @@ +# Flutter & Dart Development + +Complete reference for Flutter and Dart development in Neovim. + +## Quick Start + +1. Open any `.dart` file to activate Flutter tools +2. Select device: `fd` +3. Run app: `fr` +4. Hot reload during development: `fh` + +## Essential Keymaps + +### App Lifecycle + +| Key | Command | Description | +|-----|---------|-------------| +| `fr` | FlutterRun | Run the app (auto-selects last used device) | +| `fh` | FlutterReload | Hot reload (faster, preserves state) | +| `fR` | FlutterRestart | Hot restart (full reload, resets state) | +| `fq` | FlutterQuit | Stop the running app | + +**Workflow**: First time, use `fd` to select a device, then `fr` to run. Subsequent runs remember your device. + +### Device Management + +| Key | Command | Description | +|-----|---------|-------------| +| `fd` | FlutterDevices | List and select connected devices | +| `fe` | FlutterEmulators | Launch an emulator | +| `fa` | FlutterAttach | Attach to an already running app | +| `fD` | FlutterDetach | Detach from app (keeps it running) | + +### Developer Tools + +| Key | Command | Description | +|-----|---------|-------------| +| `ft` | FlutterDevTools | Start Dart DevTools server | +| `fc` | FlutterCopyProfilerUrl | Copy profiler URL to clipboard | +| `fo` | FlutterOutlineToggle | Toggle widget tree outline | +| `fL` | FlutterLogToggle | Show/hide application logs | + +**DevTools Workflow**: +1. Run your app: `fr` +2. Start DevTools: `ft` +3. Copy profiler URL: `fc` +4. Open URL in browser for full DevTools experience + +### Code Actions & Refactoring + +| Key | Command | Description | +|-----|---------|-------------| +| `.` | Code Actions | Quick actions (like Cmd+. in VS Code) | +| `gra` | Code Actions | Alternative LSP keymap | + +**Common Code Actions**: +- Wrap widget with Padding, Center, Column, etc. +- Remove widget (unwrap) +- Extract widget to new class +- Extract method +- Add import +- Organize imports + +### LSP & Language Server + +| Key | Command | Description | +|-----|---------|-------------| +| `fl` | FlutterLspRestart | Restart Dart language server | +| `K` | Hover | Show documentation | +| `grd` | Go to Definition | Jump to definition | +| `grr` | Go to References | Find all references | +| `grn` | Rename | Rename symbol | + +## Flutter-Specific Features + +### Widget Tree Outline + +The outline window shows your widget tree structure: + +``` +fo # Toggle outline window +``` + +The outline updates as you edit and shows: +- Widget hierarchy +- Widget types +- Quick navigation to widgets + +### Closing Tags + +Automatically shows closing tags for deeply nested widgets: + +```dart +Container( // Container + child: Column( // Column + children: [ + Text('Hello'), + Text('World'), + ], + ), // Column +), // Container +``` + +### Color Preview + +Material Design colors show inline preview: + +```dart +Colors.red # Shows red color indicator +Color(0xFF42A5F5) # Shows the actual color +``` + +### Hot Reload vs Hot Restart + +| Hot Reload (`fh`) | Hot Restart (`fR`) | +|---------------------------|---------------------------| +| Fast (< 1 second) | Slower (few seconds) | +| Preserves app state | Resets app state | +| UI changes only | Can handle code structure changes | +| Use during active development | Use after changing initState, constructors | + +## Debugging + +### Debug Keymaps + +Available when debugging (after `` or breakpoint hit): + +| Key | Description | +|-----|-------------| +| `F5` | Start/Continue | +| `F10` | Step over | +| `F11` | Step into | +| `F12` | Step out | +| `db` | Toggle breakpoint | +| `dB` | Conditional breakpoint | +| `dt` | Terminate debug session | +| `dr` | Toggle REPL | +| `du` | Toggle debug UI | + +### Debug Workflow + +1. Set breakpoints: Position cursor, press `db` +2. Start debugging: `F5` (launches app in debug mode) +3. App pauses at breakpoint +4. Inspect variables in debug UI panels +5. Step through code: `F10`, `F11`, `F12` +6. Continue execution: `F5` + +### Debug UI Panels + +When debugging starts, you get: +- **Scopes**: Local and global variables +- **Breakpoints**: All breakpoints in your project +- **Call Stack**: Function call hierarchy +- **Watches**: Custom expressions to monitor +- **REPL**: Evaluate Dart expressions live +- **Console**: Debug output and print statements + +## Logs + +``` +fL # Toggle log buffer +``` + +The log buffer shows: +- `print()` statements +- Flutter framework messages +- Hot reload/restart confirmations +- Error messages and stack traces + +## Tips & Tricks + +### Fast Development Loop + +``` +1. Make UI changes +2. fh for instant hot reload +3. See changes immediately +4. Repeat +``` + +### When Hot Reload Fails + +If hot reload shows unexpected behavior: + +``` +fR # Hot restart (full reload) +``` + +If issues persist: + +``` +fq # Quit app +fl # Restart LSP +fr # Run again +``` + +### Multiple Devices + +Switch between devices without restarting: + +``` +fq # Quit current +fd # Select new device +fr # Run on new device +``` + +### Widget Extraction + +To extract a widget to a new class: + +1. Visual select the widget code +2. Press `.` or `gra` +3. Choose "Extract Widget" +4. Enter new widget name + +### Attach to Running App + +If your app is already running (started outside Neovim): + +``` +fa # Attach to running process +``` + +This enables hot reload and debugging for external apps. + +## Configuration + +Flutter tools are configured in `lua/custom/plugins/flutter.lua`. + +Key settings: +- **Auto-start DevTools**: `dev_tools.autostart = false` (manual start) +- **Widget guides**: `widget_guides.enabled = true` (visual nesting guides) +- **Closing tags**: `closing_tags.enabled = true` (shows widget closing comments) +- **Color preview**: `lsp.color.enabled = true` (inline color indicators) + +## Troubleshooting + +### LSP Not Working + +``` +:FlutterLspRestart +# or +fl +``` + +### Can't Select Device + +Ensure Flutter can see your devices: + +``` +:!flutter devices +``` + +If devices don't show, check: +- Android emulator is running +- iOS simulator is running +- Physical device is connected and authorized +- Chrome is installed (for web) + +### Hot Reload Not Responding + +``` +fR # Force hot restart +``` + +If still not working: + +``` +fq # Quit +fr # Restart fresh +``` + +### Dart Analysis Errors + +Force re-analysis: + +``` +:FlutterReanalyze +``` + +Or restart LSP: `fl` + +## Resources + +- [Flutter Documentation](https://flutter.dev/docs) +- [Dart Language Tour](https://dart.dev/guides/language/language-tour) +- [Widget Catalog](https://flutter.dev/docs/development/ui/widgets) +- [flutter-tools.nvim GitHub](https://github.com/akinsho/flutter-tools.nvim) + +## See Also + +- [Debug Keymaps](../keymaps/README.md#debugging) - Complete debugging reference +- [LSP Features](../plugins/lsp.md) - Language Server Protocol features +- [Code Actions](../keymaps/README.md#lsp) - All code action keymaps diff --git a/docs/vim-mastery/README.md b/docs/vim-mastery/README.md new file mode 100644 index 00000000000..7acdb666716 --- /dev/null +++ b/docs/vim-mastery/README.md @@ -0,0 +1,272 @@ +# ๐ŸŽ“ Vim Mastery - Progressive Learning Path + +Master Vim one technique at a time, building real skill over months instead of trying to learn everything at once. + +--- + +## ๐ŸŽฏ Philosophy: The One-Trick-Per-Week Method + +Instead of overwhelming yourself with hundreds of commands: +1. **Learn ONE new command/technique each week** +2. **Practice it consciously** in your daily work +3. **Use it until it becomes muscle memory** +4. **Move to the next technique** + +After one year: **52 new powerful techniques!** + +--- + +## ๐Ÿ—บ๏ธ Learning Roadmap + +### Weeks 1-4: Foundation +Build essential motion and editing skills +- **[Week 1: Motion Basics](week-01-motions.md)** - Move efficiently +- **[Week 2: Text Objects](week-02-text-objects.md)** - Edit intelligently +- **[Week 3: Advanced Editing](week-03-advanced.md)** - Visual mode & macros intro +- **[Week 4: Macros & Registers](week-04-macros.md)** - Automate repetitive tasks + +### Weeks 5-8: Power User +Master Vim's unique features +- **[Week 5: Command Line](week-05-cmdline.md)** - Ex commands & substitution +- **[Week 6: Windows & Tabs](week-06-windows.md)** - Workspace management +- **[Week 7: Search & Replace](week-07-search.md)** - Advanced patterns +- **[Week 8: Marks & Jumps](week-08-marks.md)** - Navigate large codebases + +### Ongoing: Mastery +Continuous improvement +- **[Tips & Tricks](tips-and-tricks.md)** - Productivity boosters +- **[Workflows](workflows.md)** - Real-world patterns +- **[Advanced Topics](advanced.md)** - Vim script, Lua, custom commands + +--- + +## ๐Ÿ“Š Skill Progression + +``` +Week 0: hjkl, basic editing [Beginner] + โ†“ +Week 2: Word motions, text objects [Functional] + โ†“ +Week 4: Visual mode, basic macros [Comfortable] + โ†“ +Week 6: Ex commands, window management [Efficient] + โ†“ +Week 8: Advanced searching, marks [Proficient] + โ†“ +Month 3: Custom workflows [Advanced] + โ†“ +Month 6: Vim expert, teaching others [Master] +``` + +--- + +## ๐ŸŽฏ Learning Objectives + +### By Week 4 +You will be able to: +- Navigate code without arrow keys +- Edit text objects (change word, delete paragraph) +- Use visual mode for selections +- Record and replay simple macros +- Be MORE productive than with mouse + arrow keys + +### By Week 8 +You will be able to: +- Refactor code efficiently +- Use advanced search patterns +- Manage multiple windows and tabs +- Navigate large codebases with marks +- Automate repetitive tasks with macros + +### By Month 6 +You will be able to: +- Edit at the speed of thought +- Teach Vim to others +- Create custom workflows +- Write your own Vim scripts +- Never want to use another editor + +--- + +## ๐Ÿ“– Weekly Structure + +Each week follows this pattern: + +### Monday: Learn +- Read the week's guide (15 minutes) +- Watch any linked videos +- Understand the concepts + +### Tuesday-Friday: Practice +- Pick 2-3 commands from the week's list +- Use them consciously in real work +- Don't worry about speed yet +- Focus on correctness + +### Weekend: Review +- What did you learn? +- What felt natural? +- What needs more practice? +- Pick next week's focus + +--- + +## ๐Ÿ’ก Learning Tips + +### 1. Deliberate Practice +Don't just read - **use** the commands in real code. + +### 2. Start Slow +Speed comes with muscle memory. Focus on correctness first. + +### 3. One Thing at a Time +Master one command before adding another. + +### 4. Keep a Cheat Sheet +Write down your current week's commands somewhere visible. + +### 5. Use the In-Editor Cheatsheet +`sc` is your friend! + +### 6. Don't Rush +It's okay to spend 2 weeks on one topic if needed. + +### 7. Apply Immediately +Learn Monday, use in real work Tuesday. + +### 8. Embrace Mistakes +Undo (`u`) is your safety net. Experiment! + +--- + +## ๐ŸŽฎ Practice Exercises + +Each week includes: +- **Focused drills** - Specific command practice +- **Real-world scenarios** - Apply to actual code +- **Challenge tasks** - Test your skills +- **Cheat sheet** - Quick reference + +--- + +## ๐Ÿ“š Recommended Schedule + +### If You're New to Vim +- **Pace**: 1 week per topic +- **Time**: 30 minutes/day practice +- **Duration**: 8 weeks to proficiency + +### If You Know Basic Vim +- **Pace**: 2-3 topics per week +- **Time**: 15 minutes/day practice +- **Duration**: 4 weeks to level up + +### If You Want to Master Vim +- **Pace**: All topics + advanced +- **Time**: 1 hour/day practice +- **Duration**: 3-6 months to mastery + +--- + +## ๐Ÿ—บ๏ธ Your Journey Starts Here + +### Absolute Beginner? +Start with **[Week 1: Motion Basics](week-01-motions.md)** + +### Know hjkl Already? +Jump to **[Week 2: Text Objects](week-02-text-objects.md)** + +### Comfortable with Vim? +Explore **[Tips & Tricks](tips-and-tricks.md)** and **[Workflows](workflows.md)** + +### Want to Master Everything? +Follow the full 8-week program, then **[Advanced Topics](advanced.md)** + +--- + +## ๐Ÿ“ˆ Track Your Progress + +Create a file to track what you've learned: + +```vim +:e ~/vim-mastery-log.md +``` + +Template: +```markdown +# My Vim Mastery Journey + +## Week 1: Motion Basics +- Started: 2025-11-01 +- Mastered: w, b, e, 0, $ +- Still practicing: f/F, t/T +- Favorite new trick: dt, (delete till comma) + +## Week 2: Text Objects +... +``` + +--- + +## ๐ŸŽฏ Success Metrics + +You're making progress when: +- โœ… You reach for hjkl instead of arrow keys +- โœ… You think "change inner word" instead of selecting with mouse +- โœ… You prefer Vim commands over GUI operations +- โœ… You can edit without looking at keyboard +- โœ… You start teaching others +- โœ… You feel frustrated using non-Vim editors + +--- + +## ๐Ÿ’ฌ Community + +Share your progress: +- **Reddit**: r/vim, r/neovim +- **Discord**: Neovim community server +- **GitHub**: Open issues with questions + +--- + +## ๐Ÿ“š Additional Resources + +### Books +- **Practical Vim** by Drew Neil (highly recommended!) +- **Modern Vim** by Drew Neil +- **Learning the Vi and Vim Editors** + +### Videos +- **ThePrimeagen's Vim Course** +- **Vim Casts** (vimcasts.org) +- **TJ DeVries' Neovim streams** + +### Interactive +- `:Tutor` - Built into Neovim +- **Vim Adventures** - Learn through gaming +- **OpenVim** - Interactive tutorial + +### References +- `:help` - Vim's excellent documentation +- **vim.rtorr.com** - Quick reference +- **This config's cheatsheet** - `sc` + +--- + +## ๐ŸŽŠ Ready to Begin? + +Remember: **Progress > Perfection** + +Every expert was once a beginner. The only difference is they kept practicing. + +--- + +
+ +**Your journey to Vim mastery starts now!** + +[Week 1: Motion Basics โ†’](week-01-motions.md) + +[Back to Documentation](../README.md) | [Tips & Tricks](tips-and-tricks.md) + +
diff --git a/docs/vim-mastery/week-01-motions.md b/docs/vim-mastery/week-01-motions.md new file mode 100644 index 00000000000..ea487d4f024 --- /dev/null +++ b/docs/vim-mastery/week-01-motions.md @@ -0,0 +1,380 @@ +# ๐ŸŽฏ Week 1: Motion Basics + +Master efficient navigation - the foundation of Vim proficiency. + +--- + +## ๐ŸŽ“ Learning Objectives + +By the end of this week, you will: +- Navigate without arrow keys +- Move by words, not characters +- Jump to specific characters on a line +- Understand the power of count + motion +- Be faster than mouse + arrow keys + +--- + +## ๐Ÿ“š Core Commands + +### Basic Directional Movement +```vim +h " Left โ† +j " Down โ†“ +k " Up โ†‘ +l " Right โ†’ +``` + +**Practice Goal**: Use only hjkl for one full day. Unmap arrow keys if needed! + +### Word Movement (Most Important!) +```vim +w " Next word (start) +e " Next word (end) +b " Previous word (start) +ge " Previous word (end) + +W " Next WORD (whitespace separated) +E " Next WORD (end) +B " Previous WORD +``` + +**Difference**: +- `word`: Stops at punctuation (my-function โ†’ 3 words) +- `WORD`: Whitespace only (my-function โ†’ 1 WORD) + +### Line Movement +```vim +0 " Start of line +^ " First non-whitespace character +$ " End of line +g_ " Last non-whitespace character +``` + +### Character Search (Super Powerful!) +```vim +f{char} " Find next {char} on line โ†’ +F{char} " Find previous {char} on line โ† +t{char} " Till next {char} (stop before) +T{char} " Till previous {char} + +; " Repeat last f/F/t/T forward +, " Repeat last f/F/t/T backward +``` + +**Pro Tip**: `f` and `t` are game-changers for editing! + +--- + +## ๐Ÿ’ช Practice Exercises + +### Exercise 1: Word Navigation (5 minutes) +Open any code file: +```vim +:e ~/.config/nvim/init.lua +``` + +Practice: +1. Use `w` to move forward 10 words +2. Use `b` to come back +3. Use `e` to jump to word ends +4. Compare speed: `wwwww` vs `5w` (count!) + +### Exercise 2: Line Precision (5 minutes) +In the same file: +```vim +" Jump to line start +0 + +" Jump to first character +^ + +" Jump to line end +$ + +" Try this combo: Move to end, then back to start +$^ +``` + +### Exercise 3: Character Hunting (10 minutes) +Find a line with multiple parentheses or quotes: +```lua +local function test(arg1, arg2, arg3) +``` + +Practice: +```vim +f( " Jump to first ( +; " Jump to next ( +; " Jump to next ( +, " Go back one ( +``` + +Try these scenarios: +- Jump to the closing quote: `f"` +- Delete till comma: `dt,` +- Change till closing paren: `ct)` + +### Exercise 4: Combine Motions (10 minutes) +Real-world scenarios: + +**Scenario 1**: Change the word "function" to "method" +```vim +" Position cursor on 'f' in function +cw " Change word +method +``` + +**Scenario 2**: Delete from cursor to end of line +```vim +d$ " or D +``` + +**Scenario 3**: Change from here to next underscore +```vim +ct_ +``` + +--- + +## ๐ŸŽฏ Daily Challenges + +### Monday: Basic hjkl +- Disable arrow keys: Add to `init.lua`: + ```lua + vim.keymap.set('n', '', '') + vim.keymap.set('n', '', '') + vim.keymap.set('n', '', '') + vim.keymap.set('n', '', '') + ``` +- Navigate only with hjkl for the entire day + +### Tuesday: Word Motions +- Practice `w`, `b`, `e` every time you move +- Count your keystrokes: `www` = 3, `3w` = 2 +- Use counts! + +### Wednesday: Line Jumps +- Every time you need line start/end, use `^` or `$` +- Stop using `0` (except when you really need column 0) + +### Thursday: Character Search +- Find 10 opportunities to use `f` or `t` +- Practice `;` and `,` for repeating +- Try `dt,` and `ct)` patterns + +### Friday: Combinations +- Combine everything: `d3w`, `c$`, `vf)`, etc. +- Edit entire lines without arrow keys +- Feel the power! + +--- + +## ๐Ÿ”ฅ Real-World Patterns + +### Pattern 1: Change Till Character +```vim +" Change from cursor to next comma +ct, +``` +**Use when**: Editing function arguments + +### Pattern 2: Delete Word Forward +```vim +" Delete from cursor to end of word +dw + +" Delete 3 words +d3w +``` +**Use when**: Removing variable names + +### Pattern 3: Jump and Edit +```vim +" Find opening paren, then change till closing +f(ct) +``` +**Use when**: Changing function parameters + +### Pattern 4: End of Line Operations +```vim +" Append at end of line +A + +" Delete to end of line +D + +" Change to end of line +C +``` +**Use when**: Adding semicolons, removing trailing code + +--- + +## ๐Ÿ“Š Progress Checklist + +Track your mastery: + +``` +Day 1: +[ ] Used hjkl instead of arrows at least 50% of time +[ ] Felt uncomfortable (this is good!) + +Day 2: +[ ] Used w/b/e consciously 20+ times +[ ] Started thinking in "words" not "characters" + +Day 3: +[ ] Used ^ and $ instead of Home/End +[ ] Comfortable with 0/^/$ distinction + +Day 4: +[ ] Used f/t successfully 10+ times +[ ] Discovered one "aha!" moment with dt or ct + +Day 5: +[ ] Combined motions (d3w, c$, etc.) +[ ] Hjkl feels natural +[ ] Ready for Week 2! +``` + +--- + +## ๐ŸŽฎ Speed Drills + +### Drill 1: The Word Race (2 minutes) +```vim +" Open a file +" Start at top: gg +" Goal: Get to word "function" on line 50 + +" Slow way: jjjjjjjjwwwwwwww +" Fast way: 50G/function +" Week 1 way: 50G (jump to line) then use w/e +``` + +### Drill 2: Line Ninja (2 minutes) +```vim +" Create test line: +" the quick brown fox jumps over the lazy dog + +" Tasks (as fast as possible): +0 " Line start +$ " Line end +^ " First char +fb " Find 'b' +; " Next 'b' +e " End of word +``` + +### Drill 3: Edit Marathon (5 minutes) +```lua +-- Start with: +local result = calculate(arg1, arg2, arg3, arg4) + +-- Tasks: +-- 1. Change "calculate" to "compute" +-- Solution: /calccw compute +-- +-- 2. Delete ", arg4" +-- Solution: f4 (on '4') then dF, (delete back to comma) +-- +-- 3. Change "result" to "output" +-- Solution: 0 (start of line) cw output +``` + +--- + +## ๐Ÿ’ก Pro Tips + +### Tip 1: Think in Motions +Don't think: "I need to move 5 characters right" +Think: "I need to move to the next word" + +### Tip 2: Use Counts +`5w` is faster than `wwwww` and requires less thought. + +### Tip 3: f/t Are Superpowers +Once you master `f` and `t`, you'll never want to use arrow keys for horizontal navigation. + +### Tip 4: Learn the Difference +- `w` stops at punctuation: `my-word` = 3 stops +- `W` only stops at whitespace: `my-word` = 1 stop + +### Tip 5: Combine with Operators +Motions are 10x powerful with operators (d, c, y): +- `dw` = delete word +- `ct.` = change till period +- `y$` = yank to end of line + +--- + +## ๐ŸŽฏ Week 1 Goal + +**By end of week, you should prefer hjkl + word motions over arrow keys.** + +If you catch yourself reaching for arrows or mouse, that's your cue to practice more! + +--- + +## ๐Ÿ”— Quick Reference Card + +Print this or keep it visible: + +``` +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Week 1: Motion Basics โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ hjkl - Directions โ”‚ +โ”‚ w/b/e - Word motions โ”‚ +โ”‚ ^/$ - Line start/end โ”‚ +โ”‚ f/F - Find character โ”‚ +โ”‚ t/T - Till character โ”‚ +โ”‚ ;/, - Repeat find โ”‚ +โ”‚ โ”‚ +โ”‚ Combos: โ”‚ +โ”‚ dw - Delete word โ”‚ +โ”‚ dt, - Delete till comma โ”‚ +โ”‚ c$ - Change to end โ”‚ +โ”‚ 5w - Move 5 words โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +--- + +## โ“ Common Questions + +**Q: Why not use arrow keys?** +A: They're far from home row. Hjkl is faster once trained. + +**Q: When should I use w vs W?** +A: Use `w` for code (stops at punctuation). Use `W` for prose (whitespace only). + +**Q: I'm slower with hjkl!** +A: Normal! Stick with it for 3 days. Speed comes after correctness. + +**Q: Do I really need to learn f/t?** +A: YES! They're the secret weapon. Worth the practice. + +--- + +## ๐ŸŽŠ Graduation Criteria + +You're ready for Week 2 when: +- โœ… hjkl feels natural (no conscious thought) +- โœ… You use w/b/e more than arrow keys +- โœ… You've used f/t successfully in real work +- โœ… You can navigate without looking at keyboard +- โœ… You feel frustrated when using arrow keys + +--- + +
+ +**Congratulations on completing Week 1!** + +Practice these daily, and they'll become second nature. + +[โ† Back to Vim Mastery](README.md) | [Week 2: Text Objects โ†’](week-02-text-objects.md) + +
diff --git a/init.lua b/init.lua index b98ffc6198a..2e66892fc22 100644 --- a/init.lua +++ b/init.lua @@ -1,1016 +1,60 @@ --[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== + NEOVIM CONFIGURATION ===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. +This configuration started from Kickstart.nvim and has been customized +and reorganized into a modular structure. - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. +For help: + - Run `:Tutor` to learn Neovim basics + - Run `:help` to access built-in documentation + - Press `sh` to search help with Telescope + - Run `:checkhealth` to diagnose issues + - See ORGANIZATION.md for structure details - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) +This is YOUR config now! Customize it to your needs. +===================================================================== --]] --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - --- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false - --- [[ Setting options ]] --- See `:help vim.o` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default -vim.o.number = true --- You can also add relative line numbers, to help with jumping. --- Experiment for yourself to see if you like it! --- vim.o.relativenumber = true - --- Enable mouse mode, can be useful for resizing splits for example! -vim.o.mouse = 'a' - --- Don't show the mode, since it's already in the status line -vim.o.showmode = false - --- Sync clipboard between OS and Neovim. --- Schedule the setting after `UiEnter` because it can increase startup-time. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.schedule(function() - vim.o.clipboard = 'unnamedplus' -end) - --- Enable break indent -vim.o.breakindent = true - --- Save undo history -vim.o.undofile = true - --- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.o.ignorecase = true -vim.o.smartcase = true - --- Keep signcolumn on by default -vim.o.signcolumn = 'yes' - --- Decrease update time -vim.o.updatetime = 250 - --- Decrease mapped sequence wait time -vim.o.timeoutlen = 300 - --- Configure how new splits should be opened -vim.o.splitright = true -vim.o.splitbelow = true - --- Sets how neovim will display certain whitespace characters in the editor. --- See `:help 'list'` --- and `:help 'listchars'` +-- ======================================================================== +-- MODULAR NEOVIM CONFIGURATION +-- ======================================================================== +-- This configuration has been organized into modular pieces for clarity +-- and maintainability. Each module handles a specific aspect: -- --- Notice listchars is set using `vim.opt` instead of `vim.o`. --- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables. --- See `:help lua-options` --- and `:help lua-options-guide` -vim.o.list = true -vim.opt.listchars = { tab = 'ยป ', trail = 'ยท', nbsp = 'โฃ' } - --- Preview substitutions live, as you type! -vim.o.inccommand = 'split' - --- Show which line your cursor is on -vim.o.cursorline = true - --- Minimal number of screen lines to keep above and below the cursor. -vim.o.scrolloff = 10 - --- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), --- instead raise a dialog asking if you wish to save the current file(s) --- See `:help 'confirm'` -vim.o.confirm = true - --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` -vim.keymap.set('n', '', 'nohlsearch') - --- Diagnostic keymaps -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - --- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier --- for people to discover. Otherwise, you normally need to press , which --- is not what someone will guess without a bit more experience. +-- lua/config/ +-- โ”œโ”€โ”€ options.lua - Vim settings (leader, mouse, clipboard, etc.) +-- โ”œโ”€โ”€ keymaps.lua - Global keymaps (window navigation, quit, etc.) +-- โ”œโ”€โ”€ autocmds.lua - Global autocommands (highlight yank, etc.) +-- โ””โ”€โ”€ lazy.lua - Plugin manager bootstrap (~50 lines) -- --- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping --- or just use to exit terminal mode -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') - --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - --- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes --- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) --- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) --- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) --- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.hl.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.hl.on_yank() - end, -}) - --- [[ Install `lazy.nvim` plugin manager ]] --- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } - if vim.v.shell_error ~= 0 then - error('Error cloning lazy.nvim:\n' .. out) - end -end - ----@type vim.Option -local rtp = vim.opt.rtp -rtp:prepend(lazypath) - --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window +-- lua/plugins/ +-- โ”œโ”€โ”€ core/ - Always loaded plugins +-- โ”‚ โ”œโ”€โ”€ ui.lua - Colorscheme, statusline, treesitter +-- โ”‚ โ”œโ”€โ”€ editor.lua - Telescope, which-key +-- โ”‚ โ”œโ”€โ”€ git.lua - Gitsigns +-- โ”‚ โ”œโ”€โ”€ completion.lua - Blink.cmp, snippets +-- โ”‚ โ”œโ”€โ”€ session.lua - Auto-session +-- โ”‚ โ”œโ”€โ”€ extras.lua - Mini.animate, trouble, noice +-- โ”‚ โ””โ”€โ”€ neo-tree.lua - File explorer +-- โ”‚ +-- โ”œโ”€โ”€ lsp/ - LSP infrastructure +-- โ”‚ โ””โ”€โ”€ init.lua - LSP config, mason, conform +-- โ”‚ +-- โ””โ”€โ”€ lang/ - Language-specific (lazy-loaded by filetype) +-- โ”œโ”€โ”€ flutter.lua - Dart/Flutter (ft='dart') +-- โ”œโ”€โ”€ python.lua - Python (ft='python') +-- โ””โ”€โ”€ svelte.lua - Svelte (ft='svelte') -- --- To update plugins you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. -require('lazy').setup({ - -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically - - -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded. - -- - - -- Alternatively, use `config = function() ... end` for full control over the configuration. - -- If you prefer to call `setup` explicitly, use: - -- { - -- 'lewis6991/gitsigns.nvim', - -- config = function() - -- require('gitsigns').setup({ - -- -- Your gitsigns configuration here - -- }) - -- end, - -- } - -- - -- Here is a more advanced example where we pass configuration - -- options to `gitsigns.nvim`. - -- - -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = 'โ€พ' }, - changedelete = { text = '~' }, - }, - }, - }, - - -- NOTE: Plugins can also be configured to run Lua code when they are loaded. - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `opts` key (recommended), the configuration runs - -- after the plugin has been loaded as `require(MODULE).setup(opts)`. - - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - opts = { - -- delay between pressing a key and opening which-key (milliseconds) - -- this setting is independent of vim.o.timeoutlen - delay = 0, - icons = { - -- set icon mappings to true if you have a Nerd Font - mappings = vim.g.have_nerd_font, - -- If you are using a Nerd Font: set icons.keys to an empty table which will use the - -- default which-key.nvim defined Nerd Font icons, otherwise define a string table - keys = vim.g.have_nerd_font and {} or { - Up = ' ', - Down = ' ', - Left = ' ', - Right = ' ', - C = ' ', - M = ' ', - D = ' ', - S = ' ', - CR = ' ', - Esc = ' ', - ScrollWheelDown = ' ', - ScrollWheelUp = ' ', - NL = ' ', - BS = ' ', - Space = ' ', - Tab = ' ', - F1 = '', - F2 = '', - F3 = '', - F4 = '', - F5 = '', - F6 = '', - F7 = '', - F8 = '', - F9 = '', - F10 = '', - F11 = '', - F12 = '', - }, - }, - - -- Document existing key chains - spec = { - { 's', group = '[S]earch' }, - { 't', group = '[T]oggle' }, - { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, - }, - }, - }, - - -- NOTE: Plugins can specify dependencies. - -- - -- The dependencies are proper plugin specifications as well - anything - -- you do for a plugin at the top level, you can do for a dependency. - -- - -- Use the `dependencies` key to specify the dependencies of a particular plugin - - { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - end, - }, - - -- LSP Plugins - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, - }, - }, - }, - { - -- Main LSP Configuration - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - -- Mason must be loaded before its dependents so we need to set it up here. - -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})` - { 'mason-org/mason.nvim', opts = {} }, - 'mason-org/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - { 'j-hui/fidget.nvim', opts = {} }, - - -- Allows extra capabilities provided by blink.cmp - 'saghen/blink.cmp', - }, - config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- NOTE: Remember that Lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('grn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) - - -- Find references for the word under your cursor. - map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. - map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') - - -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) - ---@param client vim.lsp.Client - ---@param method vim.lsp.protocol.Method - ---@param bufnr? integer some lsp support methods only in specific files - ---@return boolean - local function client_supports_method(client, method, bufnr) - if vim.fn.has 'nvim-0.11' == 1 then - return client:supports_method(method, bufnr) - else - return client.supports_method(method, { bufnr = bufnr }) - end - end - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then - local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } - end, - }) - end - - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then - map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - end, '[T]oggle Inlay [H]ints') - end - end, - }) - - -- Diagnostic Config - -- See :help vim.diagnostic.Opts - vim.diagnostic.config { - severity_sort = true, - float = { border = 'rounded', source = 'if_many' }, - underline = { severity = vim.diagnostic.severity.ERROR }, - signs = vim.g.have_nerd_font and { - text = { - [vim.diagnostic.severity.ERROR] = '๓ฐ…š ', - [vim.diagnostic.severity.WARN] = '๓ฐ€ช ', - [vim.diagnostic.severity.INFO] = '๓ฐ‹ฝ ', - [vim.diagnostic.severity.HINT] = '๓ฐŒถ ', - }, - } or {}, - virtual_text = { - source = 'if_many', - spacing = 2, - format = function(diagnostic) - local diagnostic_message = { - [vim.diagnostic.severity.ERROR] = diagnostic.message, - [vim.diagnostic.severity.WARN] = diagnostic.message, - [vim.diagnostic.severity.INFO] = diagnostic.message, - [vim.diagnostic.severity.HINT] = diagnostic.message, - } - return diagnostic_message[diagnostic.severity] - end, - }, - } - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. - local capabilities = require('blink.cmp').get_lsp_capabilities() - - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, - -- - - lua_ls = { - -- cmd = { ... }, - -- filetypes = { ... }, - -- capabilities = {}, - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, - }, - } - - -- Ensure the servers and tools above are installed - -- - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu. - -- - -- `mason` had to be setup earlier: to configure its options see the - -- `dependencies` table for `nvim-lspconfig` above. - -- - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format Lua code - }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) - automatic_installation = false, - handlers = { - function(server_name) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, - }, - - { -- Autoformat - 'stevearc/conform.nvim', - event = { 'BufWritePre' }, - cmd = { 'ConformInfo' }, - keys = { - { - 'f', - function() - require('conform').format { async = true, lsp_format = 'fallback' } - end, - mode = '', - desc = '[F]ormat buffer', - }, - }, - opts = { - notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } - if disable_filetypes[vim.bo[bufnr].filetype] then - return nil - else - return { - timeout_ms = 500, - lsp_format = 'fallback', - } - end - end, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, - }, - }, - }, - - { -- Autocompletion - 'saghen/blink.cmp', - event = 'VimEnter', - version = '1.*', - dependencies = { - -- Snippet Engine - { - 'L3MON4D3/LuaSnip', - version = '2.*', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - dependencies = { - -- `friendly-snippets` contains a variety of premade snippets. - -- See the README about individual language/framework/plugin snippets: - -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, - }, - opts = {}, - }, - 'folke/lazydev.nvim', - }, - --- @module 'blink.cmp' - --- @type blink.cmp.Config - opts = { - keymap = { - -- 'default' (recommended) for mappings similar to built-in completions - -- to accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - -- 'super-tab' for tab to accept - -- 'enter' for enter to accept - -- 'none' for no mappings - -- - -- For an understanding of why the 'default' preset is recommended, - -- you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - -- - -- All presets have the following mappings: - -- /: move to right/left of your snippet expansion - -- : Open menu or open docs if already open - -- / or /: Select next/previous item - -- : Hide menu - -- : Toggle signature help - -- - -- See :h blink-cmp-config-keymap for defining your own keymap - preset = 'default', - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - - appearance = { - -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- Adjusts spacing to ensure icons are aligned - nerd_font_variant = 'mono', - }, - - completion = { - -- By default, you may press `` to show the documentation. - -- Optionally, set `auto_show = true` to show the documentation after a delay. - documentation = { auto_show = false, auto_show_delay_ms = 500 }, - }, - - sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, - providers = { - lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, - }, - }, - - snippets = { preset = 'luasnip' }, - - -- Blink.cmp includes an optional, recommended rust fuzzy matcher, - -- which automatically downloads a prebuilt binary when enabled. - -- - -- By default, we use the Lua implementation instead, but you may enable - -- the rust implementation via `'prefer_rust_with_warning'` - -- - -- See :h blink-cmp-config-fuzzy for more information - fuzzy = { implementation = 'lua' }, - - -- Shows a signature help window while you type arguments for a function - signature = { enabled = true }, - }, - }, - - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. - config = function() - ---@diagnostic disable-next-line: missing-fields - require('tokyonight').setup { - styles = { - comments = { italic = false }, -- Disable italics in comments - }, - } - - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' - end, - }, - - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, - }, - { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - }, - - -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the - -- init.lua. If you want these files, they are in the repository, so you can just download them and - -- place them in the correct locations. - - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart - -- - -- Here are some example plugins that I've included in the Kickstart repository. - -- Uncomment any of the lines below to enable them (you will need to restart nvim). - -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps - - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- This is the easiest way to modularize your config. - -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, - -- - -- For additional information with loading, sourcing and examples see `:help lazy.nvim-๐Ÿ”Œ-plugin-spec` - -- Or use telescope! - -- In normal mode type `sh` then write `lazy.nvim-plugin` - -- you can continue same window with `sr` which resumes last telescope search -}, { - ui = { - -- If you are using a Nerd Font: set icons to an empty table which will use the - -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table - icons = vim.g.have_nerd_font and {} or { - cmd = 'โŒ˜', - config = '๐Ÿ› ', - event = '๐Ÿ“…', - ft = '๐Ÿ“‚', - init = 'โš™', - keys = '๐Ÿ—', - plugin = '๐Ÿ”Œ', - runtime = '๐Ÿ’ป', - require = '๐ŸŒ™', - source = '๐Ÿ“„', - start = '๐Ÿš€', - task = '๐Ÿ“Œ', - lazy = '๐Ÿ’ค ', - }, - }, -}) +-- See ORGANIZATION.md for detailed information about the structure. +-- See MIGRATION.md for the migration guide from monolithic to modular. +-- ======================================================================== + +-- Load core configuration modules +require 'config.options' -- Vim options and settings +require 'config.keymaps' -- Global keymaps +require 'config.autocmds' -- Global autocommands +require 'config.lazy' -- Plugin manager and plugins -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..5048a86e823 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,38 @@ +{ + "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, + "auto-session": { "branch": "main", "commit": "292492ab7af4bd8b9e37e28508bc8ce995722fd5" }, + "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, + "conform.nvim": { "branch": "master", "commit": "9fd3d5e0b689ec1bf400c53cbbec72c6fdf24081" }, + "copilot.vim": { "branch": "release", "commit": "da369d90cfd6c396b1d0ec259836a1c7222fb2ea" }, + "crates.nvim": { "branch": "main", "commit": "ac9fa498a9edb96dc3056724ff69d5f40b898453" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, + "emmet-vim": { "branch": "master", "commit": "e98397144982d1e75b20d94d55a82de3ec8f648d" }, + "fidget.nvim": { "branch": "main", "commit": "e32b672d8fd343f9d6a76944fedb8c61d7d8111a" }, + "flutter-tools.nvim": { "branch": "main", "commit": "69db9cdac65ce536e20a8fc9a83002f007cc049c" }, + "gitsigns.nvim": { "branch": "main", "commit": "20ad4419564d6e22b189f6738116b38871082332" }, + "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, + "lazy.nvim": { "branch": "main", "commit": "f0f5bbb9e5bfae5e6468f9359ffea3d151418176" }, + "lazydev.nvim": { "branch": "main", "commit": "faf46237f0df43a29e12abd143ff1a0bbac27b7e" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3590d66effccc7376d8c3dbe45e8291f9fed2843" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, + "mini.animate": { "branch": "main", "commit": "8ce6df739aa9d14c876bace722af28c3d09e9971" }, + "mini.nvim": { "branch": "main", "commit": "ee4a4a4abed25e3d108d985b0553c5271f2f71aa" }, + "neo-tree.nvim": { "branch": "main", "commit": "8cdd6b1940f333c1dd085526a9c45b30fb2dbf50" }, + "noice.nvim": { "branch": "main", "commit": "5099348591f7d3ba9e547b1e631c694c65bbe0b9" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-dap": { "branch": "master", "commit": "6782b097af2417a4c3e33849b0a26ae2188bd7ea" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "nvim-lspconfig": { "branch": "master", "commit": "c8c9420b7676caf14e1e1d96caed204a81ba860f" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "rustaceanvim": { "branch": "master", "commit": "e9c5aaba16fead831379d5f44617547a90b913c7" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "todo-comments.nvim": { "branch": "main", "commit": "411503d3bedeff88484de572f2509c248e499b38" }, + "tokyonight.nvim": { "branch": "main", "commit": "2642dbb83333e0575d1c3436e1d837926871c5fb" }, + "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 00000000000..afc7daa6741 --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,63 @@ +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.hl.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.hl.on_yank({ higroup = 'IncSearch', timeout = 300 }) + end, +}) + +-- Ensure focus starts in the editor, not file tree +vim.api.nvim_create_autocmd('VimEnter', { + desc = 'Focus editor window on startup, not Neo-tree', + group = vim.api.nvim_create_augroup('kickstart-focus-editor', { clear = true }), + callback = function() + -- Wait a bit for plugins to load, then focus first non-special buffer + vim.defer_fn(function() + -- Find the first normal buffer window + for _, win in ipairs(vim.api.nvim_list_wins()) do + local buf = vim.api.nvim_win_get_buf(win) + local buftype = vim.api.nvim_buf_get_option(buf, 'buftype') + local filetype = vim.api.nvim_buf_get_option(buf, 'filetype') + -- Skip special buffers like neo-tree, terminal, etc. + if buftype == '' and filetype ~= 'neo-tree' then + vim.api.nvim_set_current_win(win) + break + end + end + end, 50) -- 50ms delay to let plugins initialize + end, +}) + +-- Ensure virtual text diagnostics are enabled after all plugins load +-- This needs to be set after plugins that might override diagnostic config +vim.api.nvim_create_autocmd('User', { + pattern = 'VeryLazy', + once = true, + callback = function() + vim.diagnostic.config { + virtual_text = { + spacing = 4, + source = 'if_many', + prefix = 'โ– ', + format = function(diagnostic) + return diagnostic.message + end, + }, + } + end, +}) + +-- Command to restart Python LSP (useful when switching projects/venvs) +vim.api.nvim_create_user_command('PythonRestart', function() + local clients = vim.lsp.get_clients { name = 'pyright' } + for _, client in ipairs(clients) do + vim.lsp.stop_client(client.id, true) + end + vim.notify('Pyright stopped. It will restart on next edit.', vim.log.levels.INFO) +end, { desc = 'Restart Python LSP (pyright)' }) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 00000000000..b56d188af07 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,92 @@ +-- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` + +-- Close floating windows with Escape from anywhere +vim.keymap.set('n', '', function() + -- Try to close any floating windows + for _, win in ipairs(vim.api.nvim_list_wins()) do + local config = vim.api.nvim_win_get_config(win) + if config.relative ~= '' then + vim.api.nvim_win_close(win, false) + return -- Found and closed a floating window + end + end + -- No floating window found, do normal escape behavior + vim.cmd('nohlsearch') +end, { silent = true, desc = 'Close floating window or clear highlight' }) + +-- Diagnostic keymaps +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier +-- for people to discover. Otherwise, you normally need to press , which +-- is not what someone will guess without a bit more experience. +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use to exit terminal mode +vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) + +-- TIP: Disable arrow keys in normal mode +-- vim.keymap.set('n', '', 'echo "Use h to move!!"') +-- vim.keymap.set('n', '', 'echo "Use l to move!!"') +-- vim.keymap.set('n', '', 'echo "Use k to move!!"') +-- vim.keymap.set('n', '', 'echo "Use j to move!!"') + +-- Keybinds to make split navigation easier. +-- Use CTRL+ to switch between windows +-- See `:help wincmd` for a list of all window commands +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) + +-- Quit keymaps - easier ways to close Neovim (using capital Q to avoid conflict with diagnostic quickfix) +-- Session management is automatic via auto-session plugin (saves on exit, restores on startup) +vim.keymap.set('n', 'Q', 'qa', { desc = '[Q]uit [A]ll' }) + +-- Alternative quit options (commented out, uncomment if needed): +-- vim.keymap.set('n', 'Qq', 'qa!', { desc = '[Q]uit all without saving (force)' }) +-- vim.keymap.set('n', 'Qw', function() +-- vim.cmd 'wa' -- Write all buffers +-- vim.cmd 'qa' +-- end, { desc = '[Q]uit all and [W]rite files' }) + +-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes +-- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) +-- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) +-- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) +-- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) + +-- ======================================================================== +-- BUFFER OPERATIONS (b) +-- ======================================================================== +vim.keymap.set('n', 'bd', 'bd', { desc = 'Delete buffer' }) +vim.keymap.set('n', 'bD', 'bd!', { desc = 'Delete buffer (force)' }) +vim.keymap.set('n', 'bn', 'bnext', { desc = 'Next buffer' }) +vim.keymap.set('n', 'bp', 'bprevious', { desc = 'Previous buffer' }) +vim.keymap.set('n', 'bo', '%bd|e#|bd#', { desc = 'Delete other buffers' }) + +-- ======================================================================== +-- WINDOW OPERATIONS (w) +-- ======================================================================== +vim.keymap.set('n', 'ww', 'w', { desc = 'Other window' }) +vim.keymap.set('n', 'wd', 'c', { desc = 'Delete window' }) +vim.keymap.set('n', 'ws', 's', { desc = 'Split window below' }) +vim.keymap.set('n', 'wv', 'v', { desc = 'Split window right' }) +vim.keymap.set('n', 'wm', '_|', { desc = 'Maximize window' }) +vim.keymap.set('n', 'w=', '=', { desc = 'Balance windows' }) +vim.keymap.set('n', 'wh', 'h', { desc = 'Go to left window' }) +vim.keymap.set('n', 'wj', 'j', { desc = 'Go to lower window' }) +vim.keymap.set('n', 'wk', 'k', { desc = 'Go to upper window' }) +vim.keymap.set('n', 'wl', 'l', { desc = 'Go to right window' }) + +-- ======================================================================== +-- UI OPERATIONS (u) +-- ======================================================================== +vim.keymap.set('n', 'ul', 'Lazy', { desc = 'Open Lazy' }) +vim.keymap.set('n', 'um', 'Mason', { desc = 'Open Mason' }) +vim.keymap.set('n', 'ui', vim.show_pos, { desc = 'Inspect position' }) +vim.keymap.set('n', 'uI', 'InspectTree', { desc = 'Inspect tree' }) +vim.keymap.set('n', 'un', function() + require('noice').cmd 'dismiss' +end, { desc = 'Dismiss notifications' }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 00000000000..bf7f985d109 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,49 @@ +-- ======================================================================== +-- LAZY.NVIM PLUGIN MANAGER +-- ======================================================================== +-- Bootstrap and configure lazy.nvim +-- Plugins are organized in: +-- lua/plugins/core/ - Always loaded (UI, editor, git, completion) +-- lua/plugins/lsp/ - LSP infrastructure +-- lua/plugins/lang/ - Language-specific (lazy-loaded by filetype) +-- ======================================================================== + +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + if vim.v.shell_error ~= 0 then + error('Error cloning lazy.nvim:\n' .. out) + end +end + +---@type vim.Option +local rtp = vim.opt.rtp +rtp:prepend(lazypath) + +-- Configure and load plugins +require('lazy').setup({ + -- Import all plugins from the new modular structure + { import = 'plugins.core' }, -- Core plugins (always loaded) + { import = 'plugins.lsp' }, -- LSP configuration + { import = 'plugins.lang' }, -- Language-specific plugins (lazy-loaded) +}, { + ui = { + icons = vim.g.have_nerd_font and {} or { + cmd = 'โŒ˜', + config = '๐Ÿ› ', + event = '๐Ÿ“…', + ft = '๐Ÿ“‚', + init = 'โš™', + keys = '๐Ÿ—', + plugin = '๐Ÿ”Œ', + runtime = '๐Ÿ’ป', + require = '๐ŸŒ™', + source = '๐Ÿ“„', + start = '๐Ÿš€', + task = '๐Ÿ“Œ', + lazy = '๐Ÿ’ค ', + }, + }, +}) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 00000000000..f72ec64bfde --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,120 @@ +-- [[ Setting options ]] +-- See `:help vim.opt` +-- See `:help vim.o` +-- See `:help option-list` + +-- Set as the leader key +-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Set to true if you have a Nerd Font installed and selected in the terminal +vim.g.have_nerd_font = false + +-- [[ Setup Node.js PATH for plugins like Copilot ]] +-- Add fnm's Node.js to PATH so Neovim can find it +-- This is required for GitHub Copilot and other Node.js based plugins +-- Uses fnm's alias resolution to always point to the default/latest version +local home = vim.env.HOME +local fnm_node_path = home .. '/.local/share/fnm/aliases/default/bin' +-- Fallback: also add the fnm multishell path if it exists +local fnm_multishell = home .. '/.local/state/fnm_multishells' +if vim.fn.isdirectory(fnm_node_path) == 1 then + vim.env.PATH = fnm_node_path .. ':' .. vim.env.PATH +elseif vim.fn.isdirectory(fnm_multishell) == 1 then + -- If multishell is being used, fnm will handle it via shell integration + -- We just need to ensure the PATH includes typical fnm locations + vim.env.PATH = home .. '/.local/share/fnm:' .. vim.env.PATH +end + +-- Make line numbers default +vim.o.number = true + +-- Enable relative line numbers for easier jumping +vim.o.relativenumber = true + +-- Enable mouse mode, can be useful for resizing splits for example! +vim.o.mouse = 'a' + +-- Don't show the mode, since it's already in the status line +vim.o.showmode = false + +-- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. +-- See `:help 'clipboard'` +vim.schedule(function() + vim.o.clipboard = 'unnamedplus' +end) + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.o.signcolumn = 'yes' + +-- Decrease update time +vim.o.updatetime = 250 + +-- Decrease mapped sequence wait time +-- Displays which-key popup sooner +vim.o.timeoutlen = 300 + +-- Configure how new splits should be opened +vim.o.splitright = true +vim.o.splitbelow = true + +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` and `:help 'listchars'` +vim.o.list = true +vim.opt.listchars = { tab = 'ยป ', trail = 'ยท', nbsp = 'โฃ' } + +-- Preview substitutions live, as you type! +vim.o.inccommand = 'split' + +-- Show which line your cursor is on +vim.o.cursorline = true + +-- Minimal number of screen lines to keep above and below the cursor. +vim.o.scrolloff = 10 + +-- If performing an operation that would fail due to unsaved changes in the buffer (like `:q`), +-- instead raise a dialog asking if you wish to save the current file(s) +-- See `:help 'confirm'` +vim.o.confirm = true + +-- ======================================================================== +-- FOLDING CONFIGURATION - For Flutter widgets and code blocks +-- ======================================================================== +-- Enable folding based on Treesitter (for Flutter widgets, functions, etc.) +vim.o.foldmethod = 'expr' +vim.o.foldexpr = 'nvim_treesitter#foldexpr()' + +-- Start with all folds open (don't fold on file open) +vim.o.foldenable = false + +-- Set fold level (higher = more unfolded by default) +vim.o.foldlevel = 99 +vim.o.foldlevelstart = 99 + +-- Customize fold text to show more context +vim.o.foldtext = '' + +-- Hide fold column globally (saves space, folds still work with za/zc/zo) +-- Set to '1' if you want the fold column back +vim.o.foldcolumn = '0' + +-- Folding keymaps: +-- za - Toggle fold under cursor +-- zc - Close fold under cursor +-- zo - Open fold under cursor +-- zM - Close all folds +-- zR - Open all folds +-- zj - Move to next fold +-- zk - Move to previous fold diff --git a/lua/custom/plugins/flutter.lua b/lua/custom/plugins/flutter.lua new file mode 100644 index 00000000000..b9fc85cca5a --- /dev/null +++ b/lua/custom/plugins/flutter.lua @@ -0,0 +1,485 @@ +-- ======================================================================== +-- FLUTTER/DART PROFILE - Language-specific plugins and LSP configuration +-- ======================================================================== +-- +-- This file contains all Flutter and Dart-specific plugins and configurations. +-- These plugins will ONLY load when you open a .dart file, keeping your +-- startup time fast and avoiding conflicts with other languages. +-- +-- Key features to configure here: +-- - Flutter tools (hot reload, device management, widget inspector) +-- - Dart LSP (dartls via flutter-tools) +-- - Dart-specific formatters and linters +-- - Flutter-specific keymaps (e.g., fr for Flutter Run) +-- +-- Usage: Just open a .dart file and these plugins will automatically load! +-- ======================================================================== + +return { + -- ======================================================================== + -- NVIM-DAP - Debug Adapter Protocol for Flutter debugging + -- ======================================================================== + -- Load DAP when opening Dart files to enable breakpoint debugging + { + 'mfussenegger/nvim-dap', + ft = 'dart', + dependencies = { + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', + }, + }, + + -- ======================================================================== + -- FLUTTER TOOLS - Complete Flutter development environment + -- ======================================================================== + -- Provides Flutter-specific features like hot reload, device management, + -- widget inspector, and integrates the Dart LSP server. + -- + -- Flutter-specific keymaps (available in .dart files): + -- fr - Flutter Run (start app) + -- fq - Flutter Quit (stop app) + -- fR - Flutter Hot Restart + -- fh - Flutter Hot Reload + -- fd - Flutter Devices (show connected devices) + -- fe - Flutter Emulators (launch emulator) + -- fo - Flutter Outline (toggle outline/widget tree) + -- ft - Flutter DevTools (start DevTools server) + -- fa - Flutter Attach (attach to running app) + -- fD - Flutter Detach (detach from running app) + -- fL - Flutter Log Toggle (show/hide logs) + -- fc - Flutter Copy Profiler URL (for DevTools) + -- + -- Debug keymaps: + -- - Start/Continue debugging + -- - Step over + -- - Step into + -- - Step out + -- db - Toggle breakpoint + -- dB - Set conditional breakpoint + -- dc - Continue + -- dt - Terminate debugging + -- ======================================================================== + { + 'nvim-flutter/flutter-tools.nvim', + ft = 'dart', -- Only load when opening Dart files + dependencies = { + 'nvim-lua/plenary.nvim', + 'stevearc/dressing.nvim', -- Optional: better UI for Flutter commands + 'mfussenegger/nvim-dap', + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', + }, + config = function() + -- Get shared LSP capabilities from blink.cmp + local capabilities = require('blink.cmp').get_lsp_capabilities() + + require('flutter-tools').setup { + -- UI configuration + ui = { + border = 'rounded', -- border type for floating windows + notification_style = 'native', -- 'native' or 'plugin' (native uses vim.notify) + }, + + -- Flutter SDK path (usually auto-detected, but you can specify if needed) + -- flutter_path = '/path/to/flutter/bin/flutter', + -- flutter_lookup_cmd = nil, -- example: "dirname $(which flutter)" or "asdf where flutter" + + -- FVM support - takes priority over path, uses /.fvm/flutter_sdk if enabled + fvm = false, + + -- Root patterns to find the root of your flutter project + root_patterns = { '.git', 'pubspec.yaml' }, + + -- Uncomment to set a default device (get ID from `flutter devices`) + -- device = { + -- id = 'chrome', -- or 'macos', 'emulator-5554', etc. + -- }, + + lsp = { + capabilities = capabilities, + + -- Suppress didChange errors during snippet expansion + on_attach = function(client, bufnr) + -- Reduce didChange notification frequency to prevent errors with snippets + client.server_capabilities.textDocumentSync = vim.tbl_deep_extend('force', client.server_capabilities.textDocumentSync or {}, { + change = 2, -- 2 = Incremental (less prone to errors than full sync) + }) + + -- Filter out didChange error notifications (they're harmless during snippet expansion) + -- We'll use an autocmd to do this after noice.nvim is loaded + vim.api.nvim_create_autocmd('User', { + pattern = 'VeryLazy', + once = true, + callback = function() + local notify = vim.notify + vim.notify = function(msg, level, opts) + if type(msg) == 'string' and msg:match('textDocument/didChange') then + return -- Suppress this specific error + end + notify(msg, level, opts) + end + end, + }) + end, + + -- Color preview for dart variables (Colors.red, Color(0xFF...), etc.) + -- This shows the actual Material Design colors inline! + color = { + enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 + background = true, -- highlight the background + background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},) + foreground = false, -- highlight the foreground + virtual_text = true, -- show the highlight using virtual text + virtual_text_str = 'โ– ', -- the virtual text character to highlight + }, + -- Settings passed to the Dart LSP + settings = { + -- Show TODOs in the problems pane + showTodos = true, + -- Completion settings + completeFunctionCalls = true, + -- Enable/disable specific lints + -- analysisExcludedFolders = {}, + renameFilesWithClasses = 'prompt', -- "always" or "prompt" + enableSnippets = true, + updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed + }, + }, + + -- Flutter-specific settings + decorations = { + statusline = { + -- Set to true to show Flutter app info in statusline + app_version = false, + device = true, -- Show device name + }, + }, + + widget_guides = { + enabled = true, -- Show visual guides for widget nesting + }, + + closing_tags = { + highlight = 'Comment', -- Highlight color for closing tags + prefix = '// ', -- Text to show before closing tag + enabled = true, -- Show closing tags for widgets + }, + + dev_log = { + enabled = true, + notify_errors = false, -- Don't show error notifications for log buffer issues + open_cmd = 'tabedit', -- Open logs in a new tab + focus_on_open = false, -- Don't auto-focus the log window + }, + + dev_tools = { + autostart = false, -- autostart devtools server if not detected + auto_open_browser = false, -- Automatically opens devtools in the browser + }, + + outline = { + open_cmd = '30vnew', -- command to use to open the outline buffer + auto_open = false, -- if true this will open the outline automatically when it is first populated + }, + + debugger = { + enabled = true, -- Enable Flutter debugger integration + run_via_dap = true, -- Use DAP for debugging + -- if empty dap will not stop on any exceptions, otherwise it will stop on those specified + -- see |:help dap.set_exception_breakpoints()| for more info + exception_breakpoints = {}, + -- Whether to call toString() on objects in debug views like hovers and the variables list. + -- Invoking toString() has a performance cost and may introduce side-effects, + -- although users may expected this functionality. null is treated like false. + evaluate_to_string_in_debug_views = true, + -- Flutter tools will automatically register DAP configurations + -- No need to manually configure launch.json + }, + } + + -- ======================================================================== + -- DAP UI SETUP - Beautiful debugging interface + -- ======================================================================== + local dap, dapui = require 'dap', require 'dapui' + + -- Configure DAP UI to open in tabs for better half-width screen support + dapui.setup { + icons = { expanded = 'โ–พ', collapsed = 'โ–ธ', current_frame = '*' }, + controls = { + icons = { + pause = 'โธ', + play = 'โ–ถ', + step_into = 'โŽ', + step_over = 'โญ', + step_out = 'โฎ', + step_back = 'b', + run_last = 'โ–ถโ–ถ', + terminate = 'โน', + disconnect = 'โ', + }, + }, + -- Open each element in a new tab instead of side panels + -- This prevents layout issues on small/half-width screens + layouts = { + { + elements = { + { id = 'scopes', size = 0.25 }, + { id = 'breakpoints', size = 0.25 }, + { id = 'stacks', size = 0.25 }, + { id = 'watches', size = 0.25 }, + }, + size = 40, + position = 'right', + }, + { + elements = { + { id = 'repl', size = 0.5 }, + { id = 'console', size = 0.5 }, + }, + size = 10, + position = 'bottom', + }, + }, + -- Override element window commands to open in tabs + element_mappings = {}, + windows = { indent = 1 }, + } + + -- Custom function to open DAP UI elements in tabs + local function open_dapui_in_tabs() + -- Save current tab to return to it + local current_tab = vim.fn.tabpagenr() + + -- Create new tab with a named buffer for debug views + vim.cmd 'tabnew' + local debug_buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_name(debug_buf, 'Flutter Debug') + vim.api.nvim_set_current_buf(debug_buf) + + -- Open DAP UI in this tab + dapui.open() + + -- Return to original tab so user continues coding there + vim.cmd('tabnext ' .. current_tab) + end + + -- Custom function to close DAP UI tabs + local function close_dapui_tabs() + dapui.close() + + -- Find and close the Flutter Debug tab + local current_tab = vim.fn.tabpagenr() + for i = 1, vim.fn.tabpagenr '$' do + vim.cmd('tabnext ' .. i) + local bufname = vim.api.nvim_buf_get_name(0) + if bufname:match('Flutter Debug') then + vim.cmd 'tabclose' + break + end + end + + -- Return to original tab + if vim.fn.tabpagenr '$' >= current_tab then + vim.cmd('tabnext ' .. current_tab) + end + end + + -- Automatically open/close DAP UI in tabs + dap.listeners.after.event_initialized['dapui_config'] = open_dapui_in_tabs + dap.listeners.before.event_terminated['dapui_config'] = close_dapui_tabs + dap.listeners.before.event_exited['dapui_config'] = close_dapui_tabs + + -- Fix for Flutter Tools log buffer - make it non-saveable + -- This prevents Vim from asking to save changes to the log file on exit + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, { + pattern = '*', + callback = function(args) + local bufname = vim.api.nvim_buf_get_name(args.buf) + -- Check if this is a Flutter log buffer + if bufname:match('__FLUTTER_DEV_LOG__') or vim.bo[args.buf].filetype == 'log' then + vim.bo[args.buf].modifiable = true -- Allow Flutter to write to it + vim.bo[args.buf].modified = false -- Mark as unmodified + vim.bo[args.buf].buftype = 'nofile' -- Don't associate with a file (prevents save prompt) + vim.bo[args.buf].swapfile = false -- Don't create swap file + end + end, + }) + + -- Keep log buffer marked as unmodified whenever it changes + -- This prevents the "save changes?" prompt on exit + vim.api.nvim_create_autocmd('BufModifiedSet', { + pattern = '*', + callback = function(args) + local bufname = vim.api.nvim_buf_get_name(args.buf) + if bufname:match('__FLUTTER_DEV_LOG__') then + vim.bo[args.buf].modifiable = true + vim.bo[args.buf].modified = false -- Keep it marked as unmodified + end + end, + }) + + -- ======================================================================== + -- ENABLE TREESITTER FOLDING FOR DART FILES + -- ======================================================================== + -- Set fold method to use Treesitter for Flutter widgets + -- Using multiple autocmds to ensure it sticks (some plugins override it) + local fold_augroup = vim.api.nvim_create_augroup('DartFolding', { clear = true }) + + vim.api.nvim_create_autocmd({ 'BufRead', 'BufEnter', 'BufWinEnter' }, { + group = fold_augroup, + pattern = '*.dart', + callback = function() + vim.opt_local.foldmethod = 'expr' + vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()' + vim.opt_local.foldlevel = 99 -- High level = everything unfolded + vim.opt_local.foldlevelstart = 99 -- Start with everything unfolded + + -- Hide fold column (no extra column, folds still work!) + vim.opt_local.foldcolumn = '0' + + -- Minimal fold display (VS Code style - just shows first line) + vim.opt_local.foldtext = '' + end, + }) + + -- Also set after LSP attaches (flutter-tools might reset it) + vim.api.nvim_create_autocmd('LspAttach', { + group = fold_augroup, + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and client.name == 'dartls' then + vim.opt_local.foldmethod = 'expr' + vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()' + vim.opt_local.foldlevel = 99 -- Everything unfolded + end + end, + }) + + -- ======================================================================== + -- FLUTTER-SPECIFIC KEYMAPS + -- ======================================================================== + -- These keymaps are only available when editing Dart files + -- They provide quick access to common Flutter commands + -- ======================================================================== + vim.api.nvim_create_autocmd('FileType', { + pattern = 'dart', + callback = function() + local opts = { buffer = true, silent = true } + + -- ======================================================================== + -- ENABLE TREESITTER FOLDING FOR DART FILES + -- ======================================================================== + -- Set fold method to use Treesitter for Flutter widgets + vim.opt_local.foldmethod = 'expr' + vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()' + vim.opt_local.foldenable = false -- Start with folds open + vim.opt_local.foldlevel = 99 + vim.opt_local.foldlevelstart = 99 + + -- Flutter run/quit + -- WORKFLOW: + -- 1. First time: fd to select device + -- 2. Then: fr to run (uses selected device) + -- 3. Subsequent runs: fr uses same device + vim.keymap.set('n', 'fr', 'FlutterRun', vim.tbl_extend('force', opts, { desc = 'Flutter: Run app' })) + vim.keymap.set('n', 'fR', 'FlutterRestart', vim.tbl_extend('force', opts, { desc = 'Flutter: Hot restart' })) + vim.keymap.set('n', 'fh', 'FlutterReload', vim.tbl_extend('force', opts, { desc = 'Flutter: Hot reload' })) + vim.keymap.set('n', 'fq', 'FlutterQuit', vim.tbl_extend('force', opts, { desc = 'Flutter: Quit app' })) + + -- Code Actions (Cmd+. equivalent) - wrap, remove, extract widgets, etc. + vim.keymap.set('n', '.', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = 'Flutter: Code actions (Cmd+.)' })) + vim.keymap.set('v', '.', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = 'Flutter: Code actions (Cmd+.)' })) + -- Alternative: use the default LSP keymap + vim.keymap.set('n', 'gra', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = '[G]oto Code [A]ction' })) + vim.keymap.set('v', 'gra', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = '[G]oto Code [A]ction' })) + + -- Device management + -- Use fd to see/select devices FIRST, then fr will use that device + vim.keymap.set('n', 'fd', 'FlutterDevices', vim.tbl_extend('force', opts, { desc = 'Flutter: Select device' })) + vim.keymap.set('n', 'fe', 'FlutterEmulators', vim.tbl_extend('force', opts, { desc = 'Flutter: Launch emulator' })) + + -- Dev tools and debugging + vim.keymap.set('n', 'fo', 'FlutterOutlineToggle', vim.tbl_extend('force', opts, { desc = 'Flutter: Toggle outline' })) + vim.keymap.set('n', 'ft', 'FlutterDevTools', vim.tbl_extend('force', opts, { desc = 'Flutter: Start DevTools' })) + vim.keymap.set( + 'n', + 'fc', + 'FlutterCopyProfilerUrl', + vim.tbl_extend('force', opts, { desc = 'Flutter: Copy profiler URL' }) + ) + + -- Attach/Detach + vim.keymap.set('n', 'fa', 'FlutterAttach', vim.tbl_extend('force', opts, { desc = 'Flutter: Attach to app' })) + vim.keymap.set('n', 'fD', 'FlutterDetach', vim.tbl_extend('force', opts, { desc = 'Flutter: Detach from app' })) + + -- Logs + vim.keymap.set('n', 'fL', 'FlutterLogToggle', vim.tbl_extend('force', opts, { desc = 'Flutter: Toggle logs' })) + + -- LSP + vim.keymap.set('n', 'fl', 'FlutterLspRestart', vim.tbl_extend('force', opts, { desc = 'Flutter: Restart LSP' })) + + -- ======================================================================== + -- DEBUG KEYMAPS - Available only in Dart files + -- ======================================================================== + -- Function key shortcuts (standard debugging) + vim.keymap.set('n', '', function() + require('dap').continue() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Start/Continue' })) + + vim.keymap.set('n', '', function() + require('dap').step_over() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Step Over' })) + + vim.keymap.set('n', '', function() + require('dap').step_into() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Step Into' })) + + vim.keymap.set('n', '', function() + require('dap').step_out() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Step Out' })) + + -- Leader-based debug commands + vim.keymap.set('n', 'db', function() + require('dap').toggle_breakpoint() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: Toggle [B]reakpoint' })) + + vim.keymap.set('n', 'dB', function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: Set Conditional [B]reakpoint' })) + + vim.keymap.set('n', 'dc', function() + require('dap').continue() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: [C]ontinue' })) + + vim.keymap.set('n', 'dt', function() + require('dap').terminate() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: [T]erminate' })) + + vim.keymap.set('n', 'du', function() + require('dapui').toggle() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: Toggle [U]I' })) + + -- Register groups with which-key + require('which-key').add { + { 'f', group = '[F]lutter', mode = 'n' }, + { 'd', group = '[D]ebug', mode = 'n' }, + } + end, + }) + end, + }, + + -- ======================================================================== + -- DART TREESITTER - Ensure dart parser is installed for proper folding + -- ======================================================================== + { + 'nvim-treesitter/nvim-treesitter', + ft = 'dart', + opts = function(_, opts) + -- Ensure Dart parser is installed + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { 'dart' }) + return opts + end, + }, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d8d7a..00000000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua deleted file mode 100644 index b59d08649af..00000000000 --- a/lua/kickstart/health.lua +++ /dev/null @@ -1,52 +0,0 @@ ---[[ --- --- This file is not required for your own configuration, --- but helps people determine if their system is setup correctly. --- ---]] - -local check_version = function() - local verstr = tostring(vim.version()) - if not vim.version.ge then - vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) - return - end - - if vim.version.ge(vim.version(), '0.10-dev') then - vim.health.ok(string.format("Neovim version is: '%s'", verstr)) - else - vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) - end -end - -local check_external_reqs = function() - -- Basic utils: `git`, `make`, `unzip` - for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do - local is_executable = vim.fn.executable(exe) == 1 - if is_executable then - vim.health.ok(string.format("Found executable: '%s'", exe)) - else - vim.health.warn(string.format("Could not find executable: '%s'", exe)) - end - end - - return true -end - -return { - check = function() - vim.health.start 'kickstart.nvim' - - vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` - - Fix only warnings for plugins and languages you intend to use. - Mason will give warnings for languages that are not installed. - You do not need to install, unless you want to use those languages!]] - - local uv = vim.uv or vim.loop - vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) - - check_version() - check_external_reqs() - end, -} diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua deleted file mode 100644 index 386d392e7ad..00000000000 --- a/lua/kickstart/plugins/autopairs.lua +++ /dev/null @@ -1,8 +0,0 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - -return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - opts = {}, -} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua deleted file mode 100644 index 8e332bf2ff9..00000000000 --- a/lua/kickstart/plugins/debug.lua +++ /dev/null @@ -1,148 +0,0 @@ --- debug.lua --- --- Shows how to use the DAP plugin to debug your code. --- --- Primarily focused on configuring the debugger for Go, but can --- be extended to other languages as well. That's why it's called --- kickstart.nvim and not kitchen-sink.nvim ;) - -return { - -- NOTE: Yes, you can install new plugins here! - 'mfussenegger/nvim-dap', - -- NOTE: And you can specify dependencies as well - dependencies = { - -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', - - -- Required dependency for nvim-dap-ui - 'nvim-neotest/nvim-nio', - - -- Installs the debug adapters for you - 'mason-org/mason.nvim', - 'jay-babu/mason-nvim-dap.nvim', - - -- Add your own debuggers here - 'leoluz/nvim-dap-go', - }, - keys = { - -- Basic debugging keymaps, feel free to change to your liking! - { - '', - function() - require('dap').continue() - end, - desc = 'Debug: Start/Continue', - }, - { - '', - function() - require('dap').step_into() - end, - desc = 'Debug: Step Into', - }, - { - '', - function() - require('dap').step_over() - end, - desc = 'Debug: Step Over', - }, - { - '', - function() - require('dap').step_out() - end, - desc = 'Debug: Step Out', - }, - { - 'b', - function() - require('dap').toggle_breakpoint() - end, - desc = 'Debug: Toggle Breakpoint', - }, - { - 'B', - function() - require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, - desc = 'Debug: Set Breakpoint', - }, - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - { - '', - function() - require('dapui').toggle() - end, - desc = 'Debug: See last session result.', - }, - }, - config = function() - local dap = require 'dap' - local dapui = require 'dapui' - - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_installation = true, - - -- You can provide additional configuration to the handlers, - -- see mason-nvim-dap README for more information - handlers = {}, - - -- You'll need to check that you have the required things installed - -- online, please don't ask me how to install them :) - ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', - }, - } - - -- Dap UI setup - -- For more information, see |:help nvim-dap-ui| - dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. - icons = { expanded = 'โ–พ', collapsed = 'โ–ธ', current_frame = '*' }, - controls = { - icons = { - pause = 'โธ', - play = 'โ–ถ', - step_into = 'โŽ', - step_over = 'โญ', - step_out = 'โฎ', - step_back = 'b', - run_last = 'โ–ถโ–ถ', - terminate = 'โน', - disconnect = 'โ', - }, - }, - } - - -- Change breakpoint icons - -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) - -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) - -- local breakpoint_icons = vim.g.have_nerd_font - -- and { Breakpoint = '๎ฉฑ', BreakpointCondition = '๎ชง', BreakpointRejected = '๎ฎŒ', LogPoint = '๎ชซ', Stopped = '๎ฎ‹' } - -- or { Breakpoint = 'โ—', BreakpointCondition = 'โŠœ', BreakpointRejected = 'โŠ˜', LogPoint = 'โ—†', Stopped = 'โญ”' } - -- for type, icon in pairs(breakpoint_icons) do - -- local tp = 'Dap' .. type - -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' - -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) - -- end - - dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup { - delve = { - -- On Windows delve must be run attached or it crashes. - -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring - detached = vim.fn.has 'win32' == 0, - }, - } - end, -} diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua deleted file mode 100644 index cbbd22d24fc..00000000000 --- a/lua/kickstart/plugins/gitsigns.lua +++ /dev/null @@ -1,61 +0,0 @@ --- Adds git related signs to the gutter, as well as utilities for managing changes --- NOTE: gitsigns is already included in init.lua but contains only the base --- config. This will add also the recommended keymaps. - -return { - { - 'lewis6991/gitsigns.nvim', - opts = { - on_attach = function(bufnr) - local gitsigns = require 'gitsigns' - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map('n', ']c', function() - if vim.wo.diff then - vim.cmd.normal { ']c', bang = true } - else - gitsigns.nav_hunk 'next' - end - end, { desc = 'Jump to next git [c]hange' }) - - map('n', '[c', function() - if vim.wo.diff then - vim.cmd.normal { '[c', bang = true } - else - gitsigns.nav_hunk 'prev' - end - end, { desc = 'Jump to previous git [c]hange' }) - - -- Actions - -- visual mode - map('v', 'hs', function() - gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'git [s]tage hunk' }) - map('v', 'hr', function() - gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'git [r]eset hunk' }) - -- normal mode - map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) - map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) - map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) - map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) - map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) - map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) - map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) - map('n', 'hD', function() - gitsigns.diffthis '@' - end, { desc = 'git [D]iff against last commit' }) - -- Toggles - map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) - end, - }, - }, -} diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua deleted file mode 100644 index ed7f269399f..00000000000 --- a/lua/kickstart/plugins/indent_line.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - { -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help ibl` - main = 'ibl', - opts = {}, - }, -} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua deleted file mode 100644 index dec42f097c6..00000000000 --- a/lua/kickstart/plugins/lint.lua +++ /dev/null @@ -1,60 +0,0 @@ -return { - - { -- Linting - 'mfussenegger/nvim-lint', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local lint = require 'lint' - lint.linters_by_ft = { - markdown = { 'markdownlint' }, - } - - -- To allow other plugins to add linters to require('lint').linters_by_ft, - -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } - -- - -- However, note that this will enable a set of default linters, - -- which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- You can disable the default linters by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil - -- lint.linters_by_ft['dockerfile'] = nil - -- lint.linters_by_ft['inko'] = nil - -- lint.linters_by_ft['janet'] = nil - -- lint.linters_by_ft['json'] = nil - -- lint.linters_by_ft['markdown'] = nil - -- lint.linters_by_ft['rst'] = nil - -- lint.linters_by_ft['ruby'] = nil - -- lint.linters_by_ft['terraform'] = nil - -- lint.linters_by_ft['text'] = nil - - -- Create autocommand which carries out the actual linting - -- on the specified events. - local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { - group = lint_augroup, - callback = function() - -- Only run the linter in buffers that you can modify in order to - -- avoid superfluous noise, notably within the handy LSP pop-ups that - -- describe the hovered symbol using Markdown. - if vim.bo.modifiable then - lint.try_lint() - end - end, - }) - end, - }, -} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua deleted file mode 100644 index c7067891df0..00000000000 --- a/lua/kickstart/plugins/neo-tree.lua +++ /dev/null @@ -1,25 +0,0 @@ --- Neo-tree is a Neovim plugin to browse the file system --- https://github.com/nvim-neo-tree/neo-tree.nvim - -return { - 'nvim-neo-tree/neo-tree.nvim', - version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended - 'MunifTanjim/nui.nvim', - }, - lazy = false, - keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, - }, - opts = { - filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - }, - }, - }, - }, -} diff --git a/lua/plugins/core/cheatsheet.lua b/lua/plugins/core/cheatsheet.lua new file mode 100644 index 00000000000..91d16909148 --- /dev/null +++ b/lua/plugins/core/cheatsheet.lua @@ -0,0 +1,396 @@ +-- ======================================================================== +-- CHEATSHEET - Comprehensive keymap reference +-- ======================================================================== +-- Complete cheatsheet including: +-- - Vim default keymaps +-- - Custom leader keymaps +-- - Plugin-specific keymaps (Telescope, Neo-tree, etc.) +-- - LSP keymaps +-- - Language-specific keymaps +-- ======================================================================== + +return { + -- Enhanced cheatsheet with custom data + { + 'nvim-telescope/telescope.nvim', + keys = { + { + 'sc', + function() + -- Create a custom cheatsheet picker + local pickers = require 'telescope.pickers' + local finders = require 'telescope.finders' + local conf = require('telescope.config').values + local actions = require 'telescope.actions' + local action_state = require 'telescope.actions.state' + + -- Comprehensive keymap data + local cheatsheet = { + -- ============================================================ + -- VIM ESSENTIALS + -- ============================================================ + { category = 'Vim: Motion', key = 'h/j/k/l', desc = 'Left/Down/Up/Right' }, + { category = 'Vim: Motion', key = 'w/b/e', desc = 'Word forward/backward/end' }, + { category = 'Vim: Motion', key = '0/$', desc = 'Start/end of line' }, + { category = 'Vim: Motion', key = 'gg/G', desc = 'First/last line' }, + { category = 'Vim: Motion', key = '{/}', desc = 'Previous/next paragraph' }, + { category = 'Vim: Motion', key = '%', desc = 'Jump to matching bracket' }, + { category = 'Vim: Motion', key = 'f/F{char}', desc = 'Find char forward/backward' }, + { category = 'Vim: Motion', key = 't/T{char}', desc = 'Till char forward/backward' }, + { category = 'Vim: Motion', key = ';/,', desc = 'Repeat f/t forward/backward' }, + { category = 'Vim: Motion', key = '*/#', desc = 'Search word under cursor' }, + { category = 'Vim: Motion', key = 'n/N', desc = 'Next/previous search result' }, + + { category = 'Vim: Editing', key = 'i/a', desc = 'Insert before/after cursor' }, + { category = 'Vim: Editing', key = 'I/A', desc = 'Insert at line start/end' }, + { category = 'Vim: Editing', key = 'o/O', desc = 'New line below/above' }, + { category = 'Vim: Editing', key = 'x/X', desc = 'Delete char under/before cursor' }, + { category = 'Vim: Editing', key = 'd{motion}', desc = 'Delete (dw, dd, d$)' }, + { category = 'Vim: Editing', key = 'c{motion}', desc = 'Change (cw, cc, c$)' }, + { category = 'Vim: Editing', key = 'y{motion}', desc = 'Yank/copy (yw, yy, y$)' }, + { category = 'Vim: Editing', key = 'p/P', desc = 'Paste after/before cursor' }, + { category = 'Vim: Editing', key = 'u/Ctrl-r', desc = 'Undo/redo' }, + { category = 'Vim: Editing', key = '.', desc = 'Repeat last change' }, + { category = 'Vim: Editing', key = 'r{char}', desc = 'Replace character' }, + { category = 'Vim: Editing', key = 'J', desc = 'Join lines' }, + { category = 'Vim: Editing', key = '~', desc = 'Toggle case' }, + { category = 'Vim: Editing', key = '>>/<<', desc = 'Indent/unindent line' }, + + { category = 'Vim: Visual', key = 'v/V/Ctrl-v', desc = 'Visual/line/block mode' }, + { category = 'Vim: Visual', key = 'o', desc = 'Go to other end of selection' }, + { category = 'Vim: Visual', key = 'gv', desc = 'Reselect last visual' }, + + { category = 'Vim: Search', key = '/{pattern}', desc = 'Search forward' }, + { category = 'Vim: Search', key = '?{pattern}', desc = 'Search backward' }, + { category = 'Vim: Search', key = ':s/old/new/g', desc = 'Substitute in line' }, + { category = 'Vim: Search', key = ':%s/old/new/g', desc = 'Substitute in file' }, + { category = 'Vim: Search', key = ':noh', desc = 'Clear search highlight' }, + + { category = 'Vim: Windows', key = 'Ctrl-w s', desc = 'Split horizontal' }, + { category = 'Vim: Windows', key = 'Ctrl-w v', desc = 'Split vertical' }, + { category = 'Vim: Windows', key = 'Ctrl-w c', desc = 'Close window' }, + { category = 'Vim: Windows', key = 'Ctrl-w o', desc = 'Close other windows' }, + { category = 'Vim: Windows', key = 'Ctrl-w =', desc = 'Balance windows' }, + { category = 'Vim: Windows', key = 'Ctrl-h/j/k/l', desc = 'Navigate windows' }, + + { category = 'Vim: Tabs', key = ':tabnew', desc = 'New tab' }, + { category = 'Vim: Tabs', key = ':tabc', desc = 'Close tab' }, + { category = 'Vim: Tabs', key = 'gt/gT', desc = 'Next/previous tab' }, + + { category = 'Vim: Files', key = ':w', desc = 'Save file' }, + { category = 'Vim: Files', key = ':q', desc = 'Quit' }, + { category = 'Vim: Files', key = ':wq or ZZ', desc = 'Save and quit' }, + { category = 'Vim: Files', key = ':q! or ZQ', desc = 'Quit without saving' }, + + -- ============================================================ + -- LEADER KEYMAPS (CORE) + -- ============================================================ + { category = 'Core: Quit', key = 'Q', desc = 'Quit all' }, + { category = 'Core: Quit', key = 'q', desc = 'Quickfix diagnostics' }, + { category = 'Core: Files', key = '\\', desc = 'Toggle Neo-tree' }, + { category = 'Core: Terminal', key = 'Esc Esc', desc = 'Exit terminal mode (in terminal)' }, + + -- ============================================================ + -- BUFFER OPERATIONS + -- ============================================================ + { category = 'Buffer', key = 'bd', desc = 'Delete buffer' }, + { category = 'Buffer', key = 'bD', desc = 'Delete buffer (force)' }, + { category = 'Buffer', key = 'bn', desc = 'Next buffer' }, + { category = 'Buffer', key = 'bp', desc = 'Previous buffer' }, + { category = 'Buffer', key = 'bo', desc = 'Delete other buffers' }, + { category = 'Buffer', key = '', desc = 'Find buffers (Telescope)' }, + + -- ============================================================ + -- WINDOW OPERATIONS + -- ============================================================ + { category = 'Window', key = 'ww', desc = 'Other window' }, + { category = 'Window', key = 'wd', desc = 'Delete window' }, + { category = 'Window', key = 'ws', desc = 'Split below' }, + { category = 'Window', key = 'wv', desc = 'Split right' }, + { category = 'Window', key = 'wm', desc = 'Maximize' }, + { category = 'Window', key = 'w=', desc = 'Balance windows' }, + { category = 'Window', key = 'wh/j/k/l', desc = 'Navigate windows' }, + + -- ============================================================ + -- SEARCH (TELESCOPE) + -- ============================================================ + { category = 'Search', key = 'sh', desc = 'Help' }, + { category = 'Search', key = 'sk', desc = 'Keymaps' }, + { category = 'Search', key = 'sf', desc = 'Files' }, + { category = 'Search', key = 'ss', desc = 'Select Telescope' }, + { category = 'Search', key = 'sw', desc = 'Current word' }, + { category = 'Search', key = 'sg', desc = 'Grep' }, + { category = 'Search', key = 'sd', desc = 'Diagnostics' }, + { category = 'Search', key = 'sr', desc = 'Resume' }, + { category = 'Search', key = 's.', desc = 'Recent files' }, + { category = 'Search', key = 's/', desc = 'In open files' }, + { category = 'Search', key = 'sn', desc = 'Neovim config' }, + { category = 'Search', key = 'sc', desc = 'Cheatsheet (this!)' }, + { category = 'Search', key = 'sK', desc = 'All keymaps (which-key)' }, + { category = 'Search', key = '/', desc = 'Fuzzy find in buffer' }, + + -- ============================================================ + -- SESSION + -- ============================================================ + { category = 'Session', key = 'Ss', desc = 'Save session' }, + { category = 'Session', key = 'Sr', desc = 'Restore session' }, + { category = 'Session', key = 'Sd', desc = 'Delete session' }, + + -- ============================================================ + -- UI OPERATIONS + -- ============================================================ + { category = 'UI', key = 'ul', desc = 'Open Lazy' }, + { category = 'UI', key = 'um', desc = 'Open Mason' }, + { category = 'UI', key = 'ui', desc = 'Inspect position' }, + { category = 'UI', key = 'uI', desc = 'Inspect tree' }, + { category = 'UI', key = 'un', desc = 'Dismiss notifications' }, + + -- ============================================================ + -- TOGGLE + -- ============================================================ + { category = 'Toggle', key = 'th', desc = 'Inlay hints' }, + + -- ============================================================ + -- DIAGNOSTICS + -- ============================================================ + { category = 'Diagnostics', key = 'xx', desc = 'Toggle diagnostics (Trouble)' }, + { category = 'Diagnostics', key = 'xX', desc = 'Buffer diagnostics (Trouble)' }, + { category = 'Diagnostics', key = 'xs', desc = 'Symbols (Trouble)' }, + + -- ============================================================ + -- GIT + -- ============================================================ + { category = 'Git', key = 'hs', desc = 'Stage hunk' }, + { category = 'Git', key = 'hr', desc = 'Reset hunk' }, + { category = 'Git', key = 'hS', desc = 'Stage buffer' }, + { category = 'Git', key = 'hu', desc = 'Undo stage hunk' }, + { category = 'Git', key = 'hR', desc = 'Reset buffer' }, + { category = 'Git', key = 'hp', desc = 'Preview hunk' }, + { category = 'Git', key = 'hb', desc = 'Blame line' }, + { category = 'Git', key = 'hd', desc = 'Diff this' }, + { category = 'Git', key = 'hD', desc = 'Diff this ~' }, + + -- ============================================================ + -- LSP (ALL LANGUAGES) + -- ============================================================ + { category = 'LSP', key = 'K', desc = 'Hover documentation' }, + { category = 'LSP', key = 'grd', desc = 'Go to definition' }, + { category = 'LSP', key = 'grD', desc = 'Go to declaration' }, + { category = 'LSP', key = 'gri', desc = 'Go to implementation' }, + { category = 'LSP', key = 'grr', desc = 'Go to references' }, + { category = 'LSP', key = 'grt', desc = 'Go to type definition' }, + { category = 'LSP', key = 'grn', desc = 'Rename' }, + { category = 'LSP', key = 'gra', desc = 'Code action' }, + { category = 'LSP', key = 'gO', desc = 'Document symbols' }, + { category = 'LSP', key = 'gW', desc = 'Workspace symbols' }, + + -- ============================================================ + -- DEBUG (ALL LANGUAGES) + -- ============================================================ + { category = 'Debug', key = 'F5 or dc', desc = 'Start/Continue' }, + { category = 'Debug', key = 'F10 or dO', desc = 'Step over' }, + { category = 'Debug', key = 'F11 or di', desc = 'Step into' }, + { category = 'Debug', key = 'F12 or do', desc = 'Step out' }, + { category = 'Debug', key = 'db', desc = 'Toggle breakpoint' }, + { category = 'Debug', key = 'dB', desc = 'Conditional breakpoint' }, + { category = 'Debug', key = 'dc or F5', desc = 'Continue' }, + { category = 'Debug', key = 'di or F11', desc = 'Step into' }, + { category = 'Debug', key = 'do or F12', desc = 'Step out' }, + { category = 'Debug', key = 'dO or F10', desc = 'Step over' }, + { category = 'Debug', key = 'dt', desc = 'Terminate' }, + { category = 'Debug', key = 'dr', desc = 'Toggle REPL' }, + { category = 'Debug', key = 'dl', desc = 'Run last' }, + { category = 'Debug', key = 'dC', desc = 'Run to cursor' }, + { category = 'Debug', key = 'du', desc = 'Toggle UI' }, + { category = 'Debug', key = 'de', desc = 'Eval expression' }, + + -- ============================================================ + -- FLUTTER (DART FILES) + -- ============================================================ + { category = 'Flutter', key = 'fr', desc = 'Run app' }, + { category = 'Flutter', key = 'fR', desc = 'Hot restart' }, + { category = 'Flutter', key = 'fh', desc = 'Hot reload' }, + { category = 'Flutter', key = 'fq', desc = 'Quit app' }, + { category = 'Flutter', key = 'fd', desc = 'Select device' }, + { category = 'Flutter', key = 'fe', desc = 'Launch emulator' }, + { category = 'Flutter', key = 'fo', desc = 'Toggle outline' }, + { category = 'Flutter', key = 'ft', desc = 'Start DevTools' }, + { category = 'Flutter', key = 'fa', desc = 'Attach to app' }, + { category = 'Flutter', key = 'fD', desc = 'Detach from app' }, + { category = 'Flutter', key = 'fL', desc = 'Toggle logs' }, + { category = 'Flutter', key = 'fc', desc = 'Copy profiler URL' }, + { category = 'Flutter', key = 'fl', desc = 'Restart LSP' }, + { category = 'Flutter', key = '. or gra', desc = 'Code actions (Cmd+.)' }, + + -- ============================================================ + -- RUST (RUST FILES) + -- ============================================================ + { category = 'Rust', key = 'rh', desc = 'Hover actions' }, + { category = 'Rust', key = 'ra', desc = 'Code actions' }, + { category = 'Rust', key = 're', desc = 'Explain error' }, + { category = 'Rust', key = 'rC', desc = 'Open Cargo.toml' }, + { category = 'Rust', key = 'rp', desc = 'Parent module' }, + { category = 'Rust', key = 'rj', desc = 'Join lines' }, + { category = 'Rust', key = 'rr', desc = 'Runnables' }, + { category = 'Rust', key = 'rd', desc = 'Debuggables' }, + { category = 'Rust', key = 'rm', desc = 'Expand macro' }, + + -- ============================================================ + -- RUST CRATES (CARGO.TOML) + -- ============================================================ + { category = 'Rust: Crates', key = 'rct', desc = 'Toggle' }, + { category = 'Rust: Crates', key = 'rcr', desc = 'Reload' }, + { category = 'Rust: Crates', key = 'rcv', desc = 'Show versions' }, + { category = 'Rust: Crates', key = 'rcf', desc = 'Show features' }, + { category = 'Rust: Crates', key = 'rcd', desc = 'Show dependencies' }, + { category = 'Rust: Crates', key = 'rcu', desc = 'Update crate' }, + { category = 'Rust: Crates', key = 'rca', desc = 'Update all' }, + { category = 'Rust: Crates', key = 'rcU', desc = 'Upgrade crate' }, + { category = 'Rust: Crates', key = 'rcA', desc = 'Upgrade all' }, + + -- ============================================================ + -- PYTHON (PYTHON FILES) + -- ============================================================ + { category = 'Python', key = 'pr', desc = 'Run file' }, + { category = 'Python', key = 'pR', desc = 'Run with args' }, + { category = 'Python', key = 'pe', desc = 'Select venv' }, + { category = 'Python', key = 'pl', desc = 'Restart LSP' }, + { category = 'Python', key = 'pi', desc = 'Organize imports' }, + { category = 'Python', key = 'pf', desc = 'Format code' }, + + -- ============================================================ + -- SVELTE (SVELTE FILES) + -- ============================================================ + { category = 'Svelte', key = 'vf', desc = 'Format with prettier' }, + { category = 'Svelte', key = 'vl', desc = 'Restart Svelte LSP' }, + { category = 'Svelte', key = 'vt', desc = 'Restart TypeScript LSP' }, + { category = 'Svelte', key = 'vo', desc = 'Open component in split' }, + + -- ============================================================ + -- TELESCOPE (INSIDE TELESCOPE) + -- ============================================================ + { category = 'Telescope', key = 'Ctrl-j/k or j/k', desc = 'Next/previous item' }, + { category = 'Telescope', key = 'Ctrl-d/u', desc = 'Scroll preview down/up' }, + { category = 'Telescope', key = 'Enter', desc = 'Open in current window' }, + { category = 'Telescope', key = 'Ctrl-x', desc = 'Open in horizontal split' }, + { category = 'Telescope', key = 'Ctrl-v', desc = 'Open in vertical split' }, + { category = 'Telescope', key = 'Ctrl-t', desc = 'Open in new tab' }, + { category = 'Telescope', key = 'Ctrl-c/Esc/q', desc = 'Close' }, + { category = 'Telescope', key = 'Tab/Shift-Tab', desc = 'Toggle selection' }, + { category = 'Telescope', key = 'Ctrl-q', desc = 'Send all to quickfix' }, + { category = 'Telescope', key = 'Alt-q', desc = 'Send selected to quickfix' }, + { category = 'Telescope', key = '? (normal)', desc = 'Show help' }, + { category = 'Telescope', key = 'gg/G (normal)', desc = 'First/last item' }, + + -- ============================================================ + -- NEO-TREE (INSIDE NEO-TREE) + -- ============================================================ + { category = 'Neo-tree', key = '\\, q, or Esc', desc = 'Close Neo-tree' }, + { category = 'Neo-tree', key = 'Enter, o, or 2-click', desc = 'Open file' }, + { category = 'Neo-tree', key = 'Ctrl-x or S', desc = 'Open in horizontal split' }, + { category = 'Neo-tree', key = 'Ctrl-v or s', desc = 'Open in vertical split' }, + { category = 'Neo-tree', key = 'Ctrl-t or t', desc = 'Open in new tab' }, + { category = 'Neo-tree', key = 'w', desc = 'Open with window picker' }, + { category = 'Neo-tree', key = 'Ctrl-j or >', desc = 'Next source (files/buffers/git)' }, + { category = 'Neo-tree', key = 'Ctrl-k or <', desc = 'Previous source' }, + { category = 'Neo-tree', key = 'P', desc = 'Toggle preview (float)' }, + { category = 'Neo-tree', key = 'l', desc = 'Focus preview' }, + { category = 'Neo-tree', key = 'R', desc = 'Refresh' }, + { category = 'Neo-tree', key = 'H', desc = 'Toggle hidden files' }, + { category = 'Neo-tree', key = '-', desc = 'Navigate up (parent dir)' }, + { category = 'Neo-tree', key = '.', desc = 'Set root (cd into directory)' }, + { category = 'Neo-tree', key = 'C', desc = 'Close node (collapse folder)' }, + { category = 'Neo-tree', key = 'z', desc = 'Close all nodes' }, + { category = 'Neo-tree', key = 'e', desc = 'Toggle auto expand width' }, + { category = 'Neo-tree', key = 'a', desc = 'Add file' }, + { category = 'Neo-tree', key = 'A', desc = 'Add directory' }, + { category = 'Neo-tree', key = 'd', desc = 'Delete' }, + { category = 'Neo-tree', key = 'r', desc = 'Rename' }, + { category = 'Neo-tree', key = 'y', desc = 'Copy to clipboard' }, + { category = 'Neo-tree', key = 'x', desc = 'Cut to clipboard' }, + { category = 'Neo-tree', key = 'p', desc = 'Paste from clipboard' }, + { category = 'Neo-tree', key = 'c', desc = 'Copy (with path input)' }, + { category = 'Neo-tree', key = 'm', desc = 'Move (with path input)' }, + { category = 'Neo-tree', key = '?', desc = 'Show help (in Neo-tree)' }, + { category = 'Neo-tree', key = 'sf', desc = 'Telescope find from this dir' }, + { category = 'Neo-tree', key = 'sg', desc = 'Telescope grep from this dir' }, + + -- ============================================================ + -- MINI.AI (TEXT OBJECTS) + -- ============================================================ + { category = 'Text Objects', key = 'a/i + object', desc = 'Around/inside (w, p, [, {, ", \', `, t)' }, + { category = 'Text Objects', key = 'daw', desc = 'Delete around word' }, + { category = 'Text Objects', key = 'ciw', desc = 'Change inside word' }, + { category = 'Text Objects', key = 'di"', desc = 'Delete inside quotes' }, + { category = 'Text Objects', key = 'da(', desc = 'Delete around parentheses' }, + { category = 'Text Objects', key = 'vit', desc = 'Visual inside tag' }, + + -- ============================================================ + -- MINI.SURROUND + -- ============================================================ + { category = 'Surround', key = 'sa{motion}{char}', desc = 'Add surround' }, + { category = 'Surround', key = 'sd{char}', desc = 'Delete surround' }, + { category = 'Surround', key = 'sr{old}{new}', desc = 'Replace surround' }, + { category = 'Surround', key = 'sf{char}', desc = 'Find right surround' }, + { category = 'Surround', key = 'sF{char}', desc = 'Find left surround' }, + { category = 'Surround', key = 'sh', desc = 'Highlight surround' }, + } + + -- Create picker + pickers + .new({}, { + prompt_title = ' Complete Cheatsheet', + finder = finders.new_table { + results = cheatsheet, + entry_maker = function(entry) + return { + value = entry, + display = string.format('%-20s %-25s %s', entry.category, entry.key, entry.desc), + ordinal = entry.category .. ' ' .. entry.key .. ' ' .. entry.desc, + } + end, + }, + sorter = conf.generic_sorter {}, + attach_mappings = function(prompt_bufnr, map) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + if selection then + vim.notify( + string.format('%s: %s\n%s', selection.value.category, selection.value.key, selection.value.desc), + vim.log.levels.INFO, + { title = 'Keymap' } + ) + end + end) + return true + end, + }) + :find() + end, + desc = 'Cheatsheet (complete reference)', + }, + { + '?', + function() + require('telescope.builtin').keymaps() + end, + desc = 'Search keymaps', + }, + }, + }, + + -- Which-key can also show a searchable list + { + 'folke/which-key.nvim', + keys = { + { + 'sK', + function() + require('which-key').show { global = true } + end, + desc = 'All keymaps (which-key)', + }, + }, + }, +} diff --git a/lua/plugins/core/completion.lua b/lua/plugins/core/completion.lua new file mode 100644 index 00000000000..6d07082d43a --- /dev/null +++ b/lua/plugins/core/completion.lua @@ -0,0 +1,64 @@ +-- ======================================================================== +-- COMPLETION PLUGIN +-- ======================================================================== +-- Autocompletion engine with LSP integration +-- - Blink.cmp: Fast completion engine +-- - LuaSnip: Snippet engine +-- - Lazydev: Lua LSP for Neovim config +-- ======================================================================== + +return { + -- Autocompletion + { + 'saghen/blink.cmp', + event = 'VimEnter', + version = '1.*', + dependencies = { + { + 'L3MON4D3/LuaSnip', + version = '2.*', + build = (function() + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + opts = {}, + }, + 'folke/lazydev.nvim', + }, + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + keymap = { + preset = 'enter', + }, + appearance = { + nerd_font_variant = 'mono', + }, + completion = { + documentation = { auto_show = false, auto_show_delay_ms = 500 }, + }, + sources = { + default = { 'lsp', 'path', 'snippets', 'lazydev' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + }, + }, + snippets = { preset = 'luasnip' }, + fuzzy = { implementation = 'lua' }, + signature = { enabled = true }, + }, + }, + + -- Lazydev: Lua LSP for Neovim config + { + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + }, + }, + }, +} diff --git a/lua/plugins/core/debug.lua b/lua/plugins/core/debug.lua new file mode 100644 index 00000000000..e84693aedfb --- /dev/null +++ b/lua/plugins/core/debug.lua @@ -0,0 +1,49 @@ +-- ======================================================================== +-- DEBUG CONFIGURATION - Global DAP keymaps +-- ======================================================================== +-- These keymaps are available whenever nvim-dap is loaded +-- Works for all languages: Flutter, Rust, Python, etc. +-- ======================================================================== + +return { + -- nvim-dap: Debug Adapter Protocol client + { + 'mfussenegger/nvim-dap', + optional = true, + keys = { + -- Function key shortcuts (standard debugging across all editors) + { '', function() require('dap').continue() end, desc = 'Debug: Start/Continue' }, + { '', function() require('dap').step_over() end, desc = 'Debug: Step over' }, + { '', function() require('dap').step_into() end, desc = 'Debug: Step into' }, + { '', function() require('dap').step_out() end, desc = 'Debug: Step out' }, + + -- Leader-based debug commands (more discoverable) + { 'db', function() require('dap').toggle_breakpoint() end, desc = 'Toggle breakpoint' }, + { 'dB', function() require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = 'Conditional breakpoint' }, + { 'dc', function() require('dap').continue() end, desc = 'Continue' }, + { 'di', function() require('dap').step_into() end, desc = 'Step into' }, + { 'do', function() require('dap').step_out() end, desc = 'Step out' }, + { 'dO', function() require('dap').step_over() end, desc = 'Step over' }, + { 'dt', function() require('dap').terminate() end, desc = 'Terminate' }, + { 'dr', function() require('dap').repl.toggle() end, desc = 'Toggle REPL' }, + { 'dl', function() require('dap').run_last() end, desc = 'Run last' }, + { 'dC', function() require('dap').run_to_cursor() end, desc = 'Run to cursor' }, + }, + config = function() + -- Register which-key group + require('which-key').add { + { 'd', group = ' debug' }, + } + end, + }, + + -- nvim-dap-ui: UI for nvim-dap + { + 'rcarriga/nvim-dap-ui', + optional = true, + keys = { + { 'du', function() require('dapui').toggle() end, desc = 'Toggle UI' }, + { 'de', function() require('dapui').eval() end, desc = 'Eval', mode = { 'n', 'v' } }, + }, + }, +} diff --git a/lua/plugins/core/editor.lua b/lua/plugins/core/editor.lua new file mode 100644 index 00000000000..572e44a5743 --- /dev/null +++ b/lua/plugins/core/editor.lua @@ -0,0 +1,225 @@ +-- ======================================================================== +-- CORE EDITOR PLUGINS +-- ======================================================================== +-- Essential editing tools that are always loaded +-- - Telescope: Fuzzy finder +-- - Which-key: Keybinding helper +-- - Neo-tree: File explorer +-- - guess-indent: Auto-detect indentation +-- ======================================================================== + +return { + -- Detect tabstop and shiftwidth automatically + 'NMAC427/guess-indent.nvim', + + -- Telescope: Fuzzy finder (files, LSP, etc) + { + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + require('telescope').setup { + defaults = { + mappings = { + i = { + -- Navigation (consistent with Neo-tree) + [''] = require('telescope.actions').move_selection_next, + [''] = require('telescope.actions').move_selection_previous, + + -- Preview scrolling + [''] = require('telescope.actions').preview_scrolling_down, + [''] = require('telescope.actions').preview_scrolling_up, + + -- Open actions (consistent with Neo-tree) + [''] = require('telescope.actions').select_default, -- Open in current window + [''] = require('telescope.actions').select_horizontal, -- Open in horizontal split + [''] = require('telescope.actions').select_vertical, -- Open in vertical split + [''] = require('telescope.actions').select_tab, -- Open in new tab + + -- Close + [''] = require('telescope.actions').close, + [''] = require('telescope.actions').close, + + -- Cycle history + [''] = require('telescope.actions').cycle_history_next, + [''] = require('telescope.actions').cycle_history_prev, + + -- Selection + [''] = require('telescope.actions').toggle_selection + require('telescope.actions').move_selection_worse, + [''] = require('telescope.actions').toggle_selection + require('telescope.actions').move_selection_better, + + -- Send to quickfix + [''] = require('telescope.actions').send_to_qflist + require('telescope.actions').open_qflist, + [''] = require('telescope.actions').send_selected_to_qflist + require('telescope.actions').open_qflist, + }, + n = { + -- Same mappings in normal mode + [''] = require('telescope.actions').move_selection_next, + [''] = require('telescope.actions').move_selection_previous, + [''] = require('telescope.actions').preview_scrolling_down, + [''] = require('telescope.actions').preview_scrolling_up, + + [''] = require('telescope.actions').select_default, + [''] = require('telescope.actions').select_horizontal, + [''] = require('telescope.actions').select_vertical, + [''] = require('telescope.actions').select_tab, + + ['q'] = require('telescope.actions').close, + [''] = require('telescope.actions').close, + + [''] = require('telescope.actions').toggle_selection + require('telescope.actions').move_selection_worse, + [''] = require('telescope.actions').toggle_selection + require('telescope.actions').move_selection_better, + + [''] = require('telescope.actions').send_to_qflist + require('telescope.actions').open_qflist, + [''] = require('telescope.actions').send_selected_to_qflist + require('telescope.actions').open_qflist, + + -- Vim-like navigation + ['j'] = require('telescope.actions').move_selection_next, + ['k'] = require('telescope.actions').move_selection_previous, + ['gg'] = require('telescope.actions').move_to_top, + ['G'] = require('telescope.actions').move_to_bottom, + + ['?'] = require('telescope.actions').which_key, -- Show help + }, + }, + }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + vim.keymap.set('n', '/', function() + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + vim.keymap.set('n', 's/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + + vim.keymap.set('n', 'sn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, + }, + + -- Which-key: Shows pending keybinds + { + 'folke/which-key.nvim', + event = 'VimEnter', + opts = { + delay = 0, + -- Floating window configuration (bottom right) + win = { + width = { min = 30, max = 60 }, -- Width range for the popup + height = { min = 4, max = 0.9 }, -- Max 90% of screen height - fits all items + col = 0.99, -- Position close to right edge + row = 0.95, -- Position close to bottom + border = 'rounded', -- Border style + padding = { 1, 2 }, -- Padding inside window + title = true, -- Show title + title_pos = 'center', -- Center the title + wo = { + winblend = 0, -- No transparency (0-100) + }, + }, + layout = { + width = { min = 30 }, -- Minimum column width + spacing = 3, -- Spacing between columns + }, + icons = { + mappings = vim.g.have_nerd_font, + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, + spec = { + -- Core groups with icons + { 'b', group = '๓ฐŠ„ buffer', icon = '๓ฐŠ„' }, + { 'c', group = ' code', icon = '' }, + { 'd', group = ' debug', icon = '' }, + { 'f', group = ' flutter', icon = '' }, -- Only visible in Dart files + { 'g', group = ' git', icon = '' }, + { 'p', group = ' python', icon = '' }, -- Only visible in Python files + { 'r', group = '๓ฑ˜— rust', icon = '๓ฑ˜—' }, -- Only visible in Rust files + { 's', group = ' search', icon = '' }, + { 'S', group = '๓ฑ‚ฌ session', icon = '๓ฑ‚ฌ' }, + { 't', group = '๓ฐ”ก toggle', icon = '๓ฐ”ก' }, + { 'u', group = ' ui', icon = '' }, + { 'v', group = ' svelte', icon = '' }, -- Only visible in Svelte files + { 'w', group = ' window', icon = '' }, + { 'x', group = '๓ฑ–ซ diagnostics', icon = '๓ฑ–ซ' }, + + -- Special groups + { 'q', desc = '๓ฐจ Quickfix diagnostics' }, + { 'Q', desc = '๓ฐ—ผ Quit all' }, + + -- Git hunks (normal and visual mode) + { 'h', group = ' git hunk', mode = { 'n', 'v' }, icon = '' }, + }, + }, + }, + + -- Neo-tree: File explorer + -- Imported from kickstart/plugins/neo-tree.lua +} diff --git a/lua/plugins/core/extras.lua b/lua/plugins/core/extras.lua new file mode 100644 index 00000000000..67e48b139c6 --- /dev/null +++ b/lua/plugins/core/extras.lua @@ -0,0 +1,406 @@ +-- ======================================================================== +-- COMMON PLUGINS - Loaded for all filetypes/profiles +-- ======================================================================== +-- +-- This file contains plugins that are always loaded regardless of what +-- file type you're working with. These are your "core" plugins that +-- provide functionality across all your language profiles. +-- +-- Examples: file explorers, git tools, common UI elements, copilot, etc. +-- +-- See the kickstart.nvim README for more information +-- ======================================================================== + +return { + -- ======================================================================== + -- FILE EXPLORER - Neo-tree + -- ======================================================================== + -- Neo-tree provides a modern file explorer sidebar similar to VS Code. + -- It's loaded for all profiles so you can browse files regardless of + -- what language you're working with. + -- + -- Keybindings: + -- \ (backslash) - Toggle Neo-tree file explorer + -- Within Neo-tree: + -- a - Add file/folder + -- d - Delete + -- r - Rename + -- x - Cut + -- c - Copy + -- p - Paste + -- ? - Show help (see all keybindings) + -- + -- Note: This references the existing neo-tree configuration from + -- kickstart/plugins/neo-tree.lua. We're just ensuring it's loaded. + -- ======================================================================== +-- { +-- 'nvim-neo-tree/neo-tree.nvim', +-- version = '*', +-- dependencies = { +-- 'nvim-lua/plenary.nvim', +-- 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended +-- 'MunifTanjim/nui.nvim', +-- }, +-- cmd = 'Neotree', -- Lazy load on command +-- keys = { +-- { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, +-- }, +-- opts = { +-- filesystem = { +-- window = { +-- mappings = { +-- ['\\'] = 'close_window', +-- }, +-- }, +-- follow_current_file = { +-- enabled = true, -- Focus on the current file when opening +-- }, +-- hijack_netrw_behavior = 'open_current', -- Use neo-tree instead of netrw +-- }, +-- }, +-- }, + + -- ======================================================================== + -- GITHUB COPILOT - AI pair programming assistant + -- ======================================================================== + -- GitHub Copilot provides AI-powered code completions and suggestions. + -- Works across all file types and integrates with your completion engine. + -- + -- Setup: + -- 1. After installing, run :Copilot setup + -- 2. Follow the authentication flow + -- 3. You'll need an active GitHub Copilot subscription + -- + -- Usage: + -- - Copilot suggestions appear automatically as you type + -- - Press Tab to accept a suggestion + -- - Press Ctrl+] to see next suggestion + -- - Press Ctrl+[ to see previous suggestion + -- - :Copilot panel - Open completion panel with multiple suggestions + -- + -- Commands: + -- :Copilot setup - Authenticate with GitHub + -- :Copilot status - Check authentication status + -- :Copilot enable - Enable Copilot + -- :Copilot disable - Disable Copilot + -- ======================================================================== + { + 'github/copilot.vim', + lazy = false, -- Load immediately on startup (not lazy-loaded) + config = function() + -- Copilot keybindings (optional customization) + -- By default, Tab accepts suggestions, but this might conflict with completion + -- Uncomment below to use Ctrl+J to accept instead: + -- vim.keymap.set('i', '', 'copilot#Accept("\\")', { + -- expr = true, + -- replace_keycodes = false, + -- }) + -- vim.g.copilot_no_tab_map = true + + -- Optional: Disable Copilot for certain filetypes + -- vim.g.copilot_filetypes = { + -- ['*'] = true, + -- ['markdown'] = false, + -- ['text'] = false, + -- } + end, + }, + + -- ======================================================================== + -- SMOOTH SCROLLING & ANIMATIONS - mini.animate + -- ======================================================================== + -- Provides smooth scrolling and cursor animations for a better visual experience. + -- + -- Features: + -- - Smooth scrolling (when using Ctrl+D, Ctrl+U, etc.) + -- - Cursor path animation when jumping + -- - Window resize animations + -- - Window open/close animations + -- + -- All animations are non-blocking and can be customized or disabled independently. + -- ======================================================================== + { + 'echasnovski/mini.animate', + event = 'VeryLazy', -- Load after UI is ready + opts = function() + -- Don't use animate when scrolling with the mouse + local mouse_scrolled = false + for _, scroll in ipairs({ 'Up', 'Down' }) do + local key = '' + vim.keymap.set({ '', 'i' }, key, function() + mouse_scrolled = true + return key + end, { expr = true }) + end + + local animate = require('mini.animate') + return { + -- Cursor path animation - shows path when cursor jumps + cursor = { + enable = true, + timing = animate.gen_timing.linear({ duration = 100, unit = 'total' }), + }, + + -- Smooth scrolling + scroll = { + enable = true, + timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }), + subscroll = animate.gen_subscroll.equal({ + predicate = function(total_scroll) + if mouse_scrolled then + mouse_scrolled = false + return false + end + return total_scroll > 1 + end, + }), + }, + + -- Window resize animation + resize = { + enable = true, + timing = animate.gen_timing.linear({ duration = 50, unit = 'total' }), + }, + + -- Window open/close animation + open = { + enable = false, -- Disabled by default as it can be distracting + timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }), + }, + + close = { + enable = false, -- Disabled by default + timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }), + }, + } + end, + }, + + -- ======================================================================== + -- TROUBLE.NVIM - Beautiful diagnostics list (LazyVim-style) + -- ======================================================================== + -- Provides a nice list view of diagnostics, quickfix, LSP references, etc. + -- Shows errors inline in a dedicated panel like LazyVim/VS Code. + -- Auto-opens when diagnostics are present to show errors in editor area. + -- + -- Keymaps: + -- xx - Toggle diagnostics list + -- xX - Buffer diagnostics + -- cs - Symbols list + -- cl - LSP references + -- xL - Location list + -- xQ - Quickfix list + -- [q / ]q - Previous/next item in trouble list + -- ======================================================================== + { + 'folke/trouble.nvim', + cmd = 'Trouble', -- Lazy load on command + opts = { + focus = false, -- Don't focus the window when opened (LazyVim behavior) + auto_close = true, -- Auto close when no items + auto_open = false, -- Don't auto open (we'll handle this with autocmd) + warn_no_results = false, + open_no_results = false, + modes = { + -- Configure the diagnostics mode to show in editor area + diagnostics = { + mode = 'diagnostics', + preview = { + type = 'split', + relative = 'win', + position = 'right', + size = 0.3, + }, + }, + }, + }, + keys = { + { + 'xx', + 'Trouble diagnostics toggle', + desc = 'Diagnostics (Trouble)', + }, + { + 'xX', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Buffer Diagnostics (Trouble)', + }, + { + 'cs', + 'Trouble symbols toggle focus=false', + desc = 'Symbols (Trouble)', + }, + { + 'cl', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'LSP Definitions / references / ... (Trouble)', + }, + { + 'xL', + 'Trouble loclist toggle', + desc = 'Location List (Trouble)', + }, + { + 'xQ', + 'Trouble qflist toggle', + desc = 'Quickfix List (Trouble)', + }, + { + '[q', + function() + if require('trouble').is_open() then + require('trouble').prev({ skip_groups = true, jump = true }) + else + local ok, err = pcall(vim.cmd.cprev) + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + desc = 'Previous Trouble/Quickfix Item', + }, + { + ']q', + function() + if require('trouble').is_open() then + require('trouble').next({ skip_groups = true, jump = true }) + else + local ok, err = pcall(vim.cmd.cnext) + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + desc = 'Next Trouble/Quickfix Item', + }, + }, + }, + + -- ======================================================================== + -- NOICE.NVIM - Better UI for messages, cmdline, and notifications + -- ======================================================================== + -- Provides a modern UI for command line, messages, and notifications (LazyVim-style). + -- Makes the editor feel more polished with popup notifications and floating cmdline. + -- + -- Features: + -- - Floating command line + -- - Modern notification system + -- - Better message display + -- - Signature help while typing + -- + -- Note: This can be disabled if you prefer the classic Vim UI + -- ======================================================================== + { + 'folke/noice.nvim', + event = 'VeryLazy', + dependencies = { + 'MunifTanjim/nui.nvim', + -- Optional: If you want to use `nvim-notify` for notifications + -- 'rcarriga/nvim-notify', + }, + opts = { + lsp = { + -- Override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, + }, + }, + -- Presets for easier configuration + presets = { + bottom_search = true, -- Use a classic bottom cmdline for search + command_palette = true, -- Position the cmdline and popupmenu together + long_message_to_split = true, -- Long messages will be sent to a split + inc_rename = false, -- Enables an input dialog for inc-rename.nvim + lsp_doc_border = true, -- Add a border to hover docs and signature help + }, + -- Routes configuration (optional customization) + routes = { + { + filter = { + event = 'msg_show', + kind = '', + find = 'written', + }, + opts = { skip = true }, + }, + }, + }, + keys = { + { + 'sn', + '', + desc = '+noice', + }, + { + 'snl', + function() + require('noice').cmd('last') + end, + desc = 'Noice Last Message', + }, + { + 'snh', + function() + require('noice').cmd('history') + end, + desc = 'Noice History', + }, + { + 'sna', + function() + require('noice').cmd('all') + end, + desc = 'Noice All', + }, + { + 'snd', + function() + require('noice').cmd('dismiss') + end, + desc = 'Dismiss All', + }, + { + '', + function() + if not require('noice.lsp').scroll(4) then + return '' + end + end, + silent = true, + expr = true, + desc = 'Scroll Forward', + mode = { 'i', 'n', 's' }, + }, + { + '', + function() + if not require('noice.lsp').scroll(-4) then + return '' + end + end, + silent = true, + expr = true, + desc = 'Scroll Backward', + mode = { 'i', 'n', 's' }, + }, + }, + }, + + -- ======================================================================== + -- ADDITIONAL COMMON PLUGINS + -- ======================================================================== + -- You can add more common plugins here that should be available across + -- all language profiles. Examples: + -- + -- - Better terminal integration + -- - Git integration enhancements (beyond gitsigns in init.lua) + -- - Session management + -- - Project management + -- - Alternative completion sources + -- - UI enhancements + -- + -- Just add them to this return table following the same pattern as above. + -- ======================================================================== +} diff --git a/lua/plugins/core/git.lua b/lua/plugins/core/git.lua new file mode 100644 index 00000000000..b931efdb5a5 --- /dev/null +++ b/lua/plugins/core/git.lua @@ -0,0 +1,22 @@ +-- ======================================================================== +-- GIT INTEGRATION PLUGINS +-- ======================================================================== +-- Git tools for version control +-- - Gitsigns: Git decorations and utilities +-- ======================================================================== + +return { + -- Git signs in gutter and utilities for managing changes + { + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = 'โ€พ' }, + changedelete = { text = '~' }, + }, + }, + }, +} diff --git a/lua/plugins/core/neo-tree.lua b/lua/plugins/core/neo-tree.lua new file mode 100644 index 00000000000..1f9d0e67e85 --- /dev/null +++ b/lua/plugins/core/neo-tree.lua @@ -0,0 +1,122 @@ +-- Neo-tree is a Neovim plugin to browse the file system +-- https://github.com/nvim-neo-tree/neo-tree.nvim + +return { + 'nvim-neo-tree/neo-tree.nvim', + version = '*', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'MunifTanjim/nui.nvim', + }, + lazy = false, + keys = { + { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + }, + opts = { + -- Don't open Neo-tree on startup, only when toggled + close_if_last_window = true, -- Close Neo-tree if it's the last window + popup_border_style = 'rounded', + enable_git_status = true, + enable_diagnostics = true, + + -- Default to filesystem view + default_component_configs = { + indent = { + padding = 0, + }, + }, + + -- Global window mappings (apply to all Neo-tree windows) + window = { + mappings = { + -- Disable for toggle_node to allow (Space) to work + [''] = 'none', + -- Use (Enter) to toggle nodes instead (already default, but making it explicit) + [''] = 'toggle_node', + -- Use 'za' (vim fold toggle) as alternative for toggle node + ['za'] = 'toggle_node', + }, + }, + + filesystem = { + -- Follow the current file in the tree + follow_current_file = { + enabled = true, + leave_dirs_open = false, + }, + -- Use system commands for file operations + use_libuv_file_watcher = true, + + window = { + position = 'left', + width = 30, + mappings = { + ['\\'] = 'close_window', + + -- Consistent with Telescope: = split, = vsplit, = tabnew + [''] = 'split_with_window_picker', + [''] = 'vsplit_with_window_picker', + [''] = 'open_tabnew', + + -- Open file (consistent with Telescope ) + [''] = 'open', + ['o'] = 'open', + + -- Navigation + [''] = 'next_source', -- Match Telescope down navigation + [''] = 'prev_source', -- Match Telescope up navigation + + -- Preview (like Telescope) + ['P'] = { 'toggle_preview', config = { use_float = true } }, + + -- Telescope integration from Neo-tree + ['sf'] = 'telescope_find', + ['sg'] = 'telescope_grep', + + -- Refresh + ['R'] = 'refresh', + + -- Toggle hidden files + ['H'] = 'toggle_hidden', + + -- Navigation + ['-'] = 'navigate_up', + ['.'] = 'set_root', + + -- File operations + ['a'] = 'add', + ['A'] = 'add_directory', + ['d'] = 'delete', + ['r'] = 'rename', + ['y'] = 'copy_to_clipboard', + ['x'] = 'cut_to_clipboard', + ['p'] = 'paste_from_clipboard', + ['c'] = 'copy', -- Copy (takes a path as input) + ['m'] = 'move', -- Move (takes a path as input) + + -- Help + ['?'] = 'show_help', + }, + }, + }, + + -- Add custom commands for Telescope integration + commands = { + telescope_find = function(state) + local node = state.tree:get_node() + local path = node:get_id() + require('telescope.builtin').find_files { + cwd = vim.fn.isdirectory(path) == 1 and path or vim.fn.fnamemodify(path, ':h'), + } + end, + telescope_grep = function(state) + local node = state.tree:get_node() + local path = node:get_id() + require('telescope.builtin').live_grep { + cwd = vim.fn.isdirectory(path) == 1 and path or vim.fn.fnamemodify(path, ':h'), + } + end, + }, + }, +} diff --git a/lua/plugins/core/session.lua b/lua/plugins/core/session.lua new file mode 100644 index 00000000000..4c6e337a908 --- /dev/null +++ b/lua/plugins/core/session.lua @@ -0,0 +1,105 @@ +-- ======================================================================== +-- SESSION MANAGEMENT - Auto-save and restore your workspace +-- ======================================================================== +-- +-- This plugin automatically saves your session (open files, window layout, +-- buffers, etc.) when you quit Neovim and restores it when you reopen +-- the same directory. +-- +-- Features: +-- - โœ… Auto-saves session on exit (automatically!) +-- - โœ… Auto-restores session when you `cd` into a directory and run `nvim` +-- - Saves per-directory (each project has its own session) +-- - Saves open buffers, window splits, cursor positions, and more +-- +-- IMPORTANT: Auto-restore works when you: +-- 1. cd /path/to/your/project +-- 2. nvim (without specifying files) +-- +-- If you open a specific file (e.g., `nvim main.dart`), auto-restore is skipped. +-- Use manual restore (Sr) if needed. +-- +-- Keymaps: +-- Ss - Save session manually +-- Sr - Restore session manually (if auto-restore didn't trigger) +-- Sd - Delete session for current directory +-- Sf - Find/search all sessions (Telescope) +-- +-- Quit keymaps (in init.lua, integrated with auto-session): +-- Qa - Quit all and save session (most common) +-- Qq - Force quit all without saving (no session save) +-- Qw - Save all files, save session, then quit +-- +-- WORKFLOW: +-- 1. cd into your project directory +-- 2. nvim (session auto-restores if it exists!) +-- 3. Work on your project +-- 4. Quit with Qa or just :qa (auto-saves!) +-- 5. Next time: repeat from step 1 - your workspace is restored! +-- +-- Sessions are saved in: ~/.local/share/nvim/sessions/ +-- ======================================================================== + +return { + 'rmagatti/auto-session', + lazy = false, -- Load on startup to restore session + opts = { + -- Session save/restore options + auto_session_enabled = true, -- Automatically save sessions on exit + auto_restore_enabled = true, -- Automatically restore sessions on startup + auto_save_enabled = true, -- Auto-save session on exit + auto_session_suppress_dirs = { '~/', '~/Downloads', '/' }, -- Don't save sessions in these dirs + auto_session_use_git_branch = false, -- One session per directory (not per git branch) + + -- What to save in the session + auto_session_enable_last_session = false, -- Don't restore last session if not in a project + auto_session_create_enabled = true, -- Auto-create session on first save + + -- Hooks to run before/after session save/restore + pre_save_cmds = { + 'Neotree close', -- Close Neo-tree before saving session + }, + post_restore_cmds = { + -- You can add commands to run after restore here + }, + + -- Session lens (Telescope integration for browsing sessions) + session_lens = { + load_on_setup = true, + theme_conf = { border = true }, + previewer = false, + }, + }, + keys = { + -- Manual session control (Capital S to avoid conflict with search) + { + 'Ss', + 'AutoSession save', + desc = '[S]ession: [S]ave', + }, + { + 'Sr', + 'AutoSession restore', + desc = '[S]ession: [R]estore', + }, + { + 'Sd', + 'AutoSession delete', + desc = '[S]ession: [D]elete', + }, + { + 'Sf', + 'AutoSession search', + desc = '[S]ession: [F]ind/search', + }, + }, + config = function(_, opts) + require('auto-session').setup(opts) + + -- Register with which-key + require('which-key').add { + { 's', group = '[S]ession' }, + { 'Q', group = '[Q]uit' }, + } + end, +} diff --git a/lua/plugins/core/ui.lua b/lua/plugins/core/ui.lua new file mode 100644 index 00000000000..106626255c9 --- /dev/null +++ b/lua/plugins/core/ui.lua @@ -0,0 +1,93 @@ +-- ======================================================================== +-- UI PLUGINS +-- ======================================================================== +-- Visual enhancements and UI components +-- - Colorscheme: tokyonight +-- - Statusline: mini.statusline +-- - Treesitter: Syntax highlighting +-- - Mini modules: Textobjects, surround, pairs +-- - Todo comments: Highlight TODOs/FIXMEs +-- ======================================================================== + +return { + -- Colorscheme + { + 'folke/tokyonight.nvim', + priority = 1000, + config = function() + require('tokyonight').setup { + styles = { + comments = { italic = false }, + }, + } + vim.cmd.colorscheme 'tokyonight-night' + end, + }, + + -- Highlight todo, notes, etc in comments + { + 'folke/todo-comments.nvim', + event = 'VimEnter', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { signs = false }, + }, + + -- Mini.nvim collection + { + 'echasnovski/mini.nvim', + config = function() + -- Better Around/Inside textobjects + require('mini.ai').setup { n_lines = 500 } + + -- Add/delete/replace surroundings (brackets, quotes, etc.) + require('mini.surround').setup() + + -- Autopairs - automatically close brackets, quotes, etc. + require('mini.pairs').setup() + + -- Simple and easy statusline + local statusline = require 'mini.statusline' + statusline.setup { use_icons = vim.g.have_nerd_font } + + ---@diagnostic disable-next-line: duplicate-set-field + statusline.section_location = function() + return '%2l:%-2v' + end + end, + }, + + -- Treesitter: Syntax highlighting and code understanding + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + main = 'nvim-treesitter.configs', + opts = { + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'javascript', + 'typescript', + 'css', + 'json', + }, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = { 'ruby' }, + }, + indent = { enable = true, disable = { 'ruby' } }, + fold = { + enable = true, + }, + }, + }, +} diff --git a/lua/plugins/lang/flutter.lua b/lua/plugins/lang/flutter.lua new file mode 100644 index 00000000000..4c72f9105fc --- /dev/null +++ b/lua/plugins/lang/flutter.lua @@ -0,0 +1,427 @@ +-- ======================================================================== +-- FLUTTER/DART PROFILE - Language-specific plugins and LSP configuration +-- ======================================================================== +-- +-- This file contains all Flutter and Dart-specific plugins and configurations. +-- These plugins will ONLY load when you open a .dart file, keeping your +-- startup time fast and avoiding conflicts with other languages. +-- +-- Key features to configure here: +-- - Flutter tools (hot reload, device management, widget inspector) +-- - Dart LSP (dartls via flutter-tools) +-- - Dart-specific formatters and linters +-- - Flutter-specific keymaps (e.g., fr for Flutter Run) +-- +-- Usage: Just open a .dart file and these plugins will automatically load! +-- ======================================================================== + +return { + -- ======================================================================== + -- NVIM-DAP - Debug Adapter Protocol for Flutter debugging + -- ======================================================================== + -- Load DAP when opening Dart files to enable breakpoint debugging + { + 'mfussenegger/nvim-dap', + ft = 'dart', + dependencies = { + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', + }, + }, + + -- ======================================================================== + -- FLUTTER TOOLS - Complete Flutter development environment + -- ======================================================================== + -- Provides Flutter-specific features like hot reload, device management, + -- widget inspector, and integrates the Dart LSP server. + -- + -- Flutter-specific keymaps (available in .dart files): + -- fr - Flutter Run (start app) + -- fq - Flutter Quit (stop app) + -- fR - Flutter Hot Restart + -- fd - Flutter Devices (show connected devices) + -- fe - Flutter Emulators (launch emulator) + -- fo - Flutter Outline (toggle outline/widget tree) + -- fc - Flutter Copy Profile URL (for DevTools) + -- + -- Debug keymaps: + -- - Start/Continue debugging + -- - Step over + -- - Step into + -- - Step out + -- db - Toggle breakpoint + -- dB - Set conditional breakpoint + -- dc - Continue + -- dt - Terminate debugging + -- ======================================================================== + { + 'nvim-flutter/flutter-tools.nvim', + ft = 'dart', -- Only load when opening Dart files + dependencies = { + 'nvim-lua/plenary.nvim', + 'stevearc/dressing.nvim', -- Optional: better UI for Flutter commands + 'mfussenegger/nvim-dap', + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', + }, + config = function() + -- Get shared LSP capabilities from blink.cmp + local capabilities = require('blink.cmp').get_lsp_capabilities() + + require('flutter-tools').setup { + -- UI configuration + ui = { + border = 'rounded', -- border type for floating windows + notification_style = 'native', -- 'native' or 'plugin' (native uses vim.notify) + }, + + -- Flutter SDK path (usually auto-detected, but you can specify if needed) + -- flutter_path = '/path/to/flutter/bin/flutter', + -- flutter_lookup_cmd = nil, -- example: "dirname $(which flutter)" or "asdf where flutter" + + -- FVM support - takes priority over path, uses /.fvm/flutter_sdk if enabled + fvm = false, + + -- Root patterns to find the root of your flutter project + root_patterns = { '.git', 'pubspec.yaml' }, + + -- Uncomment to set a default device (get ID from `flutter devices`) + -- device = { + -- id = 'chrome', -- or 'macos', 'emulator-5554', etc. + -- }, + + lsp = { + capabilities = capabilities, + + -- Suppress didChange errors during snippet expansion + on_attach = function(client, bufnr) + -- Reduce didChange notification frequency to prevent errors with snippets + client.server_capabilities.textDocumentSync = vim.tbl_deep_extend('force', client.server_capabilities.textDocumentSync or {}, { + change = 2, -- 2 = Incremental (less prone to errors than full sync) + }) + + -- Filter out didChange error notifications (they're harmless during snippet expansion) + -- We'll use an autocmd to do this after noice.nvim is loaded + vim.api.nvim_create_autocmd('User', { + pattern = 'VeryLazy', + once = true, + callback = function() + local notify = vim.notify + vim.notify = function(msg, level, opts) + if type(msg) == 'string' and msg:match('textDocument/didChange') then + return -- Suppress this specific error + end + notify(msg, level, opts) + end + end, + }) + end, + + -- Color preview for dart variables (Colors.red, Color(0xFF...), etc.) + -- This shows the actual Material Design colors inline! + color = { + enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 + background = true, -- highlight the background + background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},) + foreground = false, -- highlight the foreground + virtual_text = true, -- show the highlight using virtual text + virtual_text_str = 'โ– ', -- the virtual text character to highlight + }, + -- Settings passed to the Dart LSP + settings = { + -- Show TODOs in the problems pane + showTodos = true, + -- Completion settings + completeFunctionCalls = true, + -- Enable/disable specific lints + -- analysisExcludedFolders = {}, + renameFilesWithClasses = 'prompt', -- "always" or "prompt" + enableSnippets = true, + updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed + }, + }, + + -- Flutter-specific settings + decorations = { + statusline = { + -- Set to true to show Flutter app info in statusline + app_version = false, + device = true, -- Show device name + }, + }, + + widget_guides = { + enabled = true, -- Show visual guides for widget nesting + }, + + closing_tags = { + highlight = 'Comment', -- Highlight color for closing tags + prefix = '// ', -- Text to show before closing tag + enabled = true, -- Show closing tags for widgets + }, + + dev_log = { + enabled = true, + notify_errors = false, -- Don't show error notifications for log buffer issues + open_cmd = 'tabedit', -- Open logs in a new tab + focus_on_open = false, -- Don't auto-focus the log window + }, + + dev_tools = { + autostart = false, -- autostart devtools server if not detected + auto_open_browser = false, -- Automatically opens devtools in the browser + }, + + outline = { + open_cmd = '30vnew', -- command to use to open the outline buffer + auto_open = false, -- if true this will open the outline automatically when it is first populated + }, + + debugger = { + enabled = true, -- Enable Flutter debugger integration + run_via_dap = true, -- Use DAP for debugging + -- if empty dap will not stop on any exceptions, otherwise it will stop on those specified + -- see |:help dap.set_exception_breakpoints()| for more info + exception_breakpoints = {}, + -- Whether to call toString() on objects in debug views like hovers and the variables list. + -- Invoking toString() has a performance cost and may introduce side-effects, + -- although users may expected this functionality. null is treated like false. + evaluate_to_string_in_debug_views = true, + -- Flutter tools will automatically register DAP configurations + -- No need to manually configure launch.json + }, + } + + -- ======================================================================== + -- DAP UI SETUP - Beautiful debugging interface + -- ======================================================================== + local dap, dapui = require 'dap', require 'dapui' + + -- Configure DAP UI to open in tabs for better half-width screen support + dapui.setup { + icons = { expanded = 'โ–พ', collapsed = 'โ–ธ', current_frame = '*' }, + controls = { + icons = { + pause = 'โธ', + play = 'โ–ถ', + step_into = 'โŽ', + step_over = 'โญ', + step_out = 'โฎ', + step_back = 'b', + run_last = 'โ–ถโ–ถ', + terminate = 'โน', + disconnect = 'โ', + }, + }, + -- Open each element in a new tab instead of side panels + -- This prevents layout issues on small/half-width screens + layouts = { + { + elements = { + { id = 'scopes', size = 0.25 }, + { id = 'breakpoints', size = 0.25 }, + { id = 'stacks', size = 0.25 }, + { id = 'watches', size = 0.25 }, + }, + size = 40, + position = 'right', + }, + { + elements = { + { id = 'repl', size = 0.5 }, + { id = 'console', size = 0.5 }, + }, + size = 10, + position = 'bottom', + }, + }, + -- Override element window commands to open in tabs + element_mappings = {}, + windows = { indent = 1 }, + } + + -- Custom function to open DAP UI elements in tabs + local function open_dapui_in_tabs() + -- Save current tab to return to it + local current_tab = vim.fn.tabpagenr() + + -- Create new tab with a named buffer for debug views + vim.cmd 'tabnew' + local debug_buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_name(debug_buf, 'Flutter Debug') + vim.api.nvim_set_current_buf(debug_buf) + + -- Open DAP UI in this tab + dapui.open() + + -- Return to original tab so user continues coding there + vim.cmd('tabnext ' .. current_tab) + end + + -- Custom function to close DAP UI tabs + local function close_dapui_tabs() + dapui.close() + + -- Find and close the Flutter Debug tab + local current_tab = vim.fn.tabpagenr() + for i = 1, vim.fn.tabpagenr '$' do + vim.cmd('tabnext ' .. i) + local bufname = vim.api.nvim_buf_get_name(0) + if bufname:match('Flutter Debug') then + vim.cmd 'tabclose' + break + end + end + + -- Return to original tab + if vim.fn.tabpagenr '$' >= current_tab then + vim.cmd('tabnext ' .. current_tab) + end + end + + -- Automatically open/close DAP UI in tabs + dap.listeners.after.event_initialized['dapui_config'] = open_dapui_in_tabs + dap.listeners.before.event_terminated['dapui_config'] = close_dapui_tabs + dap.listeners.before.event_exited['dapui_config'] = close_dapui_tabs + + -- Fix for Flutter Tools log buffer - make it non-saveable + -- This prevents Vim from asking to save changes to the log file on exit + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, { + pattern = '*', + callback = function(args) + local bufname = vim.api.nvim_buf_get_name(args.buf) + -- Check if this is a Flutter log buffer + if bufname:match('__FLUTTER_DEV_LOG__') or vim.bo[args.buf].filetype == 'log' then + vim.bo[args.buf].modifiable = true -- Allow Flutter to write to it + vim.bo[args.buf].modified = false -- Mark as unmodified + vim.bo[args.buf].buftype = 'nofile' -- Don't associate with a file (prevents save prompt) + vim.bo[args.buf].swapfile = false -- Don't create swap file + end + end, + }) + + -- Keep log buffer marked as unmodified whenever it changes + -- This prevents the "save changes?" prompt on exit + vim.api.nvim_create_autocmd('BufModifiedSet', { + pattern = '*', + callback = function(args) + local bufname = vim.api.nvim_buf_get_name(args.buf) + if bufname:match('__FLUTTER_DEV_LOG__') then + vim.bo[args.buf].modifiable = true + vim.bo[args.buf].modified = false -- Keep it marked as unmodified + end + end, + }) + + -- ======================================================================== + -- ENABLE TREESITTER FOLDING FOR DART FILES + -- ======================================================================== + -- Set fold method to use Treesitter for Flutter widgets + -- Using multiple autocmds to ensure it sticks (some plugins override it) + local fold_augroup = vim.api.nvim_create_augroup('DartFolding', { clear = true }) + + vim.api.nvim_create_autocmd({ 'BufRead', 'BufEnter', 'BufWinEnter' }, { + group = fold_augroup, + pattern = '*.dart', + callback = function() + vim.opt_local.foldmethod = 'expr' + vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()' + vim.opt_local.foldlevel = 99 -- High level = everything unfolded + vim.opt_local.foldlevelstart = 99 -- Start with everything unfolded + + -- Hide fold column (no extra column, folds still work!) + vim.opt_local.foldcolumn = '0' + + -- Minimal fold display (VS Code style - just shows first line) + vim.opt_local.foldtext = '' + end, + }) + + -- Also set after LSP attaches (flutter-tools might reset it) + vim.api.nvim_create_autocmd('LspAttach', { + group = fold_augroup, + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and client.name == 'dartls' then + vim.opt_local.foldmethod = 'expr' + vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()' + vim.opt_local.foldlevel = 99 -- Everything unfolded + end + end, + }) + + -- ======================================================================== + -- FLUTTER-SPECIFIC KEYMAPS + -- ======================================================================== + -- These keymaps are only available when editing Dart files + -- They provide quick access to common Flutter commands + -- ======================================================================== + vim.api.nvim_create_autocmd('FileType', { + pattern = 'dart', + callback = function(event) + local opts = { buffer = true, silent = true } + + -- ======================================================================== + -- ENABLE TREESITTER FOLDING FOR DART FILES + -- ======================================================================== + -- Set fold method to use Treesitter for Flutter widgets + vim.opt_local.foldmethod = 'expr' + vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()' + vim.opt_local.foldenable = false -- Start with folds open + vim.opt_local.foldlevel = 99 + vim.opt_local.foldlevelstart = 99 + + -- Flutter run/quit + -- WORKFLOW: + -- 1. First time: fd to select device + -- 2. Then: fr to run (uses selected device) + -- 3. Subsequent runs: fr uses same device + vim.keymap.set('n', 'fr', 'FlutterRun', vim.tbl_extend('force', opts, { desc = '[F]lutter [R]un' })) + vim.keymap.set('n', 'fR', 'FlutterRestart', vim.tbl_extend('force', opts, { desc = '[F]lutter Hot [R]estart' })) + vim.keymap.set('n', 'fq', 'FlutterQuit', vim.tbl_extend('force', opts, { desc = '[F]lutter [Q]uit' })) + + -- Code Actions (Cmd+. equivalent) - wrap, remove, extract widgets, etc. + vim.keymap.set('n', '.', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = 'Code Actions (Cmd+.)' })) + vim.keymap.set('v', '.', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = 'Code Actions (Cmd+.)' })) + -- Alternative: use the default LSP keymap + vim.keymap.set('n', 'gra', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = '[G]oto Code [A]ction' })) + vim.keymap.set('v', 'gra', vim.lsp.buf.code_action, vim.tbl_extend('force', opts, { desc = '[G]oto Code [A]ction' })) + + -- Device management + -- Use fd to see/select devices FIRST, then fr will use that device + vim.keymap.set('n', 'fd', 'FlutterDevices', vim.tbl_extend('force', opts, { desc = '[F]lutter [D]evices (select)' })) + vim.keymap.set('n', 'fe', 'FlutterEmulators', vim.tbl_extend('force', opts, { desc = '[F]lutter [E]mulators' })) + + -- Dev tools + vim.keymap.set('n', 'fo', 'FlutterOutlineToggle', vim.tbl_extend('force', opts, { desc = '[F]lutter [O]utline Toggle' })) + vim.keymap.set( + 'n', + 'fc', + 'FlutterCopyProfilerUrl', + vim.tbl_extend('force', opts, { desc = '[F]lutter [C]opy Profiler URL' }) + ) + vim.keymap.set('n', 'fl', 'FlutterLspRestart', vim.tbl_extend('force', opts, { desc = '[F]lutter [L]SP Restart' })) + + -- Register which-key group for Flutter + require('which-key').add { + { 'f', group = ' flutter', mode = 'n', buffer = event.buf }, + } + end, + }) + end, + }, + + -- ======================================================================== + -- DART TREESITTER - Ensure dart parser is installed for proper folding + -- ======================================================================== + { + 'nvim-treesitter/nvim-treesitter', + ft = 'dart', + opts = function(_, opts) + -- Ensure Dart parser is installed + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { 'dart' }) + return opts + end, + }, +} diff --git a/lua/plugins/lang/python.lua b/lua/plugins/lang/python.lua new file mode 100644 index 00000000000..a2cd8e8e643 --- /dev/null +++ b/lua/plugins/lang/python.lua @@ -0,0 +1,226 @@ +-- ======================================================================== +-- PYTHON PROFILE - Language-specific plugins and LSP configuration +-- ======================================================================== +-- +-- This file contains all Python-specific plugins and configurations. +-- These plugins will ONLY load when you open a .py file, keeping your +-- startup time fast and avoiding conflicts with other languages. +-- +-- Key features to configure here: +-- - Python LSP (pyright or pylsp) +-- - Python formatters (black, ruff, isort, etc.) +-- - Python linters and type checkers +-- - Debugger integration (debugpy) +-- - Testing tools (pytest) +-- - Virtual environment detection +-- - Python-specific keymaps +-- +-- Usage: Just open a .py file and these plugins will automatically load! +-- ======================================================================== + +return { + -- ======================================================================== + -- MASON TOOL INSTALLER - Install Python tools on-demand + -- ======================================================================== + { + 'WhoIsSethDaniel/mason-tool-installer.nvim', + ft = 'python', + dependencies = { 'williamboman/mason.nvim' }, + config = function() + -- Wait for Mason registry to be ready + local function install_tools() + local registry_ok, registry = pcall(require, 'mason-registry') + if not registry_ok then + vim.notify('Mason registry not ready, retrying...', vim.log.levels.WARN) + vim.defer_fn(install_tools, 100) + return + end + + -- Refresh registry and install tools + registry.refresh(function() + local tools = { 'pyright', 'ruff' } + for _, tool in ipairs(tools) do + local ok, package = pcall(registry.get_package, tool) + if ok and not package:is_installed() then + vim.notify('Installing ' .. tool .. '...', vim.log.levels.INFO) + package:install() + end + end + end) + end + + -- Start installation after a short delay + vim.defer_fn(install_tools, 200) + end, + }, + + -- ======================================================================== + -- PYTHON LSP - Language Server Protocol for Python + -- ======================================================================== + -- Pyright LSP is started via autocmd when opening .py files + -- This approach works because we set it up after LSP infrastructure loads + -- ======================================================================== + { + 'neovim/nvim-lspconfig', + ft = 'python', + config = function() + -- Python LSP - starts when opening .py files + vim.api.nvim_create_autocmd('FileType', { + pattern = 'python', + once = false, + callback = function(args) + -- Check if pyright is already attached + local clients = vim.lsp.get_clients { bufnr = args.buf, name = 'pyright' } + if #clients > 0 then + return + end + + -- Get capabilities from blink.cmp + local capabilities = require('blink.cmp').get_lsp_capabilities() + + local root_dir = vim.fs.root(args.buf, { + 'pyproject.toml', + 'setup.py', + 'setup.cfg', + 'requirements.txt', + 'Pipfile', + 'pyrightconfig.json', + '.git', + }) + + -- Find Python interpreter (prioritize virtual environments) + local function find_python() + if not root_dir then + return nil + end + + -- Check common venv locations relative to project root + local venv_paths = { + root_dir .. '/.venv/bin/python', + root_dir .. '/venv/bin/python', + root_dir .. '/.env/bin/python', + root_dir .. '/env/bin/python', + } + + for _, path in ipairs(venv_paths) do + if vim.fn.executable(path) == 1 then + return path + end + end + + return nil + end + + local python_path = find_python() + + vim.lsp.start { + name = 'pyright', + cmd = { vim.fn.stdpath 'data' .. '/mason/bin/pyright-langserver', '--stdio' }, + root_dir = root_dir or vim.fn.getcwd(), + capabilities = capabilities, + settings = { + python = { + pythonPath = python_path, + analysis = { + typeCheckingMode = 'basic', + autoImportCompletions = true, + autoSearchPaths = true, + useLibraryCodeForTypes = true, + diagnosticMode = 'openFilesOnly', + }, + }, + }, + } + end, + }) + end, + }, + + + -- ======================================================================== + -- PYTHON FORMATTERS - Auto-format Python code + -- ======================================================================== + -- Uses Ruff for fast formatting and import organization + -- Ruff provides Black-compatible formatting + import sorting in one tool + -- ======================================================================== + { + 'stevearc/conform.nvim', + ft = 'python', + opts = function(_, opts) + -- Extend the existing formatters_by_ft table + opts.formatters_by_ft = opts.formatters_by_ft or {} + opts.formatters_by_ft.python = { + -- Ruff handles both formatting and import sorting (fast & modern) + 'ruff_organize_imports', -- First: organize imports + 'ruff_format', -- Then: format code (Black-compatible) + } + return opts + end, + }, + + -- ======================================================================== + -- PYTHON-SPECIFIC KEYMAPS AND CONFIGURATION + -- ======================================================================== + -- Additional Python-specific settings and keymaps + -- ======================================================================== + { + 'nvim-treesitter/nvim-treesitter', + ft = 'python', + opts = function(_, opts) + -- Ensure Python parser is installed + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { 'python' }) + return opts + end, + }, + + -- Python keymaps (loaded only for Python files) + { + 'nvim-lspconfig', + ft = 'python', + config = function() + vim.api.nvim_create_autocmd('FileType', { + pattern = 'python', + callback = function(event) + local bufnr = event.buf + + -- Register which-key group for Python + require('which-key').add { + { 'p', group = ' python', buffer = bufnr }, + } + + -- Run current file + vim.keymap.set('n', 'pr', function() + vim.cmd('!python3 %') + end, { buffer = bufnr, desc = 'Run file' }) + + -- Run with arguments + vim.keymap.set('n', 'pR', function() + local args = vim.fn.input 'Arguments: ' + vim.cmd('!python3 % ' .. args) + end, { buffer = bufnr, desc = 'Run with args' }) + + -- Select virtual environment + vim.keymap.set('n', 'pe', function() + vim.cmd 'PythonSelectVenv' + end, { buffer = bufnr, desc = 'Select venv' }) + + -- Restart Python LSP + vim.keymap.set('n', 'pl', function() + vim.cmd 'PythonRestart' + end, { buffer = bufnr, desc = 'Restart LSP' }) + + -- Import organization (via Ruff) + vim.keymap.set('n', 'pi', function() + require('conform').format { formatters = { 'ruff_organize_imports' } } + end, { buffer = bufnr, desc = 'Organize imports' }) + + -- Format with Ruff + vim.keymap.set('n', 'pf', function() + require('conform').format { formatters = { 'ruff_format' } } + end, { buffer = bufnr, desc = 'Format code' }) + end, + }) + end, + }, +} diff --git a/lua/plugins/lang/rust.lua b/lua/plugins/lang/rust.lua new file mode 100644 index 00000000000..f36f5d1c0f7 --- /dev/null +++ b/lua/plugins/lang/rust.lua @@ -0,0 +1,272 @@ +-- Rust Development Configuration +-- Loaded only for Rust files (*.rs) + +return { + -- Rust Tools - Enhanced rust-analyzer integration + { + 'mrcjkb/rustaceanvim', + version = '^5', + lazy = false, -- Already lazy-loaded by filetype + ft = { 'rust' }, + opts = { + server = { + on_attach = function(client, bufnr) + -- Register which-key group for Rust + require('which-key').add { + { 'r', group = '๓ฑ˜— rust', buffer = bufnr }, + } + + -- Hover actions + vim.keymap.set('n', 'rh', function() + vim.cmd.RustLsp { 'hover', 'actions' } + end, { buffer = bufnr, desc = 'Hover actions' }) + + -- Code actions + vim.keymap.set('n', 'ra', function() + vim.cmd.RustLsp('codeAction') + end, { buffer = bufnr, desc = 'Code actions' }) + + -- Explain error + vim.keymap.set('n', 're', function() + vim.cmd.RustLsp('explainError') + end, { buffer = bufnr, desc = 'Explain error' }) + + -- Open Cargo.toml + vim.keymap.set('n', 'rC', function() + vim.cmd.RustLsp('openCargo') + end, { buffer = bufnr, desc = 'Open Cargo.toml' }) + + -- Parent module + vim.keymap.set('n', 'rp', function() + vim.cmd.RustLsp('parentModule') + end, { buffer = bufnr, desc = 'Parent module' }) + + -- Join lines + vim.keymap.set('n', 'rj', function() + vim.cmd.RustLsp('joinLines') + end, { buffer = bufnr, desc = 'Join lines' }) + + -- Runnables + vim.keymap.set('n', 'rr', function() + vim.cmd.RustLsp('runnables') + end, { buffer = bufnr, desc = 'Runnables' }) + + -- Debuggables + vim.keymap.set('n', 'rd', function() + vim.cmd.RustLsp('debuggables') + end, { buffer = bufnr, desc = 'Debuggables' }) + + -- Expand macro + vim.keymap.set('n', 'rm', function() + vim.cmd.RustLsp('expandMacro') + end, { buffer = bufnr, desc = 'Expand macro' }) + end, + default_settings = { + -- rust-analyzer language server configuration + ['rust-analyzer'] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + buildScripts = { + enable = true, + }, + }, + -- Add clippy lints for Rust + checkOnSave = { + allFeatures = true, + command = 'clippy', + extraArgs = { '--no-deps' }, + }, + procMacro = { + enable = true, + ignored = { + ['async-trait'] = { 'async_trait' }, + ['napi-derive'] = { 'napi' }, + ['async-recursion'] = { 'async_recursion' }, + }, + }, + }, + }, + }, + -- DAP configuration + dap = { + adapter = { + type = 'executable', + command = 'lldb-vscode', -- or 'lldb-dap' on newer versions + name = 'lldb', + }, + }, + }, + config = function(_, opts) + vim.g.rustaceanvim = vim.tbl_deep_extend('keep', vim.g.rustaceanvim or {}, opts or {}) + end, + }, + + -- Crates.io integration + { + 'saecki/crates.nvim', + event = { 'BufRead Cargo.toml' }, + opts = { + completion = { + cmp = { + enabled = true, + }, + }, + lsp = { + enabled = true, + actions = true, + completion = true, + hover = true, + }, + }, + config = function(_, opts) + local crates = require 'crates' + crates.setup(opts) + + -- Crates keymaps (only in Cargo.toml) + vim.api.nvim_create_autocmd('BufRead', { + pattern = 'Cargo.toml', + callback = function() + local bufnr = vim.api.nvim_get_current_buf() + + -- Register which-key group for Rust Crates + require('which-key').add { + { 'rc', group = ' crates', buffer = bufnr }, + } + + vim.keymap.set('n', 'rct', function() + crates.toggle() + end, { buffer = bufnr, desc = 'Toggle crates' }) + + vim.keymap.set('n', 'rcr', function() + crates.reload() + end, { buffer = bufnr, desc = 'Reload crates' }) + + vim.keymap.set('n', 'rcv', function() + crates.show_versions_popup() + end, { buffer = bufnr, desc = 'Show versions' }) + + vim.keymap.set('n', 'rcf', function() + crates.show_features_popup() + end, { buffer = bufnr, desc = 'Show features' }) + + vim.keymap.set('n', 'rcd', function() + crates.show_dependencies_popup() + end, { buffer = bufnr, desc = 'Show dependencies' }) + + vim.keymap.set('n', 'rcu', function() + crates.update_crate() + end, { buffer = bufnr, desc = 'Update crate' }) + + vim.keymap.set('v', 'rcu', function() + crates.update_crates() + end, { buffer = bufnr, desc = 'Update selected' }) + + vim.keymap.set('n', 'rca', function() + crates.update_all_crates() + end, { buffer = bufnr, desc = 'Update all' }) + + vim.keymap.set('n', 'rcU', function() + crates.upgrade_crate() + end, { buffer = bufnr, desc = 'Upgrade crate' }) + + vim.keymap.set('v', 'rcU', function() + crates.upgrade_crates() + end, { buffer = bufnr, desc = 'Upgrade selected' }) + + vim.keymap.set('n', 'rcA', function() + crates.upgrade_all_crates() + end, { buffer = bufnr, desc = 'Upgrade all' }) + + vim.keymap.set('n', 'rce', function() + crates.expand_plain_crate_to_inline_table() + end, { buffer = bufnr, desc = 'Expand to inline' }) + + vim.keymap.set('n', 'rcE', function() + crates.extract_crate_into_table() + end, { buffer = bufnr, desc = 'Extract to table' }) + + vim.keymap.set('n', 'rcH', function() + crates.open_homepage() + end, { buffer = bufnr, desc = 'Open homepage' }) + + vim.keymap.set('n', 'rcR', function() + crates.open_repository() + end, { buffer = bufnr, desc = 'Open repository' }) + + vim.keymap.set('n', 'rcD', function() + crates.open_documentation() + end, { buffer = bufnr, desc = 'Open documentation' }) + + vim.keymap.set('n', 'rcC', function() + crates.open_crates_io() + end, { buffer = bufnr, desc = 'Open crates.io' }) + end, + }) + end, + }, + + -- Mason tool installations for Rust + { + 'williamboman/mason.nvim', + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + 'rust-analyzer', + 'codelldb', -- For debugging + }) + end, + }, + + -- Treesitter for Rust + { + 'nvim-treesitter/nvim-treesitter', + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + 'rust', + 'ron', -- Rusty Object Notation + 'toml', -- For Cargo.toml + }) + end, + }, + + -- DAP configuration for Rust + { + 'mfussenegger/nvim-dap', + optional = true, + opts = function() + local dap = require 'dap' + + dap.configurations.rust = { + { + name = 'Launch', + type = 'codelldb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/target/debug/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + }, + { + name = 'Attach to process', + type = 'codelldb', + request = 'attach', + pid = require('dap.utils').pick_process, + args = {}, + }, + } + + dap.adapters.codelldb = { + type = 'server', + port = '${port}', + executable = { + command = vim.fn.exepath 'codelldb', + args = { '--port', '${port}' }, + }, + } + end, + }, +} diff --git a/lua/plugins/lang/svelte.lua b/lua/plugins/lang/svelte.lua new file mode 100644 index 00000000000..4b08807c803 --- /dev/null +++ b/lua/plugins/lang/svelte.lua @@ -0,0 +1,227 @@ +-- ======================================================================== +-- SVELTE PROFILE - Language-specific plugins and LSP configuration +-- ======================================================================== +-- +-- This file contains all Svelte-specific plugins and configurations. +-- These plugins will ONLY load when you open a .svelte file, keeping your +-- startup time fast and avoiding conflicts with other languages. +-- +-- Key features to configure here: +-- - Svelte LSP (svelte-language-server) +-- - TypeScript/JavaScript support for Svelte components +-- - Tailwind CSS integration (if using Tailwind) +-- - Prettier formatting for Svelte files +-- - Emmet support for Svelte +-- - Svelte-specific keymaps +-- +-- Note: You may also want to configure support for related web files: +-- - JavaScript/TypeScript (.js, .ts) +-- - HTML/CSS (.html, .css) +-- +-- Usage: Just open a .svelte file and these plugins will automatically load! +-- ======================================================================== + +return { + -- ======================================================================== + -- SVELTE LSP - Language Server Protocol for Svelte + -- ======================================================================== + -- Provides intelligent code completion, diagnostics, and more for Svelte + -- components, including support for TypeScript, CSS, and HTML within .svelte files + -- ======================================================================== + { + 'neovim/nvim-lspconfig', + ft = { 'svelte', 'typescript', 'javascript' }, -- Load for web files + dependencies = { + 'WhoIsSethDaniel/mason-tool-installer.nvim', + }, + config = function() + -- Get shared LSP capabilities from blink.cmp + local capabilities = require('blink.cmp').get_lsp_capabilities() + + -- Setup Svelte LSP server using new vim.lsp.config API (Neovim 0.11+) + local svelte_config = require('lspconfig.configs').svelte + if svelte_config then + vim.lsp.config('svelte', { + cmd = svelte_config.default_config.cmd, + filetypes = svelte_config.default_config.filetypes, + root_markers = svelte_config.default_config.root_dir, + capabilities = capabilities, + settings = { + svelte = { + plugin = { + html = { completions = { enable = true, emmet = true } }, + svelte = { completions = { enable = true } }, + css = { completions = { enable = true } }, + typescript = { diagnostics = { enable = true } }, + }, + }, + }, + }) + end + + -- Setup TypeScript LSP for .ts/.js files in Svelte projects + local tsserver_config = require('lspconfig.configs').ts_ls + if tsserver_config then + vim.lsp.config('ts_ls', { + cmd = tsserver_config.default_config.cmd, + filetypes = { + 'javascript', + 'javascriptreact', + 'typescript', + 'typescriptreact', + }, + root_markers = tsserver_config.default_config.root_dir, + capabilities = capabilities, + }) + end + + -- Setup Tailwind CSS LSP if you're using Tailwind + local tailwind_config = require('lspconfig.configs').tailwindcss + if tailwind_config then + vim.lsp.config('tailwindcss', { + cmd = tailwind_config.default_config.cmd, + filetypes = { + 'svelte', + 'html', + 'css', + 'scss', + 'javascript', + 'javascriptreact', + 'typescript', + 'typescriptreact', + }, + root_markers = tailwind_config.default_config.root_dir, + capabilities = capabilities, + }) + end + + -- Install web development tools via Mason + require('mason-tool-installer').setup { + ensure_installed = { + 'svelte-language-server', -- Svelte LSP + 'typescript-language-server', -- TypeScript/JavaScript LSP + 'tailwindcss-language-server', -- Tailwind CSS LSP (optional) + 'prettier', -- Code formatter for web files + 'eslint_d', -- Fast ESLint for linting JS/TS + }, + } + end, + }, + + -- ======================================================================== + -- WEB FORMATTERS - Prettier for Svelte/JS/TS/CSS + -- ======================================================================== + -- Configures prettier to format Svelte and related web files + -- ======================================================================== + { + 'stevearc/conform.nvim', + ft = { 'svelte', 'typescript', 'javascript', 'css', 'html', 'json' }, + opts = function(_, opts) + -- Extend the existing formatters_by_ft table + opts.formatters_by_ft = opts.formatters_by_ft or {} + opts.formatters_by_ft.svelte = { 'prettier' } + opts.formatters_by_ft.javascript = { 'prettier' } + opts.formatters_by_ft.javascriptreact = { 'prettier' } + opts.formatters_by_ft.typescript = { 'prettier' } + opts.formatters_by_ft.typescriptreact = { 'prettier' } + opts.formatters_by_ft.css = { 'prettier' } + opts.formatters_by_ft.html = { 'prettier' } + opts.formatters_by_ft.json = { 'prettier' } + opts.formatters_by_ft.markdown = { 'prettier' } + return opts + end, + }, + + -- ======================================================================== + -- TREESITTER PARSERS - Syntax highlighting for web languages + -- ======================================================================== + -- Ensures Treesitter parsers are installed for better syntax highlighting + -- ======================================================================== + { + 'nvim-treesitter/nvim-treesitter', + ft = { 'svelte', 'typescript', 'javascript', 'css', 'html' }, + opts = function(_, opts) + -- Ensure web language parsers are installed + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + 'svelte', + 'typescript', + 'tsx', + 'javascript', + 'jsdoc', + 'css', + 'html', + 'json', + }) + return opts + end, + }, + + -- ======================================================================== + -- EMMET - HTML/CSS abbreviation expansion + -- ======================================================================== + -- Provides Emmet abbreviation support for faster HTML/CSS writing + -- Type abbreviations like `div.container>ul>li*3` and expand with , + -- ======================================================================== + { + 'mattn/emmet-vim', + ft = { 'svelte', 'html', 'css', 'javascript', 'typescript' }, + init = function() + -- Set Emmet leader key (default is ) + vim.g.user_emmet_leader_key = '' + -- Enable only for specific file types + vim.g.user_emmet_install_global = 0 + -- Enable Emmet for Svelte files + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'html', 'css', 'svelte', 'javascript', 'typescript' }, + callback = function() + vim.cmd 'EmmetInstall' + end, + }) + end, + }, + + -- ======================================================================== + -- SVELTE-SPECIFIC KEYMAPS + -- ======================================================================== + -- Additional Svelte-specific settings and keymaps + -- ======================================================================== + { + 'nvim-lspconfig', + ft = 'svelte', + config = function() + vim.api.nvim_create_autocmd('FileType', { + pattern = 'svelte', + callback = function(event) + local bufnr = event.buf + + -- Register which-key group for Svelte + require('which-key').add { + { 'v', group = ' svelte', buffer = bufnr }, + } + + -- Format with Prettier + vim.keymap.set('n', 'vf', function() + require('conform').format { formatters = { 'prettier' } } + end, { buffer = bufnr, desc = 'Format with prettier' }) + + -- Restart Svelte LSP + vim.keymap.set('n', 'vl', function() + vim.cmd 'LspRestart svelte' + end, { buffer = bufnr, desc = 'Restart LSP' }) + + -- Restart TypeScript LSP (often needed in Svelte projects) + vim.keymap.set('n', 'vt', function() + vim.cmd 'LspRestart ts_ls' + end, { buffer = bufnr, desc = 'Restart TypeScript LSP' }) + + -- Open component in split + vim.keymap.set('n', 'vo', function() + local word = vim.fn.expand '' + vim.cmd('split ' .. word) + end, { buffer = bufnr, desc = 'Open component in split' }) + end, + }) + end, + }, +} diff --git a/lua/plugins/lsp/init.lua b/lua/plugins/lsp/init.lua new file mode 100644 index 00000000000..1d971323818 --- /dev/null +++ b/lua/plugins/lsp/init.lua @@ -0,0 +1,214 @@ +-- ======================================================================== +-- LSP CONFIGURATION +-- ======================================================================== +-- Language Server Protocol setup +-- Provides features like: +-- - Go to definition +-- - Find references +-- - Autocompletion +-- - Symbol search +-- - Code actions +-- - Rename refactoring +-- ======================================================================== + +return { + -- Main LSP Configuration + { + 'neovim/nvim-lspconfig', + dependencies = { + { 'mason-org/mason.nvim', opts = {} }, + 'mason-org/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + { 'j-hui/fidget.nvim', opts = {} }, + 'saghen/blink.cmp', + }, + config = function() + -- LSP UI Enhancements - Better hover, signature help, and borders + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { + border = 'rounded', + max_width = 80, + }) + + vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = 'rounded', + max_width = 80, + }) + + -- LSP Keymaps (applied when LSP attaches to a buffer) + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + map('grn', vim.lsp.buf.rename, '[R]e[n]ame') + map('K', vim.lsp.buf.hover, 'Hover Documentation') + map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) + map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') + map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') + map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + + local function client_supports_method(client, method, bufnr) + if vim.fn.has 'nvim-0.11' == 1 then + return client:supports_method(method, bufnr) + else + return client.supports_method(method, { bufnr = bufnr }) + end + end + + -- Highlight references under cursor + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) + end + + -- Inlay hints toggle + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then + map('th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') + end + end, + }) + + -- Diagnostic Config + vim.diagnostic.config { + severity_sort = true, + underline = { + severity = { min = vim.diagnostic.severity.WARN }, + }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = '๓ฐ…š', + [vim.diagnostic.severity.WARN] = '๓ฐ€ช', + [vim.diagnostic.severity.INFO] = '๓ฐ‹ฝ', + [vim.diagnostic.severity.HINT] = '๓ฐŒถ', + }, + }, + virtual_text = { + spacing = 4, + source = 'if_many', + prefix = 'โ– ', + format = function(diagnostic) + return diagnostic.message + end, + }, + float = { + border = 'rounded', + source = 'always', + header = '', + prefix = '', + focusable = true, + }, + update_in_insert = false, + } + + -- Get capabilities from blink.cmp + local capabilities = require('blink.cmp').get_lsp_capabilities() + + -- General LSP servers (lua_ls for Neovim config) + local servers = { + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + }, + }, + }, + } + + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', -- Lua formatter + }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + ensure_installed = {}, + automatic_installation = false, + handlers = { + function(server_name) + local server = servers[server_name] or {} + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + + local ok, lspconfig_server = pcall(require, 'lspconfig.server_configurations.' .. server_name) + if ok and lspconfig_server.default_config then + local config = lspconfig_server.default_config + vim.lsp.config(server_name, { + cmd = server.cmd or config.cmd, + filetypes = server.filetypes or config.filetypes, + root_markers = config.root_dir, + capabilities = server.capabilities, + settings = server.settings, + }) + vim.lsp.enable(server_name) + end + end, + }, + } + end, + }, + + -- Autoformat + { + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + 'f', + function() + require('conform').format { async = true, lsp_format = 'fallback' } + end, + mode = '', + desc = '[F]ormat buffer', + }, + }, + opts = { + notify_on_error = false, + format_on_save = function(bufnr) + local disable_filetypes = { c = true, cpp = true } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = 'never' + else + lsp_format_opt = 'fallback' + end + return { + timeout_ms = 500, + lsp_format = lsp_format_opt, + } + end, + formatters_by_ft = { + lua = { 'stylua' }, + }, + }, + }, +}