@@ -15,29 +15,22 @@ Plugin 'gmarik/Vundle.vim'
1515
1616" Frameworks/languages
1717Plugin ' tpope/vim-rails'
18- Plugin ' tpope/vim-bundler'
1918Plugin ' tpope/vim-fugitive'
20- " follow instructions here => https://github.com/skwp/vim-rspec
2119Plugin ' thoughtbot/vim-rspec'
2220Plugin ' tpope/vim-dispatch'
23-
24- " Coding
2521Plugin ' Lokaltog/vim-easymotion'
2622Plugin ' scrooloose/nerdcommenter'
2723Plugin ' scrooloose/nerdtree'
28- Plugin ' kien/ctrlp.vim'
29- Plugin ' jc00ke/vim-tomdoc'
24+ Plugin ' ervandew/supertab'
25+ Plugin ' junegunn/vim-easy-align'
26+ Plugin ' szw/vim-ctrlspace'
27+
3028Plugin ' mattn/emmet-vim'
3129Plugin ' scrooloose/syntastic'
32- Plugin ' nathanaelkane/vim-indent-guides'
3330Plugin ' MarcWeber/vim-addon-mw-utils'
3431Plugin ' tomtom/tlib_vim'
35- Plugin ' garbas/vim-snipmate'
36- Plugin ' honza/vim-snippets'
37- Plugin ' ervandew/supertab'
3832Plugin ' bling/vim-airline'
3933Plugin ' tpope/vim-endwise'
40- Plugin ' junegunn/vim-easy-align'
4134Plugin ' vim-scripts/EasyGrep'
4235Plugin ' gorkunov/smartpairs.vim'
4336
@@ -46,6 +39,7 @@ Plugin 'rizzatti/funcoo.vim'
4639Plugin ' rizzatti/dash.vim'
4740
4841" Syntaxes
42+ Plugin ' nathanaelkane/vim-indent-guides'
4943Plugin ' tpope/vim-haml'
5044Plugin ' slim-template/vim-slim'
5145Plugin ' vim-ruby/vim-ruby'
@@ -68,14 +62,6 @@ filetype plugin indent on " Turn on file type detection.
6862let mapleader = " ,"
6963nnoremap \ ,
7064
71- " Use ii to escape
72- inoremap jk <ESC> :w<CR>
73-
74- " close
75- nnoremap <leader> cl :close<CR>
76- " Buffer hotkey
77- nnoremap <Leader> b :buffer
78-
7965" au FocusLost * :wa " Autosave everything
8066set autowriteall " save file when buffer switched
8167set ttyfast
@@ -99,12 +85,44 @@ set hlsearch " highlight matches
9985set incsearch " incremental searching
10086set ignorecase " searches are case insensitive...
10187set smartcase " ... unless they contain at least one capital letter
102- " set grepprg=git\ grep\ -nHI\ --exclude-standard\ --heading\ --color\ --no-index\ -e\ $1
103- " command -nargs=+ Ggr execute 'silent Ggrep!' <q-args> | cw | redraw!
88+
89+ " Run a given vim command on the results of fuzzy selecting from a given shell
90+ " command. See usage below.
91+ " Note: I'm using Iterm2 and remapped ^[ to "Send Hex Codes: 0x03" which is == ^C
92+ function ! SelectaCommand (choice_command, selecta_args, vim_command)
93+ try
94+ let selection = system (a: choice_command . " | selecta " . a: selecta_args )
95+ catch /Vim:Interrupt/
96+ " Swallow the ^C so that the redraw below happens; otherwise there will be
97+ " leftovers from selecta on the screen
98+ redraw !
99+ return ' '
100+ endtry
101+ redraw !
102+ exec a: vim_command . " " . selection
103+ endfunction
104+
105+ let ignore = [" .git" , " vendor" , " .svg" , " .eot" , " .jpg" , ' \/\.' , ' ^\..*' ] " ignore hidden files
106+ let excludes= " \| GREP_OPTIONS=\'\' egrep -v -e \' " . join (map (ignore , ' v:val' ), " \| " ) . " \' "
107+
108+ " Find all files in all non-dot directories starting in the working directory.
109+ " Fuzzy select one of those. Open the selected file with :e.
110+ nnoremap <space> :call SelectaCommand("git ls-files --exclude-standard" .g:excludes, "", ":e")<cr>
111+
112+ function ! SelectaBuffer ()
113+ let bufnrs = filter (range (1 , bufnr (" $" )), ' buflisted(v:val)' )
114+ let buffers = map (bufnrs, ' bufname(v:val)' )
115+ call SelectaCommand (' echo "' . join (buffers , " \n " ) . ' "' , " " , " :b" )
116+ endfunction
117+
118+ " Fuzzy select a buffer. Open the selected buffer with :b.
119+ nnoremap <C-t> :call SelectaBuffer()<cr>
120+
121+ " set grepprg=git\ grep\ --exclude-standard\ -n\ $*
104122
105123function ! Grep ()
106- let params = input (' search for: ' , expand (' % ' ))
107- exec ' :silent Ggrep!' . params
124+ let params = input (' search for: ' , expand (' <cword> ' ))
125+ exec ' :silent Ggrep! -I ' . params
108126 cw
109127 redraw !
110128endfunction
@@ -117,9 +135,9 @@ set listchars="" " Reset the listchars
117135set listchars = tab :\ \ " a tab should display as " " , trailing whitespace as " ."
118136set listchars += trail: . " show trailing spaces as dots
119137set listchars += extends: > " The character to show in the last column when wrap is
120- " " off and the line continues beyond the right of the screen
138+ " " off and the line continues beyond the right of the screen
121139set listchars += precedes: < " The character to show in the last column when wrap is
122- " " off and the line continues beyond the left of the screen
140+ " " off and the line continues beyond the left of the screen
123141
124142"
125143" Tabs Indentations
@@ -140,6 +158,11 @@ function TrimWhiteSpace()
140158 ' '
141159endfunction
142160
161+ nmap mm `
162+
163+ " Use ii to escape
164+ inoremap jk <ESC> :w<CR>
165+
143166autocmd FileWritePre * :call TrimWhiteSpace ()
144167autocmd FileAppendPre * :call TrimWhiteSpace ()
145168autocmd FilterWritePre * :call TrimWhiteSpace ()
@@ -148,7 +171,7 @@ autocmd BufWritePre * :call TrimWhiteSpace()
148171" rename current file and new file path
149172function ! RenameFile ()
150173 let old_name = expand (' %' )
151- let new_name = input (' New file name: ' , expand (' <cword> ' ))
174+ let new_name = input (' New file name: ' , expand (' % ' ))
152175 if new_name != ' ' && new_name != old_name
153176 exec ' :saveas ' . new_name
154177 exec ' :silent !rm ' . old_name
@@ -177,15 +200,6 @@ let g:syntastic_style_error_symbol='>'
177200let g: syntastic_warning_symbol= ' ⚠'
178201let g: syntastic_style_warning_symbol= ' >'
179202
180- " set nofoldenable
181- " set foldmethod=syntax " Pretty slow
182- " set foldlevel=1
183- " au BufRead * normal zR
184- " au BufNewFile,BufReadPost *.rb setl nofoldenable
185- " au BufNewFile,BufReadPost *.rb normal zi "default to unfolded
186- " autocmd InsertEnter * let w:last_fdm=&foldmethod | setlocal foldmethod=manual
187- " autocmd InsertLeave * let &l:foldmethod=w:last_fdm
188-
189203" "
190204" " Colors/ Highlights
191205" "
@@ -231,31 +245,6 @@ endfunction
231245command ! Invbg call ReverseBackground ()
232246noremap <F11> :Invbg<CR>
233247
234- function ! s: RunShellCommand (cmdline)
235- let isfirst = 1
236- let words = []
237- for word in split (a: cmdline )
238- if isfirst
239- let isfirst = 0 " don't change first word (shell command)
240- else
241- if word[0 ] = ~ ' \v[%#<]'
242- let word = expand (word)
243- endif
244- let word = shellescape (word, 1 )
245- endif
246- call add (words, word)
247- endfor
248- let expanded_cmdline = join (words)
249- botright new
250- setlocal buftype = nofile bufhidden = wipe nobuflisted noswapfile nowrap
251- call setline (1 , ' You entered: ' . a: cmdline )
252- call setline (2 , ' Expanded to: ' . expanded_cmdline)
253- call append (line (' $' ), substitute (getline (2 ), ' .' , ' =' , ' g' ))
254- silent execute ' $read !' . expanded_cmdline
255- 1
256- endfunction
257- command ! -complete =shellcmd -nargs =+ Shell call s: RunShellCommand (<q-args> )
258-
259248"
260249" Text formatting
261250"
@@ -270,17 +259,13 @@ set expandtab
270259"
271260" Maps
272261"
273- " inoremap <S-CR> <Esc>
274- " Map ✠ (U+2720) to <S-CR>, so we have <S-CR> mapped to ✠ in iTerm2 and
275- " ✠ mapped back to <S-CR> in Vim.
276- " imap ✠ <S-CR>
277262
278263" easy align
279264vmap <Enter> <Plug> (EasyAlign)
280265
281266" easy motion
282- map / <Plug> (easymotion-sn)
283- omap / <Plug> (easymotion-tn)
267+ map // <Plug> (easymotion-sn)
268+ omap // <Plug> (easymotion-tn)
284269map <Leader> l <Plug> (easymotion-lineforward)
285270map <Leader> j <Plug> (easymotion-j)
286271map <Leader> k <Plug> (easymotion-k)
@@ -303,12 +288,7 @@ nnoremap <C-k> <C-w>k
303288nnoremap <C-h> <C-w> h
304289nnoremap <C-l> <C-w> l
305290
306- map <S-right> <ESC>
307-
308- " imap <up> <nop>
309- " imap <down> <nop>
310- " imap <left> <nop>
311- " imap <right> <nop>
291+ " map <S-right> <ESC>
312292
313293nnoremap <down> :cn<CR>
314294nnoremap <up> :cp<CR>
@@ -324,20 +304,7 @@ map <Leader>p :set paste!<CR>
324304set mouse = a
325305set ttymouse = xterm2
326306
327- " always center the screen
328- " nmap n n zz
329- " nmap N N zz
330- map zo zO "open full level all the time
331-
332- " resize current buffer by +/- 5
333- nnoremap <C-left> :vertical resize +3<cr>
334- nnoremap <C-down> :resize +3<cr>
335- nnoremap <C-up> :resize -3<cr>
336- nnoremap <C-right> :vertical resize -3<cr>
337- " nnoremap <Leader>hc :set cursorline! <CR>
338- " nnoremap <Leader>hn :set nu! <CR>
339307nnoremap <Leader> d :set hlsearch! <CR>
340- " autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif " changes the cd to the directory of the current file except for /tmp/*
341308nnoremap ,cd :cd %:p:h<CR> :pwd<CR>
342309inoremap <tab> <c-r> =InsertTabWrapper()<cr>
343310
@@ -348,6 +315,10 @@ inoremap <tab> <c-r>=InsertTabWrapper()<cr>
348315" Plugin settings
349316"
350317
318+ " ctrl-space
319+ "
320+ let g: ctrlspace_default_mapping_key = ' <tab>'
321+
351322" NERDTree
352323let g: NERDTreeMinimalUI = 1
353324let g: NERDTreeChDirMode= 1 " 2 would update the cwd anytime i change the root
@@ -364,15 +335,6 @@ augroup end
364335map <Leader> m :NERDTreeToggle<CR>
365336map <Leader> n :NERDTreeFind<CR>
366337
367- " CtrlP
368- let g: ctrlp_map = ' <space>'
369- let g: ctrlp_cmd = ' CtrlP'
370- let g: ctrlp_working_path_mode = 0
371- let g: ctrlp_match_window_reversed = 0
372- let g: ctrlp_extensions = [' tag' ]
373- let g: ctrlp_custom_ignore = ' \.git$'
374- map <C-T> :CtrlPBuffer<CR>
375-
376338" vim-rspec
377339" let g:rspec_command = "!zeus rspec {spec}"
378340" let g:rspec_command = "!zeus rescue rspec -f d -c {spec}"
@@ -393,9 +355,6 @@ let g:netrw_sort_options = 'i'
393355autocmd User Rails let b: surround_ {char2nr (' -' )} = " <% \r %>" " displays <% %> correctly
394356:set cpoptions += $ " puts a $ marker for the end of words/lines in cw/c$ commands
395357
396- " coffeescript.vim
397- " au BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable
398-
399358" vim-powerline.vim
400359let g: Powerline_symbols= ' skwp'
401360
0 commit comments