Browse Source

Update .vimrc with gitgutter and custom functions

Viktor Grahn 3 years ago
parent
commit
a5491ad9bc
1 changed files with 65 additions and 14 deletions
  1. 65 14
      .vimrc

+ 65 - 14
.vimrc

@@ -17,7 +17,6 @@ call plug#begin('~/.vim/plugged')
 Plug 'preservim/nerdtree'
 Plug 'tpope/vim-fugitive'
 Plug 'tpope/vim-commentary'
-Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
 Plug 'itchyny/lightline.vim'
 Plug 'dikiaap/minimalist'
 Plug 'morhetz/gruvbox'
@@ -27,6 +26,8 @@ Plug 'preservim/tagbar'
 Plug 'vim-php/tagbar-phpctags.vim'
 Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
 Plug 'junegunn/fzf.vim'
+Plug 'arcticicestudio/nord-vim'
+Plug 'airblade/vim-gitgutter'
 call plug#end()
 		
 filetype plugin indent on
@@ -54,6 +55,7 @@ set showcmd
 set showmatch
 set smartindent
 set smarttab
+set splitright
 set tabstop=2
 set whichwrap+=<,>,[,],h,l 
 set undofile
@@ -63,7 +65,7 @@ set undodir=~/.vim/undo
 " Gruvbox
 let g:gruvbox_italic = 1
 let g:gruvbox_bold = 1
-let g:gruvbox_transparent_bg = 1
+let g:gruvbox_transaprent_bg = 1
 colorscheme gruvbox
 
 " ALE completion
@@ -167,19 +169,56 @@ function! Toggle_transparent()
 endfunction
 nnoremap <Space>T :call Toggle_transparent()<CR>
 
-" vim-go
-let g:go_highlight_types = 1
-let g:go_highlight_fields = 1
-let g:go_highlight_functions = 1
-let g:go_highlight_function_calls = 1
-let g:go_highlight_operators = 1
-let g:go_auto_type_info = 1
-let g:go_fmt_command = "goimports"
-" let g:go_list_type = "quickfix"
+" Location list
+autocmd BufEnter * if !exists("b:location_list") | let b:location_list = 0 | endif
+let b:location_list = 0
+function! Toggle_location_list()
+  if b:location_list == 0
+    lopen
+    let b:location_list = 1
+  else
+    lclose
+    let b:location_list = 0
+  endif
+endfunction
+nnoremap <Space>l :call Toggle_location_list()<CR>
+
+" Location list
+autocmd BufEnter * if !exists("b:quick_list") | let b:quick_list = 0 | endif
+let b:quick_list = 0
+function! Toggle_quick_list()
+  if b:quick_list == 0
+    copen
+    let b:quick_list = 1
+  else
+    cclose
+    let b:quick_list = 0
+  endif
+endfunction
+nnoremap <Space>c :call Toggle_quick_list()<CR>
+
+" Git blame
+autocmd BufEnter * if !exists("b:git_blame") | let b:git_blame = 0 | endif
+function! Toggle_git_blame()
+  if b:git_blame == 0
+    :Git blame
+    let b:git_blame = 1
+  else
+    let winIndex = 1
+    let winCnt = winnr('$')
+    while winIndex <= winCnt
+      if expand('%:e') == "fugitiveblame"
+        :close
+      else
+        :wincmd w
+      endif
+      let winIndex += 1
+    endwhile
+    let b:git_blame = 0
+  endif
 
-map <C-g>v :GoVet<CR>
-map <C-g>r :GoRun<CR>
-map <C-g>b :GoBuild<CR>
+endfunction
+nnoremap <Space>b :call Toggle_git_blame()<CR>
 
 " Key mappings
 map <C-l>n :cnext<CR>
@@ -190,6 +229,15 @@ nmap <Space>t :TagbarToggle<CR>
 nmap <Space>f :Files<CR>
 nmap <Space>r :Rg<CR>
 
+nmap <Space>n :GitGutterNextHunk<CR>
+nmap <Space>p :GitGutterPrevHunk<CR>
+
+" Setting title to enable better tmux titling
+if exists('$TMUX')
+  autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window 'vim | " . expand("%:t") . "'")
+  autocmd VimLeave * call system("tmux setw automatic-rename")
+endif
+
 function! PrettyXML()
   set filetype=xml
   silent %!xmllint --format --encode UTF-8 --recover - 2>/dev/null
@@ -202,3 +250,6 @@ endfunction
 
 command! PrettyXml call PrettyXML()
 command! PrettyJson call PrettyJSON()
+
+nmap <Space>j call PrettyXml()
+nmap <Space>x call PrettyJSON()