• 了解 vim text object概念

installation

brew install neovim
brew install font-hack-nerd-font
# 检索
brew install ripgrep fzf
# lsp format
brew install efm-langserver

整理中 my lazyvim config

plugin

use https://github.com/junegunn/vim-plug, install this first:

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'
mkdir ~/.config/nvim/
nvim ~/.config/nvim/init.vim

cat << EOF > ~/.config/nvim/init.vim
call plug#begin('~/.vim/plugged')
call plug#end()
EOF
  • write Plug 'fatih/vim-go' between call
  • run :PlugInstall
  • vim config is .vimrc

language support

use coc.nvim

Plug 'neoclide/coc.nvim', {'branch': 'release'}

:PlugInstall

coc-settings.json

{
  "languageserver": {
    "go": {
      "command": "gopls",
      "rootPatterns": ["go.mod"],
      "trace.server": "verbose",
      "filetypes": ["go"]
    }
  }
}

problem:

build/index.js not found, please install dependencies and compile coc.nvim by: yarn install

cd ~/.vim/plugged/coc.nvim
yarn install
yarn build

ctags

  • plugin: ‘preservim/tagbar’
    • need ctags

installation

brew install universal-ctags

config init.vim

nmap <F8> :TagbarToggle<CR>

python

使用 python language server,neovim内置支持

pip install 'python-language-server[all]'

config coc-settings.json,设置为全局安装python-language-server的python路径

输入法切换问题

参考 https://github.com/laishulu/macism/issues/4

  • im-select
    • brew tap daipeihust/tap
    • brew install im-select
  • 设置离开insert模式的配置
    • autocmd InsertLeave * :silent !/usr/local/bin/im-select com.apple.keylayout.ABC
-- imselect.lua
--- 都是粉色的手动发送地方定义一个函数来切换输入法
local M = {}

function M.setInputMethod()
  vim.fn.system('/usr/local/bin/im-select com.apple.keylayout.ABC')
end

return M
--essentials.lua
-- 在退出插入模式时触发 setInputMethod 函数
local imselect = require('imselect')

vim.cmd([[
  augroup SetInputMethod
    autocmd!
    autocmd InsertLeave * lua require('imselect').setInputMethod()
  augroup END
]])