# LazyVim Setup LazyVim transforms Neovim into a modern IDE with minimal configuration. This guide walks through installation, first launch, and essential customizations. ## Pre-Installation Checklist ✅ **Neovim 0.9.0+** (LazyVim requires recent version) ✅ **Git** (for plugin management) ✅ **A Nerd Font** (for icons) ✅ **ripgrep** (for telescope grep) ✅ **fd** (for telescope file finding) ✅ **Node.js** (for LSP servers) ### Install Dependencies ```bash # Install Neovim brew install neovim # Install tools brew install git ripgrep fd node # Install a Nerd Font (icons support) brew tap homebrew/cask-fonts brew install --cask font-jetbrains-mono-nerd-font # or brew install --cask font-fira-code-nerd-font ``` **Configure your terminal to use the Nerd Font:** - Ghostty: Preferences → Font → "JetBrainsMono Nerd Font" - iTerm2: Preferences → Profiles → Text → Font → "JetBrainsMono Nerd Font" ## Installation ### Backup Existing Config (if any) ```bash # Backup current Neovim config mv ~/.config/nvim{,.bak} # Backup current Neovim data mv ~/.local/share/nvim{,.bak} mv ~/.local/state/nvim{,.bak} mv ~/.cache/nvim{,.bak} ``` ### Install LazyVim ```bash # Clone the starter template git clone https://github.com/LazyVim/starter ~/.config/nvim # Remove .git folder so you can make it your own rm -rf ~/.config/nvim/.git ``` ### First Launch ```bash nvim ``` **What happens:** 1. LazyVim installs lazy.nvim (plugin manager) 2. Downloads and installs all plugins 3. Downloads treesitter parsers 4. Compiles native modules 5. Shows the dashboard **This takes 1-2 minutes on first launch.** Be patient! ## Understanding the Config Structure LazyVim uses a clean directory structure: ``` ~/.config/nvim/ ├── init.lua # Entry point (don't edit) ├── lua/ │ ├── config/ │ │ ├── autocmds.lua # Your autocmds │ │ ├── keymaps.lua # Your keybindings │ │ ├── lazy.lua # Plugin manager config │ │ └── options.lua # Your Neovim options │ └── plugins/ │ ├── example.lua # Example plugin config (delete this) │ └── *.lua # Your plugin configs └── stylua.toml # Lua formatter config ``` **Key principle:** Don't edit `init.lua`. Put your customizations in: - `lua/config/options.lua` - Neovim settings - `lua/config/keymaps.lua` - Your keybindings - `lua/plugins/` - Plugin configurations ## First Customizations ### Set Line Numbers and Basics Edit `~/.config/nvim/lua/config/options.lua`: ```lua -- Set line numbers vim.opt.number = true -- Show line numbers vim.opt.relativenumber = true -- Relative line numbers -- Indentation (customize for your preference) vim.opt.tabstop = 2 -- Tab displays as 2 spaces vim.opt.shiftwidth = 2 -- Indent by 2 spaces vim.opt.expandtab = true -- Use spaces, not tabs -- Search vim.opt.ignorecase = true -- Case insensitive search vim.opt.smartcase = true -- Unless uppercase used -- Visual vim.opt.wrap = false -- Don't wrap lines vim.opt.scrolloff = 8 -- Keep 8 lines visible around cursor vim.opt.cursorline = true -- Highlight current line -- System clipboard integration vim.opt.clipboard = "unnamedplus" -- Use system clipboard ``` ### Add Custom Keybindings Edit `~/.config/nvim/lua/config/keymaps.lua`: ```lua -- Custom keybindings local map = vim.keymap.set -- Better window navigation map("n", "<C-h>", "<C-w>h", { desc = "Go to left window" }) map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" }) map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" }) map("n", "<C-l>", "<C-w>l", { desc = "Go to right window" }) -- Better save map("n", "<C-s>", ":w<CR>", { desc = "Save file" }) -- Clear search highlighting map("n", "<Esc>", ":noh<CR>", { desc = "Clear search highlighting" }) -- Stay in indent mode map("v", "<", "<gv", { desc = "Indent left and reselect" }) map("v", ">", ">gv", { desc = "Indent right and reselect" }) -- Move lines up/down map("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down" }) map("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up" }) map("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" }) map("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" }) ``` ## Installing Language Servers (LSP) LazyVim uses Mason to manage LSP servers. ### Open Mason ```vim :Mason ``` **Interface:** - `i` - Install server - `u` - Update server - `X` - Uninstall server - `q` - Quit ### Recommended Servers ```bash # Inside :Mason, press 'i' on these: # Web Development typescript-language-server tailwindcss-language-server html-lsp css-lsp json-lsp # Python pyright # Lua lua-language-server # Markdown marksman # Docker dockerfile-language-server # Shell bash-language-server ``` **Or install from command line:** ```bash # Open Neovim and run: :LspInstall typescript-language-server :LspInstall pyright :LspInstall lua-language-server ``` ## Essential Plugins to Add Create `~/.config/nvim/lua/plugins/custom.lua`: ```lua return { -- Better escape from insert mode { "max397574/better-escape.nvim", config = function() require("better_escape").setup({ mapping = { "jk", "jj" }, -- jk or jj to exit insert mode timeout = 200, }) end, }, -- Auto-save { "pocco81/auto-save.nvim", config = function() require("auto-save").setup({ enabled = true, trigger_events = { "InsertLeave", "TextChanged" }, }) end, }, -- Better comments { "numToStr/Comment.nvim", config = function() require("Comment").setup() end, }, -- Surround text objects { "kylechui/nvim-surround", config = function() require("nvim-surround").setup() end, }, } ``` **Restart Neovim** to install new plugins. ## Essential Keybindings (Default LazyVim) ### Leader Key The `<leader>` key is `Space` by default. ### File Navigation | Key | Action | |-----|--------| | `<leader>ff` | Find files (Telescope) | | `<leader>fr` | Recent files | | `<leader>fg` | Find by grep | | `<leader>fb` | Find buffers (open files) | | `<leader>e` | Toggle file explorer | ### Window Management | Key | Action | |-----|--------| | `<C-w>s` | Split horizontal | | `<C-w>v` | Split vertical | | `<C-w>c` | Close window | | `<C-w>=` | Equal size windows | ### LSP (Code Intelligence) | Key | Action | |-----|--------| | `gd` | Go to definition | | `gr` | Go to references | | `K` | Hover documentation | | `<leader>ca` | Code actions | | `<leader>rn` | Rename symbol | | `]d` | Next diagnostic | | `[d` | Previous diagnostic | ### Git Integration | Key | Action | |-----|--------| | `<leader>gg` | Open LazyGit | | `<leader>gb` | Git blame line | | `]h` | Next hunk | | `[h` | Previous hunk | ### Terminal | Key | Action | |-----|--------| | `<C-\>` | Toggle terminal | | `<C-/>` | New terminal | ## Color Scheme Configuration LazyVim comes with several themes. Change in `lua/config/options.lua`: ```lua -- Set colorscheme vim.cmd([[colorscheme tokyonight]]) -- Or try these: -- vim.cmd([[colorscheme catppuccin]]) -- vim.cmd([[colorscheme gruvbox]]) -- vim.cmd([[colorscheme nord]]) ``` **Install more themes** in `lua/plugins/colorscheme.lua`: ```lua return { { "catppuccin/nvim", name = "catppuccin", priority = 1000, config = function() vim.cmd([[colorscheme catppuccin-mocha]]) end, }, } ``` ## Troubleshooting ### Plugins Won't Install ```vim :Lazy sync # Force sync plugins :Lazy clean # Remove unused plugins :Lazy update # Update all plugins ``` ### LSP Not Working ```vim :LspInfo # Check LSP status :Mason # Install missing servers :checkhealth # Run health check ``` ### Slow Startup ```vim :Lazy profile # See what's slow ``` **Common causes:** - Too many plugins loaded on startup - Use `lazy = true` for plugins you don't need immediately ### Icons Not Showing **Problem:** Boxes or weird characters instead of icons **Solution:** 1. Install a Nerd Font (see Pre-Installation) 2. Configure terminal to use that font 3. Restart terminal ## Next Steps Now that LazyVim is installed, learn the workflows: **File Management:** - [[LazyVim Workflows/File Navigation in LazyVim]] - Finding files fast **Editing:** - [[LazyVim Workflows/Code Editing Workflows]] - Efficient editing patterns **Git:** - [[LazyVim Workflows/Git Integration in LazyVim]] - Using git in editor **LSP:** - [[LazyVim Workflows/LSP and Code Intelligence]] - Autocomplete, jump to definition, etc. **Understanding:** - [[Neovim - The Vim Ecosystem]] - How Neovim, Vim, and LazyVim relate **Ecosystem:** - [[Dev Environment Stack]] - How this fits with tmux, shell, terminal ## Daily Workflow ```bash # Open project in LazyVim cd ~/Code/myproject nvim . # Inside LazyVim: Space + f + f # Find file Space + s + g # Search in files Space + e # File explorer gd # Go to definition Space + c + a # Code actions Space + g + g # Git UI ``` **Remember:** LazyVim is just Neovim with great defaults. Everything is customizable.