forked from biodiv-archived/biodiv-grails-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
212 lines (173 loc) · 6.13 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
execute pathogen#infect()
syntax on
set sta
set sw=4
set foldmethod=marker
inoremap <F9> <C-O>za
nnoremap <F9> za
onoremap <F9> <C-C>za
vnoremap <F9> zf
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
set hlsearch
set showmatch
" use smart c-like indentation.
set cindent
" dont insert tabs on indentation. use spaces instead.
set expandtab
set autoindent
syntax on
filetype plugin indent on
set wildignore+=*.class,.git,.hg,.svn,target/**
set runtimepath^=~/.vim/bundle/ctrlp.vim
" keys for easy saving and restoring vim session
map <F2> :mksession! ~/vim_session <cr> " Quick write session with F2
map <F3> :source ~/vim_session <cr> " And load session with F3
"source ~/.vim/bundle/matchit/plugin/matchit.vim
"the cursor will briefly jump to the matching brace when you insert one.
set showmatch
set matchtime=3
"The 'showmatch' option will not scroll the screen. To scroll the screen you
"can use a mapping like:
inoremap } }<Left><c-o>%<c-o>:sleep 500m<CR><c-o>%<c-o>a
inoremap ] ]<Left><c-o>%<c-o>:sleep 500m<CR><c-o>%<c-o>a
inoremap ) )<Left><c-o>%<c-o>:sleep 500m<CR><c-o>%<c-o>a
"Bash doesn’t load your .bashrc unless it’s interactive. Use
"to make Vim’s :! shell behave like your command prompt
set shellcmdflag=-ic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
"File Browser
"autocmd vimenter * NERDTree
map <C-n> :NERDTreeToggle<CR>
"Fuzzy Search
map <C-p> :CtrlP<CR>
map <C-m> :CtrlPMRU<CR>
map <C-a> :CtrlPMixed<CR>
" markdown helpers
nnoremap <leader>1 yypVr=
nnoremap <leader>2 yypVr-
nnoremap <leader>3 I# <Esc>A #<Esc>
nnoremap <leader>4 I## <Esc>A ##<Esc>
nnoremap <leader>5 I### <Esc>A ###<Esc>
nnoremap <leader>6 I#### <Esc>A ####<Esc>
" working with split windows
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" EasyGrep
let g:EasyGrepMode=2
let g:EasyGrepCommand=0
let g:EasyGrepRecursive=1
let g:EasyGrepIgnoreCase=1
"Open file under cursor
"map <C-i> :call OpenVariableUnderCursor(expand("<cword>"))<CR>
"map <Leader>h :call FindSubClasses(expand("<cword>"))<CR>
"function! OpenVariableUnderCursor(varName)
" let filename = substitute(a:varName,'(<w+>)', 'u1', 'g')
" :call OpenFileUnderCursor(filename)
"endfunction
"
"function! OpenFileUnderCursor(filename)
" let ext = fnamemodify(expand("%:p"), ":t:e")
" execute ":find " . a:filename . "." . ext
"endfunction
"
"function! FindSubClasses(filename)
" execute ":Grep \(implements\|extends\) " . a:filename
"endfunction
"call ExtractSnips("/home/sravanthi/.vim/bundle/snipmate.vim/snippets/groovyVim/html", "gsp")
"call ExtractSnips("/home/sravanthi/.vim/bundle/snipmate.vim/snippets/groovyVim/grails", "groovy")
"
"On Mac, ‘D’ is the command key in .vimrc. As you can probably guess, Cmd-1
"will copy local changes to the merged file, Cmd-2 will copy from the remote
"file, and Cmd-3 will copy from the base.
map <D-1> :diffget LOCAL<CR>
map <D-2> :diffget REMOTE<CR>
map <D-3> :diffget BASE<CR>
"Grails testing
map <S-F9> <Esc>:w<CR>:call RunSingleGrailsTest()<CR>
map <F9> <Esc>:w<CR>:call RunGrailsTestFile()<CR>
map <D-F9> :call RunLastCommandInTerminal()<CR>
command! TestResults :call TestResults()
function! RunSingleGrailsTest()
let testName = expand("%:t:r.") . "." . expand("<cword>")
:call RunGrailsTest(testName)
endfunction
function! RunGrailsTestFile()
let testName = expand("%:t:r")
:call RunGrailsTest(testName)
endfunction
function! RunGrailsTest(testName)
let path = expand("%:r")
if path =~ "integration"
let flag = "--integration"
else
let flag = "--unit"
endif
execute ":!grails test-app " . flag . " " . a:testName
endfunction
function! TestResults()
silent execute ":!open target/test-reports/html/index.html"
endfunction
" set these up as environment variables on your system, or override
" " per session by using ':let g:grails_user = foo'
let g:grails_user = $DEFAULT_GRAILS_USER
let g:grails_password = $DEFAULT_GRAILS_PASSWORD
let g:grails_base_url = $DEFAULT_GRAILS_BASE_URL
function! Grails_eval_vsplit() range
let temp_source = s:copy_groovy_buffer_to_temp(a:firstline, a:lastline)
let temp_file = s:select_new_temp_buffer()
if strlen(g:grails_user) > 0
" replace current buffer with grails' output
silent execute ":%! postCode.groovy -u " . g:grails_user . " -p " . g:grails_password . " -b " . g:grails_base_url . " " . temp_source . " 2>&1 "
else
silent execute ":%! postCode.groovy -b " . g:grails_base_url . " " . temp_source . " 2>&1 "
endif
wincmd p " change back to the source buffer
endfunction
au BufNewFile,BufRead *.groovy vmap <silent> <F8> :call Grails_eval_vsplit()<CR>
au BufNewFile,BufRead *.groovy nmap <silent> <F8> mzggVG<F8>`z
au BufNewFile,BufRead *.groovy imap <silent> <F8> <Esc><F8>a
au BufNewFile,BufRead *.groovy map <silent> <S-F8> :wincmd P<CR>:q<CR>
au BufNewFile,BufRead *.groovy imap <silent> <S-F8> <Esc><S-F8>a
"to kill running grails application and start app again
nmap <F5> :wa<CR> :silent !pkill -f grails<CR> :call system("screen -X stuff 'ra\n'")<CR>
inoremap <F6> <C-O>za
nnoremap <F6> za
onoremap <F6> <C-C>za
vnoremap <F6> zf
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab