2022-10-05 19:22:26 +00:00
# My personal nvim configuration
I made this public so I can easily clone without authentication,
but since I treat this as a personal use only stuff,
there can be some(read "a lot of") messy stuff.
2022-10-19 13:11:04 +00:00
2022-10-05 19:22:26 +00:00
Much of this might have been selectively copy pasted from plugin repos.
Those repos are obviously listed in plugin setup part.
2022-10-14 07:09:25 +00:00
# Basic usage of this config
2022-10-14 07:08:35 +00:00
### First Time Setup
Installing system stuff (Fedora example):
```bash
sudo dnf install \
2022-11-12 11:54:14 +00:00
python3-pip \
2022-10-14 07:08:35 +00:00
neovim \
ripgrep \
fd-find \
2022-10-29 17:54:28 +00:00
npm \
2022-10-14 07:08:35 +00:00
tree-sitter-cli \
2022-10-19 13:11:04 +00:00
wl-clipboard \
2022-11-12 11:54:14 +00:00
dejavu-fonts-all \
2022-12-21 13:25:50 +00:00
gnu-free-mono-fonts \
clang \
perl-App-cpanminus # optional, allow perlnavigator lsp working properly
2022-10-14 07:08:35 +00:00
2022-12-21 13:25:50 +00:00
pip install pynvim
2022-10-19 13:11:04 +00:00
2022-12-21 13:25:50 +00:00
git clone --depth 1 https://github.com/wbthomason/packer.nvim\
~/.local/share/nvim/site/pack/packer/start/packer.nvim
2022-10-14 07:08:35 +00:00
```
2022-11-12 11:54:14 +00:00
#####
2022-10-14 07:08:35 +00:00
##### Inside vim
```
2022-12-21 13:25:50 +00:00
:PackerInstall
:PackerSync
2022-11-12 11:54:14 +00:00
# installing packages, which mason-lspconfig cannot autoinstall (?)
:MasonInstall phpcs
2022-12-21 13:25:50 +00:00
# tree-sitter setup
:TSInstall html dockerfile cpp css markdown c gitcommit bash phpdoc comment python http php regex json5 lua gitattributes gitignore json git_rebase javascript perl sql yaml
2022-10-14 07:08:35 +00:00
```
2022-10-29 17:54:28 +00:00
On Fedora there is need to make sure your system can display any unicode character. Hacked fonts are needed for filetype icons but there is also need for a dedicated package with unicode fonts (like unifont-fonts.noarch) that will have every character missing from default font used in Neovim editor. Link to hacked fonts:
2022-10-14 07:08:35 +00:00
[https://www.nerdfonts.com/font-downloads ](https://www.nerdfonts.com/font-downloads )
2022-11-12 11:54:14 +00:00
#### General info
##### Mason:
Mason installs stuff in `.local/share/nvim/mason/packages` so they are independent from system stuff, like pip installed python packages.
2022-10-14 07:08:35 +00:00
### Usage
2022-11-12 11:54:14 +00:00
##### root perms when editing
```bash
# Re-open a current file with sudo
:SudaRead
# Open /etc/sudoers with sudo
:SudaRead /etc/sudoers
```
```bash
# Forcedly save a current file with sudo
:SudaWrite
# Write contents to /etc/profile
:SudaWrite /etc/profile
```
2022-10-14 07:08:35 +00:00
##### Opened files navigation:
2022-10-29 17:54:28 +00:00
< table border = "1" id = "bkmrk-ctrl-w-%3Carrow%3E-movin" style = "border-collapse: collapse; width: 100%; height: 506.6px;" > < colgroup > < col style = "width: 50%;" > < / col > < col style = "width: 50%;" > < / col > < / colgroup > < tbody > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> m m
< / td > < td style = "height: 29.8px;" > open minimap
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> m c
< / td > < td style = "height: 29.8px;" > close minimap
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> m f
< / td > < td style = "height: 29.8px;" > focus minimap
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl w w
< / td > < td style = "height: 29.8px;" > Move to next splitted frame
2022-10-14 07:08:35 +00:00
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl w < arrow>
< / td > < td style = "height: 29.8px;" > moving throught splitted frame
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl w c
< / td > < td style = "height: 29.8px;" > close split< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl w v
< / td > < td style = "height: 29.8px;" > split vertically
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl w s
< / td > < td style = "height: 29.8px;" > split horizontally
2022-10-29 17:54:28 +00:00
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl w x
< / td > < td style = "height: 29.8px;" > swap places of two splits
2022-10-14 07:08:35 +00:00
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > gt< / td > < td style = "height: 29.8px;" > next tab< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > gT
< / td > < td style = "height: 29.8px;" > previous tab
2022-10-29 17:54:28 +00:00
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > :tabnew
< / td > < td style = "height: 29.8px;" > Create new tab
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl+g Ctrl+t
< / td > < td style = "height: 29.8px;" > (when in file tree) open selected file in new tab
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > :bd
< / td > < td style = "height: 29.8px;" > close buffer
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > :bnext
< / td > < td style = "height: 29.8px;" > next buffer
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > :b3
< / td > < td style = "height: 29.8px;" > switch to buffer 3
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > :buffers
< / td > < td style = "height: 29.8px;" > list buffers and their numbers
2022-10-14 07:08:35 +00:00
< / td > < / tr > < / tbody > < / table >
##### File explorer:
2022-10-19 13:11:04 +00:00
< table border = "1" id = "bkmrk-ctrl%2Bt-toggle-file-e" style = "border-collapse: collapse; width: 100%; height: 327.8px;" > < colgroup > < col style = "width: 50%;" > < / col > < col style = "width: 50%;" > < / col > < / colgroup > < tbody > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl+t
2022-10-14 07:08:35 +00:00
< / td > < td style = "height: 29.8px;" > Toggle file explorer when not focused on it
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > f
< / td > < td style = "height: 29.8px;" > Toggle filtering when focused on explorer
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> n
< / td > < td style = "height: 29.8px;" > Move focus to explorer
2022-10-19 13:11:04 +00:00
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > d
< / td > < td style = "height: 29.8px;" > Delete selected file
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > rn
< / td > < td style = "height: 29.8px;" > Rename file
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > c
< / td > < td style = "height: 29.8px;" > add file to clipboard
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > p
< / td > < td style = "height: 29.8px;" > paste (file) from clipboard
2022-10-14 07:08:35 +00:00
< / td > < / tr > < / tbody > < / table >
##### File searching / Telescope
< table border = "1" id = "bkmrk-%3Cleader%3Eff-find-file" style = "border-collapse: collapse; width: 100%;" > < colgroup > < col style = "width: 50%;" > < / col > < col style = "width: 50%;" > < / col > < / colgroup > < tbody > < tr > < td > < leader> ff< / td > < td > Find files
< / td > < / tr > < tr > < td > < leader> fg< / td > < td > Live grep
< / td > < / tr > < tr > < td > < leader> fb< / td > < td > Buffers
2022-10-19 13:11:04 +00:00
< / td > < / tr > < tr > < td > < leader> fh< / td > < td > Help tags< / td > < / tr > < tr > < td > Ctrl+q< / td > < td > Open search result list as a dedicated split (quickfix list) (will overwrite previous one created this way in current tab)< / td > < / tr > < tr > < td > Ctrl+u
< / td > < td > Scroll preview up
< / td > < / tr > < tr > < td > Ctrl+d
< / td > < td > Scroll preview down
< / td > < / tr > < tr > < td > Ctrl+x
< / td > < td > Open selection as a split
< / td > < / tr > < tr > < td > Ctrl+v
< / td > < td > Open selection as a vsplit
< / td > < / tr > < tr > < td > Ctrl+t
< / td > < td > Open selection in new tab
< / td > < / tr > < / tbody > < / table >
2022-10-14 07:08:35 +00:00
##### Git stuff
2022-11-12 11:54:14 +00:00
< table border = "1" id = "bkmrk-ctrl%2Bs-show-current-" style = "border-collapse: collapse; width: 100%; height: 208.6px;" > < colgroup > < col style = "width: 50%;" > < / col > < col style = "width: 50%;" > < / col > < / colgroup > < tbody > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl+g
< / td > < td style = "height: 29.8px;" > show current code chunk changes< / td > < / tr > < tr > < td > < leader> hb
2022-12-21 13:25:50 +00:00
< / td > < td > show full git blame of current line (double use to enter displayed diff)
< / td > < / tr > < tr > < td > < leader> hD< / td > < td > show splitted blame diff (double use to enter displayed diff)
2022-11-12 11:54:14 +00:00
< / td > < / tr > < tr > < td > < leader> hd< / td > < td > show splitted diff< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> hr
< / td > < td style = "height: 29.8px;" > reset hunk
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> hR< / td > < td style = "height: 29.8px;" > reset whole buffer
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> td< / td > < td style = "height: 29.8px;" > toggle deleted
< / td > < / tr > < / tbody > < / table >
2022-10-14 07:08:35 +00:00
Genreal git commands:
```bash
:Git < command >
2022-10-19 13:11:04 +00:00
#Commands with dedicated display
:Git # show nice interactive summary of whole git project state
:Git mergetool, :Git difftool # load their changesets into the quickfix list
2022-10-14 07:08:35 +00:00
:Git blame # this will nicely show \
# for every line in separate split
2022-10-19 13:11:04 +00:00
# Useful shortcuts for blame mode:
# o - jump to patch or blob in horizontal split
# A, C, D - different display (lenght) modes
# g? - other keybindings
#other examples:
2022-10-14 07:08:35 +00:00
:Git add .
2022-10-19 13:11:04 +00:00
:Git commit
2022-10-14 07:08:35 +00:00
```
Nice single file diff viewer:
```
:Gdiffsplit
```
2022-11-12 11:54:14 +00:00
GitSings provides some commands for displaying git stuff:
2022-10-14 07:08:35 +00:00
```bash
2022-11-12 11:54:14 +00:00
:Gitsigns *
2022-10-14 07:08:35 +00:00
#examples:
2022-11-12 11:54:14 +00:00
:Gitsigns toggle_word_diff
:Gitsigns toggle_linehl
:Gitsigns toggle_numhl
:Gitsigns toggle_signs
2022-10-14 07:08:35 +00:00
```
2022-10-19 13:11:04 +00:00
##### Code editing stuff
2022-10-14 07:08:35 +00:00
2022-10-19 13:11:04 +00:00
< table border = "1" id = "bkmrk-%3Cleader%3Ern-rename-el" style = "border-collapse: collapse; width: 100%; height: 387.4px;" > < colgroup > < col style = "width: 50%;" > < / col > < col style = "width: 50%;" > < / col > < / colgroup > < tbody > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > w
< / td > < td style = "height: 29.8px;" > jump forward by one word
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > b
< / td > < td style = "height: 29.8px;" > jump backward by one word
2022-10-14 07:08:35 +00:00
</ td ></ tr >< tr style = "height: 29.8px;" >< td style = "height: 29.8px;" > :%s/^original.\*/replacement/gc
< / td > < td style = "height: 29.8px;" > regex replacing (c is for choice prompt, its optional)
2022-10-19 13:11:04 +00:00
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl+q
2022-10-29 17:54:28 +00:00
< / td > < td style = "height: 29.8px;" > Visual block select mode
< / td > < / tr > < / tbody > < / table >
##### LSP usage
< table border = "1" id = "bkmrk-%3Cspace%3Eq-open-list-w" style = "border-collapse: collapse; width: 100%; height: 476.8px;" > < colgroup > < col style = "width: 50%;" > < / col > < col style = "width: 50%;" > < / col > < / colgroup > < tbody > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < space> q
< / td > < td style = "height: 29.8px;" > open list with diagnostics postions
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < space> e
< / td > < td style = "height: 29.8px;" > open diagnostics floating window
</ td ></ tr >< tr style = "height: 29.8px;" >< td style = "height: 29.8px;" > \[d
< / td > < td style = "height: 29.8px;" > next diagnostic
</ td ></ tr >< tr style = "height: 29.8px;" >< td style = "height: 29.8px;" > \]
< / td > < td style = "height: 29.8px;" > previous diagnostic
< / td > < / tr > < tr > < td > < leader> k
< / td > < td > open hoover box and enter it
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> rn< / td > < td style = "height: 29.8px;" > rename element (function name, etc):< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> f< / td > < td style = "height: 29.8px;" > format file
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > gd< / td > < td style = "height: 29.8px;" > go to definition< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > gD< / td > < td style = "height: 29.8px;" > go to declaration< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < space> D< / td > < td style = "height: 29.8px;" > go to type definition< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > gi< / td > < td style = "height: 29.8px;" > go to implementation< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > gr< / td > < td style = "height: 29.8px;" > go to references< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl+f< / td > < td style = "height: 29.8px;" > scroll down popup with docstring< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > Ctrl+b< / td > < td style = "height: 29.8px;" > scroll up popup with docstring< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> wa
< / td > < td style = "height: 29.8px;" > add workspace folder< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> wr
< / td > < td style = "height: 29.8px;" > remove workspace folder
< / td > < / tr > < tr style = "height: 29.8px;" > < td style = "height: 29.8px;" > < leader> wl
< / td > < td style = "height: 29.8px;" > list workspace folders
2022-10-14 07:08:35 +00:00
< / td > < / tr > < / tbody > < / table >
2022-10-29 17:54:28 +00:00
#####
2022-10-14 07:08:35 +00:00
##### Sessions
To save **new** session on specific path, just use `:SaveSession` , then when opening nvim there, without arguments, the session will be restored.