-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
304 lines (251 loc) · 11.1 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
" ============= Basics ============={
set nocompatible " get out of horrible vi-compatible mode
set background=dark " we are using a dark background
" ============= Configuring Pathogen ============={
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" }
syntax on " syntax highlighting on
filetype on
filetype plugin indent on " load filetype plugins and indent settings
if has("gui_running")
colorscheme railscasts
set guifont=Ubuntu\ Mono\ 12
set guioptions=aem "adding otherelse
set showtabline=2
endif
" }
" ============= General ============={
set history=1000 " How many lines of history to remember
set clipboard+=unnamed " turns out I do like is sharing windows clipboard
set fileformats=unix,dos,mac " support all three, in this order
set viminfo+=! " make sure it can save viminfo
set iskeyword+=_,$,@,%,# " none of these should be word dividers, so make them not be
set nostartofline " leave my cursor where it was
" }
" ============= Files/Backups ============={
set sessionoptions+=globals " What should be saved during sessions being saved
set sessionoptions+=localoptions " What should be saved during sessions being saved
set sessionoptions+=resize " What should be saved during sessions being saved
set sessionoptions+=winpos " What should be saved during sessions being saved
" }
" ============= Vim UI ============={
set popt+=syntax:y " Syntax when printing
set showcmd " show the command being typed
set showmode " show command mode
if has("gui_running")
set lines=35 columns=163 "Size
endif
set linespace=0 " space it out a little more (easier to read)
set wildmenu " turn on wild menu
set wildmode=list:longest " turn on wild menu in special format (long format)
set wildignore=*.pyc,*.pyo,*.dll,*.o,*.obj,*.bak,*.exe,*.swo,*.swp,*.jpg,*.gif,*.png " ignore some formats
set ruler " Always show current positions along the bottom
set cmdheight=1 " the command bar is 1 high
set number " turn on line numbers
set numberwidth=4 " If we have over 9999 lines, ohh, boo-hoo
set lazyredraw " do not redraw while running macros (much faster) (LazyRedraw)
set hidden " you can change buffer without saving
set backspace=2 " make backspace work normal
set whichwrap+=<,>,[,],h,l " backspace and cursor keys wrap to
"set mouse=a " use mouse everywhere
"set shortmess=atI " shortens messages to avoid 'press a key' prompt
set report=0 " tell us when anything is changed via :...
set noerrorbells " don't make noise
set ttyfast
set list listchars=tab:\ \ ,trail:· " mark trailing white space
" }
" ============= Visual Cues ============={
set showmatch " show matching brackets
set matchtime=5 " how many tenths of a second to blink matching brackets for
set hlsearch
set incsearch " BUT do highlight as you type you search phrase
set scrolloff=3 " Keep 5 lines (top/bottom) for scope
set sidescrolloff=3 " Keep 5 lines at the size
set vb " blink instead beep
set statusline=%f%m%r%h%w\ [TYPE=%Y]\ [ENCODE=%{&fenc}]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]\ %{fugitive#statusline()}
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ENCODE=%{&fenc}]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2 " always show the status line
" }
" ============= Indent Related ============={
set nosmartindent " smartindent (filetype indenting instead)
set autoindent " autoindent (should be overwrote by cindent or filetype indent)
set cindent " do c-style indenting
set softtabstop=4 " unify
set shiftwidth=4 " unify
set tabstop=4 " real tabs should be 4, but they will show with set list on
set expandtab
set copyindent " but above all -- follow the conventions laid before us
" }
" ============= Text Formatting/Layout ============={
set formatoptions=tcrq " See Help (complex)
set shiftround " when at 3 spaces, and I hit > ... go to 4, not 5
set nowrap " do not wrap line
set preserveindent " but above all -- follow the conventions laid before us
set ignorecase " case insensitive by default
set smartcase " if there are caps, go case-sensitive
set completeopt=menu,longest,preview " improve the way autocomplete works
set nocursorcolumn " show the current column
" }
" ============= Folding ============={
set foldenable " Turn on folding
" set foldmarker={,} " Fold C style code (only use this as default if you use a high foldlevel)
" set foldcolumn=2 " Give 1 column for fold markers
set foldopen-=search " don't open folds when you search into them
set foldopen-=undo " don't open folds when you undo stuff
set foldmethod=marker " Fold on the marker
set foldlevel=1000 " Don't autofold anything (but I can still fold manually)
:highlight Folded guibg=grey guifg=blue " Customize color folded
:highlight FoldColumn guibg=darkgrey guifg=white" Customize fold column
" }
" ============= Indent Guides ============={
let g:indent_guides_start_level=2
let g:indent_guides_indent_levels=20
let g:indent_guides_color_change_percent=5
let g:indent_guides_guide_size=1
let g:indent_guides_space_guides=1
let g:indent_guides_enable_on_vim_startup = 1
" }
" ============= Gist ============={
let g:gist_clip_command = 'xclip -selection clipboard' " copy the gist code
let g:gist_detect_filetype = 1 " detect filetype from filename
let g:gist_open_browser_after_post = 1 " open browser after the post
let g:gist_browser_command = 'google-chrome %URL% &' " change the browser
let g:github_user = 'gilsondev'
let g:github_token = '<insert your token github account>'
" }
" ============= Vim PEP8 ============={
let g:pep8_args = "--show-source --ignore=E501" "View source and ignore type error E501
autocmd FileType python map <buffer> <F5> :call Pep8()<CR>
" }
" ============= Mappings =========== {
" ============= Tab navigation ============={
noremap <C-S-N> :tabnew <CR>
inoremap <C-S-N> :tabnew <CR><Insert>
noremap <S-Right> :tabn<CR>
inoremap <S-Right> <esc>:tabn<CR><Insert>
noremap <S-Left> :tabprev<CR>
inoremap <S-Left> <ESC>tabprev<CR><Insert>
" }
" ============= Shortcut Save (default in others editors) ============={
noremap <C-S> :w<CR>
inoremap <C-S> <ESC>:w<CR><Insert>
noremap <C-X> :x<CR>
noremap <C-C> :y <CR>
" }
" ============= Switch background modes ============={
noremap <leader>l :set background=light<CR>
noremap <leader>d :set background=dark<CR>
" }
" ============= Shortcuts NERDTree ============={
noremap <C-B> :NERDTreeToggle<CR>
" }
" ============= Shortcuts Buffers ============={
map <A-Left> :bnext <CR>
map <A-Right> :bprevious <CR>
" }
" ============= Shortcuts Fuzzy Finder ============={
noremap <C-P> :FufFile **/<CR>
noremap <C-G> :FufLine<CR>
noremap <C-M-P> :FufBuffer<CR>
noremap <C-R> :FufRenewCache<CR>
" }
" ============= Shortcuts Fontzoom ============={
nnoremap <silent> <Plug>(fontzoom-larger)
\ :<C-u>Fontzoom +<C-r>=v:count1<CR><CR>
nnoremap <silent> <Plug>(fontzoom-smaller)
\ :<C-u>Fontzoom _<C-r>=v:count1<CR><CR>
" }
" }
function LoadDjangoGoodies()
" Django customization
" it only works if you are at base of django site
if filewritable('settings.py')
" set DJANGO_SETTINGS_MODULE
let $DJANGO_SETTINGS_MODULE=split( getcwd(),'/')[-1].".settings"
" set right type of file, python.django for .py files,
" htmldjango.django_template.xhtml or htmldjango.django_template.html
" for html files. This bigname for html ft is to use both syntax of
" Dave Hodder and SnipMate of Michael Sanders (and xhtml/html goodies
" too)
let l:escapefromhere=0
if &ft=="python"
set ft=python.django
elseif &ft=="html" || &ft=="xhtml"
set ft=htmldjango.html
else
let l:escapefromhere=1
endif
if l:escapefromhere == 0
" Set python path on enviroment, vim and python
" if you are at /www/mysite/ we add to path /www and /www/mysite
" so can complete mysite.
let $PYTHONPATH .= ":/".join(split( getcwd(),'/')[-3:-2],'/')."/:/".join(split( getcwd(),'/')[0:-1],'/')."/"
exec "set path+='/".join(split( getcwd(),'/')[0:-2],'/')."/,/".join(split( getcwd(),'/')[0:-1],'/')."/'"
python import os,sys,vim
exec "python sys.path.insert(0,'/".join(split( getcwd(),'/')[0:-2],'/')."')"
exec "python sys.path.insert(0,'/".join(split( getcwd(),'/')[0:-1],'/')."')"
endif
endif
endfunction
" ============= Python customization ============={
function LoadPythonGoodies()
if &ft=="python"||&ft=="html"||&ft=="xhtml"
" settings for django, for something unknow I need to call before python
" path set
call LoadDjangoGoodies()
" set python path to vim
python << EOF
import os, sys, vim
for p in sys.path:
if os.path.isdir(p):
vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))
EOF
" some nice adjustaments to show errors
syn match pythonError "^\s*def\s\+\w\+(.*)\s*$" display
syn match pythonError "^\s*class\s\+\w\+(.*)\s*$" display
syn match pythonError "^\s*for\s.*[^:]\s*$" display
syn match pythonError "^\s*except\s*$" display
syn match pythonError "^\s*finally\s*$" display
syn match pythonError "^\s*try\s*$" display
syn match pythonError "^\s*else\s*$" display
syn match pythonError "^\s*else\s*[^:].*" display
"syn match pythonError "^\s*if\s.*[^\:]$" display
syn match pythonError "^\s*except\s.*[^\:]$" display
syn match pythonError "[;]$" display
syn keyword pythonError do
let python_highlight_builtins = 1
let python_highlight_exceptions = 1
let python_highlight_string_formatting = 1
let python_highlight_string_format = 1
let python_highlight_string_templates = 1
let python_highlight_indent_errors = 1
let python_highlight_space_errors = 1
let python_highlight_doctests = 1
"PEP8 Checker
noremap <C-S> :!pep8 %<CR>
" complain to PEP 8 (Style Guide for Python Code) : http://www.python.org/dev/peps/pep-0008/
" I added here too in case of make some shit in middle code :D
set ai tw=79 ts=4 sts=4 sw=4 et
endif
endfunction
if !exists("myautocmds")
let g:myautocmds=1
" Sparkup
let g:sparkupExecuteMapping = '<c-d>'
" Pyflakes
let g:pyflakes_use_quickfix = 0
"call LoadPythonGoodies()
"autocmd Filetype python,html,xhtml call LoadPythonGoodies()
au BufNewFile,BufRead *.py,*.html call LoadPythonGoodies()
" JSON Extension
au BufNewFile,BufRead *.json set filetype=json foldmethod=syntax
" Django
autocmd FileType python set ft=python.django " For SnipMate
autocmd FileType html set ft=htmldjango.html " For SnipMate
" Omni completion
"autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
endif