179 lines
7.4 KiB
Markdown
179 lines
7.4 KiB
Markdown
# My Neovim configuration
|
|
|
|
## Motivation
|
|
|
|
After doing my first steps with <https://github.com/nvim-lua/kickstart.nvim>,
|
|
I decided to roll my own, custom, "lightweight" Neovim configuration in order to
|
|
better understand Neovim and its configuration/customization, package managers,
|
|
plugins etc. and have "my own" config that only includes things I really need.
|
|
|
|
## Installation
|
|
|
|
1. Install Neovim 0.9.x
|
|
1. Install OS dependencies documented in `init.lua`
|
|
1. Clone this Git repository to `~/.config/nvim`
|
|
|
|
### Finishing touches
|
|
|
|
- Install Treesitter comment parser (to highlight `FIXME:/NOTE:/TODO:/XXX:`)
|
|
with `:TSInstall comment`
|
|
- Create a `$HOME/.ignore` file and add big, useless directories to it, so
|
|
Telescope/ripgrep/fd can ignore those. My current list of files/directories is
|
|
available in `lua/weeheavy/plugins/telescope-fzf-native.lua`
|
|
|
|
## Speed
|
|
|
|
Output from lazy.nvim profiling (`:Lazy`, then `P`):
|
|
|
|
### Start and open init.lua
|
|
|
|
```bash
|
|
Startuptime: 71.69ms
|
|
|
|
Based on the actual CPU time of the Neovim process till UIEnter.
|
|
This is more accurate than `nvim --startuptime`.
|
|
LazyStart 10.92ms
|
|
LazyDone 40.71ms (+29.78ms)
|
|
UIEnter 71.69ms (+30.99ms)
|
|
```
|
|
|
|
### Starting with empty file
|
|
|
|
Around 50% of the plugins are lazy-loaded.
|
|
|
|
```bash
|
|
Startuptime: 46.94ms
|
|
|
|
Based on the actual CPU time of the Neovim process till UIEnter.
|
|
This is more accurate than `nvim --startuptime`.
|
|
LazyStart 10.59ms
|
|
LazyDone 40.6ms (+30.02ms)
|
|
UIEnter 46.94ms (+6.34ms)
|
|
```
|
|
|
|
## Plugins
|
|
|
|
| Name | Purpose | URL |
|
|
| ------------------------------- | ----------------------------------------------------------- | ---------------------------------------------------------------- |
|
|
| **lazy.nvim** | Package manager | <https://github.com/folke/lazy.nvim> |
|
|
| **telescope.nvim** | Find, Filter, Preview, Pick | <https://github.com/nvim-telescope/telescope.nvim> |
|
|
| **telescope-fzf-native.nvim** | Fuzzy finder for Telescope | <https://github.com/nvim-telescope/telescope-fzf-native.nvim> |
|
|
| **nvim-treesitter** | Parser/syntax highlighting | <https://github.com/nvim-treesitter/nvim-treesitter> |
|
|
| **nvim-treesitter-context** | Shows current line context | <https://github.com/nvim-treesitter/nvim-treesitter-context> |
|
|
| **nvim-treesitter-textobjects** | ? | <https://github.com/nvim-treesitter/nvim-treesitter-textobjects> |
|
|
| **nightfox.nvim** | Theme with treesitter/lsp support | <https://github.com/EdenEast/nightfox.nvim> |
|
|
| **tokyonight.nvim** | Theme with treesitter/lsp support | <https://github.com/folke/tokyonight.nvim> |
|
|
| **lualine.nvim** | Status line | <https://github.com/nvim-lualine/lualine.nvim> |
|
|
| **nvim-web-devicons** | filetype glyphs (icons) for plugins | <https://github.com/nvim-tree/nvim-web-devicons> |
|
|
| **gitsigns.nvim** | Git change indicator | <https://github.com/lewis6991/gitsigns.nvim> |
|
|
| **which-key.nvim** | Shows contextual key bindings | <https://github.com/folke/which-key.nvim> |
|
|
| **indent-blankline.nvim** | Visual indentation guide | <https://github.com/lukas-reineke/indent-blankline.nvim> |
|
|
| **vim-illuminate** | Highlight word under the cursor (w/ LSP, Treesitter, regex) | <https://github.com/RRethy/vim-illuminate> |
|
|
| **lsp-zero.nvim** | LSP for mere mortals | <https://github.com/VonHeikemen/lsp-zero.nvim> |
|
|
| **conform.nvim** | Black magic wizardry, replacement for `null-ls` | <https://github.com/stevearc/conform.nvim> |
|
|
|
|
## Looks
|
|
|
|
This is how it looks like:
|
|
|
|

