-filetype off
-set runtimepath& " reset rtp
-" remove all autocommands
-autocmd!
-
-set runtimepath+=$XDG_DATA_HOME/vim/vundle
-call vundle#begin('$XDG_DATA_HOME/vim')
-
-Plugin 'gmarik/vundle'
-
-Plugin 'AndrewRadev/switch.vim'
-Plugin 'airblade/vim-gitgutter'
-Plugin 'alepez/vim-gtest'
-Plugin 'bling/vim-airline'
-Plugin 'chrisbra/checkattach'
-Plugin 'derekwyatt/vim-fswitch'
-Plugin 'elzr/vim-json'
-Plugin 'firef0x/pkgbuild.vim'
-Plugin 'junegunn/vim-easy-align'
-Plugin 'justinmk/vim-sneak'
-Plugin 'klen/python-mode'
-Plugin 'kshenoy/vim-signature'
-Plugin 'majutsushi/tagbar'
-Plugin 'octol/vim-cpp-enhanced-highlight'
-Plugin 'raimondi/delimitmate'
-Plugin 'ram-z/vim-clang-format'
-Plugin 'ram-z/vimwiki'
-Plugin 'scrooloose/syntastic'
-Plugin 'sgeb/vim-diff-fold'
-Plugin 'shougo/unite.vim'
-Plugin 'shougo/vimproc.vim'
-Plugin 'sjl/gundo.vim'
-Plugin 'tomtom/tcomment_vim'
-Plugin 'tpope/vim-abolish'
-Plugin 'tpope/vim-endwise'
-Plugin 'tpope/vim-eunuch'
-Plugin 'tpope/vim-fugitive'
-Plugin 'tpope/vim-repeat'
-Plugin 'tpope/vim-surround'  "investigate vim-sandwich
-Plugin 'tpope/vim-unimpaired'
-Plugin 'tweekmonster/spellrotate.vim'
-Plugin 'valloric/youcompleteme'
-Plugin 'vim-scripts/mediawiki.vim'
-Plugin 'vim-scripts/replacewithregister'
-Plugin 'vim-scripts/yankring.vim'
-
-" colorschemes
-Plugin 'flazz/vim-colorschemes'
-
-" snippets
-Plugin 'sirver/ultisnips'
-Plugin 'honza/vim-snippets'
+call plug#begin('$XDG_DATA_HOME/vim')
+" This does not update vim-plug, use PlugUpgrade instead
+Plug 'junegunn/vim-plug'
+
+if !has("nvim")
+  Plug 'bling/vim-airline' " {{{2
+    let g:airline#extensions#whitespace#enabled = 1
+    let g:airline#extensions#tabline#enabled = 1
+    let g:airline#extensions#searchcount#enabled = 0
+    let g:airline_powerline_fonts = 1
+
+    let g:asyncrun_status = "stopped"
+    " let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
+  "}}}
+  Plug 'raimondi/delimitmate' " {{{2
+    let delimitMate_expand_cr = 2
+    let g:delimitMate_expand_space = 1
+  "}}}
+  Plug 'tpope/vim-surround' "{{{2
+  "}}}
+  " Plug 'valloric/youcompleteme' {{{2
+  Plug 'valloric/youcompleteme',
+        \{ 'do': './install.py --clangd-completer --clang-completer' }
+    let g:ycm_clangd_binary_path = 'clangd'   " use clangd in path
+    let g:ycm_clangd_args = ['--clang-tidy']
+    let g:ycm_extra_conf_vim_data = ['getcwd()']
+    let g:ycm_add_preview_to_completeopt = 1
+    let g:ycm_complete_in_comments = 1
+    let g:ycm_complete_in_strings  = 1
+    let g:ycm_autoclose_preview_window_after_insertion = 0
+
+    let g:ycm_language_server =
+          \ [
+          \   {
+          \     'name': 'haskell',
+          \     'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
+          \     'filetypes': [ 'haskell', 'lhaskell'  ]
+          \   },
+          \ ]
+  " }}}
+  Plug 'svermeulen/vim-yoink' " {{{2
+  ""}}}
+  Plug 'arcticicestudio/nord-vim' " {{{2
+    let g:nord_bold = 1
+    let g:nord_italic = 1
+    let g:nord_italic_comments = 1
+    let g:nord_underline = 1
+    let g:nord_uniform_status_lines = 0
+    let g:nord_uniform_diff_background = 0
+    let g:nord_cursor_line_number_background = 0
+    let g:nord_bold_vertical_split_line = 0
+  "}}}
+  Plug 'sirver/ultisnips' " replaced by lua-snip {{{2
+  Plug 'honza/vim-snippets'
+    let g:UltiSnipsEditSplit = 'vertical'
+    let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
+    if has('fname_case')
+      let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
+    endif
+    let g:UltiSnipsExpandTrigger       = "<tab>"
+    let g:UltiSnipsJumpForwardTrigger  = "<tab>"
+    let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
+    
+    " UltiSnips completion function that tries to expand a snippet. If there's no
+    " snippet for expanding, it checks for completion window and if it's shown,
+    " selects first element. If there's no completion window it tries to jump to
+    " next placeholder. If there's no placeholder it just returns TAB key
+    " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
+    function! g:UltiSnips_Complete()
+        call UltiSnips#ExpandSnippet()
+        if g:ulti_expand_res == 0
+            if pumvisible()
+                return "\<C-n>"
+            else
+                call UltiSnips#JumpForwards()
+                if g:ulti_jump_forwards_res == 0
+                  return "\<TAB>"
+                endif
+            endif
+        endif
+        return ""
+    endfunction
+    au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
+    let g:UltiSnipsListSnippets="<c-e>"
+  "}}}
+  Plug 'vim-utils/vim-man'  " replaced by builtin {{{2
+    let g:man_width = 80
+  "}}}
+  Plug 'airblade/vim-gitgutter' " replaced by gitsigns {{{
+  " prefer other signs such as ycm diags
+  let g:gitgutter_sign_priority = 1
+  " don't clobber other signs
+  let g:gitgutter_sign_allow_clobber = 0
+  "}}}
+  Plug 'justinmk/vim-sneak' " replaced by leap {{{2
+  let g:sneak#streak = 1
+  let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
+  let g:sneak#use_ic_scs = 1  " follow 'ignorecase' and 'smartcase'
+
+  " sneaky f and t
+  nmap f <Plug>Sneak_f
+  nmap F <Plug>Sneak_F
+  xmap f <Plug>Sneak_f
+  xmap F <Plug>Sneak_F
+  omap f <Plug>Sneak_f
+  omap F <Plug>Sneak_F
+  nmap t <Plug>Sneak_t
+  nmap T <Plug>Sneak_T
+  xmap t <Plug>Sneak_t
+  xmap T <Plug>Sneak_T
+  omap t <Plug>Sneak_t
+  omap T <Plug>Sneak_T
+  "}}}
+  Plug 'shougo/unite.vim' " replaced by telescope {{{2
+    function! UniteSetup()
+      call unite#filters#matcher_default#use(['matcher_fuzzy'])
+      call unite#custom#profile('default', 'context', {
+            \ 'winheight': 20,
+            \ 'direction': 'botright'
+            \ })
+
+      nnoremap [unite] <Nop>
+      nmap <leader>u [unite]
+      nnoremap [unite]u :UniteResume<CR>
+      nnoremap <silent> [u :UnitePrevious<CR>
+      nnoremap <silent> ]u :UniteNext<CR>
+
+      " unite-grep {{{3
+      " seems not respected
+      let g:unite_source_grep_max_candidates = 2000
+      if executable('ag')
+        " Use ag in unite grep source.
+        let g:unite_source_grep_command = 'ag'
+        let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
+        let g:unite_source_grep_recursive_opt = ''
+      end
+      nnoremap <silent> [unite]a :<C-u>Unite grep:.::\12\17<CR>
+      nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:\12\17<CR>
+      command! -nargs=+ Ag Unite grep:.::<args>
+
+      " unite-file_rec {{{3
+      if executable('ag')
+        " Use ag in unite rec source
+        let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
+      end
+      nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
+
+      " unite-buffer {{{3
+      call unite#custom#default_action('buffer', 'open')
+      nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
+
+      " unite-jumplist {{{3
+      nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
+
+      " unite-menu {{{3
+      let g:unite_source_menu_menus = {}
+      let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
+      let g:unite_source_menu_menus.fugitive.command_candidates = {
+            \ 'Gstatus <Leader>gs' : 'Gstatus',
+            \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
+            \ 'Glog' : 'Glog',
+            \}
+
+      nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
+
+      let g:unite_source_history_yank_enable = 1
+      nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
+    endfunction
+    augroup unit_setup
+      autocmd VimEnter * ++once call UniteSetup()
+    augroup END
+  "}}}2
+  Plug 'shougo/vimproc.vim', {'do': 'make'} " {{{2
+  "}}}2
+  Plug 'tomtom/tcomment_vim' " replaced by comment.nvim {{{2
+    let g:tcomment_textobject_inlinecomment = 'gic'
+    let g:tcomment#filetype#guess = 0
+    "let g:tcomment#options = {'whitespace' : 'no'}
+  "}}}2
+  " colorschemes
+  Plug 'morhetz/gruvbox' " {{{2
+    let g:gruvbox_contrast_dark  = 'hard'
+    let g:gruvbox_contrast_light = 'soft'
+  " }}}2
+  " staging
+  Plug 'puremourning/vimspector' " replaced by lsp {{{2
+    let g:vimspector_enable_mappings = 'HUMAN'
+  " }}}
+  Plug 'vim-scripts/syntaxrange' " replaced by treesitter {{{2
+  " }}}
+endif
+
+Plug 'alepez/vim-gtest'
+Plug 'alx741/vinfo'
+Plug 'andrewradev/sideways.vim' " {{{2
+nnoremap <silent> ,h :SidewaysLeft<CR>:delmarks z<CR>
+nnoremap <silent> ,l :SidewaysRight<CR>:delmarks z<CR>
+"}}}
+Plug 'andrewradev/switch.vim'
+Plug 'chrisbra/checkattach'
+Plug 'derekwyatt/vim-fswitch'
+Plug 'elzr/vim-json'
+Plug 'firef0x/pkgbuild.vim'
+Plug 'junegunn/vim-easy-align'
+Plug 'kshenoy/vim-signature'
+" Plug 'majutsushi/tagbar' " TODO: delete? {{{2
+"   map <F5> :TagbarToggle<cr>
+"   let g:tagbar_sort = 0
+"   let g:tagbar_compact = 1
+"   let g:tagbar_autoshowtag = 1
+"   let g:tagbar_width = 25
+"   let g:tagbar_iconchars = ['+', '-']
+"}}}
+Plug 'octol/vim-cpp-enhanced-highlight'
+Plug 'sgeb/vim-diff-fold'
+Plug 'skywind3000/asyncrun.vim' " {{{2
+command! -bang -nargs=* -complete=file Make AsyncRun -save=2 -program=make @ <args>
+let g:asyncrun_open = 10
+"}}}
+Plug 'sjl/gundo.vim'
+" Plug 'thinca/vim-qfreplace' " TODO: delete?
+Plug 'tpope/vim-abolish'
+Plug 'tpope/vim-characterize'
+" Plug 'tpope/vim-endwise' " TODO: delete?
+Plug 'tpope/vim-eunuch'
+Plug 'tpope/vim-fugitive'
+Plug 'tpope/vim-repeat'
+Plug 'tpope/vim-scriptease'
+Plug 'tpope/vim-speeddating'
+Plug 'tpope/vim-unimpaired'
+Plug 'tweekmonster/spellrotate.vim'
+" Plug 'vim-scripts/mediawiki.vim' " TODO: delete?
+Plug 'vim-scripts/replacewithregister' " FIXME: is overridden by lsp
+Plug 'wincent/loupe'