-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
341 lines (281 loc) · 10.5 KB
/
vimrc
File metadata and controls
341 lines (281 loc) · 10.5 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
" List of mappings
"----------------
" ,ve - Open vimrc
" ,vs - Source vimrc
" ,d - Insert current date
" ,hl - Toggle search highlighting
" ,l - Show hidden characters
" ,py - Execute current python script
" ,w - Toggle word wrapping
" ,s - Toggle spell checking
"
" ,nt - Open NERDtree
" ,nf - Open NERDtree using current file's directory
" ,wm - Toggle NERDTree
"
" C-down - Move current line/selection down
" C-up - Move current line/selection up
" C-] - Simple brace completion
" Pathogen
call pathogen#infect()
"==============================================================================
"HOW IT WORKS
"==============================================================================
set backspace=indent,eol,start "Allows backspacing over stuff
set complete+=t "Tag completion
"set cpoptions+=$ "Overwrite text (visually)
set cursorline
set cursorcolumn
set encoding=utf-8
set fillchars= "Remove the characters in window separators
set hidden "Allows hidden buffers with changes
set hlsearch "When there is a previous search pattern, highlight all its matches.
set ignorecase "Search is case insensitive unless...
set incsearch "Show match while entering search
set laststatus=2 "Status line is always on
"set mouse-=a "Disable mouse
set nocompatible "Git tae, Vi compatibility
set nostartofline "Stop jumping to the start of a line
set nofoldenable "Don't fold by default"
set pastetoggle=<F2> "Use F2 to toggle paste on/off in insert mode
set ruler "Show the line and column number of the cursor position, separated by a comma.
"set scrolloff=8 "Keeps the cursor centered while scrolling
"set shellslash "Use / instead of \ for file paths and such
set shortmess+=I "Remove the intro message
set showmatch "Jump to matching paren when inserting
set smartcase "An uppercase letter is found
set spl=en_gb "Language for spellchecking
set vb "Visual bell
set viminfo+=<0 "Don't save registers
set viminfo-=<50 "Same as above, removes default stuff from viminfo
set virtualedit=all "Cursor can move anywhere (ish)
"set wildmenu "Display options when autocompleting in cmdline mode
set fileencoding=utf8
set termencoding=utf8
if version >= 703
set colorcolumn=72,79 "Highlight columns
set relativenumber "Show the line number relative to the line with the cursor in front of each line.
set undofile
endif
"filetype off
filetype plugin indent on "Filetype plugin
syntax on "Syntax highlighting
"==============================================================================
"MAPPINGS
"==============================================================================
let mapleader=','
"Default vimrc mappings
nnoremap <Leader>ve :e $MYVIMRC<CR>
nnoremap <Leader>vs :so $MYVIMRC<CR>
"Macvim vimrc mappings
if has('unix')
nnoremap <Leader>ve :e ~/.gvimrc<CR>
nnoremap <Leader>vs :so ~/.gvimrc<CR>
endif
"Cd to current file's dir
nnoremap <Leader>cd :cd %:h<CR>:pwd<CR>
"Insert current date
nnoremap <Leader>d "=strftime('%d %b %Y')<CR>P
"Moving between buffers
nnoremap <silent> <C-n> :bn<CR>
nnoremap <silent> <C-b> :bp<CR>
"Toggle search highlighting
nnoremap <Leader>hl :set invhls<CR>:set hls?<CR>
"Show hidden chars
nnoremap <silent> <Leader>l :set invlist<CR>
"Run python script
nnoremap <Leader>py :!python %<CR>
"wrap / Nowrap
nnoremap <Leader>w :set invwrap<CR>
"Spell checking
nnoremap <Leader>s :set invspell<CR>
"Simple brace completion
inoremap <C-]> {<CR>}<ESC>O
"Remove quoutes
nnoremap <Leader>q di'hPl2x<CR>
"==============================================================================
"HOW IT LOOKS
"==============================================================================
set t_Co=256
"colorscheme wombat256mod
colorscheme onedark
set tabstop=4 "Tab character width
set softtabstop=4 "Amount of whitespace to be inserted
set shiftwidth=4 "Amount of whitespace in Normal mode
set expandtab "Spaces rather than tabs
set autoindent
set smarttab
set number "Line numbering
set background=dark "Better colours for a dark background
set go-=T
"Stops words being hypenated when wrapping
set wrap lbr
" Show hidden tabs
set list!
" Shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>
"Setting hidden chars
set listchars=tab:>-,trail:~
"set listchars=tab:>-,trail:~,eol:¬
"" Use the same symbols as TextMate for tabstops and EOLs
"set listchars=tab:▸\ ,eol:¬
"Autocmds
"--------
if has('autocmd')
"Setting filetypes
au BufRead,BufNewFile *.ini set filetype=dosini
au BufRead,BufNewFile supervisord.conf set filetype=dosini
au BufRead,BufNewFile Vagrantfile set filetype=ruby
au BufRead,BufNewFile Rakefile set filetype=ruby
" nginx
au BufRead,BufNewFile */webserver/files/conf/* set ft=nginx
" Python indent for Twitter
au BufRead,BufNewFile *.py setl shiftwidth=2 tabstop=2 softtabstop=2
"html/css/js indentation
au BufRead,BufNewFile *.html setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile *.css setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile *.js setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile *.jade setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile *.scss setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile *.yml setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile Vagrantfile setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile Rakefile setl shiftwidth=2 tabstop=2 softtabstop=2
au BufRead,BufNewFile *.rb setl shiftwidth=2 tabstop=2 softtabstop=2
endif
"==============================================================================
"PLUGINS
"==============================================================================
"NERDTree
let NERDTreeWinPos='left'
nnoremap <silent> <Leader>nt :NERDTree.<CR>
"Open tree using file's directory
nnoremap <silent> <Leader>nf :NERDTree %:p:h<CR>
nmap wm :NERDTreeToggle<cr>
" MiniBufExpl
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
" Grep
nnoremap <silent> <F3> :Grep<CR>
" Tagbar
nnoremap <silent> <F4> :TagbarToggle<CR>
if executable("/usr/local/bin/ctags")
let g:tagbar_ctags_bin = '/usr/local/bin/ctags'
else
let g:tagbar_ctags_bin = '/usr/bin/ctags'
endif
let g:tagbar_width = 30
" For gotags per https://github.com/jstemmer/gotags
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" Gundo
nnoremap <silent> <F6> :GundoToggle<CR>
" Python-mode
let g:pymode_virtualenv = 1 "Enable automatic virtualenv detection
let g:pymode_python = 'python3'
" CtrlP
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'rc'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*~,.DS_Store " MacOSX/Linux
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'python': '\.pyc$\|\.ptlc$',
\ 'link': 'some_bad_symbolic_links',
\ }
" unimpaired
" Bubbing single line
nmap <C-Up> [e
nmap <C-Down> ]e
" Bubbing multiple lines
vmap <C-UP> [egv
vmap <C-Down> ]egv
" LustyExplorer
let g:LustyJugglerSuppressRubyWarning = 1
let g:LustyExplorerSuppressRubyWarning = 1
"==============================================================================
"FUNCTIONS
"==============================================================================
if has("autocmd")
autocmd bufwritepost .vimrc source $MYVIMRC
"" Resovle the stange color mass up issue
"if !has('gui_macvim')
" au VimEnter * source ~/.vim/bundle/wombat256mod/colors/wombat256mod.vim
"endif
endif
function! <SID>StripTrailingWhitespacesAndDuplicateBlankLines()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
%s/^\n$//g
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nnoremap <silent> <F5> :call <SID>StripTrailingWhitespacesAndDuplicateBlankLines()<CR>
" In line copy and paste to system clipboard
" reference: http://vim.wikia.com/wiki/In_line_copy_and_paste_to_system_clipboard
"vmap <C-S-c> y:call system("pbcopy", getreg("\""))<CR>
"nmap <C-S-v> :call setreg("\"",system("pbpaste"))<CR>p
hi link EasyMotionTarget ErrorMsg
hi link EasyMotionShade Comment
" ultisnips
let g:UltiSnipsListSnippets = "<F8>"
let g:UltiSnipsJumpForwardTrigger="<C-j>"
let g:UltiSnipsJumpBackwardTrigger="<C-k>"
let g:UltiSnipsDontReverseSearchPath="1"
let g:UltiSnipsSnippetDirectories = ['UltiSnips', 'snippets']
" vim-markdonw
let g:vim_markdown_initial_foldlevel=1
" vim-easy-align
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
"
" Start interactive EasyAlign for a motion/text object (e.g. <Leader>aip)
nmap <Leader>a <Plug>(EasyAlign)
" Disable new window auto documentation
" reference: https://github.com/klen/python-mode/issues/384
set completeopt=menu
set completeopt+=menuone " show the popup menu even when there is only 1 match
set completeopt-=longest " don't insert the longest common text
set completeopt-=preview " don't show preview window
set completeopt+=noinsert " don't insert any text until user chooses a match
set completeopt-=noselect " select first match
" vim freezes when using pymode autocomplete, disable it
" reference: https://github.com/klen/python-mode/issues/405
" let g:pymode_rope_lookup_project = 0
" let g:pymode_rope_complete_on_dot = 0
" let g:pymode_rope = 0
"==============================================================================
"ALIAS
"==============================================================================
:command FS set guifont=Menlo:h17
let g:tagbar_ctags_bin = "/opt/homebrew/bin/ctags"