-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
291 lines (213 loc) · 6.59 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
" Godwin's .vimrc
set nocompatible
set encoding=UTF-8
filetype on
filetype plugin on
filetype indent on
syntax on
set number
" Smart indenting
set smartindent
" Set shift width to 4 spaces.
set shiftwidth=4
" Set tab width to 4 columns.
set tabstop=4
" Use space characters instead of tabs.
set expandtab
" Do not save backup files.
set nobackup
" Do not let cursor scroll below or above N number of lines when scrolling.
set scrolloff=10
" Do not wrap lines. Allow long lines to extend as far as the line goes.
set nowrap
" While searching though a file incrementally highlight matching characters as you type.
set incsearch
" Ignore capital letters during search.
set ignorecase
" Override the ignorecase option if searching for capital letters.
" This will allow you to search specifically for capital letters.
set smartcase
" Show partial command you type in the last line of the screen.
set showcmd
" Show the mode you are on the last line.
set showmode
" Show matching words during a search.
set showmatch
" Use highlighting when doing a search.
set hlsearch
" Set the commands to save in history default number is 20.
set history=1000
" Enable auto completion menu after pressing TAB.
set wildmenu
" Make wildmenu behave like similar to Bash completion.
set wildmode=list:longest
" There are certain files that we would never want to edit with Vim.
" Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" Hard wrapping at 80 chars and wrapping cursor at the end of a line
set textwidth=80
set whichwrap+=<,>,h,l
" Visual Border for the 80 char border
set colorcolumn=80
highlight ColorColumn ctermbg=8
" Enable use of the mouse
set mouse=a
" Folding options. Indent folding with manual folds
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
set foldnestmax=1
" Save the folds automatically
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
" Open new windows on the right
set splitright
" SHORTCUTS
let mapleader = "\<Space>"
set notimeout
" Beginning and end of line
nnoremap H ^
nnoremap L $
" Search results always in middle, and open fold
nnoremap n nzzzv
nnoremap N Nzzzv
" Editing .vimrc
nnoremap <leader>ev :tabe $MYVIMRC<cr>
nnoremap <leader>sv :w<cr> :source $MYVIMRC<cr> :noh<cr>
" Editing .bashrc
nnoremap <leader>eb :tabe ~/.bashrc<cr>
nnoremap <leader>sb :w<cr> :source ~/.bashrc<cr> :noh<cr>
" Load the termdebug plugin
packadd termdebug
" Open termdebug vertically
nnoremap <leader>d :Termdebug<cr>
let g:termdebug_wide=1
" Better tab shortcuts
nnoremap <leader>tn :tabnew<cr>
nnoremap <leader><tab> :tabnext<cr>
nnoremap <leader><S-tab> :tabprev<cr>
nnoremap <leader>to :tabonly<cr>
" Go to tab #
nnoremap <leader>1 1gt
nnoremap <leader>2 2gt
nnoremap <leader>3 3gt
nnoremap <leader>4 4gt
nnoremap <leader>5 5gt
nnoremap <leader>6 6gt
nnoremap <leader>7 7gt
nnoremap <leader>8 8gt
nnoremap <leader>9 9gt
nnoremap <leader>0 0gt
" Move to tab #
nnoremap <leader>! :tabmove 0<cr>
nnoremap <leader>@ :tabmove 1<cr>
nnoremap <leader># :tabmove 2<cr>
nnoremap <leader>$ :tabmove 3<cr>
nnoremap <leader>% :tabmove 4<cr>
nnoremap <leader>^ :tabmove 5<cr>
nnoremap <leader>& :tabmove 6<cr>
nnoremap <leader>* :tabmove 7<cr>
nnoremap <leader>( :tabmove 8<cr>
nnoremap <leader>) :tabmove 9<cr>
" DWM-like window navigation
" https://vim.fandom.com/wiki/Get_Alt_key_to_work_in_terminal
set <a-l>=l
set <a-h>=h
set <a-j>=j
set <a-k>=k
noremap <a-l> <C-w>l
noremap <a-h> <C-w>h
noremap <a-j> <C-w>j
noremap <a-k> <C-w>k
set <a-L>=L
set <a-H>=H
set <a-J>=J
set <a-K>=K
noremap <a-L> <C-w>L
noremap <a-H> <C-w>H
noremap <a-J> <C-w>J
noremap <a-K> <C-w>K
set <a-t>=t
noremap <a-t> <C-w>T
set <a-=>==
noremap <a-=> <C-w>=
" Open file explorer to the right
nnoremap <leader>; :Vexplore!<cr>
" Open file explorer in new tab
nnoremap <leader>: :tabnew<cr>:Explore<cr>
" Open terminal to the right
nnoremap <leader><cr> :vertical terminal<cr>
" Open terminal in new tab
nnoremap <leader>T :tab terminal<cr>
" Vim terminal mappings
" I did noremap earlier. Are the tnoremap's redundant?
tnoremap <esc> <C-w>N
tnoremap <a-l> <C-w>l
tnoremap <a-h> <C-w>h
tnoremap <a-j> <C-w>j
tnoremap <a-k> <C-w>k
tnoremap <a-L> <C-w>L
tnoremap <a-H> <C-w>H
tnoremap <a-J> <C-w>J
tnoremap <a-K> <C-w>K
" PLUGINS using vim-plug
call plug#begin()
Plug 'ryanoasis/vim-devicons'
Plug 'rafi/awesome-vim-colorschemes'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline_theme='bubblegum'
" Smooth scrolling
Plug 'psliwka/vim-smoothie'
" Startup screen
Plug 'mhinz/vim-startify'
" Removes highlighting after search
Plug 'romainl/vim-cool'
" Git markers
Plug 'airblade/vim-gitgutter'
" Git integration
Plug 'tpope/vim-fugitive'
Plug 'voldikss/vim-floaterm'
let g:floaterm_keymap_toggle = '<F4>'
let g:floaterm_width = 0.95
let g:floaterm_height = 0.95
" Fuzzy finder
Plug 'junegunn/fzf.vim'
" Drawer file explorer
Plug 'preservim/nerdtree'
"Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
" Commenting
Plug 'preservim/nerdcommenter'
" Live linting
Plug 'dense-analysis/ale'
" LaTeX integration
Plug 'xuhdev/vim-latex-live-preview' ", { 'for': 'tex' }
call plug#end()
" Change colorscheme - had to be done after loading plugins
colorscheme sonokai
" FZF keybinds
nnoremap <silent> <leader>f :Files<CR>
nnoremap <silent> <C-f> :BLines<CR>
nnoremap <silent> <C-F> :Rg<CR>
" NERDTree keybinds
set <a-d>=d
set <a-f>=f
nnoremap <a-d> :NERDTreeToggle<CR>
nnoremap <a-f> :NERDTreeFind<CR>
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
" Open the existing NERDTree on each new tab.
"autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif
" ALE settings
" ALE status in the status bar
let g:airline#extensions#ale#enabled = 1
" LaTeX Preview Settings
"autocmd Filetype tex setl updatetime=1000
nnoremap <leader>L :LLPStartPreview<CR>
let g:livepreview_engine = 'pdflatex'