Skip to content

Neovim

This is my Neovim config README.md file.

It takes a lot of time to configure Neovim from scratch, I am currently enjoying using AstronNvim LazyVim which comes with a lot of functionality.

LazyVim

Fundamentals

Learn how to:

  • Change Configuration
  • Disable plugins
  • Add plugins and other things listed in the documentation.

Programming in LazyVim

LSP key bindings

  • K: Keyword documentation under cursor
  • gK: Signature help
  • gd: Go to definition
  • gD: Go to declaration
  • <leader>ca: Code action

Configuration

Too much stuff in the left columns. Signcolumn, Statuscolumn. mini.indentscope creates distracting animations.

Getting rid of things to the left of the text

  • Disable gitsigns
  • Disable statuscolumn: :set stc=
  • Disable signscolumn: :set signscolumn=no

Installing (Windows)

In Powershell, install packer with: git clone https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\start\packer.nvim"

Clone the repo into ~\AppData\Local\nvim:

  • gh repo clone jmn/nvim-config nvim

Open the file nvim\lua\plug.lua and execute it with:

  • :luafile %

Then run PackerSync:

  • :PackerSync

Partially baked from:

Then restart nvim.

Installing extras

Fonts

Install nerdfont: Hack-NF and configure terminal to use it.

1
scoop bucket add nerd-fonts
2
scoop install sudo
3
sudo scoop install -g Hack-NF

In Terminal, Right click tab, choose:

  • Settings -> Profiles -> Command Prompt -> Appearance -> Text -> Font Face

Other good fonts include, jetbrainsmono-nf.

Configure Windows Terminal to open tabs in the same directory

1
set PROMPT=$e]9;9;$P$e\%PROMPT%
2
setx PROMPT "%PROMPT%"

Ripgrep

Telescope grep uses rg (ripgrep). Install it using:

  • scoop install ripgrep

Comment.nvim

  • important keystrokes: gcc in normal mode, gc in visual mode.

🔥 Usage

When you call setup() method, Comment.nvim sets up some basic mapping which can used in NORMAL and VISUAL mode to get you started with the pleasure of commenting stuff out.

Basic mappings

These mappings are enabled by default. (config: mappings.basic)

  • NORMAL mode
1
help
2
`gcc` - Toggles the current line using linewise comment
3
`gbc` - Toggles the current line using blockwise comment
4
`[count]gcc` - Toggles the number of line given as a prefix-count using linewise
5
`[count]gbc` - Toggles the number of line given as a prefix-count using blockwise
6
`gc[count]{motion}` - (Op-pending) Toggles the region using linewise comment
7
`gb[count]{motion}` - (Op-pending) Toggles the region using blockwise comment
  • VISUAL mode
1
help
2
`gc` - Toggles the region using linewise comment
3
`gb` - Toggles the region using blockwise comment

#### Extra mappings These mappings are enabled by default. (config: mappings.extra)

  • NORMAL mode
1
help
2
`gco` - Insert comment to the next line and enters INSERT mode
3
`gcO` - Insert comment to the previous line and enters INSERT mode
4
`gcA` - Insert comment to end of the current line and enters INSERT mode
Examples
1
help
2
# Linewise
3
4
`gcw` - Toggle from the current cursor position to the next word
5
`gc$` - Toggle from the current cursor position to the end of line
6
`gc}` - Toggle until the next blank line
7
`gc5j` - Toggle 5 lines after the current cursor position
8
`gc8k` - Toggle 8 lines before the current cursor position
9
`gcip` - Toggle inside of paragraph
10
`gca}` - Toggle around curly brackets
11
12
# Blockwise
13
14
`gb2}` - Toggle until the 2 next blank line
15
`gbaf` - Toggle comment around a function (w/ LSP/treesitter support)
16
`gbac` - Toggle comment around a class (w/ LSP/treesitter support)

Folding

  • Important Key: z.
  • Examples: z-o (open fold), z-c (close fold)

Folding Markdown

  • Folding via tree-sitter sexp can work to some extent in markdown mode.

Moving in windows

C-w +,

  • o - only
  • j - navigate to window below
  • k - navigate to window above.
  • s - split

Yank (Copy) the entire buffer to system clipboard

use ggVGY to yank the entire buffer to the system clipboard. Afterwards you can use C-o to get back to where you were.

Another idea could be to use :%y to yank the buffer.