使用vim有7,8年了,整理一下自己用到的vim配置,方便自查。

vim

basic

基本设置,语法高亮,行号,等等:

1
2
3
4
execute pathogen#infect()
syntax on
filetype plugin indent on
set number

paste

复制粘贴: disable auto indent

1
set paste

Notice the “– INSERT (paste) –” at the bottom of the Vim window.

fold

代码折叠: Folding wiki

1
2
" close  zc
" open zo

font

安装字体: install powerline font

1
2
3
wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf  
open .
# double click the otf file you've just downloaded.

kubectl eidt issue

使用kubectl edit时,当yaml文件的annotation行过大会报错:

annotation: kubectl.kubernetes.io/last-applied-configuration is too large

1
2
3
" annotation: kubectl.kubernetes.io/last-applied-configuration
" is too large
set maxmempattern=200000

neovim

neovim v0.5.1

今年(2020),我从vim 8 迁移到了neovim,下面是 ~/.config/nvim/init.vim的配置内容

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
" cp from ~/.vimrc
" execute pathogen#infect()
"syntax on
"filetype plugin indent on
language en_US.UTF-8

set rtp+=/usr/local/opt/fzf
set number
set encoding=utf-8

" You need to set ignorecase if you want to use what smartcase provides
set ignorecase
set smartcase

" kubectl edit
" annotation: kubectl.kubernetes.io/last-applied-configuration
" is too large
set maxmempattern=200000
"set foldmethod=syntax
"set clipboard=unnamed

"autocmd vimenter * NERDTree
"
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif

call plug#begin(stdpath('data') .'/plugged')
" call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
"
Plug 'tpope/vim-commentary'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
"
" " Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
"
" " Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
"
" " On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'preservim/tagbar'


" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
"
" " Using a non-default branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
"
" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
"
"
" " Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'

" Track the engine.
Plug 'SirVer/ultisnips'
"
" Snippets are separated from the engine. Add this if you want them:
Plug 'honza/vim-snippets'

if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'tpope/vim-sensible'

Plug 'rust-lang/rust.vim'

" for reactjs jsx
"
"
"
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }

" Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh' }
"Plug 'jparise/vim-graphql'

"Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()

" let g:coc_global_extensions = ['coc-json', 'coc-tsserver']

" for js/ts synax
" syntax highlighting can get out of sync i
" https://thoughtbot.com/blog/modern-typescript-and-react-development-in-vim
autocmd BufEnter *.{js,jsx,ts,tsx} :syntax sync fromstart
autocmd BufLeave *.{js,jsx,ts,tsx} :syntax sync clear

let g:deoplete#enable_at_startup = 1

let g:go_def_mode='gopls'
let g:go_info_mode='gopls'

let g:UltiSnipsEditSplit="vertical"

call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' })


"set list
"set listchars=tab:>-
set tabstop=4
"
"set expandtab
"set shiftwidth=2
set autoindent
set smartindent
"

let mapleader=','	

nmap <C-P> :FZF<CR>

let NERDTreeShowHidden=1


" If more than one window and previous buffer was NERDTree, go back to it.
autocmd BufEnter * if bufname('#') =~# "^NERD_tree_" && winnr('$') > 1 | b# | endif
let g:plug_window = 'noautocmd vertical topleft new'

if has('nvim')
  "highlight! link TermCursor Cursor
  highlight! TermCursorNC guibg=red guifg=white ctermbg=1 ctermfg=15
endif

set clipboard+=unnamedplus
let g:go_imports_autosave = 1

" nmap <silent> gd <Plug>(coc-definition)
" nmap <silent> gy <Plug>(coc-type-definition)
" nmap <silent> gr <Plug>(coc-references)
" nmap <leader>rn <Plug>(coc-rename)
"let g:LanguageClient_serverCommands = {'javascript': ['javascript-typescript-stdio']}