-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.simple
356 lines (255 loc) · 9.09 KB
/
vimrc.simple
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Gustavo Cortez
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable modifiable
set modifiable
"PLUGINS ----------------------------------------------------------------- {{{
" Install vim-plug if not found
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
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
call plug#begin()
Plug 'preservim/nerdtree'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'jlanzarotta/bufexplorer'
Plug 'yegappan/mru'
Plug 'morhetz/gruvbox'
" Initialize plugin system.
call plug#end()
" }}}
" Do not make vim compatible with vi.
set nocompatible
" Allow plugins to be used.
filetype plugin indent on
" Use syntax highlighting.
syntax on
" Always leave 10 rows below cursor.
set scrolloff=15
" Hide cursor line.
set nocursorline
" Not Show cursor column.
set nocursorcolumn
" Set title of window to the name of the file.
set title
" Backup files.
set backup
" Backup directory.
set backupdir=~/.vim/backup/
" Hide mouse when typing.
set mousehide
" Check to see if an external file has changed.
set autoread
" Split window with cursor in bottom window.
set splitbelow splitright
" Leave windows uneven after split or close.
set noequalalways
" Switch buffers without saving.
set hidden
" Show error bell visually.
set visualbell
" Set the text width.
set textwidth=80
" Allow backspacing to work as expected.
set backspace=indent,eol,start
" Tabbing over moves four spaces.
set tabstop=2
" Number of spaces to use in automatically indent.
set shiftwidth=2
" Copy indent from current line when starting a new line.
set autoindent
" Use C style indentation
set cindent
" Use space characters instead of tabs.
set expandtab
" Incremental search an you type.
set incsearch
" Ignore capital letters during search.
set ignorecase
" Override the ignorecase option if searching for captial letters.
set smartcase
" Show the line and column position of cursor.
set ruler
" Show partial command in the last line of the screen.
set showcmd
" Show matching words.
set showmatch
" Use highlighting when doing a search.
set hlsearch
" Set the character enconding when writing file.
set fileencoding=utf8
" Set the character encoding.
set encoding=utf8
" Show auto complete menus.
set wildmenu
" Make wildmenu behave like bash completion.
set wildmode=longest:full,full
" Ignore files with these extentions.
set wildignore=*.odt,*.doc*,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.JPG,*.exe,*.bmp,*.flv,*.gz,*.tgz,*.zip,*.iso,*.gzip,*.mov,*.xz,*.tar,*.img,*.docx,*.xlsx,*.xls
" Temporary files.
set directory=/tmp
" Show popup documentation
set completeopt=menu,menuone,popup,noselect,noinsert
" Do not show -- INSERT ---
set noshowmode
" MAPPINGS --------------------------------------------------------------- {{{
" Set the leader to '-' instead of the default '\'.
let mapleader = " "
" Enable syntax highlighting in markdown code blocks.
let g:markdown_fenced_languages = ['html', 'python', 'css', 'vim', 'rust', 'c']
" Select all text in buffer.
noremap <leader>a ggVG
" Paste a block of code without formatting it.
nnoremap <mousemiddle> <esc>"*P
if has("gui_running")
nnoremap <silent> <Esc> :nohlsearch<Bar>:echo<CR>
else
map <silent> <leader><cr> :noh<cr>
endif
noremap <F12> <Esc>:syntax sync fromstart<CR>
inoremap <F12> <C-o>:syntax sync fromstart<CR>
nnoremap <silent> <leader>s :update<CR>
nnoremap <silent> <leader>q :x<CR>
nnoremap <up> :echoerr "Don't use arrow keys, use H, J, K, L instead!"<CR>
nnoremap <down> :echoerr "Don't use arrow keys, use H, J, K, L instead!"<CR>
nnoremap <right> :echoerr "Don't use arrow keys, use H, J, K, L instead!"<CR>
nnoremap <left> :echoerr "Don't use arrow keys, use H, J, K, L instead!"<CR>
" Close the current buffer
map <leader>xx :bd<cr>
" Close all the buffers
map <leader>xa :bufdo bd<cr>
map <leader>l :bnext<cr>
map <leader>h :bprevious<cr>
" Close a buffer and switching to another buffer, do not close the
" window, see https://goo.gl/Wd8yZJ
nnoremap <silent> \d :bprevious <bar> bdelete #<CR>
" Map Ctrl-<Space> to / (search)
map <leader>f /
" Highlight words but do not jump
nnoremap * :keepjumps normal! mi*`i<CR>
" }}}
" VIMSCRIPT FILE SETTINGS ------------------------------------------------ {{{
" Auto set current file directory
autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif
" Turn on cursorline and cursorcolumn only in active window.
augroup cursor_off
autocmd!
autocmd WinLeave * set nocursorline
autocmd WinEnter * set cursorline
augroup END
" Set indentation of HTML to 2 spaces.
autocmd Filetype html setlocal tabstop=2 shiftwidth=2 expandtab
" If vim version is equal to or greater than 7.3 enable undofile.
if version >= 703
set undodir=~/.vim/backup
set undofile
set undoreload=10000
endif
augroup resume_edit_position
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | execute "normal! g`\"zvzz"
\ | endif
augroup END
function! InsertConsoleLog()
let word = expand("<cword>")
let linenumber = line(".")
execute "normal A \<BS>\<CR>\<ESC>0Aconsole.log('[" . expand('%:t'). ":" .linenumber. "]', ".word."); \/* TODO *\/"
endfunction
map <silent> <leader>v :call InsertConsoleLog()<CR>bbbbi
" Set terminal color
set t_Co=256
" Set the background tone.
set background=light
" Set the color scheme.
colorscheme gruvbox
if has("gui_running")
" Set font to DejaVu Sans Mono 10
set guifont=Hack\ Nerd\ Font:h12
" Hide the toolbar.
set guioptions-=T
" Hide the the left-side scroll bar.
set guioptions-=L
" Hide the the left-side scroll bar.
set guioptions-=r
" Hide the the menu bar.
set guioptions-=m
" Hide the the bottom scroll bar.
set guioptions-=b
" Map the F4 key to toggle the menu, tool, and scroll bar.
nnoremap <F4> :if &guioptions=~#'mTr'<Bar>
\set guioptions-=mTr<Bar>
\else<Bar>
\set guioptions+=mTr<Bar>
\endif<CR>
endif
" }}}
"PLUGINS CONFIGURATION ------------------------------------------------------- {{{
" MRU
let MRU_Max_Entries = 20
map <leader>r :MRU<CR>
" NerdTree
let NERDTreeIgnore=['\.jpg$', '\.mp4$', '\.zip$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.svg$', '\.gif$', '\.tar$', '\.gz$', '\.xz$', '\.bz2$', '\.db$', '\.vim$', '\~$', '\.pyc$', 'node_modules']
nnoremap <leader>0 :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-m> :NERDTreeFind<CR>
let NERDTreeMinimalUI=1
let NERDTreeShowBookmarks=1
" 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 bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
" BufExplorer
map <leader><tab> :b#<CR> " switch to latest buffer
nnoremap <silent> <leader>e :BufExplorer<CR>
" FZF
let g:fzf_layout = { 'down': '40%' }
nnoremap <silent> <C-p> :GFiles<CR>
nnoremap <silent> <C-g> :Rg<CR>
" }}}
"STATUS LINE ------------------------------------------------------------ {{{
" Set colors for the status line.
hi StatusLine guifg=white guibg=darkgray ctermbg=2 ctermfg=0
hi NormalColor guifg=Black guibg=Green ctermbg=46 ctermfg=0
hi InsertColor guifg=Black guibg=Cyan ctermbg=51 ctermfg=0
hi ReplaceColor guifg=Black guibg=maroon1 ctermbg=165 ctermfg=0
hi VisualColor guifg=Black guibg=Orange ctermbg=202 ctermfg=0
" Clear status line when vimrc is reloaded.
set statusline=
set statusline+=%#NormalColor#%{(mode()=='n')?'\ \ NORMAL\ ':''}
set statusline+=%#InsertColor#%{(mode()=='i')?'\ \ INSERT\ ':''}
set statusline+=%#ReplaceColor#%{(mode()=='R')?'\ \ REPLACE\ ':''}
set statusline+=%#VisualColor#%{(mode()=='v')?'\ \ VISUAL\ ':''}
" White on gray.
set statusline+=%0*
" Full path to the file.
set statusline+=\ %t
" Modified flag.
set statusline+=\ %M
" Read only.
set statusline+=\ %R
" Split the left from the right.
set statusline+=%=
" White transparent.
set statusline+=\ %1*
" File type.
set statusline+=\ %y
" Show the row the cursor is on.
set statusline+=\ %l
" Show the lenth of the line.
set statusline+=\ %p%%
" Show the status on the second to last line.
set laststatus=2
" }}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""