Code Monkey home page Code Monkey logo

nvimdots's Introduction

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Structure
  4. Plugins
  5. Keybindings
  6. Issues
  7. Credit
  8. TODO

Introduction

Dashboard

Telescope

Coding

Gitui

This is my neovim's configuration, which contains four branch.

I use packer.nvim to manage plugins.

Branch Completion Solution
main nvim-lspconfig+nvim-cmp
coq nvim-lspconfig+coq_nvim
coc coc.nvim

Chinese introduction is here.

Pros:

  • Fast. Less than 50ms to start(Depends on SSD, tested on Sumsung 970 evo).
  • Simple. Run out of the box.
  • Modern. Pure lua to config.
  • Modular. Easy to customize.
  • Powerful. Full functionality to code.

startup_with_light

startup_with_dark

(Tested with rhysd/vim-startuptime)

Prerequisites

  1. Neovim base installation for archlinux
# gitui required by tui git operations
# ripgrep required by telescope word search engine
# ripgrep required by telescope-zoxide
# sqlite required by telescope-frecency
# fd required by telescope file search engine
# yarn required by markdown preview
# nerd-fonts-ibm-plex-mono required by devicons
sudo pacman -S git gitui zoxide ripgrep sqlite fd yarn nerd-fonts-ibm-plex-mono

# nodejs, neovim-git required by copilot.
# neovim version >= 0.6
yay -S nodejs neovim-git

# for neovim python module
pip install neovim --user

# clone
git clone https://github.com/ayamir/nvimdots ~/.config/nvim

# sync plugins(maybe need multiple times)
nvim +PackerSync
  1. Recommended Terminals:

    alacritty, kitty, wezterm

sudo pacman -S alacritty kitty wezterm
  1. Recommended GUI applications:

    neovide, goneovim

paru neovide
paru goneovim
  1. Tools for plugins

The default html server has bug which does not support embeded javascript completion. So you need to install another server manually.

npm i -g vscode-html-languageserver-bin
  • For nvim-treesitter, all maintained parser will be installed by default.

  • For format.nvim, you need to install corresponding formatter manually:

# clangformat for c/cpp etc
sudo pacman -S clang
# gofmt and goimports for golang
go get -u golang.org/x/tools/...
# lua-format for lua
paru -S lua-format-git
# yapf and autopep8 for python
pip install autopep8 yapf --user
# rustfmt
sudo pacman -S rustup
# on the stable toolchain
rustup component add rustfmt
# on the nightly toolchain
rustup component add rustfmt --toolchain nightly
# prettier for markdown/html etc
sudo pacman -S prettier
# jq for json
sudo pacman -S jq
# shfmt for shell
sudo pacman -S shfmt

Structure

init.lua is the kernel config file. It requires configuration in lua directory.

  • lua directory contains 3 parts.

    • core directory contains base configuration of neovim.

    • keymap directory contains keybindings of plugins.

    • modules directory contains 5 parts.

      • completion directory contains code completion's configuration.

      • editor directory contains plugins' configuration about editing.

      • lang directory contains plugins' configuration about specific language.

      • tools directory contains telescope and its extensions' configuration.

      • ui directory contains plugins' configuration about ui.

How to customize

  • Add plugin

    1. Determine this plugin belongs to what kind(completion, editor, lang, tools, ui).

    2. Add a list item in corresponding plugins.lua.

      For example, I want to add rmagatti/auto-session to editor category.

      Then I need to modify lua/modules/editor/plugins.lua:

      add_plugin

      (You should learn how to use packer.nvim install and configure plugin on your own)

      I also need to modify lua/modules/editor/config.lua:

      add_config

      Then press <leader>ps:

      packer_sync

      Then try its command: SaveSession

      sync_success1

      Then restart nvim and execute RestoreSession.

      sync_success2

      So this plugin is added successfully!

  • Remove plugin

    1. Determine this plugin belongs to what kind(completion, editor, lang, tools, ui).

    2. Remove its config located in corresponding plugins.lua and config.lua.

    3. Remove corresponding keymap if exists.

    4. Press <leader>ps to recompile.

  • Modify keymap

    • For vanilla nvim's keymap

      modify lua/core/mapping.lua

    • For specific plugin's keymap

      modify lua/keymap/init.lua

  • Modify event defined by autocmd

    modify lua/core/event.lua

  • Modify vanilla nvim's options

    modify lua/core/options.lua

  • Switch light/dark theme(if you use edge theme)

# To light
    sed -i "s/\=dark/\=light/g" ~/.config/nvim/lua/modules/ui/config.lua
    sed -i "s/onedark/onelight/g" ~/.config/nvim/lua/modules/ui/config.lua
    nvim +PackerSync
