-
Notifications
You must be signed in to change notification settings - Fork 120
/
.vimrc
131 lines (118 loc) · 3.55 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
" I Moved to neovim, this is for the sake if I ever need vim again. See
" ~/.config/nvim for more
"Auto Download
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'gruvbox-community/gruvbox'
Plug 'jiangmiao/auto-pairs' "auto completes [] and () and makes life a bit easier
Plug 'tpope/vim-commentary' "Comment stuff
Plug 'tpope/vim-surround' "Allows me to change { to [ and what not
Plug 'wellle/targets.vim' "adds more targets like [ or , - lazy but useful
Plug 'junegunn/fzf.vim'
call plug#end()
"Global options
filetype plugin indent on
syntax on "activates syntax highlighting among other things
set background=dark "set hg group to dark
set backspace=indent,eol,start "Fixes the backspace
set conceallevel=1 "Allows me to conceal latex syntax if not on line
set encoding=utf-8 "required by YCM
set expandtab
set foldlevel=99
set foldmethod=indent "fold your code.
set hidden "work with multiple unsaved buffers.
set incsearch "highlights as you search
set ignorecase
set smartcase
set rnu nu "sets line numbers
set splitbelow splitright
set termguicolors "True colors term support
set viminfo+=n~/.vim/viminfo
set omnifunc=syntaxcomplete#Complete
set undodir="~/.vim/undo/"
set undofile
set laststatus=2
set showcmd
set guifont=MesloLGMDZ\ Nerd\ Font\ Bold\ 16
"Key remapping
let mapleader = ","
noremap <leader>s :source ~/.vim/vimrc<cr>
noremap <leader>e <C-w><C-w>
noremap <leader>z [s1z=
noremap <leader>p "+p
noremap <leader>P "+P
noremap <leader>f :Files<cr>
noremap <leader>c :cd %:p:h<cr>:pwd<cr>
noremap <leader><cr> o<Esc>
noremap <space>h <C-w>h
noremap <space>j <C-w>j
noremap <space>k <C-w>k
noremap <space>l <C-w>l
noremap <down> :resize +2<Cr>
noremap <up> :resize -2<cr>
noremap <right> :vertical resize +2<CR>
noremap <left> :vertical resize -2<CR>
inoremap jk <Esc>
vnoremap <leader>y "*y :let @+=@*<cr>
nmap <leader>1 :bn<cr>
nmap <leader>2 :bp<cr>
nmap <leader>3 :retab<cr>
nmap <leader>5 :call SpellToggle()<cr>
"Extra
let g:gruvbox_italic='1'
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_invert_selection='0'
let g:gruvbox_termcolors='256'
let g:AutoPairsFlyMode=0
source ~/.config/nvim/fzfConfig.vim
source ~/.config/nvim/myhighlights.vim
colorscheme gruvbox "colorscheme
if executable('rg')
set grepprg=rg\ --vimgrep
set grepformat^=%f:%l:%c:%m
endif
" statusline
set noshowmode
let g:currentmode={
\ 'n' : 'NORMAL ',
\ 'v' : 'VISUAL ',
\ 'V' : 'V·Line ',
\ '' : 'V·Block ',
\ 'i' : 'INSERT ',
\ 'R' : 'Replace ',
\ 'r' : 'Replace ',
\ 'Rv' : 'V·Replace ',
\ 'c' : 'Command ',
\ 't' : 'Terminal ',
\ 's' : 'Select ',
\ '!' : 'Shell '
\}
set statusline=%{toupper(g:currentmode[mode()])}%{toupper(&spelllang)}\ %{b:gitbranch}%<%F%h%m%r%=%-5.(%l,%c%V%)\ %y
function! StatuslineGitBranch()
let b:gitbranch=""
if &modifiable
try
let l:dir=expand('%:p:h')
let l:gitrevparse = system("git -C ".l:dir." rev-parse --abbrev-ref HEAD")
if !v:shell_error
let b:gitbranch="(".substitute(l:gitrevparse, '\n', '', 'g').") "
endif
catch
endtry
endif
endfunction
augroup GetGitBranch
autocmd!
autocmd VimEnter,WinEnter,BufEnter * call StatuslineGitBranch()
augroup END
function! SpellToggle()
if &spell
setlocal spell! spelllang&
else
setlocal spell spelllang=en_us
endif
endfunction