forked from sontek/homies
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_vimrc
324 lines (279 loc) · 9.76 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
" https://github.com/sontek/dotfiles/
" ==========================================================
" Dependencies - Libraries/Applications outside of vim
" ==========================================================
" Pep8 - http://pypi.python.org/pypi/pep8
" Pyflakes
" Ack
" Rake & Ruby for command-t
" nose, django-nose
" ==========================================================
" Plugins included
" ==========================================================
" Pathogen
" Better Management of VIM plugins
"
" GunDo
" Visual Undo in vim with diff's to check the differences
"
" Pytest
" Runs your Python tests in Vim.
"
" Commant-T
" Allows easy search and opening of files within a given path
"
" Snipmate
" Configurable snippets to avoid re-typing common comands
"
" PyFlakes
" Underlines and displays errors with Python on-the-fly
"
" Fugitive
" Interface with git from vim
"
" Git
" Syntax highlighting for git config files
"
" Minibufexpl
" Visually display what buffers are currently opened
"
" Pydoc
" Opens up pydoc within vim
"
" Surround
" Allows you to surround text with open/close tags
"
" Py.test
" Run py.test test's from within vim
"
" MakeGreen
" Generic test runner that works with nose
"
" ==========================================================
" Shortcuts
" ==========================================================
set nocompatible " Don't be compatible with vi
let mapleader="," " change the leader to be a comma vs slash
set hidden
nnoremap ' `
nnoremap ` '
set history=1000
set winheight=40
" Seriously, guys. It's not like :W is bound to anything anyway.
command! W :w
" sudo write this
cmap W! w !sudo tee % >/dev/null
" remap arrow keys
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
map ; :
" Toggle the tasklist
map <leader>td <Plug>TaskList
" Run pep8
let g:pep8_map='<leader>8'
" run py.test's
nmap <silent><Leader>tf <Esc>:Pytest file<CR>
nmap <silent><Leader>tc <Esc>:Pytest class<CR>
nmap <silent><Leader>tm <Esc>:Pytest method<CR>
nmap <silent><Leader>tn <Esc>:Pytest next<CR>
nmap <silent><Leader>tp <Esc>:Pytest previous<CR>
nmap <silent><Leader>te <Esc>:Pytest error<CR>
" Run django tests
map <leader>dt :set makeprg=python\ manage.py\ test\|:call MakeGreen()<CR>
" ,v brings up my .vimrc
" ,V reloads it -- making all changes active (have to save first)
map <leader>v :sp ~/.vimrc<CR><C-W>_
map <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
" open/close the quickfix window
nmap <leader>c :copen<CR>
nmap <leader>cc :cclose<CR>
" for when we forget to use sudo to open/edit a file
cmap w!! w !sudo tee % >/dev/null
" softbol
imap <home> <esc>^i
" ctrl-jklm changes to that split
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
let i = 1
while i <= 9
execute 'nnoremap <Leader>' . i . ' :' . i . 'wincmd w<CR>'
let i = i + 1
endwhile
function! WindowNumber()
let str=tabpagewinnr(tabpagenr())
return str
endfunction
set laststatus=2
" and lets make these all work in insert mode too ( <C-O> makes next cmd
" happen as if in command mode )
imap <C-W> <C-O><C-W>
" Open NerdTree
map <leader>n :NERDTreeToggle<CR>
" Run command-t file search
map <leader><leader> :CommandT<CR>
" Ack searching
nmap <leader>a <Esc>:Ack!
" Load the Gundo window
map <leader>g :GundoToggle<CR>
" Jump to the definition of whatever the cursor is on
map <leader>j :RopeGotoDefinition<CR>
" Rename whatever the cursor is on (including references to it)
map <leader>r :RopeRename<CR>
" hide matches on <leader>space
nnoremap <leader><space> :nohlsearch<cr>
" vimgrep and display in quickfix window
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
function! MarkWindowSwap()
let g:markedWinNum = winnr()
endfunction
function! DoWindowSwap()
"Mark destination
let curNum = winnr()
let curBuf = bufnr( "%" )
exe g:markedWinNum . "wincmd w"
"Switch to source and shuffle dest->source
let markedBuf = bufnr( "%" )
"Hide and open so that we aren't prompted and keep history
exe 'hide buf' curBuf
"Switch to dest and shuffle source->dest
exe curNum . "wincmd w"
"Hide and open so that we aren't prompted and keep history
exe 'hide buf' markedBuf
endfunction
nmap <silent> <leader>ms :call MarkWindowSwap()<CR>
nmap <silent> <leader>mp :call DoWindowSwap()<CR>
" Fast saving, conflicts with EasyMotion
" nmap <leader>w :w!<cr>
" start easy motion, no leareder Key
noremap r .
let g:EasyMotion_leader_key = '.'
" ==========================================================
" Pathogen - Allows us to organize our vim plugins
" ==========================================================
" Load pathogen with docs for all plugins
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" extend % matching
runtime macros/matchit.vim
" vimrc file for following the coding standards specified in PEP 7 & 8.
"
" To use this file, source it in your own personal .vimrc file (``source
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
" (read below for an explanation of the command) so blind sourcing of this file
" is safe and will not affect your settings for non-Python or non-C files.
"
"
" All setting are protected by 'au' ('autocmd') statements. Only files ending
" in .py or .pyw will trigger the Python settings while files ending in *.c or
" *.h will trigger the C settings. This makes the file "safe" in terms of only
" adjusting settings for Python and C files.
"
" Only basic settings needed to enforce the style guidelines are set.
" Some suggested options are listed but commented out at the end of this file.
" Number of spaces to use for an indent.
" This will affect Ctrl-T and 'autoindent'.
" Python: 4 spaces
" C: 8 spaces (pre-existing files) or 4 spaces (new files)
syntax on " syntax highlighing
filetype on " try to detect filetypes
filetype plugin on
filetype plugin indent on " enable loading indent file for filetype
set nosmartindent
set background=dark " We are using dark background in vim
set title " show title in console title bar
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set undodir=~/.vim-tim/undodir
set undofile
" searches case-sensitive only if there is a capital letter in the search expression. *-style searches continue to be consistently case-sensitive.
set ignorecase
set smartcase
set hls
set shiftwidth=4
"While typing a search command, show where the pattern matches
setlocal incsearch
"When there is a previous search pattern, highlight all its matches
setlocal hlsearch
" Ignore these files when completing
set wildignore+=*.o,*.obj,.git,*.pyc
set grepprg=ack-grep " replace the default grep program with ack
au FileType python set omnifunc=pythoncomplete#Complete
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
au BufRead *.c,*.cpp,*.h set shiftwidth=4
au BufNewFile *.c,*.cpp,*.h set shiftwidth=4
" Number of spaces that a pre-existing tab is equal to.
" For the amount of space used for a new tab use shiftwidth.
" Python: 4
" C: 4
set softtabstop=4 " makes the spaces feel like real tabs
set tabstop=4
au BufRead,BufNewFile *py,*pyw,*.c,*.cpp,*.h set tabstop=4
" Replace tabs with the equivalent number of spaces.
" Also have an autocmd for Makefiles since they require hard tabs.
" Python: yes
" C: no
" Makefile: no
au BufRead,BufNewFile *.py,*.pyw set expandtab
au BufRead,BufNewFile *.c,*.h set noexpandtab
au BufRead,BufNewFile Makefile* set noexpandtab
au BufNewFile,BufRead *.mako set ft=mako
" Use the below highlight group when displaying bad whitespace is desired
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.cpp,*.h match BadWhitespace /\s\+$/
" Wrap text after a certain number of characters
" Python: 79
" C: 79
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=179
" Use UNIX (\n) line endings.
" Only used for new files so as to not force existing files to change their
" line endings.
" Python: yes
" C: yes
au BufNewFile *.py,*.pyw,*.c,*.cpp,*.h set fileformat=unix
" ----------------------------------------------------------------------------
" The following section contains suggested settings. While in no way required
" to meet coding standards, they are helpful.
" Set the default file encoding to UTF-8: ``
set encoding=utf-8
" Puts a marker at the beginning of the file to differentiate between UTF and
" UCS encoding (WARNING: can trick shells into thinking a text file is actually
" a binary file when executing the text file): ``set bomb``
" For full syntax highlighting:
let python_highlight_all=1
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set wildmenu
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set wildmenu
set wildmode=longest:full
set wildignore=*.pyc
set foldmethod=indent " allow us to fold on indents
set foldlevel=99 " don't fold by default
"inoremap # #
"setlocal omnifunc=syntaxcomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
set completeopt=menuone,longest,preview
let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
highlight Pmenu guibg=brown gui=bold
colorscheme mustang
set guifont=Akkurat-Mono\ 9
" remove toolbar
set guioptions-=T
" and the scroll bars
set guioptions-=L
set guioptions-=r
let g:pyflakes_use_quickfix = 0
let g:sql_type_default = 'plsql'