# To Dark
    sed -i "s/\=light/\=dark/g" ~/.config/nvim/lua/modules/ui/config.lua
    sed -i "s/onelight/onedark/g" ~/.config/nvim/lua/modules/ui/config.lua
    nvim +PackerSync

You need to execute PackerSync or just press <leader>ps to compile the latest config if you modify the any config in lua directory.

Don't worry if you meet any error for your new config.

The old compiled file called bak_compiled.lua is located in $HOME/.local/share/nvim/site/lua directory.

If you just want to restore to old config:

cd $HOME/.local/share/nvim/site/lua
cp ./bak_compiled.lua ./_compiled.lua

Then you can figure out what modification makes error.

Plugins

UI

Name Effect
sainnhe/edge My light/dark theme
catppuccin/nvim A low contrast dark theme
kyazdani42/nvim-web-devicons For nvim-tree's icons
hoob3rt/lualine.nvim Minimal, fast but customizable line
glepnir/dashboard-nvim Dashboard for Neovim
kyazdani42/nvim-tree.lua Replacement of Nerdtree
lewis6991/gitsigns.nvim Show git status in nvim
lukas-reineke/indent-blankline.nvim Show indent with different level
akinsho/bufferline.nvim Tab and buffer management
Xuyuanp/scrollbar.nvim Show buffer scrollbar

Tools

Name Effect
nvim-lua/popup.nvim Required by telescope.nvim
nvim-lua/plenary.nvim Required by telescope.nvim
tami5/sqlite.lua Required by telescope-frecency.nvim
nvim-telescope/telescope.nvim Find, Filter, Preview, Pick
nvim-telescope/telescope-fzy-native.nvim Fzy search for telescope
nvim-telescope/telescope-project.nvim Manage projects with telescope
nvim-telescope/telescope-frecency.nvim Frequent and recent file cache
thinca/vim-quickrun Run code quickly
michaelb/sniprun Run code snippet quickly
folke/trouble.nvim Show code troubles etc
folke/which-key.nvim Help you learn keybindings
dstein64/vim-startuptime Profiling starup time quickly
gelguy/wilder.nvim More useful wild menu

Editor

Name Effect
itchyny/vim-cursorword Highlight cursor word
junegunn/vim-easy-align Easy alignment
terrortylor/nvim-comment Comment code quickly
simrat39/symbols-outline.nvim Display code structure
nvim-treesitter/nvim-treesitter Super powerful code highlighter
nvim-treesitter/nvim-treesitter-textobjects Select text objects quickly
romgrk/nvim-treesitter-context Show current context
p00f/nvim-ts-rainbow Rainbow brackets
JoosepAlviste/nvim-ts-context-commentstring Comment base on context
mfussenegger/nvim-ts-hint-textobject Select region like hop.nvim
SmiteshP/nvim-gps Show current context in lualine
andymass/vim-matchup Better matchup for %
jdhao/better-escape.vim Replace esc with jk
lukas-reineke/format.nvim Format code asynchronously
windwp/nvim-ts-autotag Faster vim-closetag
norcalli/nvim-colorizer.lua Display detected color
rhysd/accelerated-jk Accelerated j/k
hrsh7th/vim-eft Enhanced f/t
phaazon/hop.nvim easymotion's replacement
karb94/neoscroll.nvim smooth scroll
vimlab/split-term Utilites around neovim's :terminal
akinsho/nvim-toggleterm.lua Toggled terminal
numtostr/FTerm.nvim Float terminal
tpope/vim-fugitive Git operations inside neovim

Completion

Name Effect
neovim/nvim-lspconfig Neovim native LSP configuration
williamboman/nvim-lsp-installer Manage each LSP engine
ray-x/lsp_signature.nvim Show signature when completing function parameters
hrsh7th/nvim-cmp Auto completion plugin for nvim
lukas-reineke/cmp-under-comparator more underline completion for nvim-cmp
hrsh7th/cmp-buffer buffer source for nvim-cmp
hrsh7th/cmp-path path source for nvim-cmp
tzachar/cmp-tabnine tabnine source for nvim-cmp
hrsh7th/cmp-nvim-lua lua source for nvim-cmp
hrsh7th/cmp-nvim-lsp lsp source for nvim-cmp
f3fora/cmp-spell spell source for nvim-cmp
kdheepak/cmp-latex-symbols latex symbols source for nvim-cmp
hrsh7th/cmp-cmdline cmdline source for nvim-cmp
andersevenrud/compe-tmux tmux source for nvim-cmp
saadparwaiz1/cmp_luasnip luasnip source for nvim-cmp
L3MON4D3/LuaSnip snippets completion engine for nvim-cmp
rafamadriz/friendly-snippets snippets source for LusSnip
windwp/nvim-autopairs Completion pairs
github/copilot Copilot neovim port

Lang

