diff --git a/docs.json b/docs.json index 2f8762811..3519fc815 100644 --- a/docs.json +++ b/docs.json @@ -24,6 +24,7 @@ "index", "quickstart", "installation", + "neovim", { "group": "Web editor", "icon": "mouse-pointer-2", diff --git a/neovim.mdx b/neovim.mdx new file mode 100644 index 000000000..ca51e3e8c --- /dev/null +++ b/neovim.mdx @@ -0,0 +1,340 @@ +--- +title: "Neovim" +description: "Install and set up Neovim for efficient text editing and development" +icon: "terminal" +--- + + + + +Neovim is a modern, extensible text editor that builds on the legacy of Vim while adding powerful features for developers. This guide will help you install and configure Neovim for an optimal development experience. + +## Installation + + + **Prerequisites**: Neovim requires a terminal emulator and works best with a modern shell like Bash, Zsh, or Fish. + + + + + Choose your preferred installation method based on your operating system: + + + ```bash macOS (Homebrew) + brew install neovim + ``` + + ```bash Ubuntu/Debian + sudo apt update + sudo apt install neovim + ``` + + ```bash Fedora/CentOS/RHEL + sudo dnf install neovim + ``` + + ```bash Arch Linux + sudo pacman -S neovim + ``` + + ```bash Windows (Chocolatey) + choco install neovim + ``` + + ```bash Windows (Scoop) + scoop install neovim + ``` + + + + + Confirm Neovim is installed correctly by checking the version: + + ```bash + nvim --version + ``` + + You should see output showing the Neovim version and build information. + + + + Set up the configuration directory structure: + + + ```bash macOS/Linux + mkdir -p ~/.config/nvim + ``` + + ```bash Windows (PowerShell) + mkdir $env:LOCALAPPDATA\nvim + ``` + + + + +## Basic configuration + +Create a basic configuration file to get started with Neovim: + + + + Create the main configuration file: + + + ```bash macOS/Linux + touch ~/.config/nvim/init.lua + ``` + + ```bash Windows (PowerShell) + New-Item -Path "$env:LOCALAPPDATA\nvim\init.lua" -ItemType File + ``` + + + + + Open the `init.lua` file and add these essential settings: + + ```lua init.lua + -- Basic settings + vim.opt.number = true -- Show line numbers + vim.opt.relativenumber = true -- Show relative line numbers + vim.opt.tabstop = 2 -- Number of spaces tabs count for + vim.opt.shiftwidth = 2 -- Size of an indent + vim.opt.expandtab = true -- Use spaces instead of tabs + vim.opt.smartindent = true -- Insert indents automatically + vim.opt.wrap = false -- Disable line wrap + vim.opt.ignorecase = true -- Ignore case in search + vim.opt.smartcase = true -- Don't ignore case with capitals + vim.opt.termguicolors = true -- True color support + + -- Key mappings + vim.g.mapleader = " " -- Set leader key to space + + -- Basic key mappings + vim.keymap.set("n", "w", ":w", { desc = "Save file" }) + vim.keymap.set("n", "q", ":q", { desc = "Quit" }) + vim.keymap.set("n", "e", ":Ex", { desc = "File explorer" }) + ``` + + + +## Package management + +For a more powerful Neovim setup, install a package manager: + + + + Add lazy.nvim package manager to your configuration: + + ```lua init.lua + -- Bootstrap lazy.nvim + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) + end + vim.opt.rtp:prepend(lazypath) + + -- Setup lazy.nvim + require("lazy").setup({ + -- Add plugins here + }) + ``` + + + + Install some useful plugins by updating your lazy.nvim setup: + + ```lua init.lua + require("lazy").setup({ + -- File explorer + { + "nvim-tree/nvim-tree.lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("nvim-tree").setup() + end, + }, + + -- Syntax highlighting + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { "lua", "javascript", "python", "markdown" }, + highlight = { enable = true }, + }) + end, + }, + + -- Color scheme + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + vim.cmd.colorscheme("catppuccin") + end, + }, + }) + ``` + + + +## Getting started + + + + Start Neovim from your terminal: + + ```bash + nvim + ``` + + Or open a specific file: + + ```bash + nvim filename.txt + ``` + + + + Master these essential Neovim commands: + + - `i` - Enter insert mode + - `Esc` - Return to normal mode + - `:w` - Save file + - `:q` - Quit + - `:wq` - Save and quit + - `dd` - Delete current line + - `yy` - Copy current line + - `p` - Paste + + + + If you added lazy.nvim, install the plugins: + + 1. Restart Neovim + 2. Run `:Lazy` to open the plugin manager + 3. Press `I` to install plugins + + + +## Advanced configuration + +For a more sophisticated setup, consider these enhancements: + +### Language Server Protocol (LSP) + +Add LSP support for intelligent code completion and error checking: + +```lua init.lua +-- Add to your lazy.nvim plugins +{ + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + }, + config = function() + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "tsserver", "pyright" } + }) + + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({}) + lspconfig.tsserver.setup({}) + lspconfig.pyright.setup({}) + end, +} +``` + +### Fuzzy finder + +Add telescope for powerful file and text searching: + +```lua init.lua +{ + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local builtin = require("telescope.builtin") + vim.keymap.set("n", "ff", builtin.find_files, { desc = "Find files" }) + vim.keymap.set("n", "fg", builtin.live_grep, { desc = "Live grep" }) + end, +} +``` + +## Troubleshooting + + + + If you get a "command not found" error: + + 1. Verify installation: Check if Neovim is installed correctly + 2. Check PATH: Ensure the installation directory is in your PATH + 3. Restart terminal: Close and reopen your terminal + 4. Try full path: Use the full path to the Neovim executable + + + + If your configuration isn't working: + + 1. Check file location: Ensure `init.lua` is in the correct directory + 2. Check syntax: Look for Lua syntax errors in your configuration + 3. Start with minimal config: Comment out plugins and add them back gradually + 4. Check logs: Run `:messages` in Neovim to see error messages + + + + If lazy.nvim plugins aren't installing: + + 1. Check internet connection: Ensure you can access GitHub + 2. Clear cache: Delete the lazy.nvim data directory and restart + 3. Check configuration: Verify your lazy.nvim setup is correct + 4. Manual install: Try installing plugins manually with `:Lazy install` + + + + If colors appear wrong or missing: + + 1. Enable true colors: Add `vim.opt.termguicolors = true` to your config + 2. Check terminal support: Ensure your terminal supports 24-bit colors + 3. Try different colorscheme: Test with built-in colorschemes first + 4. Update terminal: Use a modern terminal emulator + + + +## Next steps + +Now that you have Neovim installed and configured, explore these resources: + + + Master efficient text editing with Vim motions through interactive games and tutorials. + + + + Discover hundreds of plugins to extend Neovim's functionality for your specific needs. + + + + Connect with other Neovim users, get help, and share configurations. + + + + Dive deeper into Neovim's extensive documentation and advanced features. + \ No newline at end of file