|
|
|
|
## Command cheat sheet
|
|
|
|
### Neovim
|
|
|
|
Some of these are plain Vim commands, other specific to Neovim.
|
|
|
|
#### Basics
|
|
|
|
- `Space` is set as the leader key
|
|
|
|
#### Plugin things and debugging
|
|
|
|
- `:so` Source file
|
|
- `:checkhealth <pluginname>` check for problems of a plugin. Use `:checkhealth`
|
|
to check base and all plugins
|
|
- `:Lazy` to bring up package manager UI
|
|
- `:Mason` to show Mason UI
|
|
- `:verbose set expandtab?` check where `expandtab` has been set last
|
|
|
|
#### Navigation
|
|
|
|
##### Code navigation
|
|
|
|
- `w` move to **start of next word** (ignores punctuation due to remap)
|
|
- `e` move to **end of next word** (ignores punctuation due to remap)
|
|
- `b` move to **start of previous word** (ignores punctuation due to remap)
|
|
- `Ctrl`+`d` scroll **down** 1/2 page while keeping the cursor centered
|
|
- `Ctrl`+`u` scroll **up** 1/2 page while keeping the cursor centered
|
|
|
|
##### Code editing
|
|
|
|
- `leader`+`i` re-indent whole file
|
|
- `leader`+`o` re-format whole file or visual with `conform.nvim`
|
|
- `i` insert mode at cursor position
|
|
- `I` insert mode at the **beginning of the line**
|
|
- `a` insert mode **one character after the current** one
|
|
- `A` insert mode at the **end of the line**
|
|
- `o` insert mode a line **below** the cursor
|
|
- `O` insert mode a line **above** the cursor
|
|
- `s` delete character and replace (substitute) it
|
|
- `cw` replace the current word
|
|
- `yy` copy (yank) the current line
|
|
- `p` paste yanked line below
|
|
- `P` paste yanked line above
|
|
- `"3p` redo (put) e.g. your third last delete [source](https://www.reddit.com/r/neovim/comments/18ri1bm/its_been_like_10_years_and_i_just_learned_that/)
|
|
|
|
##### Visual mode
|
|
|
|
- `v` visual mode at cursor position
|
|
- `V` visual mode line mode
|
|
- `Ctrl`+`v` visual block mode
|
|
|
|
##### Tab navigation
|
|
|
|
(Don't use tabs by default, but use buffers instead).
|
|
|
|
- `Ctrl`+`t` to open a file in e.g. a Telescope finder in a new tab
|
|
- `gt` or `gT` to switch between open tabs
|
|
|
|
##### Window navigation
|
|
|
|
- `Ctrl`+`wq` close window
|
|
- `Ctrl`+`ws` split window **horizontally**
|
|
- `Ctrl`+`wv` split window **vertically**
|
|
- `Ctrl`+`<h/j/k/l>` move between split windows
|
|
- `Ctrl`+`w=` equalize split window width and height
|
|
|
|
##### Buffer navigation
|
|
|
|
- `Space`+`Space` shows open buffers (via `Telescope buffers`)
|
|
- `:bd` close current buffer
|
|
|
|
### Telescope
|
|
|
|
#### Navigation in live_grep, find_files, git_status and file_browser
|
|
|
|
- `↓` or `Ctrl`+`n` scroll down (**n**ext) file list
|
|
- `↑` or `Ctrl`+`p` scroll up (**p**revious) file list
|
|
- `Ctrl`+`d` scroll **d**own in preview
|
|
- `Ctrl`+`u` scroll **u**p in preview
|
|
- `Ctrl`+`/` help
|
|
- `Ctrl`+`v` open file in **vertical** split
|
|
- `Ctrl`+`x` open file in **horizontal** split
|
|
|
|
### Treesitter
|
|
|
|
- `:TSUpdate` update all parsers
|
|
- `:TSModuleInfo` show installed parsers
|
|
|
|
### LSP
|
|
|
|
- `LspInfo` show attached LSP client info
|
|
|
|
## Open issues/TODOs
|
|
|
|
- ollama integration <https://github.com/nomnivore/ollama.nvim>
|
|
- Solution to run file_browser when doing a vertical/horizontal split?
|
|
- <https://github.com/folke/trouble.nvim>
|
|
- Implement linting, see <https://www.josean.com/posts/neovim-linting-and-formatting>
|