set nocompatible " be iMproved, required
filetype off " required
" 在 vim 中使用 :PlugInstall 安装
call plug#begin('~/.vim/plugged')
Plug 'terryma/vim-expand-region'
Plug 'fatih/vim-go'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'MattesGroeger/vim-bookmarks'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdcommenter'
Plug 'jiangmiao/auto-pairs'
Plug 'scrooloose/nerdtree'
Plug 'liuchengxu/space-vim-theme'
Plug 'majutsushi/tagbar'
Plug 'terryma/vim-multiple-cursors'
Plug 'rking/ag.vim'
Plug 'morhetz/gruvbox'
"Plug 'davidhalter/jedi'
" Initialize plugin system
call plug#end()
" 定义快捷键的前缀,即
let mapleader="\
syntax on " 语法高亮
" 开启文件类型侦测
filetype on
" 根据侦测到的不同类型加载对应的插件
filetype plugin on
" 开启实时搜索功能
set incsearch
" 搜索时大小写不敏感
set ignorecase
set number "显示行号
set tabstop=4 " 设置制表符(tab键)的宽度
set shiftwidth=4 "(自动) 缩进使用的4个空格
set hlsearch " 高亮显示搜索结果
set splitright " 竖直分屏时,在右侧新建缓冲区, 同理也可以设置 splitbelow
set splitbelow
set autoindent " 设置自动对齐(缩进):即每行的缩进值与上一行相等;使用 noautoindent 取消设置
set noswapfile "禁止生成 swp 文件
set autoread "自动刷新加载的文件
set cursorline "高亮显示当前行
set backspace=2 " 设置退格键可用
set t_Co=256 "为了使用 gruvbox 主题
set term=xterm-256color
"set background=light
set background=dark
"colorscheme molokai
"colorscheme gruvbox
colorscheme space_vim_theme
"
set termguicolors
"if &term =~# '^screen'
" let &t_8f = "\
" let &t_8b = "\
"endif
" vim 自动补全 颜色设置
hi Pmenu ctermfg=black ctermbg=gray guibg=#444444
hi PmenuSel ctermfg=7 ctermbg=4 guibg=#555555 guifg=#ffffff
" ====================================================== vim-go 配置
let g:go_def_mode='gopls'
"let g:go_gopls_enabled = 0 "关闭 gopls
"let g:go_info_mode='gopls'
let g:go_disable_autoinstall = 0 "禁止自动下载
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_tags = 1
let g:go_highlight_variable_declarations = 1
let g:go_highlight_variable_assignments = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_chan_whitespace_error = 1
let g:go_auto_type_info = 1
let g:go_fmt_command = "goimports"
let g:go_metalinter_autosave = 0
"au FileType go nmap
au FileType go nmap
au FileType go nmap
au FileType go nmap
"au FileType go nmap
"au FileType go nmap
au FileType go nmap
"au FileType go nmap
"
" 按 F5 执行当前 Python 代码"
au FileType python map
func! PRUN()
exec "w"
if &filetype == 'python'
exec "!python3 %"
endif
endfunc
" -------------------------------------------------------------------------------------------------
" coc.nvim default settings
" help :coc-nvim
" -------------------------------------------------------------------------------------------------
" if hidden is not set, TextEdit might fail.
set hidden
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap
"inoremap
"\ pumvisible() ? "\
"\
"\ coc#refresh()
"inoremap
inoremap
\ pumvisible() ? "\
\
\ coc#refresh()
inoremap
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use
inoremap
" Use `[c` and `]c` to navigate diagnostics
nmap
nmap
" Remap keys for gotos
nmap
nmap
nmap
nmap
" Use U to show documentation in preview window
nnoremap
" Remap for rename current word
nmap
" Remap for format selected region
vmap
nmap
" Show all diagnostics
nnoremap
" Manage extensions
nnoremap
" Show commands
nnoremap
" Find symbol of current document
nnoremap
" Search workspace symbols
nnoremap
" Do default action for next item.
nnoremap
" Do default action for previous item.
nnoremap
" Resume latest coc list
nnoremap
" disable vim-go :GoDef short cut (gd)
" this is handled by LanguageClient [LC]
let g:go_def_mapping_enabled = 0
"为插件 terryma/vim-expand-region 做按键映射:
vmap v
vmap
set mouse=a
nmap
nmap
nmap
nmap
imap
imap
vmap
vmap
" 窗体改变时,分屏保持等宽
nmap
nmap
autocmd VimResized * exec "normal!\
" 保存文件
nnoremap
nnoremap
map
map
map
map
map
map
" tab
map
map
map
map
" fzf.vim
"在当前目录搜索文件
nnoremap
"切换Buffer中的文件
nnoremap
"在当前所有加载的Buffer中搜索包含目标词的所有行,:BLines只在当前Buffer中搜索
nnoremap
"在Vim打开的历史文件中搜索,相当于是在MRU中搜索,:History:命令历史查找
nnoremap
"调用Rg进行搜索,包含隐藏文件
"command! -bang -nargs=* Rg
"\ call fzf#vim#grep(
"\ 'rg --column --line-number --no-heading --color=always --smart-case --hidden '.shellescape(
"\
"\ : fzf#vim#with_preview('right:50%:hidden', '?'),
"\
"command! -bang -nargs=* Ag
"\ call fzf#vim#ag(
"\
"\ : fzf#vim#with_preview('right:50%:hidden', '?'),
"\
"nnoremap
nnoremap
nnoremap
nmap
let g:fzf_history_dir = '~/.local/share/fzf-history'
" vim-airline
let g:airline_theme='gruvbox'
" 在 airline 的状态栏上显示文件的绝对路径
let g:airline_section_c = "%{expand('%:p')}"
" 关闭状态显示空白符号计数
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" jiangmiao/auto-pairs
let g:AutoPairsShortcutToggle = '
" MattesGroeger/vim-bookmarks
nmap
imap
let g:bookmark_sign = '●'
let g:bookmark_disable_ctrlp = 0
"tmux 设置
"if exists('$TMUX')
"set TERM=screen-256color
"endif
" ====================================================== ale
"let g:ale_set_loclist = 0
"let g:ale_open_list = 1
"let g:ale_keep_list_window_open = 1
""自定义error和warning图标
"let g:ale_sign_error = '✗'
"let g:ale_sign_warning = '⚡'
""在vim自带的状态栏中整合ale
"let g:ale_statusline_format = ['✗ %d', '⚡ %d', '✔ OK']
""显示Linter名称,出错或警告等相关信息
"let g:ale_echo_msg_error_str = 'E'
"let g:ale_echo_msg_warning_str = 'W'
"let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
""普通模式下,sp前往上一个错误或警告,sn前往下一个错误或警告
"nmap sp
"nmap sn
""
"nmap
""设置状态栏显示的内容
""set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\
""%{strftime(\"%d/%m/%y\ -\ %H:%M\")}\ %{ALEGetStatusLine()}
""文件内容发生变化时不进行检查
"let g:ale_lint_on_text_changed = 'never'
""打开文件时不进行检查
"let g:ale_lint_on_enter = 0
""对C/C++使用Clang进行语法检查
"" "let g:ale_linters = {'c': 'clang'}
"" "let g:ale_c_clang_options = '-std=c11 -Wall'
"" "let g:ale_linters = {'c++': 'clang++'}
"" let g:ale_cpp_clangcheck_options = '-std=c++11 -Wall'
"" let g:ale_cpp_gcc_options = '-std=c++11 -Wall'
""
"" "关闭 golang 的语法检测
""let g:ale_linters = {'go': ['gofmt']}
""let g:ale_linters = {
""\ 'c': ['clang'],
""\ 'c++': ['clang++'],
""\ 'go': ['go build', 'gofmt', 'go vet']
""\}
"let g:ale_linters = {
"\ 'c': ['clang'],
"\ 'c++': ['clang++'],
"\ 'go': ['gobuild','gofmt']
"\}
""打开golang语法检测
""let g:ale_linters = {'go':['gometalinter','gofmt']}
" scrooloose/nerdtree
nmap
" 设置子窗体位置
"let NERDTreeWinPos="right"
"显示隐藏文件
let NERDTreeShowHidden=1
"删除文件时自动删除文件对应的 buffer
let NERDTreeAutoDeleteBuffer=1
" majutsushi/tagbar 配合 gotags 使用
" https://github.com/jstemmer/gotags
" 设置标签子窗口的宽度
let tagbar_width=32
" tagbar 子窗口中不显示冗余帮助信息
let g:tagbar_compact=1
nmap
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }