-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugins.vim
385 lines (312 loc) · 10.3 KB
/
plugins.vim
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
" Syntax options for php {{{
" Do not use short tags to find PHP blocks {{{
let php_noShortTags = 1
" }}}
" Highlight SQL inside PHP strings {{{
let php_sql_query=1
" }}}
let php_special_functions = 0
" }}}
if has("autocmd")
au Filetype html,markdown,textile,htmlphp,xml,xsl,rhtml,htmldjango,php source $HOME/.vim/scripts/closetag.vim
endif
"
" Navigate into window with standard hjkl
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne=9999
let g:debuggerMiniBufExpl = 1
let python_highlight_all = 1
let did_django_syn_inits = 1
let python_highlight_space_errors = 0
let NERDTreeIgnore = ['\.pyc$', '\.pyo$', '\.egg-info$', '\.egg-link', '\.class']
let NERDTreeChDirMode = 2
let NERDTreeSortOrder = ['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let NERDTreeShowBookmarks = 1
" CTRLP {{{
noremap <D-t> :CtrlP<CR>
let g:ctrlp_working_path_mode = 2
nnoremap <silent> <D-t> :CtrlP<CR>
nnoremap <silent> <D-r> :CtrlPMRU<CR>
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.pyc$\|\.pyo$\|\.rbc$|\.rbo$\|\.class$\|\.o$\|\~$\',
\ }
" }}}
" MRU {{{
map <Leader>m :MRU<CR>
let MRU_Window_Height = 15
" }}}
if !has('python')
let g:gundo_disable = 1
nnoremap <F5> :GundoToggle<CR>
let g:gundo_debug = 1
let g:gundo_preview_bottom = 1
let g:gundo_tree_statusline = "Gundo"
let g:gundo_preview_statusline = "Gundo Preview"
endif
let delimitMate_expand_cr = 1
let g:pylint_onwrite = 0
let g:pylint_cwindow = 0
let g:pylint_show_rate = 0
let g:pyflakes_use_quickfix = 0
map <D-F> :Ack<space>
map <D-e> :call StartTerm()<CR>
" Project Tree
autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
autocmd FocusGained * call s:UpdateNERDTree()
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
q
endif
endif
endif
endfunction
" If the parameter is a directory, cd into it
function s:CdIfDirectory(directory)
let explicitDirectory = isdirectory(a:directory)
let directory = explicitDirectory || empty(a:directory)
if explicitDirectory
exe "cd " . fnameescape(a:directory)
endif
" Allows reading from stdin
" ex: git diff | mvim -R -
if strlen(a:directory) == 0
return
endif
if directory
NERDTree
wincmd p
bd
endif
if explicitDirectory
wincmd p
endif
endfunction
" NERDTree utility function
function s:UpdateNERDTree(...)
let stay = 0
if(exists("a:1"))
let stay = a:1
end
if exists("t:NERDTreeBufName")
let nr = bufwinnr(t:NERDTreeBufName)
if nr != -1
exe nr . "wincmd w"
exe substitute(mapcheck("R"), "<CR>", "", "")
if !stay
wincmd p
end
endif
endif
if exists(":CommandTFlush") == 2
CommandTFlush
endif
endfunction
" Utility functions to create file commands
function s:CommandCabbr(abbreviation, expansion)
execute 'cabbrev ' . a:abbreviation . ' <c-r>=getcmdpos() == 1 && getcmdtype() == ":" ? "' . a:expansion . '" : "' . a:abbreviation . '"<CR>'
endfunction
function s:FileCommand(name, ...)
if exists("a:1")
let funcname = a:1
else
let funcname = a:name
endif
execute 'command -nargs=1 -complete=file ' . a:name . ' :call ' . funcname . '(<f-args>)'
endfunction
function s:DefineCommand(name, destination)
call s:FileCommand(a:destination)
call s:CommandCabbr(a:name, a:destination)
endfunction
" Public NERDTree-aware versions of builtin functions
function ChangeDirectory(dir, ...)
execute "cd " . fnameescape(a:dir)
let stay = exists("a:1") ? a:1 : 1
NERDTree
if !stay
wincmd p
endif
endfunction
function Touch(file)
execute "!touch " . shellescape(a:file, 1)
call s:UpdateNERDTree()
endfunction
function Remove(file)
let current_path = expand("%")
let removed_path = fnamemodify(a:file, ":p")
if (current_path == removed_path) && (getbufvar("%", "&modified"))
echo "You are trying to remove the file you are editing. Please close the buffer first."
else
execute "!rm " . shellescape(a:file, 1)
endif
call s:UpdateNERDTree()
endfunction
function Mkdir(file)
execute "!mkdir " . shellescape(a:file, 1)
call s:UpdateNERDTree()
endfunction
function Edit(file)
if exists("b:NERDTreeRoot")
wincmd p
endif
execute "e " . fnameescape(a:file)
ruby << RUBY
destination = File.expand_path(VIM.evaluate(%{system("dirname " . shellescape(a:file, 1))}))
pwd = File.expand_path(Dir.pwd)
home = pwd == File.expand_path("~")
if home || Regexp.new("^" + Regexp.escape(pwd)) !~ destination
VIM.command(%{call ChangeDirectory(fnamemodify(a:file, ":h"), 0)})
end
RUBY
endfunction
" Define the NERDTree-aware aliases
call s:DefineCommand("cd", "ChangeDirectory")
call s:DefineCommand("touch", "Touch")
call s:DefineCommand("rm", "Remove")
call s:DefineCommand("e", "Edit")
call s:DefineCommand("mkdir", "Mkdir")
" gist-vim defaults
if has("mac")
let g:gist_clip_command = 'pbcopy'
elseif has("unix")
let g:gist_clip_command = 'xclip -selection clipboard'
endif
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
" Enable syntastic syntax checking
let g:syntastic_enable_signs=1
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_javascript_checkers = ['jslint']
let g:syntastic_python_django_flake8_args = '--ignore=E501'
let g:syntastic_django_flake8_args = '--ignore=E501'
let g:syntastic_python_flake8_args = '--ignore=E501'
let s:opt_indent_size = 4
let s:opt_indent_char = " "
let $JS_CMD='node'
" Fugitive {
nnoremap <leader>gd :Gdiff<cr>
nnoremap <leader>gs :Gstatus<cr>
nnoremap <leader>gp :Gpush<cr>
nnoremap <leader>gw :Gwrite<cr>
nnoremap <leader>ga :Gadd<cr>
nnoremap <leader>gb :Gblame<cr>
nnoremap <leader>gco :Gcheckout<cr>
nnoremap <leader>gci :Gcommit<cr>
nnoremap <leader>gm :Gmove<cr>
nnoremap <leader>gr :Gremove<cr>
nnoremap <leader>gl :Shell git gl -18<cr>:wincmd \|<cr>
augroup ft_fugitive
au!
au BufNewFile,BufRead .git/index setlocal nolist
augroup END
"}
let g:DisableAutoPHPFolding = 1
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" }
"
let s:opt_indent_size = 4
let s:opt_indent_char = " "
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
" return neocomplete#close_popup() . "\<CR>"
" For no inserting <CR> key.
return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"
" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left> neocomplete#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplete#close_popup() . "\<Right>"
"inoremap <expr><Up> neocomplete#close_popup() . "\<Up>"
"inoremap <expr><Down> neocomplete#close_popup() . "\<Down>"
" Or set this.
"let g:neocomplete#enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplete#enable_insert_char_pre = 1
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" Enable snipMate compatibility feature.
let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
let g:go_fmt_command = "gofmt"
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
source $HOME/.vim/rst_table.vim