-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
280 lines (216 loc) · 7 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pluginloader
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call pathogen#infect()
call pathogen#helptags()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" GUI
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" enable automatic title setting for terminals
set title
set titleold="Terminal"
set titlestring=%F
set guioptions=aegitc
set gcr=a:blinkon0
if has("gui_running")
set cursorline
endif
set ttyfast
" GUI Tab settings
function! GuiTabLabel()
let label = ''
let buflist = tabpagebuflist(v:lnum)
if exists('t:title')
let label .= t:title . ' '
endif
let label .= '[' . bufname(buflist[tabpagewinnr(v:lnum) - 1]) . ']'
for bufnr in buflist
if getbufvar(bufnr, '&modified')
let label .= '+'
break
endif
endfor
return label
endfunction
set guitablabel=%{GuiTabLabel()}
" Remember cursor position
au BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Menus I like :-)
" This must happen before the syntax system is enabled
aunmenu Help.
aunmenu Window.
let no_buffers_menu=1
set mousemodel=popup
colorscheme molokai
set guifont=Ubuntu\ \Mono\ 18px
set lsp=4
" Make the command line one line high
set showcmd
set cmdheight=1
set laststatus=2
function! SyntaxItem()
return synIDattr(synID(line("."),col("."),1),"name")
endfunction
set statusline+=%(%3p\ %%\ %9(%3.6l,%-2v%)\ %10f%M\ (%{&ff})\ %r%h%w%)
set statusline+=\ %=%(%{fugitive#statusline()}%)
set number
" %-10.{SyntaxItem()}\
let NERDTreeMinimalUI=1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indentsettings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" go with smartindent if there is no plugin indent file.
" but don't outdent hashes
set smartindent
inoremap # X#
" Tab Settings
set smarttab
set tabstop=4
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntax
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufEnter * :syntax sync fromstart
" Better Search
set hlsearch
set incsearch
" Enable python folding
let g:pymode_folding = 0
filetype plugin indent on
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Filesettings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let NERDTreeIgnore=['\~$', '\.pyc$', '\.pyo$', '\.class$',
\ 'pip-log\.txt$', '\.o$']
let g:netrw_list_hide='^\.,.\(pyc\|pyo\|o\)$'
" Enable hidden buffers
set hidden
" utf-8 default encoding
set enc=utf-8
" prefer unix over windows over os9 formats
set fileformats=unix,dos,mac
" No Compatibility. That just sucks
" especially annoying on redhat/windows/osx
set nocompatible
set backspace=indent,eol,start
" Better modes. Remeber where we are, support yankring
set viminfo=!,'100,\"100,:20,<50,s10,h,n~/.viminfo
" customize the wildmenu
set wildmenu
set wildignore=*.dll,*.o,*.pyc,*.bak,*.exe,*.jpg,*.jpeg,*.png,*.gif,*$py.class
set wildmode=list:full
" change working directory automatically
set autochdir
" Move Backup Files to ~/.vim/sessions
set backupdir=~/.vim/sessions
set dir=~/.vim/sessions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Keymappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = ","
" quicker window switching
nnoremap <silent> <C-h> <C-w>h
nnoremap <silent> <C-j> <C-w>j
nnoremap <silent> <C-k> <C-w>k
nnoremap <silent> <C-l> <C-w>l
nnoremap <silent> <C-Left> <C-w>h
nnoremap <silent> <C-Down> <C-w>j
nnoremap <silent> <C-Up> <C-w>k
nnoremap <silent> <C-Right> <C-w>l
" arrow keys move visible lines
inoremap <silent> <Down> <C-R>=pumvisible()
\ ? "\<lt>Down>" : "\<lt>C-O>gj"<CR>
inoremap <silent> <Up> <C-R>=pumvisible() ? "\<lt>Up>" : "\<lt>C-O>gk"<CR>
nnoremap <silent> <Down> gj
nnoremap <silent> <Up> gk
vnoremap <silent> <Down> gj
vnoremap <silent> <Up> gk
" And be global by default
set gdefault
" tab for brackets
nnoremap <silent> <tab> %
vnoremap <silent> <tab> %
" NERDtree on <leader>t
nnoremap <silent> <leader>t :NERDTree<CR>
nnoremap <silent> <leader>o :CtrlP<CR>
nnoremap <silent> <leader>l :CtrlPBufTag<CR>
nnoremap <silent> <leader>p :CtrlPBufTagAll<CR>
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_extensions = ['tag', 'buffertag']
" LineNr Toggle
nnoremap <F3> :NumbersToggle<CR>
" gundo
nnoremap <silent> <Leader>u :GundoToggle<CR>
" Set key 'R' for run python code
let g:pymode_run_key = '<leader>R'
" remove stupid help
map <silent> <C-b> :Explore!<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Utils
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove trailing whitespace on <leader>S
nnoremap <leader>S :%s/\s\+$//<cr>:let @/=''<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Specific Syntax
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Python
autocmd FileType python setlocal expandtab
\ shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4 smartindent
let python_highlight_all = 1
let python_no_highlight_builtins = 1
let g:pymode_lint_write = 0
let g:pymode_lint_onfly = 0
let g:pymode_lint_cwindow = 0
let g:pymode_lint_ignore = "E501,W402"
""" Rust
autocmd FileType rust setlocal expandtab
\ shiftwidth=4 tabstop=8 colorcolumn=79
\ softtabstop=4 smartindent
""" Coffe
autocmd FileType coffee setlocal expandtab
\ shiftwidth=2 tabstop=2 softtabstop=2
""" PHP (hopefully not)
autocmd FileType php setlocal expandtab
\ shiftwidth=4 tabstop=8 softtabstop=4 smartindent
""" Lua
autocmd FileType lua setlocal expandtab shiftwidth=4 tabstop=8
\ formatoptions+=croq softtabstop=4 smartindent
""" Go
autocmd BufNewFile,BufRead *.go setlocal ft=go
autocmd FileType go setlocal expandtab
\ shiftwidth=4 tabstop=8 softtabstop=4
""" CSS
autocmd FileType css setlocal expandtab
\ shiftwidth=4 tabstop=4 softtabstop=4
""" Rst
autocmd BufNewFile,BufRead *.txt setlocal ft=rst
autocmd FileType rst setlocal expandtab
\ shiftwidth=4 tabstop=4 softtabstop=4
\ formatoptions+=nqt textwidth=74
""" C/C++
autocmd FileType c setlocal expandtab
\ tabstop=4 softtabstop=4 shiftwidth=4
autocmd FileType cpp setlocal expandtab
\ tabstop=4 softtabstop=4 shiftwidth=4
""" vim
autocmd FileType vim setlocal expandtab
\ shiftwidth=2 tabstop=8 softtabstop=2
""" html
autocmd FileType html setlocal expandtab
\ shiftwidth=2 tabstop=2 softtabstop=2
""" javascript
autocmd FileType javascript setlocal expandtab
\ shiftwidth=2 tabstop=2 softtabstop=2
let javascript_enable_domhtmlcss=1
" Java (hopefully not)
" ----------
autocmd FileType java setlocal expandtab
\ tabstop=4 shiftwidth=4 softtabstop=4
nnoremap <silent> <leader>i :JavaImport<cr>
nnoremap <silent> <leader>d :JavaDocSearch -x declarations<cr>
nnoremap <silent> <cr> :JavaSearchContext<cr>