aboutsummaryrefslogtreecommitdiffstats

Overview

Features

The main goal of this config is being robust and as lightweight as possible. Nothing fancy, just minimum setup for ide-like(ish) experience.

Installation

Run checkhealth before cloning my setup

:checkhealth

Then clone this repo to your .config folder, open neovim and wait till installation is over.

git clone https://codeberg.org/philw/nvim ~/.config

After the installation it may require a restart so it can load colorscheme properly

Further development

After many years, this is the only text editor on my system, so I’ll be adding updates as long as I find something better(not gonna happen soon).

Documentation

Global Settings

Editor settings

  • nu = true: Show line numbers.
  • tabstop = 2: Set the width of a tab to 2 spaces.
  • softtabstop = 2: Number of spaces that a tab character counts for during editing.
  • shiftwidth = 2: Number of spaces to use for auto-indentation.
  • expandtab = true: Convert tabs to spaces.
  • smartindent = true: Automatically indent new lines based on the syntax.
  • ruler = false: Hide the ruler (status bar showing line and column position).
  • wrap = false: Disable line wrapping.
  • swapfile = false: Disable the creation of swap files.
  • hlsearch = false: Disable highlighting of search matches.
  • incsearch = true: Enable incremental search.
  • updatetime = 50: Set the update time for asynchronous operations like completions.
  • laststatus = 0: Hide the status line.
  • signcolumn = “number”: Display line numbers in the sign column.
  • autoindent = true: Enable automatic indentation.
  • clipboard = “unnamedplus”: Use the system clipboard for copy-pasting.
  • termguicolors = true: Enable 24-bit RGB color support in the terminal.
  • fillchars = “eob:”: Customize end-of-buffer character.
  • lazyredraw = false: Disable lazy redrawing for smoother experience.
  • timeoutlen = 500: Set timeout for key sequences to 500ms.
  • netrw_banner = 0: Disable Netrw banner.
  • netrw_liststyle = 3: Use a tree-style layout for Netrw.
  • netrw_altv = 0: Disable vertical splits for Netrw.
  • netrw_winsize = 25: Set Netrw window size.
  • netrw_browse_split = 4: Open Netrw in a horizontal split.
  • rustfmt_autosave = 1: Enable automatic formatting for Rust files using rustfmt.
  • mkdp_auto_start = 1: Automatically start Markdown Preview (for mkdp).
  • vimtex_view_method = “zathura”: Set PDF viewer to zathura for LaTeX files.
  • vimtex_compiler_method = “latexmk”: Use latexmk for compiling LaTeX files.
  • vimtex_quickfix_mode = 0: Disable quickfix window for VimTeX.
  • tex_conceal = “abdmg”: Enable automatic concealment of LaTeX formatting.
  • tex_flavor = “latex”: Set the flavor of TeX to LaTeX.
  • gitgutter_set_sign_backgrounds = 1: Enable background color for GitGutter signs.

Auto Commands and custom functions (api.nvim_create_autocmd)

Format on Save

  • Formats the buffer using vim.lsp.buf.format before saving any file.

Run Prettier and Compile LaTeX on Save

  • For JavaScript, TypeScript, CSS, HTML, YAML, Markdown, and JSON files, Prettier is run automatically after saving. Yes, I could use lsp features here but in my case this is the bulletproof setup.
  • For LaTeX files (*.tex), VimtexCompile is triggered upon saving to compile the document.(bugged af)

You can add anything you want. Just make sure it’s on your system.

Auto-delete Netrw Hidden Buffers

  • Automatically deletes hidden buffers when opening a Netrw window. This is quite helpful for the ToggleVExplorer function.

ToggleVExplorer

  • Toggles the VExplorer window in Neovim.
  • If the window is already open, it will be closed; if it is closed, it will be opened in the first window.

Plugin Management (require(“lazy”).setup)

The configuration uses Lazy.nvim for plugin management. I’ve tried them all. This works the best for me.

  • airblade/vim-gitgutter: Displays Git changes in the gutter (added, modified, deleted lines).
  • lervag/vimtex: Provides LaTeX support, including features like auto-compiling and PDF viewing.
  • norcalli/nvim-colorizer.lua: Highlights color codes in files.
  • nvim-treesitter/nvim-treesitter: Provides better syntax highlighting and tree-sitter integration.
  • neovim/nvim-lspconfig: Set up language servers for autocompletion and LSP features.
  • ms-jpq/coq_nvim: Provides autocompletion with COQ (a Neovim completion plugin).
  • nvim-telescope/telescope.nvim: A fuzzy finder plugin for file searching and navigation.
  • windwp/nvim-autopairs: Automatically closes pairs of parentheses, brackets, etc.

LSP (Language Server Protocol) Configuration

Rust Configuration (rust_analyzer)

  • Configures rust_analyzer with specific settings:
    • imports.granularity.group = “module”: Organizes imports by module.
    • cargo.buildScripts.enable = true: Enable build script support for Cargo.
    • procMacro.enable = true: Enable procedural macro support.

Each language server is set up using lspconfig, and the configuration is ensured with coq autocompletion.

Mason Setup

  • mason.nvim: Automatically installs LSP servers(currently just rust_analyzer) and other tools.

Key Mappings (keymap.set)

  • e: Toggle the VExplorer window.
  • z: Search and replace the word under the cursor in the entire buffer.
  • a: Select the entire buffer.
  • y: Replace the current line with cc (change the line).
  • : Yank the current line to the clipboard.
  • : Paste from the clipboard.
  • : Undo the last change.
  • J and K: Speed up moving the selected text block down or up in visual mode.
  • f: Open Telescope’s file finder.
  • g: Open Telescope’s live grep search.
  • d: Go to definition (LSP feature).
  • k: Show hover information (LSP feature).