Skip to content

Error10556/nvim-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neovim is COOKING 🔥🔥🔥

This repo is a minimalistic yet capable configuration for Neovim.

If you are updating from an earlier version of this config, reinstall treesitter in case it gives an error! Type :Lazy, press x on nvim-treesitter to remove it, and then press I to install it again.

Who is it for?

If you program in C++ or Python, you are going to enjoy the advanced debugging support provided by this configuration. Especially if you do competitive programming.

However, this configuration provides LSP support for many languages.

How to install

  1. Install one of these fonts: https://www.nerdfonts.com/font-downloads. That is, put the font files into a new subdirectory of /usr/share/fonts/truetype/ and run fc-cache.
  2. Install ripgrep, xclip, tar, curl, python3-venv, and unzip.
  3. Install tree-sitter-cli of version 0.26.1 or later. If you use Ubuntu or another distro where this package is outdated, install it with cargo:
# Install Rust - skip next 2 lines if already installed
wget --timeout=5 https://sh.rustup.rs -O rustup.sh  # get the rust installer
sh rustup.sh  # install Rust
cargo install tree-sitter-cli
  1. Change directory into ~/.config/nvim. Clear the directory if it contains files or subdirectories.
  2. Clone this repo: git clone https://github.com/Error10556/nvim-config.git . --depth=1
  3. Optionally, install language servers, formatters, linters, or debug adapters: open up nvim, type :Mason, and pick what you like. For a smooth experience, use
    • clangd for C/C++ (installed by default)
    • debugpy for Python debugging (but installed as a system-wide package python3-debugpy)
    • codelldb for C/C++ debugging
    • lua-language-server for Lua
    • basedpyright for Python (installed by default)
    • gopls for Golang

How to use

The configuration makes several remaps (custom bindings) and creates a few user commands.

General

  • Ctrl + E: open Neovim's default file explorer, netrw.
  • Space, S: replace all occurrences of the word under the caret.
  • Space, O: when used on an empty line, insert two empty lines (one above, one below) and start editing the middle one.
  • Space, [: insert a pair of square brackets and start editing an empty line between them.
  • Space, { (which is Space, Shift + [): insert a pair of curly braces and start editing an empty line between them.
  • Space, Space, [: insert a pair of square brackets with a space before the left bracket and start editing an empty line between them.
  • Space, Space, { (which is Space, Space, Shift + [): insert a pair of curly braces with a space before the left brace and start editing an empty line between them.
  • Space, A: copy all the text in the file into the clipboard.
  • (In visual mode) Shift + J: move the selected lines down.
  • (In visual mode) Shift + K: move the selected lines up.
  • (In visual mode) Space, D: delete the selected text without copying it into the default buffer.
  • :Theme: quickly switch between light and dark themes.

Language Server Settings

  • Shift + K: see information about the object under the caret.
  • G, D: go to the definition.
  • G, Shift + D: go to the declaration.
  • G, I: go to the implementation.
  • G, O: go to the type definition.
  • G, R: see all references.
  • G, S: get help on the function signature.
  • G, L: see the diagnostic messages (errors, warnings, hints, and information) on this line.
  • F2: rename the object under the caret.
  • F4: choose one of the suggested code actions (e.g. to resolve an error).
  • [, d: go to the previous problematic line.
  • ], d: go to the next problematic line.
  • Space, =: format the file using the LSP.
  • :Clangfmt: add a .clang-format file to the current working directory that contains Microsoft-style C++ formatting settings.
  • Ctrl + Space: bring up the autocompletion menu if it is not already open.

In the autocompletion menu:

  • : select the previous option.
  • : select the next option.
  • Ctrl + U: scroll the documentation upwards.
  • Ctrl + D: scroll the documentation downwards.
  • Tab or Enter: select the current option. If no option is selected, Tab selects the first one, and Enter inserts a newline.

After selecting a snippet:

  • Ctrl + L: edit the next placeholder.
  • Ctrl + K: edit the previous placeholder.

Running simple non-interactive programs

  • Space, Z: execute ./run-current-program.sh "(your file)" in Neovim's terminal

My quick-and-dirty run-current-program.sh for Haskell:

#!/bin/env bash
set -e
if [ ! -f prog ] || [ "$(date --reference=prog +%s)" -lt "$(date --reference="$1" +%s)" ]; then
    ghc -o prog "$1"
fi
echo
./prog

For C++ you could have:

#!/bin/env bash
set -e
if [ ! -f prog ] || [ "$(date --reference=prog +%s)" -lt "$(date --reference="$1" +%s)" ]; then
    g++ "$1" -o prog
fi
echo
./prog

For Python:

#!/bin/env bash
echo
python "$1"

Debugging

  • Space, D: open or close the debugging interface.
  • Space, T: open or close the task log (possible tasks are Build, Build with a different compiler, Clean, etc.).
  • Space, R: run a task (possible tasks are Build, Build with a different compiler, Clean, etc.).
  • F5: compile and launch the program.
  • F9: add or remove a breakpoint.
  • Shift + F9: add a conditional breakpoint.
  • :Codeforces: add a .vscode settings directory to the current working directory with debugger settings convenient to use with competitive programming problems.

When a program is running:

  • F1: see the value of a variable under the caret.
  • F5: resume running.
  • F6: run the program to the cursor.
  • F7: terminate the program execution.
  • F10: step over (execute the current line and move to the next one).
  • F11: step into (descend into the function called on this line).
  • F12: step out (run the program until the current function returns).
  • Space, P, S: see all variables in all scopes.

Searching

  • Space, F, F: search file names.
  • Space, F, G: search file names in the Git repository, if it is initialized.
  • :RG: search file contents.

Custom colorscheme

Do not like melange? Want to add custom keybindings? Write your own options to ~/.config/nvim/lua/conf/custom.lua. This file will be loaded last. If it does not exist, the melange colorscheme gets applied.

Example of custom.lua:

vim.cmd[[colorscheme koehler]]

Credits

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages