"设置搜索高亮
set hlsearch
"启用高亮
syntax on 
"设置当前行突出显示
set cursorline
"设置显示行号
set number
"选择颜色配置为breeze(这里可以看/usr/share/vim/vim82/colors/下的颜色方案)
colorscheme gruvbox
set bg=dark
let g:gruvbox_transparent_bg=1
"设置立即显示搜索高亮
set incsearch
"设置字典(ctrl+x;ctrl+k)模式会调用
set spell
set dictionary=/home/i/.vim/funclist.txt
set complete+=k
" autocmd是设置文件类型的自动补全,ctrl+x;ctrl+o可以调用
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" 设置SuperTabContinued插件的默认tab方式,奶牛这里用的是上方所说的ctrl+x;ctrl+o调用
" let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
" 设置默认打开html等网页文件的自动补全
autocmd BufNewFile,BufRead *.html,*.htm,*.xml inoremap </ </<c-x><c-o>
" 指定某些类型新建文件时候的自动补全方式,例如js,更上面的那个设置略有不同
autocmd BufNewFile,BufRead *.js set omnifunc=javascriptcomplete#CompleteJS
" 自动补齐括号书名号引号等设置
inoremap ( ()<LEFT>
inoremap [ []<LEFT>
inoremap { {}<LEFT>
inoremap ' ''<LEFT>
inoremap " ""<LEFT>
inoremap < <><LEFT>
" 鼠标
set mouse=a
" 跨行移动光标
set whichwrap=b,s,<,>,[,]
" 记录光标位置
augroup resCur
  autocmd!
  autocmd BufReadPost * call setpos(".", getpos("'\""))
augroup END
" 快捷键设置
vmap <C-c> "+y
"imap <C-c> <ESC>v<CR>"+y
"nmap <C-c> v<CR>"+y

"support wayland
xnoremap "+y y:call system("wl-copy", @")<cr>
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
xnoremap "+c c:call system("wl-copy", @")<cr>d<cr>

vmap <C-x> "+c
"map <C-v> "+gP
nmap <C-v> i<CR>"+gP<CR>
vmap <C-v> "+p
imap <C-v> <C-r><C-o>"+
imap <C-s> <ESC>:w<CR>
nmap <C-q> :wq<CR>
imap <C-q> <ESC>:wq<CR>
nmap <C-a> ggVG<CR>
imap <C-a> <ESC>ggVR<CR>i
imap <C-f> <ESC>/
nmap <C-f> /
imap <C-z> <ESC>u<CR>i
nmap <C-z> u<CR>
imap <C-y> <ESC>^R<CR>i
nmap <C-y> ^R<CR>
imap <C-_> <C-x><C-O>

" C配置
set cindent "设置c语言自动对齐
set noexpandtab "不要将tab转换为空格

" NERDTree config
map <C-n> :NERDTreeToggle<CR>
" 自动关闭多个窗口
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif
" 自动打开
" autocmd vimenter * NERDTree
" 显示隐藏文件
let NERDTreeShowHidden=1
" 高亮当前文件
let NERDTreeHightCursorline=1
" 关闭文件夹 o
" 显示菜单   m
" 打开上层   u

" SuperTab config
" 0 - 不记录上次的补全方式
" 1 - 记住上次的补全方式,直到用其他的补全命令改变它
" 2 - 记住上次的补全方式,直到按ESC退出插入模式为止
let g:SuperTabRetainCompletionType=2
" 快捷键
let g:SuperTabDefaultCompletionType="<C-p>"

" Tagbar config
" 将开启tagbar的快捷键设置为　<Leader>tb
nmap <F12> :TagbarToggle<CR>
let g:tagbar_ctags_bin='/usr/bin/ctags'  " 设置ctags所在路径
let g:tagbar_width=25 "设置tagbar的宽度
" 在某些情况自动打开
autocmd BufReadPost *.cpp,*.c,*.h,*.hpp,*.cc,*.cxx call tagbar#autoopen()

" syntastic config
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
let g:syntastic_loc_list_height = 4

" pandoc config
" 激活pandoc
let g:pandoc#filetypes#handled = ["pandoc", "markdown"]
let g:pandoc#filetypes#pandoc_markdown = 0
let g:pandoc#modules#disabled = ["formatting"]
let g:pandoc#modules#disabled = ["folding"]
let g:pandoc#folding#mode = "syntax" "relative差别小，stacked没有差别
" g:pandoc#folding#fold_yaml = "1" "YAML文件的folding
let g:pandoc#folding#fastfolds = "1" "为了folding的计算正确
let g:pandoc#biblio#sources = "bcg" "同名同目录b 当前目录c default文件l 规定的g:pandoc#biblio#bibs为g
"let b:pandoc_biblio_bibs = "./bib.bib" "设置bib文件名
"let g:pandoc#biblio#use_bibtool = 1 "补全，yay -S bibtool
let g:pandoc#completion#bib#mode = "fallback" "fallaback支持bibtex
" omnicppcomplete 快捷键<C-x><C-o>引用
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" vim-pandoc 与 vim-youcompleteme 联动
  if !exists('g:ycm_semantic_triggers')
    let g:ycm_semantic_triggers = {}
  endif
  let g:ycm_semantic_triggers.pandoc = ['@']

  let g:ycm_filetype_blacklist = {}

" comment
" Create default mappings
let g:NERDCreateDefaultMappings = 1
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '**/' }, 'cpp': { 'left': '/**','right': '**/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
" let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not 
let g:NERDToggleCheckAllLines = 1

" complete config
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_key_invoke_completion = '<C-b>'
let g:ycm_semantic_triggers =  {
  \   'c' : ['->', '.'],
  \   'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s',
  \             're!\[.*\]\s'],
  \   'ocaml' : ['.', '#'],
  \   'cpp,objcpp' : ['->', '.', '::'],
  \   'perl' : ['->'],
  \   'php' : ['->', '::'],
  \   'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir,go' : ['.'],
  \   'ruby' : ['.', '::'],
  \   'lua' : ['.', ':'],
  \   'erlang' : [':'],
  \ }


