Welcome to my Neovim configuration! This setup is tailored to enhance productivity, streamline development workflows, and provide a pleasant coding experience. Below you'll find an overview of key mappings, settings, and plugins that I've incorporated into my Neovim environment.
Custom key mappings to improve navigation and efficiency:
- Clear Search Highlighting: Press
Escto clear search highlights. - Diagnostic Navigation:
[d: Go to previous diagnostic message.]d: Go to next diagnostic message.<leader>e: Show diagnostic error messages.<leader>q: Open diagnostic quickfix list.
- Terminal Mode: Press
Esctwice to exit terminal mode. - Split Window Navigation:
Ctrl + h: Focus on the left window.Ctrl + j: Focus on the bottom window.Ctrl + k: Focus on the top window.Ctrl + l: Focus on the right window.
- File Navigation:
-: Open oil.nvim for filesystem navigation.<C-n>: Toggle NvimTree file explorer.<leader>t: Focus on NvimTree.
- Search and Telescope:
<leader>ph: Search help tags.<leader>pk: Search key mappings.<leader>pf: Find files.<leader>ps: List available Telescope pickers.<leader>pw: Search for the current word.<leader>pg: Live grep.<leader>pd: Search diagnostics.<leader>pr: Resume last Telescope picker.<leader>p.: Open recent files.<leader><leader>: List buffers.
- Git Integration:
<leader>lg: Open LazyGit interface.
- Formatting:
<leader>f: Format current buffer using conform.nvim.
Optimizations and configurations for an enhanced experience:
- Leader Key: Set to
<Space>. - Swap File: Disabled (
swapfile = false) to prevent swap file creation. - Line Numbers: Both absolute (
number = true) and relative (relativenumber = true) line numbers are enabled. - Mouse Support: Enabled (
mouse = 'a') for easier navigation and resizing. - Clipboard: System clipboard integration (
clipboard = 'unnamedplus'). - Search: Case-insensitive (
ignorecase = true), smart case sensitivity if uppercase letters are used (smartcase = true). - Splits: New splits open to the right (
splitright = true) and below (splitbelow = true). - Whitespace Characters: Displayed for tabs, trailing spaces, and non-breaking spaces (
list = true). - Cursor Line: Highlighted to easily locate the cursor (
cursorline = true). - Scroll Off: Keeps 10 lines visible above and below the cursor (
scrolloff = 10). - Update Time: Reduced for faster UI updates (
updatetime = 250). - Timeout Length: Shortened for quicker key sequence detection (
timeoutlen = 300). - Command Height: Set to zero to minimize command line space (
cmdheight = 0).
A curated list of plugins to extend Neovim's functionality.
- nvim-tree.lua: A file explorer tree for Neovim.
- oil.nvim: Edit your filesystem like a buffer.
- nvim-lspconfig: Quickstart configurations for the Neovim LSP client.
- mason.nvim: Package manager for LSP servers, DAP servers, linters, and formatters.
- mason-lspconfig.nvim: Bridges mason.nvim with lspconfig.
- nvim-cmp: A completion engine plugin for Neovim.
- Dependencies:
- LuaSnip: Snippet engine.
- cmp-nvim-lsp: LSP source for nvim-cmp.
- cmp-path: Path source for nvim-cmp.
- cmp_luasnip: Snippet completions.
- Dependencies:
- nvim-treesitter: Treesitter configurations and abstraction layer.
- Configured Languages: Bash, C, C++, CSS, Dockerfile, Go, HTML, Java, JSON, Lua, Markdown, Python, Rust, TOML, YAML, TypeScript React, MDX, and more.
- nvim-ts-autotag: Auto close and auto rename HTML tag.
- gitsigns.nvim: Git signs in the sign column.
- Features: Git blame, hunk actions, and inline diff.
- nvim-dap: Debug Adapter Protocol client.
- nvim-dap-ui: UI for nvim-dap.
- nvim-dap-go: Go debugging support.
- Comment.nvim: Smart and powerful commenting plugin.
- conform.nvim: Formatter for Neovim, with support for multiple filetypes.
- todo-comments.nvim: Highlight, list, and search for todo comments in code.
- which-key.nvim: Displays a popup with possible keybindings.
- mini.nvim: Collection of minimal, independent modules.
- Used Modules:
- mini.ai: Text objects.
- mini.surround: Surround functionality.
- mini.statusline: Statusline.
- Used Modules:
- tokyonight.nvim: Tokyo Night color scheme for Neovim.
- better-ts-errors.nvim: Better error messages for Neovim.
To set up this Neovim configuration:
-
Backup Existing Config: If you already have a Neovim configuration, back it up before proceeding.
mv ~/.config/nvim ~/.config/nvim.backup
-
Clone the Repository: Clone this configuration into your Neovim config directory.
git clone https://github.com/yourusername/your-nvim-config.git ~/.config/nvim -
Install Neovim: Ensure Neovim (version 0.9 or newer) is installed.
-
Install Dependencies:
- Formatter and Linter: Install
prettierd,eslint_d,stylua,black,isort, etc., depending on your language needs. - Language Servers: Install LSP servers via
mason.nvimor ensure they are available in your system.
- Formatter and Linter: Install
-
Launch Neovim: Open Neovim and let it install the plugins.
nvim
Here are some usage tips and keybindings to get the most out of this configuration.
- Leader Key: The
<Space>key is set as the leader key. - Access Keybinding Help: Press
<leader>?to bring up buffer-local keybindings viawhich-key.nvim.
- Open Oil: Press
-to open oil.nvim for filesystem navigation. - Toggle File Explorer: Press
<C-n>to togglenvim-tree.lua. - Focus File Explorer: Press
<leader>tto focus on the file explorer.
- Find Files: Press
<leader>pfto find files. - Live Grep: Press
<leader>pgto search within files. - Resume Last Search: Press
<leader>prto resume the last Telescope picker. - List Buffers: Press
<leader><leader>to list open buffers.
- Open LazyGit: Press
<leader>lgto open the LazyGit interface within Neovim.
- Go to Definition: Press
gdto go to the definition of a symbol. - Find References: Press
grto find all references of a symbol. - Rename Symbol: Press
<leader>rnto rename a symbol. - Code Actions: Press
<leader>cato view available code actions.
- Format Buffer: Press
<leader>fto format the current buffer usingconform.nvim.
- Start/Continue Debugging: Press
<F5>. - Step Into: Press
<F1>. - Step Over: Press
<F2>. - Step Out: Press
<F3>. - Toggle Breakpoint: Press
<leader>b. - Set Conditional Breakpoint: Press
<leader>B.
Ensure your Neovim environment is appropriately set up:
- Check Neovim Version: Run
:versionin Neovim. The configuration requires Neovim version 0.9.4 or newer. - Install External Tools: Ensure the following tools are installed and available in your system PATH:
gitmakeunzipripgrep(rg)
- Run Health Check: In Neovim, execute
:checkhealthto see if there are any issues.
Enjoy your enhanced Neovim experience! If you encounter any issues or have suggestions for improvements, feel free to contribute or open an issue.