-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
354 lines (292 loc) · 13.3 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
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
"-----------------basic setup------------------
set nocompatible " always use the latest vimrc file
so ~/.vim/plugins.vim " source the plugins vim file
set mouse=a " set mouse mode availiable
set t_Co=256 " use 256 colors in terminal vim
colorscheme xoria256 " the theme i am using
" colorscheme hybrid_material " alternative theme the theme i am using
set hidden " let vim to set hideen buffers by default
" set textwidth=110 " The maxim text width
" set colorcolumn=+1 " Then place a column to indicate that limit
set number " display line numbers
set autoindent " enables the auto indentation
set showmode " always show what mode we're currently editing in
set wrap " do wrap lines
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
" set copyindent " copy the previous indentation on autoindenting
set visualbell " don't beep
set noerrorbells " don't beep
set autowrite " Save on buffer switch
set completeopt=longest,menu,preview " set the completion in the current file
set clipboard=unnamed " to copy and past
set timeout timeoutlen=200 ttimeoutlen=100
"------------------Leader key-------------------
let mapleader=','
let g:mapleader = ','
set listchars=tab:▸\ ,eol:¬ " when hit set list! show invisibles
"------------------Autocommands------------------
command! -nargs=* Wrap set wrap linebreak nolist " Wrap shortcut
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source % " automatically source the vimrc file
augroup end
" Jump to the last position when repoen a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"------------------Maps--------------------------
" here are some ways to fast edit files
" %% => path/to/current/directory
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
map <leader>ew :e %%
"------------------Tab settings------------------
set tabstop=4 " a tab is four spaces
set smarttab
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set expandtab " expand tabs by default (overloadable per file type later)
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
"---------------------Search---------------------
set hlsearch " hightlight the search
set incsearch
nmap <leader><space> :nohlsearch<cr> " no hightlight search after this combination
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
"---------------Split View Settings---------------
set splitbelow " :sp open the new split below
set splitright " :vsp open the new split right
map <C-h> <C-w>h " quick switch to the left window
map <C-j> <C-w>j " quick switch to the bottom window
map <C-k> <C-w>k " quick switch to the top window
map <C-l> <C-w>l " quick swtich to the right window
"---------------Tab settings-----------------------
map <leader>1 1gt
map <leader>2 2gt
map <leader>3 3gt
map <leader>4 4gt
map <leader>5 5gt
map <leader>6 6gt
map <leader>7 7gt
map <leader>8 8gt
map <leader>9 9gt
map <leader>0 :tablast<CR>
map <silent><leader>s :set spell!<cr>
syntax enable " enable syntax highlighting
" vim-javascript plugins
let g:javascript_plugin_jsdoc = 1
" vim-better-whitespace
highlight ExtraWhitespace ctermbg=yellow
autocmd BufWritePre * StripWhitespace
" NerdTree
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <C-k> :NERDTreeToggle<CR>
let NERDTreeShowHidden=1
let NERDTreeHijackNetrw=0
" set the tagbar toggle
nmap <C-\> :TagbarToggle<CR>
" Snippets config
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsEditSplit="vertical"
" emmet config
let g:user_emmet_leader_key=','
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ },
\}
" CtrlP config
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist|coverage|_build|priv)|(\.(swp|ico|git|svn))$'
nmap <C-e> :CtrlPBufTag<cr>
nmap <Leader>e :CtrlPMRUFiles<cr>
" greplace config
set grepprg=ack " use ack for the search"
let g:grep_cmd_opts = '--noheading'
highlight LineNr ctermfg=grey
" vim ale
"let g:ale_linters = {
"\ 'javascript': ['eslint'],
"\}
"let g:ale_sign_column_always = 1
" syntatic vim
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_loc_list_height = 5
"let g:syntastic_auto_loc_list = 0
"let g:syntastic_check_on_open = 0
"let g:syntastic_check_on_wq = 0
"let g:syntastic_javascript_checkers = ['eslint']
"let g:syntastic_error_symbol = 'x'
"let g:syntastic_style_error_symbol = '?'
"let g:syntastic_warning_symbol = '!'
"let g:syntastic_style_warning_symbol = '@'
"highlight link SyntasticErrorSign SignColumn
"highlight link SyntasticWarningSign SignColumn
"highlight link SyntasticStyleErrorSign SignColumn
"highlight link SyntasticStyleWarningSign SignColumn
highlight Comment cterm=italic
highlight Type cterm=italic
highlight Constant cterm=bold
" Tips and notes
" - zz to center the screen of current line
" - gd highlight all of the existing defs in the file
" - % create a new file
" - d create a new directory
" - R rename the current file/dir
" - D delete the current file/dir
" - z= correct wrong spells
" - zg add current word to `good word` list
" - C] go to definition in the manual
" - Ct go back to the previous position
" - CD half page down
" - CU half page up
" - CB page up
" - CF page down-----------------Basic setup------------------
set nocompatible " always use the latest vimrc file
so ~/.vim/plugins.vim " source the plugins vim file
set mouse=a " set mouse mode availiable
set t_Co=256 " use 256 colors in terminal vim
colorscheme xoria256 " the theme i am using
" colorscheme hybrid_material " alternative theme the theme i am using
set hidden " let vim to set hideen buffers by default
" set textwidth=110 " The maxim text width
" set colorcolumn=+1 " Then place a column to indicate that limit
set number " display line numbers
set autoindent " enables the auto indentation
set showmode " always show what mode we're currently editing in
set wrap " do wrap lines
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
" set copyindent " copy the previous indentation on autoindenting
set visualbell " don't beep
set noerrorbells " don't beep
set autowrite " Save on buffer switch
set completeopt=longest,menu,preview " set the completion in the current file
set clipboard=unnamed " to copy and past
set timeout timeoutlen=200 ttimeoutlen=100
"------------------Leader key-------------------
let mapleader=','
let g:mapleader = ','
set listchars=tab:▸\ ,eol:¬ " when hit set list! show invisibles
"------------------Autocommands------------------
command! -nargs=* Wrap set wrap linebreak nolist " Wrap shortcut
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source % " automatically source the vimrc file
augroup end
" Jump to the last position when repoen a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"------------------Maps--------------------------
" here are some ways to fast edit files
" %% => path/to/current/directory
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
map <leader>ew :e %%
"------------------Tab settings------------------
set tabstop=4 " a tab is four spaces
set smarttab
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set expandtab " expand tabs by default (overloadable per file type later)
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
"---------------------Search---------------------
set hlsearch " hightlight the search
set incsearch
nmap <leader><space> :nohlsearch<cr> " no hightlight search after this combination
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
"---------------Split View Settings---------------
set splitbelow " :sp open the new split below
set splitright " :vsp open the new split right
map <C-h> <C-w>h " quick switch to the left window
map <C-j> <C-w>j " quick switch to the bottom window
map <C-k> <C-w>k " quick switch to the top window
map <C-l> <C-w>l " quick swtich to the right window
"---------------Tab settings-----------------------
map <leader>1 1gt
map <leader>2 2gt
map <leader>3 3gt
map <leader>4 4gt
map <leader>5 5gt
map <leader>6 6gt
map <leader>7 7gt
map <leader>8 8gt
map <leader>9 9gt
map <leader>0 :tablast<CR>
map <silent><leader>s :set spell!<cr>
syntax enable " enable syntax highlighting
" vim-javascript plugins
let g:javascript_plugin_jsdoc = 1
" vim-better-whitespace
highlight ExtraWhitespace ctermbg=yellow
autocmd BufWritePre * StripWhitespace
" NerdTree
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <C-k> :NERDTreeToggle<CR>
let NERDTreeShowHidden=1
let NERDTreeHijackNetrw=0
let NERDTreeIgnore = ['\v(node_modules|log|target|public|dist|coverage|_build|priv)|(\.(swp|ico|svn|git|nyc_output))$']
" set the tagbar toggle
nmap <C-\> :TagbarToggle<CR>
" Snippets config
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsEditSplit="vertical"
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" emmet config
let g:user_emmet_leader_key=','
" CtrlP config
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
let g:ctrlp_custom_ignore = '\v(log|node_modules|target|public|dist|coverage|_build|priv)|(\.(swp|ico|git|svn|nyc_output))$'
nmap <C-e> :CtrlPBufTag<cr>
nmap <Leader>e :CtrlPMRUFiles<cr>
" greplace config
set grepprg=ack " use ack for the search"
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
let g:grep_cmd_opts = '--noheading'
highlight LineNr ctermfg=grey
" vim ale
let g:ale_linters = {
\ 'javascript': ['eslint'],
\}
highlight clear ALEErrorSign
highlight clear ALEWarningSign
set cursorline
highlight Comment cterm=italic
highlight Type cterm=italic
highlight Constant cterm=bold
" Tips and notes
" - zz to center the screen of current line
" - gd highlight all of the existing defs in the file
" - % create a new file
" - d create a new directory
" - R rename the current file/dir
" - D delete the current file/dir
" - z= correct wrong spells
" - zg add current word to `good word` list
" - C] go to definition in the manual
" - Ct go back to the previous position
" - CD half page down
" - CU half page up
" - CB page up
" - CF page down