-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
176 lines (131 loc) · 4.1 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
syntax on
let mapleader="," " The <leader> key
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set incsearch
" set backspace=indent,eol,start
set backspace=2 " Makes backspace behave like you'd expecti
" set showmatch " Highlight matching braces
set colorcolumn=120 " Highlight 80 character limit
set showmode " Show the current mode on the open buffer
highlight ColorColumn ctermbg=0 guibg=lightgrey
" Command to write as root if we dont' have permission
cmap w!! %!sudo tee > /dev/null %
set clipboard=unnamed
set guioptions+=a
" set relativenumber
set splitright
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/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 'skanehira/gh.vim'
Plug 'vim-airline/vim-airline'
Plug 'hashivim/vim-terraform'
" Best theme ever
Plug 'morhetz/gruvbox'
"Plug 'jremmen/vim-ripgrep'
"Plug 'wakatime/vim-wakatime'
" Multiselect like in SublimeText
"Plug 'terryma/vim-multiple-cursors'
" Git blame, status etc"
Plug 'tpope/vim-fugitive'
" Man pages for VIM"
"Plug 'vim-utils/vim-man'
"Full path fuzzy file, buffer, mru, tag, ... finder for Vim
"Plug 'ctrlpvim/ctrlp.vim'
" Autocompletion"
Plug '[email protected]:Valloric/YouCompleteMe.git',"
" Python syntax
Plug 'vim-syntastic/syntastic'
"Plug 'mbbill/undotree'
Plug 'etdev/vim-hexcolor'
" GH Copilot
" Plug 'github/copilot.vim'
" NerdTree
Plug 'preservim/nerdtree'
" FZF
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Autocompletion using AI
" Plug 'codota/tabnine-vim'
" Sum/max/min/avg on columns of numbers
"Plug 'drxcc/vim-vmath'
" TableMode
Plug 'dhruvasagar/vim-table-mode'
call plug#end()
colorscheme gruvbox
set background=dark
let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_invert_selection='0'
if executable('rg')
let g:rg_derive_root='true'
endif
" let mapleader = " "
let g:netrw_browse_split=2
let g:netrw_banner=0
let g:netrw_winsize=25
let g:ctrlp_use_caching=0
" fzf
" Empty value to disable preview window altogether
let g:fzf_preview_window = ''
" Always enable preview window on the right with 60% width
let g:fzf_preview_window = 'right:60%'
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>u :UndotreeShow<CR>
" cd to the directory containing the file in the buffer. Both the local
" and global flavors.
nmap <leader>cd :cd %:h<CR>
nmap <leader>lcd :lcd %:h<CR>
" Swap \n for newline
nnoremap <leader>n :%s/\\n/\r/g<CR>
" Swap comma + space for comma + newline
nnoremap <leader>nn :%s/,\s/,\r/g<CR>
" Change vim config
nmap <silent> <leader>vim :e ~/.vimrc<CR>
" Format JSON
nmap <leader>json :%!python -m json.tool<CR>
" Format things
" Indent html
nmap <leader>html :%s/></>\r</g<CR>
" Strip tags
nmap <leader>strip :%s/<\_.\{-1,\}>//g<CR>
" Quote
nmap <leader>quote :%s/^\(.*\)$/"\1"/<CR>
" Get GitHub URL for the line under your cursor
nnoremap <leader>bb :!echo `git url`/src/`git latest`/%\#lines-<C-R>=line('.')<CR> \| xargs open<CR><CR>
nnoremap <leader>o :GFiles<CR>
nnoremap <leader>b :Buffers<CR>
" Run Python script
nmap <leader>py <Esc>:w<CR>:!clear;python %<CR>
nmap <leader>ts <Esc>:w<CR>:!clear;pytest %<CR>
" PLUGIN: NERDTree
nnoremap <leader>nf :NERDTreeFind<CR>
nnoremap <leader>nt :NERDTreeToggle<CR>
let NERDTreeIgnore = ['\.pyc$', '\.egg-info$', '__pycache__', '__pycache__']
" Emoji shortcuts
ab :white_check_mark: ✅
ab :bomb: 💣
ab :boom: 💥
ab :init: 🌱
ab :raised_hands: 🙌
" Mappings for vmath
vmap <expr> ++ VMATH_YankAndAnalyse()
nmap ++ vip++
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>