-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_vimrc
287 lines (230 loc) · 8.91 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
" Cameron's VIMRC File!
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
source $HOME/bundles.vim
" change default font
set guifont=Powerline\ Consolas:h11
" fix indenting; use spaces instead of tabs, auto-indent for detected
" filetypes, etc
filetype plugin indent on
set tabstop=4 shiftwidth=4 expandtab softtabstop=4
set backspace=indent,eol,start
" some security thing
set modelines=0
" useful lines from 'coming home to vim' blog
set encoding=utf-8
set scrolloff=3
set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set ruler
set laststatus=2
set relativenumber " gives relative line numbers from the current line!
set undofile " saves an external undo file for permanent undo history
set undodir=$HOME/.vim/undo// "puts the undo file in a central folder
" move backup and undo files to a central folder
:set directory=$HOME/.vim/swapfiles//
" search improvments
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch
nnoremap <tab> %
vnoremap <tab> %
"This unsets the "last search pattern" register by hitting return
nnoremap <CR> :noh<CR><CR>
" line wrapping shit
set wrap
set textwidth=79
set colorcolumn=85
" remap F1 to ESCAPE so you don't accidentally open HELP
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" remap semicolon to colon so you can call commands without pushing shift
nnoremap ; :
" save all files when you take focus away from vim
au FocusLost * :wa
" enable syntax highlighting
syntax on
" automatically reload vimrc file on save
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }
" set all copy-paste buffer to just use the windows clipboard. less
" confusing... maybe I'll want to turn it off someday? doubt it
" I turned it off!!!
"set clipboard=unnamed
" disable auto insertion of comment line precursor when you push enter
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" map the leader to the comma key
let mapleader=","
" hide the stupid gvim toolbar
set guioptions-=T
" hide the vim menu bar too
set guioptions-=m
" hide the nerdtree left scrollbar
set guioptions-=L
" Rainbow Paranthesis customizations and auto-enable
let g:rainbow#max_level = 16
let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']]
call rainbow_parentheses#activate()
" fix font rendering
set renderoptions=type:directx,gamma:1.0,contrast:0.2,level:1.0,geom:1,renmode:5,taamode:1
" change color scheme
let g:airline_theme='gruvbox'
let g:airline_powerline_fonts = 1
colorscheme gruvbox
" show line numbers
set number
" make sure splits appear to the right
set splitright
"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" closes all buffers out
nnoremap <Leader>bc :bufdo bd<CR>
" nerd tree leader commands
map <Leader>nt :NERDTreeToggle<CR>
map <Leader>ncd :NERDTreeCWD<CR>
" Show AIRLINE tabs at the top for each buffer
let g:airline#extensions#tabline#enabled = 1
" set ,bg to quickly toggle back and forth between light and dark colourscheme.
map <Leader>bg :let &background = ( &background == "dark"? "light" : "dark" )<CR>
" set control P to search CWD, not current file's directory
let g:ctrlp_working_path_mode = 'w'
" Allows you to save and resume working sessions!
map <F2> :mksession! ~/.vim_session <cr> " Quick write session with F2
map <F3> :source ~/.vim_session <cr> " And load session with F3
nnoremap <C-Tab> :bnext <cr> " Cycle through the buffers with control-tab
" press ,W to strip all trailing whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" awesome shortcut to instantly open _vimrc in a vertical split
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
" open a vertical split and switch to it
nnoremap <leader>w <C-w>v<C-w>l
" automatically jump to end of pasted text
nnoremap p p`]
" enable omni completion
set omnifunc=syntaxcomplete#Complete
" make a bold popup menu
highlight Pmenu gui=bold
" Set ultisnips triggers
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" ctrlP ignore jekyll build folder
let g:ctrlp_custom_ignore = '_site'
" fix MD files to be recognized as markdown
autocmd BufNewFile,BufRead *.md set filetype=markdown
" fix ASPX files to be recognized as plain html
autocmd BufNewFile,BufRead *.aspx set filetype=html
" maximize on opening
au GUIEnter * simalt ~x
" supertab customization
let g:SuperTabDefaultCompletionType="context"
let g:SuperTabClosePreviewOnPopupClose=1
let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
let g:SuperTabDefaultCompletionTypeDiscovery = ["&omnifunc:<c-x><c-o>","&completefunc:<c-x><c-n>"]
" folding stuff
set nofoldenable " don't start with everything folded!
set foldmethod=indent
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR> "space toggles folds
" disable the flashing error thing
autocmd GUIEnter * set vb t_vb= " for your GUI
autocmd VimEnter * set vb t_vb=
" Open chrome for markdown preview
autocmd BufEnter *.md exe 'noremap <F5> :silent !start chrome.exe %<CR>'
" Run python file in python (and save automatically)
autocmd BufEnter *.py exe 'noremap <F5> :w<CR>:!python %<CR>'
" Configure Jekyll plugin
let g:jekyll_post_dirs = ['_drafts']
let g:jekyll_post_extension = '.md'
let g:jekyll_post_template = [
\ '---',
\ 'title: "JEKYLL_TITLE"',
\ '---',
\ '']
let g:ConqueTerm_ReadUnfocused = 1
" trying a way to jump from html to css
function! JumpToCSS()
let id_pos = searchpos("id", "nb", line('.'))[1]
let class_pos = searchpos("class", "nb", line('.'))[1]
if class_pos > 0 || id_pos > 0
if class_pos < id_pos
execute ":vim '#".expand('<cword>')."' **/*.css"
elseif class_pos > id_pos
execute ":vim '.".expand('<cword>')."' **/*.css"
endif
endif
endfunction
nnoremap <F9> :call JumpToCSS()<CR>
" fix the grep for windows use
set grepprg=grep\ -nH
" can't remember why I put this line below, maybe for transparency? leave it
"autocmd VimEnter * hi Normal ctermbg=none
" vim-markdown options
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_new_list_item_indent = 0
" c# stuff =========================================================================
let g:OmniSharp_selector_ui = 'ctrlp' " Use ctrlp.vim
set noshowmatch "apparently helps speed up omnicomplete
"set completeopt=longest,menuone,preview
"let g:OmniSharp_want_snippet=1
set splitbelow " move documentation to the bottom
let g:syntastic_cs_checkers = ['syntax', 'semantic', 'issues']
augroup omnisharp_commands
autocmd!
"Set autocomplete function to OmniSharp (if not using YouCompleteMe completion plugin)
autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
" build the solution when you push f5
autocmd FileType cs nnoremap <F5> :wa!<cr>:OmniSharpBuildAsync<cr>
" automatic syntax check on events (TextChanged requires Vim 7.4)
autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck
" Automatically add new cs files to the nearest project on save
autocmd BufWritePost *.cs call OmniSharp#AddToProject()
"show type information automatically when the cursor stops moving
autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()
"The following commands are contextual, based on the current cursor position.
autocmd FileType cs nnoremap <F12> :OmniSharpGotoDefinition<cr>
autocmd FileType cs nnoremap <leader>fi :OmniSharpFindImplementations<cr>
autocmd FileType cs nnoremap <leader>ft :OmniSharpFindType<cr>
autocmd FileType cs nnoremap <leader>fs :OmniSharpFindSymbol<cr>
autocmd FileType cs nnoremap <leader>fu :OmniSharpFindUsages<cr>
"finds members in the current buffer
autocmd FileType cs nnoremap <leader>fm :OmniSharpFindMembers<cr>
" cursor can be anywhere on the line containing an issue
autocmd FileType cs nnoremap <leader>x :OmniSharpFixIssue<cr>
autocmd FileType cs nnoremap <leader>fx :OmniSharpFixUsings<cr>
autocmd FileType cs nnoremap <leader>tt :OmniSharpTypeLookup<cr>
autocmd FileType cs nnoremap <leader>dc :OmniSharpDocumentation<cr>
"navigate up by method/property/field
autocmd FileType cs nnoremap <C-K> :OmniSharpNavigateUp<cr>
"navigate down by method/property/field
autocmd FileType cs nnoremap <C-J> :OmniSharpNavigateDown<cr>
augroup end
" rename with dialog
nnoremap <leader>nm :OmniSharpRename<cr>
nnoremap <leader>cf :OmniSharpCodeFormat<cr>
"===================================================================================
"" syntastic beginner recommended settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_loc_list_height = 5