Welcome to my personal Neovim setup! This configuration is designed for a productive development experience in C/C++, Rust, Python, and Go, featuring modern tooling for completion, LSP, and formatting.
Before you begin, make sure you have the following installed:
-
Neovim (v0.10.0 or later recommended):
- Check the Neovim releases page for installation instructions for your OS. Using a recent version is crucial for compatibility with modern plugins.
-
Git: Essential for managing plugins and this configuration.
-
Core Language Toolchains: These are fundamental for the languages you plan to use. The
setup.shscript (see below) relies on these being installed and in yourPATH.- Rust: Install via rustup (
rustup,cargo). This is also used bysetup.shto installstylua. - Go: Install the Go toolchain (
gocommand). - Python: Install Python 3 (
python3,pip3). - macOS Users: Install Homebrew if you intend to use C/C++ tools or other packages conveniently.
- Rust: Install via rustup (
-
Node.js (LTS recommended): Required for
github/copilot.vim. Install from nodejs.org or via a version manager likenvm. Thesetup.shscript can also attempt to install this. -
Build Tools (for some plugins/LSPs):
- A C compiler (like
gccorclang) is often needed for building Treesitter parsers or other native extensions for plugins. make,cmakemight be needed if building Neovim from source or for certain plugins.
- A C compiler (like
-
Formatter Dependencies:
- This setup uses
conform.nvimwhich relies on external formatter executables. Thesetup.shscript aims to install:stylua(for Lua)ruff(for Python formatting and linting)isort(for Python import sorting, works withruff)clang-format(for C/C++)rustfmt(for Rust)
- Ensure these are installable on your system (e.g.,
cargofor Rust-based tools,pipfor Python tools).
- This setup uses
-
For
telescope.nvim(fuzzy finding):ripgrep(rg): For searching. (Installation Guide)fd(fd-find): For finding files. (Installation Guide)- These are highly recommended for Telescope to function optimally.
-
Clone this Configuration:
# Backup your existing nvim config if you have one: # mv ~/.config/nvim ~/.config/nvim.bak # mv ~/.local/share/nvim ~/.local/share/nvim.bak # mv ~/.local/state/nvim ~/.local/state/nvim.bak # mv ~/.cache/nvim ~/.cache/nvim.bak git clone https://github.com/mhxie/nvim.git ~/.config/nvim
-
Install Linters, Formatters, and Language Servers: This setup uses a helper script (
setup.sh) to install necessary development tools. Navigate to the config directory and run:cd ~/.config/nvim chmod +x setup.sh ./setup.sh install
This script supports Linux (Ubuntu/Debian, Amazon Linux) and macOS. It will attempt to install:
- Rust tools:
rust-analyzer,rustfmt,clippy,stylua(via cargo) - C/C++ tools:
clangd,clang-format - Python tools:
ruff,isort(into a venv:~/.config/nvim/venvs/nvim-python-tools) - Go tools:
gopls,goimports - Node.js: If not already installed.
To uninstall these tools later, run
./setup.sh uninstall. Review the script's output for any errors or PATH adjustments needed. You might need to source your shell config or open a new terminal after running the script. - Rust tools:
-
Launch Neovim:
nvim
lazy.nvim(our plugin manager) will automatically bootstrap itself and install all configured plugins on the first run. You might need to restart Neovim after the initial plugin installation.- After installing plugins, run
:Copilot setupin Neovim to authorize the GitHub Copilot plugin if you use it. - Run
:checkhealthto see if there are any issues, especially withnvim-treesitteror LSP configurations.
- After installing plugins, run
:Lazyor:Lazy sync: Opens the lazy.nvim UI. Synchronizes plugins (installs, updates, cleans).:Mason: Opens the Mason UI to manage LSP servers, DAPs, linters, and formatters.:ConformInfo: Shows information about available formatters for the current buffer.:Format: Manually formats the current buffer usingconform.nvim.:Copilot setup: To authorize and configure GitHub Copilot.:checkhealth: Troubleshoots loading issues (useful fornvim-treesitter, LSPs, general setup).:TSUpdate: Manually update all Treesitter parsers (if needed).
This setup is modular, with configurations in lua/options.lua, lua/keymaps.lua, lua/plugins.lua, and lua/lsp.lua.
- Plugin Manager:
folke/lazy.nvim - Completion:
hrsh7th/nvim-cmp(with sources for LSP, buffer, path) - Formatting:
stevearc/conform.nvim(handlesstylua,ruff format,isort,clang-format,rustfmt) - LSP Management:
williamboman/mason.nvimandwilliamboman/mason-lspconfig.nvim - Key LSPs Configured:
- Rust:
rust-analyzer(viarust-tools.nvim) - C/C++:
clangd - Python:
ruff(provides LSP features, linting, and formatting) - Go:
gopls
- Rust:
- Fuzzy Finding:
nvim-telescope/telescope.nvim - Treesitter:
nvim-treesitter/nvim-treesitter(for syntax highlighting and more) - Git Integration:
lewis6991/gitsigns.nvim,tpope/vim-fugitive - GitHub Copilot:
github/copilot.vim
- More language support (YAML, TOML, HTML ...) with LSP and formatters.
- Explore DAP (Debug Adapter Protocol) integration for debugging.
- Add code analysis tools (e.g., linters not covered by formatters/LSPs).
Happy Coding!