-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotvimrc
More file actions
186 lines (164 loc) · 5.8 KB
/
dotvimrc
File metadata and controls
186 lines (164 loc) · 5.8 KB
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
set nocompatible
syntax on
set backspace=indent,eol,start
set hlsearch
set statusline=%F%m%r%h%w\ [TYPE=%Y]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2
" Begin Vundle
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'https://github.com/vim-syntastic/syntastic.git'
Bundle 'scrooloose/nerdtree'
Bundle 'Valloric/MatchTagAlways'
Bundle 'L9'
Bundle 'wsdjeg/vim-fetch'
" Bundle 'FuzzyFinder'
Bundle 'https://github.com/ctrlpvim/ctrlp.vim.git'
Bundle 'https://github.com/FelikZ/ctrlp-py-matcher.git'
Bundle 'https://github.com/Shougo/unite.vim'
" End Vundle
filetype plugin indent on
" CtrlP
let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
let g:ctrlp_map = ',f'
let g:ctrlp_working_path_mode = 'c'
nnoremap ,F :CtrlP getcwd()<CR>
"let g:ctrlp_prompt_mappings = {
"\ 'PrtSelectMove("j")': ['<A-j>', '<down>'],
"\ 'PrtSelectMove("k")': ['<A-k>', '<up>'],
"\ }
" VimDiff
highlight DiffAdd term=reverse cterm=bold ctermbg=green ctermfg=white
highlight DiffChange term=reverse cterm=bold ctermbg=cyan ctermfg=black
highlight DiffText term=reverse cterm=bold ctermbg=gray ctermfg=black
highlight DiffDelete term=reverse cterm=bold ctermbg=red ctermfg=black
map <C-t> :tabnew<CR>
map <C-w> :call CloseTab()<CR>
" FuzzyFinder
" nnoremap ,f :FufFileWithCurrentBufferDir<CR>
" nnoremap ,F :FufFile<CR>
" nnoremap ,b :FufBuffer<CR>
function JV_FufToggleMatching()
if exists('g:fuf_splitPathMatching') && g:fuf_splitPathMatching == 1
let g:fuf_splitPathMatching = 0
else
let g:fuf_splitPathMatching = 1
endif
endfunction
map <C-n> :call JV_ToggleNERDTree()<CR>
function JV_ToggleNERDTree()
if exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1
execute "NERDTreeToggle"
else
let cwd = getcwd()
execute "cd %:p:h"
execute "NERDTreeCWD"
execute "NERDTreeToggle"
execute "NERDTreeFind"
execute "cd " . cwd
endif
endfunction
" Disable arrow keys
map <Up> <nop>
map <Down> <nop>
map <Right> <nop>
map <Left> <nop>
function HorizontalMove(left)
let currentWindow = winnr()
execute "wincmd " . (a:left ? "h" : "l")
if currentWindow == winnr()
let currentTab = tabpagenr()
execute "tab" . (a:left ? "p" : "n")
if currentTab != tabpagenr()
" TODO Dynamically determine how many windows to shift
execute "wincmd " . (a:left ? "l" : "h")
endif
endif
endfunction
function CloseTab()
let choice = confirm("Close this tab?", "&Yes\n&No", 2)
if choice == 1
execute "tabclose"
endif
endfunction
if has('gui_running')
nmap <silent> <A-h> :call HorizontalMove(1)<CR>
nmap <silent> <A-l> :call HorizontalMove(0)<CR>
nmap <silent> <A-k> :wincmd k<CR>
nmap <silent> <A-j> :wincmd l<CR>
nmap <silent> <A-r> :wincmd r<CR>
nmap <silent> <A-x> :wincmd x<CR>
else
nmap <silent> h :call HorizontalMove(1)<CR>
nmap <silent> l :call HorizontalMove(0)<CR>
nmap <silent> k :wincmd k<CR>
nmap <silent> j :wincmd j<CR>
nmap <silent> r :wincmd r<CR>
nmap <silent> x :wincmd x<CR>
endif
function JV_ToggleLongLineMatches(length)
let w:long_line_match_id = exists('w:long_line_match_id') ? w:long_line_match_id : 0
let w:long_line_match_length = exists('w:long_line_match_length') ? w:long_line_match_length : 0
if w:long_line_match_id == 0 || a:length != w:long_line_match_length
if w:long_line_match_id != 0
call matchdelete(w:long_line_match_id)
endif
let w:long_line_match_id = matchadd('ErrorMsg', '\%>' . a:length . 'v.\+')
let w:long_line_match_length = a:length
echo "Highlight long lines"
else
call matchdelete(w:long_line_match_id)
let w:long_line_match_id = 0
let w:long_line_match_length = 0
echo "No Highlight"
endif
endfunction
nnoremap ,8 :call JV_ToggleLongLineMatches(80)<CR>
nnoremap ,0 :call JV_ToggleLongLineMatches(100)<CR>
nnoremap ,p :set spell!<CR>
set spelllang=en_us
" Enable mouse scrolling and selecting in all mode
set mouse=a
" Emulate ctrl+c / ctrl+p to system clipboard
" set clipboard=unnamed
nmap <c-p> "+gP
imap <c-p> <c-o>"+gp
cmap <c-p> <c-r>+
vmap <c-c> "+y
set smartindent
inoremap # X#
set expandtab tabstop=2 softtabstop=2 shiftwidth=2
augroup testgroup
filetype on
au FileType java setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=2
au FileType html setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=1
au FileType ruby setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=2
au FileType python setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=2
au FileType erlang setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4
" au BufRead *.srcjar set filetype=zip
au BufReadCmd *.srcjar call zip#Browse(expand("<amatch>"))
augroup END
let g:unite_source_menu_menus = {}
let g:unite_source_menu_menus.snippets = { 'description' : 'Auto Snippets' }
let g:unite_source_menu_menus.snippets.command_candidates = {
\ 'import Mockito.when' : 'call JV_AddImport("static org.mockito.Mockito.when")',
\ 'import Mockito.verify' : 'call JV_AddImport("static org.mockito.Mockito.verify")',
\ 'import Mockito.verifyNoMoreInteractions' : 'call JV_AddImport("static org.mockito.Mockito.verifyNoMoreInteractions")',
\ 'import Mockito.verifyZeroInteractions' : 'call JV_AddImport("static org.mockito.Mockito.verifyZeroInteractions")',
\ 'import Truth.assertThat' : 'call JV_AddImport("static com.google.common.truth.Truth.assertThat")'
\ }
nnoremap ,i :Unite -silent -start-insert menu:snippets<CR>
function JV_AddImport(import)
let cursorPos = getpos(".")
let currentImport = search('^import ' . a:import . ';')
if currentImport > 0
exec 'call cursor(cursorPos[1], cursorPos[2])'
echo a:import . ' is already imported'
return
endif
let packageLine = search('^package\ .*;$')
exec 'call append(packageLine, "import " . a:import . ";")'
exec 'call cursor(cursorPos[1] + 1, cursorPos[2])'
endfunction