-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
135 lines (114 loc) · 3.4 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
syntax on
set nocompatible
set tabstop=4
set shiftwidth=4
set expandtab
set nu
set smarttab autoindent
set smartcase
filetype plugin on
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" Comment this line out if pathogen is not installed
" execute pathogen#infect()
" Open nerdtree if vim starts with no files
" autocmd vimenter * if !argc() | NERDTree | endif
"map <C-n> :NERDTreeToggle<CR>
set runtimepath^=~/.vim/bundle/ctrlp.vim
map <C-p> :CtrlP<CR>
set wildignore+=*.zip,*.swp,*.class,*.pyc,*.o,*.so
au VimEnter * RainbowParenthesesToggle
set t_Co=256
set laststatus=2
autocmd FileType make set noexpandtab
" Python settings
autocmd Filetype python set smartindent
autocmd Filetype python set expandtab
autocmd Filetype python set tabstop=4
autocmd Filetype python set shiftwidth=4
autocmd Filetype python inoremap # X#
" Auto insert closing brace and indent in java
autocmd FileType java imap { {<C-O>:call WeirdMap()<Enter>6<C-O>:call ResetMap()<Enter>
function! WeirdMap()
if !empty(matchstr(split(getline('.')),")\$"))
imap 6 <Enter>}<Left><Enter><Up><Tab>
elseif len(split(getline('.'))) == 1
imap 6 <Enter>}<Left><Enter><Up><Tab>
elseif !empty(matchstr(getline('.'), " class "))
imap 6 <Enter>}<Left><Enter><Up><Tab>
elseif !empty(matchstr(getline('.'), " interface "))
imap 6 <Enter>}<Left><Enter><Up><Tab>
else
imap 6 <Left><Right>
endif
endfunction
function! ResetMap()
imap 6 6
endfunction
function! JavaDoc() " :call JavaDoc() on a method sig
let startLine = line('.')
let indentString = ''
let spc = ' '
let i = 0
let splitLine = split(getline(startLine))
while i < indent('.')
let indentString = indentString . spc
let i += 1
endwhile
let i = 1
let hasRet = 1
let lines = [indentString . '/**', indentString . ' * ' . 'Description.']
while i < len(splitLine)
let stringm = matchstr(splitLine[i], '\zs\w\+\ze[),]')
if !empty(stringm)
call add(lines, indentString . ' * @param ' . stringm)
elseif !empty(matchstr(splitLine[i], 'void'))
let hasRet = 0
endif
let i += 1
endwhile
if hasRet
call add(lines, indentString . ' * @return')
endif
call add(lines, indentString . ' */')
exec append(startLine - 1, lines)
exec startLine + 1
endfunction
autocmd FileType java imap <silent> <C-D><C-D> <C-O>:call InsertDoc()<Enter>
function! InsertDoc() " :call JavaDoc() on a method sig
let startLine = line('.')
let indentString = ''
let spc = ' '
let i = 0
let splitLine = split(getline(startLine))
while i < indent('.')
let indentString = indentString . spc
let i += 1
endwhile
let i = 1
let hasRet = 1
let lines = [indentString . '/**', indentString . ' * ', indentString . ' */']
exec append(startLine - 1, lines)
exec startLine + 1
exec 'normal'.99.'|'
endfunction
function! MyFoldLevel( lineNumber )
let thisLine = getline( a:lineNumber )
if ( thisLine =~ '\%(^\s*/\*\*\s*$\)\|{' )
return "a1"
elseif ( thisLine =~ '\%(^\s*\*/\s*$\)\|}' )
return "s1"
endif
return '='
endfunction
" Bindings for go. Some of these will not work without running
" :GoInstallBinaries
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>ds <Plug>(go-def-split)
" Disable beeping.
set noerrorbells visualbell t_vb=