Name Effect
fatih/vim-go Most powerful plugin for go
rust-lang/rust.vim Plugin for rust
simrat39/rust-tools.nvim Plugin for rust
kristijanhusak/orgmode.nvim Org mode in nvim
iamcco/markdown-preview.nvim Markdown-preview out of box

Keybindings

The leader key is ,.

Effect shortcut
sync config and compile <leader>ps
install plugins <leader>pi
update plugins <leader>pu
clean plugins <leader>pc
toggle nvim-tree <C-n>
toggle tagbar <A-t>
Terminal
open vertical terminal <C-w>t or <F5>
toggle horizontal terminal <C-\>
quit terminal <C-d>
toggle floating terminal <A-d>
force quit floating terminal <A-S-d>
Buffer navigation
pick buffer n(nmeans No) <A-n>
right buffer <A-j>
left buffer <A-k>
move current buffer to right <A-S-k>
move current buffer to left <A-S-k>
close current buffer <A-q>
force close current buffer <A-S-q>
split buffer vertically <C-w>v
split buffer horizontally <C-w>s
navigate down <C-j>
navigate up <C-k>
navigate left <C-h>
navigate right <C-l>
Operaions in nvim-tree
new file a
remove file/directory d
rename file/directory r
open directory o/Enter
close directory o/Backspace
copy filename y
copy relative path Y
copy absolute path gy
toggle file/directory begin with dot H
toggle hidden file/directory configured in nvim-tree I
find file in recently opened <leader>fr
find file in history <leader>fe
find file in current work directory <leader>ff
find directory recorded by zoxide <leader>fz
find project <leader>fp
add project <leader>fpthen<C-A>
delete project <leader>fpthen<C-D>
escape insert mode jk
format manually <C-A-l>
back to last cursor's place <C-O>
preview definition gd
jump to definition gD
smart rename gr
toggle last diagnostics gt
toggle lsp references gR
show signature help gs
show current function/variable's definition or references gh
show hover doc K
show code action <leader>ca
toggle lsp document diagnostics <leader>cd
toggle lsp workspace diagnostics <leader>cw
toggle code quickfix <leader>cq
toggle code loclist <leader>cl
Navigate in snippet
next snippet's block <C-l>
prev snippet's block <C-h>
Code selection
select block manually vm
select current () block vab
select current {} block vaB
select current outer function block vaf
select current outer class block vac
select current inner function block vif
select current inner class block vic
Cursor movement
jump to one line <leader>j/<leader>k
find one word <leader>w
find one character <leader>c
find two characters below cursor <leader>cc
find one characterx in front of cursor in the same line Fx
find one characterx behind cursor in the same line fx
find next characterx follow direction in the same line ;
next function begin ][
prev function begin [[
next function end ]]
prev function end []
mark current place with markx mx
delete markx dmx
next mark m]
prev mark m[
next unstage git hunk ]g
prev unstage git hunk [g
next code diagnostics g]
prev code diagnostics g[
Code comment
toggle one line's comment gcc
toggle selected lines' comment <S-V>, select area then gc
Markdown preview
toggle MarkdownPreView <F12>
Session management
Save current session <leader>ss
Restore last session <leader>sr
Delete last session <leader>sd
Debug mode(only supports golang&python now)
Debug continue(run) <leader>dr/F6
Debug run last <leader>drl
Debug run to cursor <leader>drc
Debug toggle breakpoint <leader>db
Debug set breakpoint with condition <leader>dB
Debug list breakpoint <leader>dbl
Debug open repl <leader>dl
Debug step over <leader>dv/F9
Debug step into <leader>di/F10
Debug step out <leader>do/F11
Debug disconnect <leader>dd
Git management
open gitui in current directory <leader>g
Enter vim-fugitive <leader>G
Stage hunk <leader>hs(n and v mode)
Reset hunk <leader>hr(n and v mode)
Undo stage hunk <leader>hu
Reset buffer <leader>hR
Preview hunk <leader>hp
Blame hunk <leader>hb

You can see more keybinds in lua/core/mapping.lua and lua/keymap/init.lua.

Issues

  1. Clipboard for WSL2 users

Please refer to it and add win32yank.exe to your path.

Then uncomment this line.

  1. Wrong configuration may invoke the dialog asking for deleting all plugins

Input n and <CR>

  1. LSP servers don't autostart.

Please check this to make sure your directory can be detected as a working directory.

For example (gopls):

Your root directory need a go.mod and your .go file need to be created first. Then LSP will autostart when you edit .go file next time.

  1. Copilot setup.

Make sure your github account is signed up for copilot.

Then use Copilot setup command to setup.

Credit

TODO

  • More documentation for how to customize.
  • Backup old compiled configuration when error occurs.

nvimdots's People

Contributors

ayamir avatar mathjiajia avatar 1096015776 avatar hatter-long avatar pcrab avatar williamboman avatar younger-1 avatar jczhang02 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.