-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
373 lines (336 loc) · 10.6 KB
/
.vimrc
File metadata and controls
373 lines (336 loc) · 10.6 KB
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
"====================
" vim workflow
" @chrisbautista "codespud"
" features:
" - asynchronous linting
" - tree file view
" - fuzzy file search
" - more info on status and tab lines
" - keyboard mapping
" - php debugging
" - use , as <leader>
"====================
"set backupdir=~/.vim/backup
"set directory=~/.vim/swap
"set spell
"set visualbell
set autoindent
set backspace=indent,eol,start
set cursorline " enable cursoline highlight
set expandtab
set lazyredraw
set linebreak
set mouse=a
set nobackup
set nocompatible
set noeb vb t_vb=
set noswapfile
set number " enable line numbers
set shiftwidth=2
set smarttab
set splitbelow
set splitright
set switchbuf=useopen,usetab
set tabstop=2
set title
" theme
set t_Co=256
set background=dark
"
" Plugins
"
call plug#begin('~/.vim/plugged')
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
Plug 'https://github.com/ctrlpvim/ctrlp.vim'
Plug 'https://github.com/pangloss/vim-javascript'
Plug 'http://github.com/mattn/emmet-vim/'
Plug 'https://github.com/prettier/vim-prettier'
Plug 'https://github.com/tpope/vim-fugitive'
"Plug 'https://github.com/itchyny/lightline.vim'
Plug 'https://github.com/terryma/vim-multiple-cursors'
Plug 'https://github.com/tpope/vim-eunuch'
Plug 'https://github.com/scrooloose/nerdtree'
Plug 'https://github.com/editorconfig/editorconfig-vim'
Plug 'https://github.com/w0rp/ale'
Plug 'https://github.com/airblade/vim-gitgutter'
Plug 'https://github.com/junegunn/fzf.vim'
Plug 'https://github.com/Valloric/YouCompleteMe'
Plug 'https://github.com/mustache/vim-mustache-handlebars'
Plug 'junegunn/vim-easy-align'
"Plug 'junegunn/seoul256.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'NLKNguyen/papercolor-theme'
Plug 'https://github.com/vim-scripts/grep.vim'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'yegappan/mru'
Plug 'mileszs/ack.vim' " > sudo apt-get install ack-grep
Plug 'vim-vdebug/vdebug'
Plug 'SirVer/ultisnips'
"Plug 'honza/vim-snippets'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Go plugins
"Plug 'fatih/vim-go', { 'tag': '*' }
"Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Initialize plugin system
call plug#end()
"
" AUTO COMMANDS
"
" Run on load
autocmd VimEnter * if argc() == 0 | call OpenHelpers() | endif
" Close if no buffers open
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"
" Keyboard mapping
"
let mapleader = ","
map ; :Files<CR>
map <leader><leader> :Windows<CR>
map <leader>' :Buffers<CR>
map <leader>. :Lines<CR>
map <leader>p :bp<CR>
map <leader>\ :vsplit<CR>
map <leader>/ :split<CR>
map <leader>s :Snippets<CR>
map <leader>v :tabedit ~/.vimrc<CR>
map <leader>g :GFiles?<CR>
map <leader>= ggVgg=
map <leader>n :tabedit<CR>
nmap <leader><CR> :source %<CR>
nnoremap <leader>q :q<CR>
nnoremap <expr> gb '`[' . strpart(getregtype(), 0, 1) . '`]'
nmap <Leader>h :Gstatus<CR><C-w>20+
nmap <Leader>w :Git diff<CR>
nmap <Leader>c :Git add --all<CR>:Git commit -m
"nmap <Leader>l :Gpull --rebase<CR>
"nmap <Leader>p :Gpush<CR>
map <leader><F2> :wqa<CR>
map <leader><F4> :bd<CR>
map <leader><F10> :term<CR>
map <leader><F11> :source ./.vimsession<CR>
map <leader><F12> :mks! ./.vimsession<CR>
map <leader>r :MRU<CR>
map <leader>l :NERDTreeFind<CR>
map <leader>o :NERDTreeToggle<CR>
"map <C-o> :NERDTreeToggle<CR>
map <C-_> :tabedit<CR>
map <C-t><left> :tabp<cr>
map <C-t><right> :tabn<cr>
map <C-Right> <C-W><Right>
map <C-S-Left> <C-W><Left>
map <M-C-Left> :bp<CR>
map <C-F12> :Gblame<CR>
map <leader>f :Rgrep<CR>
map <C-f> :Ack <C-R><C-W>
nmap <leader><F1> :vsplit ~/todo.md<CR> :vertical resize 35<CR>
" moving through windows
nmap 1<Up> :wincmd k<CR>
nmap 1<Down> :wincmd j<CR>
nmap 1<Left> :wincmd h<CR>
nmap 1<Right> :wincmd l<CR>
nmap 1<kHome> :wincmd r<CR>
nmap 1<kEnd> :wincmd R<CR>
nmap <leader>j :call GotoJump()<CR>
nmap <leader><kHome> :call OpenHelpers()<CR>
" DO NOT MAP F5, F10
" vim annoyances
nmap <C-space> a
imap <C-space> <Esc>
vnoremap > >gv
vnoremap < <gv
nnoremap j gj
nnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
nnoremap <F1> <nop>
nnoremap Q <nop>
nnoremap K <nop>
colorscheme PaperColor
"colorscheme dracula
highlight CursorLine cterm=NONE ctermbg=darkgray ctermfg=white guibg=darkred guifg=white
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
"
" Plugin options
"
let g:UltiSnipsEditSplit = 'vertical'
let g:UltiSnipsSnippetDirectories=["UltiSnips"]
let g:UltiSnipsExpandTrigger = ',,'
let g:UltiSnipsListSnippets = ',~'
let MRU_Window_Height = 20
let Grep_Skip_Dirs = '.c9 node_modules'
let g:ycm_server_python_interpreter="/usr/bin/python"
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ctrlp#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme = 'zenburn'
let g:airline_powerline_fonts = 1
let g:prettier#config#single_quote = 'true'
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'css': ['prettier'],
\ 'scss': ['prettier'],
\}
let g:ale_javascript_prettier_options = '--single-quote --trailing-comma es5'
let g:ale_fix_on_save = 1
let g:vdebug_options = {
\ 'port' : 9001,
\ 'timeout' : 20,
\ 'server' : '172.17.0.1',
\ 'on_close' : 'stop',
\ 'break_on_open' : 0,
\ 'ide_key' : 'PHP_DEBUGGER',
\ 'debug_window_level' : 0,
\ 'debug_file_level' : 0,
\ 'debug_file' : '',
\ 'watch_window_style' : 'expanded',
\ 'marker_default' : '⬦',
\ 'marker_closed_tree' : '▸',
\ 'marker_open_tree' : '▾',
\ 'sign_breakpoint' : '▷',
\ 'sign_current' : '▶',
\ 'continuous_mode' : 1
\}
let g:vdebug_options['path_maps'] = {
\ '/code' : '/opt/dev-setup/apps/knoxportal',
\}
" Nerd tree
let NERDTreeQuitOnOpen = 1
let NERDTreeAutoDeleteBuffer = 1
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
let NERDTreeIgnore = ['\.py[co]$', '__pycache__', 'node_modules']
let g:NERDTreeWinSize = 30
"
" Open helpers
"
"
function! OpenHelpers()
echom 'Openhelpers start'
if exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1
echom 'Close helpers'
sb __MRU_Files__
q
NERDTreeToggle
sb ~/todo.md
bd
else
echom 'Open helpers'
MRU
NERDTree
wincmd l
vsplit ~/todo.md
vertical resize 35
endif
endfunction
"autocmd bufenter * if (winnr(“$”) == 1 && exists(“b:NERDTreeType”) && b:NERDTreeType == “primary”) | q | endif
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists(“s:std_in”) | NERDTree | endif
" Dim inactive windows using 'colorcolumn' setting
" This tends to slow down redrawing, but is very useful.
" Based on https://groups.google.com/d/msg/vim_use/IJU-Vk-QLJE/xz4hjPjCRBUJ
" XXX: this will only work with lines containing text (i.e. not '~')
" from
if exists('+colorcolumn')
function! s:DimInactiveWindows()
for i in range(1, tabpagewinnr(tabpagenr(), '$'))
let l:range = ""
if i != winnr()
if &wrap
" HACK: when wrapping lines is enabled, we use the maximum number
" of columns getting highlighted. This might get calculated by
" looking for the longest visible line and using a multiple of
" winwidth().
let l:width=256 " max
else
let l:width=winwidth(i)
endif
let l:range = join(range(1, l:width), ',')
endif
call setwinvar(i, '&colorcolumn', l:range)
endfor
endfunction
augroup DimInactiveWindows
au!
au WinEnter * call s:DimInactiveWindows()
au WinEnter * set cursorline
au WinLeave * set nocursorline
augroup END
endif" Dim inactive windows using 'colorcolumn' setting
" This tends to slow down redrawing, but is very useful.
" Based on https://groups.google.com/d/msg/vim_use/IJU-Vk-QLJE/xz4hjPjCRBUJ
" XXX: this will only work with lines containing text (i.e. not '~')
" from
if exists('+colorcolumn')
function! s:DimInactiveWindows()
for i in range(1, tabpagewinnr(tabpagenr(), '$'))
let l:range = ""
if i != winnr()
if &wrap
" HACK: when wrapping lines is enabled, we use the maximum number
" of columns getting highlighted. This might get calculated by
" looking for the longest visible line and using a multiple of
" winwidth().
let l:width=256 " max
else
let l:width=winwidth(i)
endif
let l:range = join(range(1, l:width), ',')
endif
call setwinvar(i, '&colorcolumn', l:range)
endfor
endfunction
augroup DimInactiveWindows
au!
au WinEnter * call s:DimInactiveWindows()
au WinEnter * set cursorline
au WinLeave * set nocursorline
augroup END
endif
function! GotoJump()
jumps
let j = input("Please select your jump: ")
if j != ''
let pattern = '\v\c^\+'
if j =~ pattern
let j = substitute(j, pattern, '', 'g')
execute "normal " . j . "\<c-i>"
else
execute "normal " . j . "\<c-o>"
endif
endif
endfunction
"## NOTES ##
" gf - goto file - goto the filename then gf
" vim -d file1 file2 - diff files
" vim file.zip - opens a zip file and list all contents - option to open file
" % - means current file
" :r !<command> - read in to current buffer
" :vertical sb 3 - create vsplit - load buffer 3
"
" <Esc> is the escape key or use <ctrl>[ sometimes written as <C-[>
"vimtutor : starts vim editing a copy of a tutorial file -- very good.
"i : insert mode. Next keys typed are inserted into the file.
"<Esc> : Escape from insert mode so you can navigate and use edit commands (stop selecting)
"h j k l : move cursor ( h: ← j: ↓ k: ↑ l: → )
"A : Append at end of line
"o : Insert at new line below
"u : undo last command, again and again
"x : delete character under cursor
"dw : delete everything right from the cursor to the start of next word (and put it into the default register)
"dd : delete line (and put it into the default register)
"p : paste the default register
"/myname : search forward for myname
":wq : write and quit
":x : write and quit
":w filename : write a copy of the file you are editing as filename
":q! : quit without saving even if changes were made!
":help : display help
"<Tab> : use tab completion to scroll through commands that start with what you typed<Esc> is the escape key or use <ctrl>[ sometimes written as <C-[>