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 cursorgK
: Signature helpgd
: Go to definitiongD
: 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.
1scoop bucket add nerd-fonts2scoop install sudo3sudo 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
1set PROMPT=$e]9;9;$P$e\%PROMPT%2setx 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
1help2`gcc` - Toggles the current line using linewise comment3`gbc` - Toggles the current line using blockwise comment4`[count]gcc` - Toggles the number of line given as a prefix-count using linewise5`[count]gbc` - Toggles the number of line given as a prefix-count using blockwise6`gc[count]{motion}` - (Op-pending) Toggles the region using linewise comment7`gb[count]{motion}` - (Op-pending) Toggles the region using blockwise comment
- VISUAL mode
1help2`gc` - Toggles the region using linewise comment3`gb` - Toggles the region using blockwise comment
#### Extra mappings
These mappings are enabled by default. (config: mappings.extra
)
- NORMAL mode
1help2`gco` - Insert comment to the next line and enters INSERT mode3`gcO` - Insert comment to the previous line and enters INSERT mode4`gcA` - Insert comment to end of the current line and enters INSERT mode
Examples
1help2# Linewise3
4`gcw` - Toggle from the current cursor position to the next word5`gc$` - Toggle from the current cursor position to the end of line6`gc}` - Toggle until the next blank line7`gc5j` - Toggle 5 lines after the current cursor position8`gc8k` - Toggle 8 lines before the current cursor position9`gcip` - Toggle inside of paragraph10`gca}` - Toggle around curly brackets11
12# Blockwise13
14`gb2}` - Toggle until the 2 next blank line15`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.
Links
- https://essais.co/better-folding-in-neovim/
- https://alpha2phi.medium.com/neovim-for-beginners-code-folding-7574925412
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.
Running shell commands from Neovim
:map <F5> :!odin run . <enter>