Neovim 基础配置

Aug 30, 2023· 2 min read

终端安装与配置

kitty

安装 neovim

Mac 可以直接使用 Homebrew 直接安装

BASH
brew install neovim

tmux (option)

tmux config file path ~/.tmux.conf

BASH
brew instal tmux

fix clear command terminal database is inaccessible error

BASH
curl -LO https://invisible-island.net/datafiles/current/terminfo.src.gz && gunzip terminfo.src.gz /usr/bin/tic -xe tmux-256color terminfo.src sudo /usr/bin/tic -xe tmux-256color terminfo.src /usr/bin/tic -xe kitty-direct,tmux-256color terminfo.src infocmp -x tmux-256color

add set -g default-terminal "tmux-256color" into .tmux.conf

tmux config

BASH
set -g default-terminal "tmux-256color"` into `.tmux.conf # keymaps unbind C-b set -g prefix C-a

Neovim 配置

可以基于以下社区方案进行安装配置

  • LazyVim
  • LernaVim
  • AstroVim

下面我将以LazyVim的安装作为示例

Requirement

BASH
brew install ripgrep brew install fd brew install tmux

Install lazyvim

BASH
git clone https://github.com/LazyVim/starter ~/.config/nvim rm -rf ~/.config/nvim/.git
  • start
BASH
nvim

macos should set defaults write -g ApplePressAndHoldEnabled --bool false

Config keymap (Option)

According to your own preference.

BASH
# ~/.config/nvim/lua/config/keymaps.lua keymap.set('n', 'jk', '<Esc>')

Shortcut key

  • indent cmd + shift + </>
  • move up/down A-j/k
  • search content leader s g
  • search file leader leader
  • hover documentaion shift k
  • variable rename leader c r
  • search in buffer leader f b or leader ,
  • split window leader |
  • close window leader w d
  • search TODO leader s t
  • search keymaps leader s k
  • switch numberline leader u l
  • replace in file leader s r
  • open git window leader g
    • add stage leader
    • commit c
    • quite lazygit window q
  • open terminal leader f t
  • switch filetree leader e
  • toggle format on save leader u f
  • toggle diagnostics leader u d

Tmux Shortcut

  • create new window C-a c
  • close window C-a x
  • switch next window C-a n
  • quite terminal exit

Quick selection

dependence flash

  • remote mode
    • yr3y copy 3 lines
    • dr3d delete 3 lines
  • treesitter
    • yr [char] S