Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 250 lines (204 sloc) 8.389 kB
17641ef @lmarburger More vimrc cleanup
authored
1 set nocompatible " screw vi-compatible features
2 set encoding=utf-8 " utf-8 is fun
03c2161 @lmarburger Initial comimt
authored
3
17641ef @lmarburger More vimrc cleanup
authored
4 call pathogen#infect() " pathogen
5 source ~/.vim/filetypes " load awesome filetypes
6 runtime macros/matchit.vim " load matchit (included with vim)
03c2161 @lmarburger Initial comimt
authored
7
8 set hidden " don't yell when hiding modified buffers
9 set history=1000 " lots o' history
10 set clipboard=unnamed " link vim and the system's clipboards
11 set visualbell " no beeping!
12 set showmatch " flash matching brackets and parens
13 set scrolloff=3 " keep a few lines visible above and below cursor
14 set backupdir=~/.vim/_backup// " store backup files
15 set directory=~/.vim/_tmp// " store swap files
16 set undodir=~/.vim/_undo " store undo history
17 set undofile
18 set undolevels=1000
19 set undoreload=10000
ba5051f @lmarburger Open splits to the right and below
authored
20 set splitbelow " I like my splits opening below
21 set splitright " and my vsplits opening to the right
03c2161 @lmarburger Initial comimt
authored
22
17641ef @lmarburger More vimrc cleanup
authored
23 set showcmd " show partial commands below status line
87305d7 @lmarburger Clean up vimrc
authored
24 set cmdheight=2 " 2-line command window
25 set textwidth=80 " break long lines at 80 characters
26
27 """ Searching
03c2161 @lmarburger Initial comimt
authored
28 set hlsearch " highlight search results
29 set incsearch " highlight matches while searching
30 set ignorecase " ignore case when searching.
31 set smartcase " override ignorecase if search contains upper case
32
87305d7 @lmarburger Clean up vimrc
authored
33 """ Whitespace
03c2161 @lmarburger Initial comimt
authored
34 set shiftwidth=2 " use 2 spaces for indentation
35 set tabstop=2 " use 2 spaces when tabbinb
36 set expandtab " use spaces instead of tabs because tabs are evil
37 set smarttab " backspacing deletes space-expanded tabs
38 set nojoinspaces " never use two spaces when joining lines
39 set backspace=indent,eol,start " allow backspacing over autoindent,
40 " line breaks, and start of insert
41
87305d7 @lmarburger Clean up vimrc
authored
42 """ Tab completion
43 set wildmenu
03c2161 @lmarburger Initial comimt
authored
44 set wildmode=list:full,full
45 set wildignore+=tmp/**
46
87305d7 @lmarburger Clean up vimrc
authored
47 """ Show invisible characters
48 set listchars="" " reset the listchars
03c2161 @lmarburger Initial comimt
authored
49 set listchars+=tab:\ \ " show tab as two spaces
50 set listchars+=trail:. " show trailing whitespace as .
87305d7 @lmarburger Clean up vimrc
authored
51 set listchars+=extends:> " the character to show in the last column when
03c2161 @lmarburger Initial comimt
authored
52 " wrap is off and line is too long.
87305d7 @lmarburger Clean up vimrc
authored
53 set listchars+=precedes:< " the character to show in the first column when
03c2161 @lmarburger Initial comimt
authored
54 " wrap is off and line is too long.
55
87305d7 @lmarburger Clean up vimrc
authored
56 """ Visual
03c2161 @lmarburger Initial comimt
authored
57 syntax on " highlight my syntax plz
87305d7 @lmarburger Clean up vimrc
authored
58 set cursorline " highlight cursor line
59 set colorcolumn=+1,+2 " highlight the 81st and 82nd columns
03c2161 @lmarburger Initial comimt
authored
60 set t_Co=256 " more than 8 colors, kthx
a3e5b00 @lmarburger Try Source Code Pro font
authored
61 set gfn=Source\ Code\ Pro:h12 " Menlo is another great font
03c2161 @lmarburger Initial comimt
authored
62 colorscheme solarized
6b9dea2 @lmarburger Remove scheme cruft
authored
63 set background=dark " light also available
03c2161 @lmarburger Initial comimt
authored
64
87305d7 @lmarburger Clean up vimrc
authored
65 """ Status bar
03c2161 @lmarburger Initial comimt
authored
66 set laststatus=2
a33c702 @lmarburger Tweak status and title lines
authored
67 set statusline=\ %f%(\ [%M%R%W%H]%) " filename
5d6c945 @lmarburger Typo
authored
68 set statusline+=%= " right align
a33c702 @lmarburger Tweak status and title lines
authored
69 set statusline+=%-14.(%l/%L,%v%)\ %<%P\ " offset
03c2161 @lmarburger Initial comimt
authored
70
a33c702 @lmarburger Tweak status and title lines
authored
71 " Set window/terminal title
03c2161 @lmarburger Initial comimt
authored
72 set title
a33c702 @lmarburger Tweak status and title lines
authored
73 set titlestring=%F " /path/to/file.txt (Vim)
03c2161 @lmarburger Initial comimt
authored
74
87305d7 @lmarburger Clean up vimrc
authored
75 """ Plugin Configuration
03c2161 @lmarburger Initial comimt
authored
76 let g:ftplugin_sql_omni_key = '<C-X>' " use C-X instead of C-C in sql.vim
034b8b6 @lmarburger Add more plugin config
authored
77 let g:CommandTMaxHeight=10
78 let g:CommandTMinHeight=4
79 let g:netrw_liststyle=4
03c2161 @lmarburger Initial comimt
authored
80
87305d7 @lmarburger Clean up vimrc
authored
81 """ Mappings
03c2161 @lmarburger Initial comimt
authored
82 let mapleader = ","
83
87305d7 @lmarburger Clean up vimrc
authored
84 " I like comma for a leader, but I'd still like to use the original Normal mode
85 " comma command. Double comma should suffice.
86 nmap <leader><leader> ,<ESC>
87
03c2161 @lmarburger Initial comimt
authored
88 " Can't be bothered to understand ESC vs <c-c> in insert mode
89 " https://github.com/garybernhardt/dotfiles/blob/master/.vimrc#L117-118
90 imap <c-c> <esc>
91
87305d7 @lmarburger Clean up vimrc
authored
92 command! W :w " alias :w as :W to fight accidental typos
93
94 " Easy expansion of the active file directory. Cite: Practical Vim pg 94.
95 cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
96
03c2161 @lmarburger Initial comimt
authored
97 " delete the active buffer keeping the split open
25b72e9 @lmarburger Tweak buffer-killing mappings
authored
98 map <leader>x :bprevious<cr>:bdelete #<cr>
99 map <leader>X :bdelete<cr>
03c2161 @lmarburger Initial comimt
authored
100
101 nmap <leader>u :GundoToggle<CR>
102 nmap <leader><cr> :nohlsearch<CR>
103 nmap <leader>S :set spell<CR>]s
104 nmap <leader>ns :set nospell<CR>
105 nmap <leader>a :Ack<space>
106 nmap <leader>A :Ack!<space>
107
108 " yank until the end of the line
109 nmap Y y$
110
111 " split and tab management and navigation
112 nmap <C-h> <C-w>h
113 nmap <C-j> <C-w>j
114 nmap <C-k> <C-w>k
115 nmap <C-S-l> <C-w>l
84886ed @lmarburger Clean up window/tab bindings
authored
116 nmap <leader>t :tabnext<cr>
117 nmap <leader>T :tabprevious<cr>
03c2161 @lmarburger Initial comimt
authored
118
66738db @lmarburger Copy edit
authored
119 " Browsing
03c2161 @lmarburger Initial comimt
authored
120 map <C-t> :CommandTFlush<cr>\|:CommandT<cr>
121
87305d7 @lmarburger Clean up vimrc
authored
122 """ Ruby
03c2161 @lmarburger Initial comimt
authored
123 imap <C-l> <Space>=><Space>
124 nmap <leader>R i, record: :new_episodes<ESC>
125
87305d7 @lmarburger Clean up vimrc
authored
126 """ Tabularize
03c2161 @lmarburger Initial comimt
authored
127 nmap <leader>j vip:Tabularize json<CR>
6493769 @lmarburger Add visual mapping to align json
authored
128 vmap <leader>j :Tabularize json<CR>
03c2161 @lmarburger Initial comimt
authored
129 vmap <leader>: :Tabularize first_colon<CR>
130 vmap <leader>l :Tabularize hash_rocket<CR>
131 vmap <leader>= :Tabularize first_equals<CR>
132 vmap <leader>' :Tabularize first_single_quote<CR>
133 vmap <leader>" :Tabularize first_double_quote<CR>
134 vmap <leader>{ :Tabularize first_left_stash<CR>
135 vmap <leader>} :Tabularize first_right_stash<CR>
136 vmap <leader>\| :Tabularize bar<CR>
137
17641ef @lmarburger More vimrc cleanup
authored
138 """ **Embolden** selection
03c2161 @lmarburger Initial comimt
authored
139 vmap <leader>* S*gvS*
140
141 """ Open file in the browser
142 map <leader>H :!open '%' -a /Applications/Google\ Chrome.app/<CR>
143
87305d7 @lmarburger Clean up vimrc
authored
144 augroup Vim
145 autocmd!
146
147 " Reload vimrc after save.
17641ef @lmarburger More vimrc cleanup
authored
148 autocmd BufWritePost ~/.vim/vimrc source ~/.vim/vimrc
87305d7 @lmarburger Clean up vimrc
authored
149
150 " Create the directory if it doesn't exist.
151 autocmd BufNewFile * silent !mkdir -p $(dirname %)
152
153 " Don't syntax highlight markdown because it's often wrong
154 autocmd! FileType markdown setlocal syn=off
155 augroup END
156
157 augroup CoffeeScript
158 autocmd!
159 autocmd BufNewFile,BufReadPost,BufEnter *.coffee imap <C-l> <Space>->
160 autocmd BufLeave *.coffee imap <C-l> <Space>=><Space>
161 augroup END
162
163 augroup PlantUML
164 autocmd!
165 autocmd BufNewFile,BufReadPost,BufEnter *.plantuml nmap <leader>. :w<CR>:!java -jar /Users/Larry/.bin/plantuml.jar %<CR>
166 autocmd BufLeave *.plantuml nmap <leader>. :call RunTestFile()<CR>
167 augroup END
03c2161 @lmarburger Initial comimt
authored
168
169
170 " Shamelessly ripped from Gary Bernhardt's vimrc
171 " https://github.com/garybernhardt/dotfiles/blob/master/.vimrc
172 function! RunRuby()
173 " Write the file and run tests for the given filename
174 w
175 silent !echo;echo;echo;echo;echo
176 exec ":!ruby " . expand("%")
177 endfunction
178
179 function! RunTestFile()
180 let in_spec_file = match(expand("%"), '_spec.rb$') != -1
181 let in_test_file = match(expand("%"), '_test.rb$') != -1
182 let in_feature_file = match(expand("%"), '.feature$') != -1
183 let in_jasmine_spec_file = match(expand("%"), '_spec.coffee$') != -1
184
185 if in_spec_file
186 call SetTestFile()
187 elseif in_test_file
188 call SetTestFile()
189 elseif in_feature_file
190 call SetTestFile()
191 elseif in_jasmine_spec_file
192 call SetTestFile()
193 elseif !exists("g:grb_test_file")
194 return
195 end
196
197 call ChooseTestRunner(g:grb_test_file)
198 endfunction
199
200 function! SetTestFile()
201 " Set the spec file that tests will be run for.
202 let g:grb_test_file=@%
203 endfunction
204
205 function! ChooseTestRunner(filename)
206 write
207 silent !echo;echo;echo;echo;echo
208
209 let run_specs = match(a:filename, '_spec.rb$') != -1
210 let run_tests = match(a:filename, '_test.rb$') != -1
211 let run_feature = match(a:filename, '.feature$') != -1
212 let in_jasmine_spec_file = match(a:filename, '_spec.coffee$') != -1
213
214 if run_specs
215 call RunSpecs(a:filename)
216 elseif run_tests
217 call RunTests(a:filename)
218 elseif run_feature
219 call RunFeature(a:filename)
220 elseif in_jasmine_spec_file
221 call RunJasmineHeadlessFeature(a:filename)
222 endif
223 endfunction
224
225 " \:<C-R>=line(".")
226 function! RunSpecs(filename)
227 silent exec ":!echo rspec " . a:filename
228 " exec ":!ruby -Ilib -Ispec " . a:filename
229 exec ":!time rspec " . a:filename
230 endfunction
231
232 function! RunTests(filename)
233 silent exec ":!echo ruby -Itest -Ilib " . a:filename
234 exec ":!time bundle exec ruby -Itest -Ilib " . a:filename
235 endfunction
236
237 function! RunFeature(filename)
238 silent exec ":!echo bundle exec cucumber -r features " . a:filename
239 " exec ":!ruby -Ilib -Ispec " . a:filename
240 exec ":!time bundle exec cucumber -r features " . a:filename
241 endfunction
242
243 function! RunJasmineHeadlessFeature(filename)
244 silent exec ":!echo jasmine-headless-webkit -c " . a:filename
245 exec ":!time jasmine-headless-webkit -c " . a:filename
246 endfunction
247
248 nmap <leader>. :call RunTestFile()<CR>
249 nmap <leader>> :silent :!clear<cr>:w<cr>:!ruby -Ilib %<cr>
Something went wrong with that request. Please try again.