-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
241 lines (202 loc) · 6.55 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
" Leader
let mapleader = ","
""" Vundle config start
filetype off " required!
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
"Add your bundles here
Bundle 'Syntastic'
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-rails'
Bundle 'altercation/vim-colors-solarized'
Bundle 'kien/ctrlp.vim'
Bundle 'Lokaltog/vim-powerline'
Bundle 'mileszs/ack.vim'
Bundle 'kana/vim-textobj-user'
Bundle 'nelstrom/vim-textobj-rubyblock'
Bundle 'scrooloose/nerdtree'
Bundle 'tomtom/tcomment_vim'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-surround'
Bundle 'vim-scripts/YankRing.vim'
Bundle 'airblade/vim-gitgutter'
Bundle 'thoughtbot/vim-rspec'
Bundle 'croaky/vim-colors-github'
"" vim-snipmate dependencies
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "honza/vim-snippets"
Bundle "garbas/vim-snipmate"
"...All your other bundles...
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
" Setting up Vundle - the vim plugin bundler end
""" Vundle config end
map <Leader>cn :e ~/Dropbox/notes/coding-notes.txt<cr>
map <Leader>pn :sp ~/Dropbox/work/infakt/notes/project-notes.txt<cr>
map <Leader>o :call RunCurrentLineInTest()<CR>
map <Leader>t :w<cr>:call RunCurrentTest()<CR>
"" General settings
syntax on
" Color scheme
colorscheme github
highlight NonText guibg=#060606
highlight Folded guibg=#0A0A0A guifg=#9090D0
set encoding=utf-8
set showcmd " display incomplete commands
filetype plugin indent on " load file type plugins + indentation
set laststatus=2 " Always show the statusline
set hidden " Maintain scroll position (don't close buffer)
runtime macros/matchit.vim " Needed for Ruby block selection support: https://github.com/nelstrom/vim-textobj-rubyblock
set ofu=syntaxcomplete#Complete
" Visual
set showmatch " Show matching brackets.
set mat=5 " Bracket blinking.
set list
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
set listchars=trail:·
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
"" Line numbering, cursor
set number " Show line numbers
set numberwidth=5
set ruler " Show cursor position.
set scrolloff=3 " Show 3 lines of context around the cursor.
" Use Ag (https://github.com/ggreer/the_silver_searcher) instead of Ack when
" available
if executable("ag")
let g:ackprg = 'ag --nogroup --nocolor --column'
endif
" Switch between the last two files
nnoremap <Leader><Leader> <c-^>
"" Yankring
let g:yankring_history_file = '.yankring_history'
map <Leader>y :YRShow<cr>
"" NERDTree
function! ShowFileInNERDTree()
if exists("t:NERDTreeBufName")
NERDTreeFind
else
NERDTree
wincmd l
NERDTreeFind
endif
endfunction
map <Leader>d :call ShowFileInNERDTree()<cr>
"" Wild stuff
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set wildignore+=vendor,log,tmp,*.swp,.git,gems,.bundle,Gemfile.lock,.gem,.rvmrc,.gitignore,.DS_Store,data
"" Misc shortcuts
nnoremap <Leader>\ :nohl<cr> " un-highlight search results
map <F5> :call system('pbcopy', @%)<cr> " Copy file path to clipboard
map <Leader>p :CtrlP<cr>
map <Leader>b :CtrlPBuffer<cr>
"" ctrl + hjkl
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Get rid of the delay when hitting esc!
set noesckeys
set nocompatible
" Make the omnicomplete text readable
:highlight PmenuSel ctermfg=black
" Snippets are activated by Shift+Tab
let g:snippetsEmu_key = "<S-Tab>"
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
set complete=.,w,t
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
"" Disable arrow keys
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
map <C-s> <esc>:w<CR>
imap <C-s> <esc>:w<CR>
map <C-x> <C-w>c
map <C-n> :cn<CR>
map <C-p> :cp<CR>
" Set the tag file search order
set tags=./tags;
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Test-running stuff
" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RunCurrentTest()
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
if in_test_file
call SetTestFile()
if match(expand('%'), '\.feature$') != -1
call SetTestRunner("!cucumber")
exec g:bjo_test_runner g:bjo_test_file
elseif match(expand('%'), '_spec\.rb$') != -1
call SetTestRunner("!bin/rspec")
exec g:bjo_test_runner g:bjo_test_file
else
call SetTestRunner("!ruby -Itest")
exec g:bjo_test_runner g:bjo_test_file
endif
else
exec g:bjo_test_runner g:bjo_test_file
endif
endfunction
function! SetTestRunner(runner)
let g:bjo_test_runner=a:runner
endfunction
function! RunCurrentLineInTest()
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
if in_test_file
call SetTestFileWithLine()
end
exec "!bin/rspec" g:bjo_test_file . ":" . g:bjo_test_file_line
endfunction
function! SetTestFile()
let g:bjo_test_file=@%
endfunction
function! SetTestFileWithLine()
let g:bjo_test_file=@%
let g:bjo_test_file_line=line(".")
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <Leader>n :call RenameFile()<cr>