nvim/README.md

201 lines
8.4 KiB
Markdown
Raw Normal View History

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
Repo: [https://github.com/Szwendacz99/nvim](https://github.com/Szwendacz99/nvim)
### First Time Setup
Installing system stuff (Fedora example):
```bash
sudo dnf install \
neovim \
ripgrep \
fd-find \
nodejs-bash-language-server \
tree-sitter-cli \
2022-10-19 13:11:04 +00:00
wl-clipboard \
unifont-fonts.noarch
2022-10-14 07:08:35 +00:00
pip install \
pynvim \
'pylama[all]' \
flake8 \
jedi \
bandit \
yapf \
rope
2022-10-19 13:11:04 +00:00
2022-10-14 07:08:35 +00:00
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
```
2022-10-19 13:11:04 +00:00
#####
2022-10-14 07:08:35 +00:00
##### Inside vim
```
:PlugInstall
:CocInstall coc-git coc-pyright coc-sh coc-json coc-css coc-tsserver coc-eslint coc-prettier coc-snippets coc-yaml
```
2022-10-19 13:11:04 +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 gacked fonts:
2022-10-14 07:08:35 +00:00
[https://www.nerdfonts.com/font-downloads](https://www.nerdfonts.com/font-downloads)
2022-10-19 13:11:04 +00:00
##### Optional stuff
perl very basic lsp server:
```bash
# Install perl module manager
sudo dnf install perl-App-cpanminus
# install language server module
sudo cpanm PLS
```
2022-10-14 07:08:35 +00:00
### Usage
##### Opened files navigation:
2022-10-19 13:11:04 +00:00
<table border="1" id="bkmrk-ctrl-w-%3Carrow%3E-movin" style="border-collapse: collapse; width: 100%; height: 178.8px;"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><tbody><tr><td>&lt;leader&gt; m m
</td><td>open minimap
</td></tr><tr><td>&lt;leader&gt; m c
</td><td>close minimap
</td></tr><tr><td>&lt;leader&gt; m f
</td><td>focus minimap
</td></tr><tr><td>Ctrl w w
2022-10-14 07:08:35 +00:00
</td><td>Move to next splitted frame
</td></tr><tr style="height: 29.8px;"><td style="height: 29.8px;">Ctrl w &lt;arrow&gt;
</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
</td></tr><tr><td>Ctrl w x
</td><td>swap places of two splits
</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
</td></tr><tr><td>:tabnew
</td><td>Create new tab
</td></tr><tr><td>Ctrl g t
</td><td>(when in file tree) open selected file in new tab
</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;">&lt;leader&gt; 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>&lt;leader&gt;ff</td><td>Find files
</td></tr><tr><td>&lt;leader&gt;fg</td><td>Live grep
</td></tr><tr><td>&lt;leader&gt;fb</td><td>Buffers
2022-10-19 13:11:04 +00:00
</td></tr><tr><td>&lt;leader&gt;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
<table border="1" id="bkmrk-ctrl%2Bs-show-current-" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><tbody><tr><td>Ctrl+g
</td><td>show current code chunk changes</td></tr></tbody></table>
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
```
coc-git provides some commands for git:
```bash
:CocCommand git.<command>
#examples:
:CocCommand git.chunkUndo
:CocCommand git.showCommit
:CocCommand git.showBlameDoc
```
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
</td></tr><tr style="height: 29.8px;"><td style="height: 29.8px;">&lt;leader&gt;rn</td><td style="height: 29.8px;">rename element (function name, etc):</td></tr><tr style="height: 29.8px;"><td style="height: 29.8px;">&lt;leader&gt;ft</td><td style="height: 29.8px;">format code
2022-10-14 07:08:35 +00:00
</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;">gy
</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;">:%s/^original.\*/replacement/gc
</td><td style="height: 29.8px;">regex replacing (c is for choice prompt, its optional)
</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;">ZZ
</td><td style="height: 29.8px;">same as :wq
2022-10-19 13:11:04 +00:00
</td></tr><tr style="height: 29.8px;"><td style="height: 29.8px;">Ctrl+q
</td><td style="height: 29.8px;">Visual block mode
2022-10-14 07:08:35 +00:00
</td></tr></tbody></table>
##### Sessions
To save **new** session on specific path, just use `:SaveSession`, then when opening nvim there, without arguments, the session will be restored.