" base
colorscheme neodark
set number
set tabstop=4
set softtabstop=4
set autoindent
set nobackup
set noswapfile
set nocompatible 
set cursorline 
set ruler 
set shiftwidth=4 
set backupcopy=yes 
set ignorecase smartcase 
set incsearch
set hlsearch
set magic
set hidden
set smartindent 
set backspace=indent,eol,start
set cmdheight=1
set laststatus=2
set autoread
set encoding=utf-8
set termencoding=utf-8
set fencs=utf-8,gbk
set noesckeys
set nocompatible
set ttimeoutlen=100
set t_Co=256 
set completeopt =menu,menuone
filetype plugin on

" plug
filetype off
call plug#begin('~/.vim/plugged')
Plug 'keitanakamura/neodark.vim'
Plug 'tpope/vim-commentary'
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
Plug 'ycm-core/YouCompleteMe'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree'
Plug 'rhysd/vim-clang-format'
Plug 'jiangmiao/auto-pairs'
call plug#end()
filetype plugin indent on

" nerdtree
map <leader>t :NERDTreeToggle<CR>
let NERDTreeWinSize=38
let g:NERDTreeHidden=0  
let NERDTreeMinimalUI = 1
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
let NERDTreeIgnore = [
        \ '\.pyc$','\.out','\.a','\.so',
        \ 'run', 'lib', 'build', 'bin',
        \ ]

" leaderf
let g:Lf_Gtagslabel = 'native-pygments'
let g:Lf_GtagsAutoGenerate = 1
let g:Lf_ShortcutF = '<C-P>'
let g:Lf_StlSeparator = { 'left': '', 'right': '', 'font': '' }
let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git']
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_WindowHeight = 0.30
let g:Lf_ShowRelativePath = 0
let g:Lf_HideHelp = 1
let g:Lf_UseCache = 0
let g:Lf_UseVersionControlTool = 0
let g:Lf_IgnoreCurrentBufferName = 1
let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 }
let g:Lf_JumpToExistingWindow = 0
" let g:Lf_WindowPosition = 'popup'
" let g:Lf_PreviewInPopup = 1

let g:Lf_WildIgnore = {
    \'dir': ['build', 'bin'],
    \'file': ['*.a', '*.lib', '*.so', '*.pb', '*.out', '*.o']
    \}

let g:Lf_RgConfig = [
    \ "--max-columns=150",
    \ "--glob=!build/*",
    \ "--glob=!bin/*",
    \ "--glob=!lib/*",
    \ "--glob=!cmake/*",
    \ ]

noremap <leader>gs :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR><CR>
noremap <leader>gg :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR><CR>
noremap <leader>gf :LeaderfFunction!<cr>
noremap <leader>gt :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
xnoremap gv :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR>
noremap gz :Leaderf! rg -F -e "
noremap <leader>gr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR>
noremap <leader>gd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR>

" youcompleme
let g:ycm_python_binary_path = '/usr/bin/python3'
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_collect_indentifier_from_tags_files = 1
let g:ycm_semantic_triggers = {'c,cc,hpp,cpp': ['re!\w{2}'],}
let g:ycm_show_diagnostics_ui = 0
let g:ycm_cache_omnifunc = 0
let g:ycm_max_num_candidates = 10
let g:ycm_enable_diagnostic_signs = 0
let g:ycm_enable_diagnostic_highlighting = 0

" airline
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
let g:airline#extensions#tabline#formatter = 'unique_tail'
nnoremap <leader>[ :bp<CR>
nnoremap <leader>] :bn<CR>

" neodark
let g:lightline = {}
let g:lightline.colorscheme = 'neodark'
let g:neodark#use_256color = 1
let g:neodark#solid_vertsplit = 1
let g:neodark#use_custom_terminal_theme = 1

" clangformat
let g:clang_format#command = 'clang-format'
let g:clang_format#auto_format = 1

" cpphighlight
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_posix_standard = 1
let g:cpp_concepts_highlight = 1
apt install ripgrep global clang-format
cd ~/.vim/plugged/YouCompleteMe/
./install.py --clang-completer