Skip to content

Instantly share code, notes, and snippets.

@JackYoung
Last active April 20, 2022 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackYoung/7cdb934c5b0a1f2b2d6548a51bf3ad92 to your computer and use it in GitHub Desktop.
Save JackYoung/7cdb934c5b0a1f2b2d6548a51bf3ad92 to your computer and use it in GitHub Desktop.
let g:python_host_prog = '~/.pyenv/versions/2.7.15/bin/python'
let g:python3_host_prog = '~/.pyenv/versions/3.6.13/bin/python'
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'crusoexia/vim-monokai'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'Valloric/YouCompleteMe'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end()
let mapleader = ","
set nocompatible
syntax enable
filetype on
filetype plugin on
filetype indent on
" set autoindent
autocmd BufEnter * :syntax sync fromstart
set nu " 显示行号
set showcmd " 显示命令
set lz " 当运行宏时,在命令执行完成之前,不重绘屏幕
set hid " 可以在没有保存的情况下切换buffer
set backspace=eol,start,indent
set whichwrap+=<,>,h,l " 退格键和方向键可以换行
set incsearch " 增量式搜索
set hlsearch " 搜索时,高亮显示匹配结果。
set magic " 额,自己:h magic吧,一行很难解释
set showmatch " 光标遇到圆括号、方括号、大括号时,自动高亮对应的另一个圆括号、方括号和大括号。
set nobackup " 关闭备份
set nowb
set noswapfile " 不使用swp文件,注意,错误退出后无法恢复
set lbr " 在breakat字符处而不是最后一个字符处断行
set ai " 自动缩进
set si " 智能缩进
set cindent " C/C++风格缩进
" set paste
set pastetoggle=<F2>
set showmode
set clipboard=unnamed
set clipboard=unnamedplus
set nofen
set fdl=10
" tab转化为4个字符
set expandtab
set smarttab
set shiftwidth=4
set tabstop=4
" 不使用beep或flash
set vb t_vb=
colorscheme monokai
" 启用256色
set t_Co=256
set t_ut=n
set encoding=utf-8
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set termencoding=utf-8
set list
set listchars=tab:>-,trail:~
nnoremap <leader>d "_d
nnoremap * *``
nnoremap <C-l> w1
nnoremap <C-h> b1
vnoremap <C-r> "hy:%s/<C-r>h//g<left><left>"
"""""" fzf
nmap <C-p> :Files<CR>
nmap <C-e> :Buffers<CR>
command! -bang -nargs=* Rng call fzf#vim#grep(
\ "rg --column --line-number --no-heading --color=always --smart-case -g '' ".<q-args>,
\ 1,
\ {'options': '--delimiter : --nth 4..'},
\ <bang>0)
let g:fzf_action = { 'ctrl-e': 'edit' }
command! -bang -nargs=* Rg call fzf#vim#grep(
\ "rg --column --line-number --no-heading --color=always --smart-case --glob '!{pybind11}' ".<q-args>,
\ 1,
\ {'options': '--delimiter : --nth 4..'},
\ <bang>0)
nnoremap <silent> <Leader>rg :Rg -w <C-R><C-W><CR>
"""""" YouCompleteMe
" let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py' "设置全局配置文件的路径
let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全
let g:ycm_confirm_extra_conf=0 " 打开vim时不再询问是否加载ycm_extra_conf.py配置
let g:ycm_key_invoke_completion = '<C-a>' " ctrl + a 触发补全,防止与其他插件冲突
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_auto_hover = ''
let g:ycm_always_populate_location_list = 1
set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
highlight YcmErrorSection term=reverse ctermfg=15 ctermbg=9 guifg=White guibg=Red
nnoremap gd :YcmCompleter GoToDefinitionElseDeclaration<CR>
nnoremap gr :YcmCompleter GoToReferences<CR>
nmap <leader>K <plug>(YCMHover)
function! s:CustomizeYcmQuickFixWindow()
" Move the window to the top of the screen.
" wincmd K
" Set the window height to 8.
8wincmd _
" disbale autoclose
autocmd! ycmquickfix WinLeave
endfunction
autocmd User YcmQuickFixOpened call s:CustomizeYcmQuickFixWindow()
""""" NERDTree
let NERDTreeShowHidden=1
""""" vim-go
" Go syntax highlighting
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_operators = 1
" Auto formatting and importing
let g:go_fmt_autosave = 1
let g:go_fmt_command = "goimports"
" Status line types/signatures
let g:go_auto_type_info = 1
let g:go_def_mode = 'godef'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment