# Neovim Configuration A single-file Neovim configuration using [lazy.nvim](https://github.com/folke/lazy.nvim) for plugin management. This setup includes fuzzy finding, file tree navigation, syntax highlighting, LSP support, and autocompletion. --- ## Plugins | Plugin | Purpose | |--------|---------| | `tokyonight.nvim` | Colorscheme (currently using `habamax`) | | `neo-tree.nvim` | File tree explorer | | `telescope.nvim` | Fuzzy finder for files, grep, buffers, keymaps, etc. | | `harpoon` | Quick file navigation and bookmarking | | `which-key.nvim` | Popup showing pending keybinds | | `todo-comments.nvim` | Highlight TODOs and notes in comments | | `nvim-highlight-colors` | Show color previews inline | | `smear-cursor.nvim` | Smooth cursor animation | | `nvim-autopairs` | Automatically close brackets and quotes | | `nvim-treesitter` | Syntax highlighting and indentation (archived, see below) | | `mason.nvim` | Package manager for LSP servers, linters, and formatters | | `mason-lspconfig.nvim` | Bridge between Mason and nvim-lspconfig | | `nvim-lspconfig` | Official LSP client configurations | | `fidget.nvim` | LSP progress UI | | `lazydev.nvim` | Enhanced Lua LSP for Neovim config development | | `nvim-cmp` | Autocompletion engine | | `cmp-nvim-lsp` | LSP completion source for nvim-cmp | | `cmp-buffer` | Buffer text completion source | | `cmp-path` | Path completion source | | `cmp-cmdline` | Command-line completion (`:` and `/`) | | `LuaSnip` | Snippet engine | | `friendly-snippets` | VS Code-style snippet collection | | `nvim-ufo` | LSP-powered code folding (with `promise-async`) | | `vim-fugitive` | Git integration (status, diff, blame, log, etc.) | | `quicker.nvim` | Editable quickfix (dd to delete, `:w` to sync) | --- ## Keymaps ### General | Key | Action | |-----|--------| | `` | Leader key | | `;` | Enter command mode (`:`) | | `nt` | Toggle Neo-tree file explorer | | `p` | Paste without overwriting register (visual mode) | | `y` | Yank to system clipboard (visual mode) | | `Y` | Yank entire file to system clipboard | | `J` / `K` | Move selected text down/up (visual mode) | ### Telescope (Search) | Key | Action | |-----|--------| | `sh` | Search Help | | `sk` | Search Keymaps | | `sf` | Search Files | | `ss` | Search Select (Telescope built-ins) | | `sw` | Search current Word | | `sg` | Search by Grep (visual mode: searches selection, literal) | | `sd` | Search Diagnostics | | `sr` | Search Resume (previous search) | | `s.` | Search Recent Files | | `` | Find existing buffers | | `/` | Fuzzily search in current buffer | | `s/` | Live Grep in Open Files | | `sn` | Search Neovim config files | ### Harpoon (File Marks) | Key | Action | |-----|--------| | `h` | Add current file to Harpoon | | `` | Toggle Harpoon quick menu | | `` through `` | Jump to Harpoon file 1–7 | | `` | Previous Harpoon file | | `` | Next Harpoon file | | `` | Open Harpoon window in Telescope | ### Git (Fugitive) These keymaps are available in any buffer. See `:help fugitive` for the full command list. | Key | Action | |-----|--------| | `gs` | Git [S]tatus (opens `:G` interactive window) | | `gd` | Git [D]iff (`:Gdiffsplit`) | | `gb` | Git [B]lame (`:G blame`) | | `gl` | Git [L]og (`:G log`) | | `gw` | Git [W]rite (stage current file) | ### Quickfix (quicker.nvim) In Telescope results: `` sends all to quickfix, `` (Alt+q) sends Tab-selected. In quickfix: `dd` deletes entry, `>` / `<` expands/collapses context, `:w` syncs. | Key | Action | |-----|--------| | `q` | Toggle quickfix | | `l` | Toggle loclist | ### Folds (nvim-ufo) These keymaps work in any buffer. Folds are powered by the LSP when available, falling back to indentation. | Key | Action | |-----|--------| | `zc` | Close fold| | `zo` | Open fold | | `zC` | Close all folds | | `zO` | Open all folds | > Standard Vim fold commands (`za`, `zo`, `zc`, etc.) also work. See `:help folding`. ### LSP (Language Server Protocol) These keymaps are active when an LSP server is attached to the current buffer. | Key | Action | |-----|--------| | `gd` | Go to Definition | | `gr` | Find References | | `gI` | Go to Implementation | | `D` | Type Definition | | `K` | Hover Documentation | | `rn` | Rename Symbol | | `ca` | Code Action | | `f` | Format Buffer (manual) | | `ds` | Document Symbols | | `[d` / `]d` | Jump to previous/next diagnostic | ### Autocomplete (nvim-cmp) | Key | Action | |-----|--------| | `` | Next completion item | | `` | Previous completion item | | `` | Scroll documentation up | | `` | Scroll documentation down | | `` | Confirm selection | | `` | Trigger completion manually | | `` | Expand snippet or jump forward | | `` | Jump snippet backward | --- ## How to Use: Folds Folds let you collapse and expand blocks of code. This config uses [`nvim-ufo`](https://github.com/kevinhwang91/nvim-ufo) with the LSP as the primary provider, so folds match your language server's understanding of the code structure. ### Basic Commands | Command | Action | |---------|--------| | `za` | Toggle fold under cursor | | `zo` | Open fold under cursor | | `zc` | Close fold under cursor | | `zR` | Open all folds (global) | | `zM` | Close all folds (global) | | `zr` | Open more folds (incremental) | | `zm` | Close more folds (incremental) | ### Quick Tips - **Navigate inside a closed fold**: Move the cursor over the fold indicator and press `za` to open it. - **Folds update automatically** when you edit the file. - **No LSP?** Folds will fall back to indentation-based folding. --- ## Sign Column (Diagnostics) The column to the left of the line numbers is the **sign column**. It appeared after adding LSP support because language servers now report issues directly in the editor. ### Symbols | Symbol | Meaning | Severity | |--------|---------|----------| | `E` | Error | Code that will not compile or run | | `W` | Warning | Suspicious or deprecated code | | `I` | Information | e.g., unused variables | | `H` | Hint | Style suggestions or quick fixes | ### Diagnostic Keymaps | Key | Action | |-----|--------| | `e` | Show full diagnostic message in a floating window | | `[d` | Jump to previous diagnostic | | `]d` | Jump to next diagnostic | --- ## LSP Servers Native servers are managed automatically via [Mason](https://github.com/williamboman/mason.nvim). The following servers are configured to auto-install: | Server | Language | Installed via | |--------|----------|---------------| | `gopls` | Go | Mason | | `rust_analyzer` | Rust | Mason | | `clangd` | C / C++ | Mason | | `lua_ls` | Lua | Mason | | `jedi_language_server` | Python | `uv` (pinned, see `dev-env/dev_env.sh`) | | `tsc` | JavaScript / TypeScript | Native TypeScript 7 binary (`tsc --lsp`, pinned) | | `biome` | HTML / CSS | Biome release binary (pinned) | No language server in this setup uses Node.js or npm. ### Managing LSP Servers Open the Mason UI: ```vim :Mason ``` Install a new server: ```vim :MasonInstall ``` Update all installed packages: ```vim :MasonUpdate ``` --- ## Treesitter Parsers These parsers are automatically installed on first launch: - `python` - `go` - `javascript` - `typescript` - `rust` - `c` - `html` - `css` - `lua` - `vim` - `vimdoc` - `query` - `markdown` Additional parsers for new filetypes are installed automatically (`auto_install = true`). --- ## Treesitter Status & Future Upgrade Path > **Note:** The [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter) plugin repository was archived by its owner on **April 3, 2026** and is now read-only. It is pinned to the `master` branch in this config, which remains stable and functional. ### Why keep it? - The `master` branch is mature, stable, and continues to work with Neovim 0.12. - Lazy.nvim installs from archived repositories without issues. - It provides convenient parser management (`:TSInstall`, `ensure_installed`, `auto_install`) that Neovim does not natively handle. ### Future upgrade paths When you're ready to move away from the archived plugin, you have two options: **Option 1: Go fully native (Neovim 0.12+)** Remove `nvim-treesitter` and use Neovim's built-in treesitter support: - Highlighting: `vim.treesitter.start()` is built-in. - Indentation: `vim.bo.indentexpr = "v:lua.vim.treesitter.query.get_indent()"` - **Trade-off:** You lose automatic parser installation. You must install parsers manually via your OS package manager (e.g., `tree-sitter-lua`) or compile them with `tree-sitter-cli`. **Option 2: Switch to a community fork** If a well-maintained community fork emerges, update the plugin spec in `init.lua`: ```lua { 'username/nvim-treesitter-fork', branch = 'main', build = ':TSUpdate' } ``` **Option 3: Keep using the archived plugin** There is no immediate need to change anything. The plugin will continue to work as long as the parsers compile and Neovim's treesitter API remains compatible. --- ## Settings | Option | Value | Description | |--------|-------|-------------| | `relativenumber` | `true` | Relative line numbers | | `number` | `true` | Absolute line number on current line | | `scrolloff` | `12` | Keep 12 lines visible above/below cursor | | `tabstop` / `shiftwidth` / `softtabstop` | `4` | 4-space indentation | | `expandtab` | `true` | Use spaces instead of tabs | | `mouse` | `a` | Enable mouse in all modes | | `termguicolors` | `true` | True color support | | `clipboard` | `unnamedplus` | Use system clipboard | | `signcolumn` | `yes` | Always show sign column | | `cursorline` | `true` | Highlight current line | | `splitright` / `splitbelow` | `true` | Split windows to right/bottom | | `undofile` | `true` | Persistent undo history | | `ignorecase` / `smartcase` | `true` | Case-insensitive search (unless uppercase used) | | `inccommand` | `split` | Live preview for `:s` substitutions | | `updatetime` | `250` | Faster completion and diagnostics | | `timeoutlen` | `300` | Faster which-key popup | | `showmode` | `false` | Hide mode indicator (shown in statusline) | --- ## Filetype-specific Settings ### `.tmpl` files HTML comment syntax (``) is used for comments in `.tmpl` template files. --- ## Installation / Setup 1. **Ensure dependencies are installed:** - Neovim 0.12+ (check with `nvim --version`) - `git` - `make` (for `telescope-fzf-native`) - A C compiler (`gcc` or `clang`) for building Treesitter parsers - A [Nerd Font](https://www.nerdfonts.com/) for icons (optional but recommended) 2. **Open Neovim:** ```bash nvim ``` 3. **Install plugins:** ```vim :Lazy sync ``` 4. **Install LSP servers and Treesitter parsers:** - LSP servers are installed automatically by Mason on first launch. - Treesitter parsers will compile on first startup (may take 10–30 seconds). 5. **Restart Neovim** after everything is installed. --- ## Troubleshooting ### Treesitter parsers failing to build Make sure you have a C compiler installed: ```bash # Ubuntu/Debian sudo apt install build-essential # macOS xcode-select --install # Arch sudo pacman -S base-devel ``` ### LSP server not found Check if the server is installed via Mason: ```vim :Mason ``` If missing, install it manually: ```vim :MasonInstall ``` ### Colors not showing correctly Ensure your terminal supports true color and you have a Nerd Font selected. --- ## File Structure ``` ~/.config/nvim/ ├── init.lua # Main configuration file (single file setup) ├── lazy-lock.json # Plugin version lockfile └── archive/ # Previous config iterations ``` --- ## Useful Commands | Command | Description | |---------|-------------| | `:Lazy` | Open lazy.nvim plugin manager UI | | `:Lazy sync` | Install/update all plugins | | `:Mason` | Open Mason LSP package manager | | `:TSUpdate` | Update all Treesitter parsers | | `:checkhealth` | Run Neovim health check | | `:LspInfo` | Show active LSP clients for current buffer | | `:LspRestart` | Restart LSP client for current buffer | | `:Telescope` | Open Telescope picker | | `:G` | Open Fugitive git status window | | `:Gdiffsplit` | Diff current file against index | | `:G blame` | Blame current file | | `:G log` | Git log | | `:G write` | Stage current file | | `:G read` | Checkout current file |