From 2ba2ea220eb4ce8b2af51304e30c16f6446ff930 Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Sun, 23 May 2021 17:21:44 +0200 Subject: [PATCH] feat(vim): add ide keybindings --- .config/nvim/init.vim | 80 ++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 83b7d92..77eee47 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -21,11 +21,9 @@ Plug 'lifepillar/vim-mucomplete' Plug 'pangloss/vim-javascript' Plug 'mxw/vim-jsx' -" Vim Wiki -Plug 'vimwiki/vimwiki' - -" DWM bindings -Plug 'spolu/dwm.vim' +" FZF +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' " Defines the sneak motion Plug 'justinmk/vim-sneak' @@ -94,53 +92,36 @@ let g:ale_fixers = { \ 'php': ['php_cs_fixer'] \} -let g:ale_rust_rls_executable = '/home/omar/.cargo/bin/rls' +let g:ale_rust_rls_executable = '~/.cargo/bin/rls' let g:ale_rust_rls_toolchain = 'stable' -let g:ale_fix_on_save = 0 +" let g:ale_fix_on_save = 0 " NerdTree let NERDTreeShowHidden=1 +let NERDTreeCustomOpenArgs={'file':{'where': 't'}} -" VimWiki - -let g:vimwiki_list = [{'path': '~/vimwiki/', - \ 'syntax': 'markdown', 'ext': '.md'}] +" Exit Vim if NERDTree is the only window left. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | + \ quit | endif -" Colorscheme -" colorscheme onedark +" Start NERDTree when Vim is started without file arguments. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif -" Autoclose Brackets -" inoremap { {} -" inoremap [ [] -" inoremap ( () -" noremap , w +" Start NERDTree when Vim starts with a directory argument. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif -" Remove newbie crutches in Command Mode -cnoremap -cnoremap -cnoremap -cnoremap +" Mirror the NERDTree before showing it. This makes it the same on all tabs. +nnoremap :NERDTreeMirror:NERDTreeFocus -" Remove newbie crutches in Insert Mode -inoremap -inoremap -inoremap -inoremap - -" Remove newbie crutches in Normal Mode -nnoremap -nnoremap -nnoremap -nnoremap +" ----------------------- +" Remaps +" ----------------------- -" Remove newbie crutches in Visual Mode -vnoremap -vnoremap -vnoremap -vnoremap -" Remaps :autocmd BufWritePost * ALEFix " Leader Remaps @@ -153,8 +134,23 @@ nnoremap k gk nnoremap j gj " NerdTree bindings -nnoremap n :NERDTreeFocus -" nnoremap :NERDTree nnoremap :NERDTreeToggle nnoremap :NERDTreeFind +" ctrl up/down (Move lines) +nnoremap :m .+1== +nnoremap :m .-2== +inoremap :m .+1==gi +inoremap :m .-2==gi +vnoremap :m '>+1gv=gv +vnoremap :m '<-2gv=gv + +" ctrl shift f (Find in directory) +nnoremap :Rg +vnoremap :Rg + +" Use yank to copy to clipboard +vnoremap y "*y + +" ctrl w (close tab) +nnoremap :tabclose