"  NCM
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or("\<CR>", 'n')

"  Ale
nmap <silent> <leader>ld <Plug>(ale_previous_wrap)
nmap <silent> <leader>ls <Plug>(ale_next_wrap)
nmap <silent> <leader>la <Plug>(ale_detail)
nmap <silent> <leader>lt <Plug>(ale_toggle)

"  Tagbar
nnoremap <silent> <leader>tt :TagbarOpen fjc<CR>
let g:tagbar_map_togglesort = "S"
let g:tagbar_map_nextfold = "zs"
let g:tagbar_map_prevfold = "zd"
let g:tagbar_map_incrementfold = "zr"
let g:tagbar_map_decrementfold = "zt"
let g:tagbar_map_openallfolds = "zR"
let g:tagbar_map_closeallfolds = "zT"

"  Elm
nmap <leader>em <Plug>(elm-make)
nmap <leader>er <Plug>(elm-repl)
nmap <leader>ee <Plug>(elm-error-detail)
nmap <leader>ed <Plug>(elm-show-docs)

"  Loupe
nmap ÷ <Plug>(LoupeClearHighlight)

" Ultisnips
" let g:UltiSnipsExpandTrigger="<Tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"

" 고요 and Limelight
noremap <leader>d :Goyo<CR>
noremap <leader>D :Limelight!!<CR>

" Fugitive
noremap <leader>g :Gstatus<CR>
noremap <leader>gp :Git push<CR>
noremap <leader>ga :Git add % -f<CR>

" Blame line
nmap <silent> <leader>gb :ToggleBlameLine<CR>

" Gitv
let g:Gitv_CustomMappings = {
  \'prevCommit': 's',
  \'nextCommit': 'd',
  \'vdiff': 'D',
  \'delete': 'l',
  \'quit': 'q',
  \'editCommit': '<cr>',
  \'vertSplitCommit': 'S',
  \'nextBranch': 'x',
  \'prevBranch': 'X',
  \'vcherryPick': 'cp'
  \}

" Nvim-R
nmap <F1> <Plug>RHelp
nmap <F2> <Plug>RStart
nmap <F3> <Plug>RUpdateObjBrowser
nmap <CR> <Plug>RDSendLine
vmap <CR> <Plug>REDSendSelection

" vim-lion
let g:lion_create_maps = 1
let g:lion_map_right = "<leader>a"
let g:lion_map_left = "<leader>A"

" UndoTree
nnoremap <leader>u :UndotreeToggle<CR> :UndotreeFocus<CR>

" vim-surround
au vimenter * unmap ds
nmap ls <Plug>Dsurround

" vim-ranger
let g:ranger_map_keys = 0
map <leader>F :Ranger<CR>
