Skip to content

Commit a1b54b8

Browse files
committed
First commit of new vim setup
0 parents  commit a1b54b8

File tree

10 files changed

+264
-0
lines changed

10 files changed

+264
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bundle

config/colors.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
" Colorscheme ------------------------------------------------------------------
2+
syntax enable
3+
set background=dark
4+
colorscheme jellybeans

config/editing.vim

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
" Searching --------------------------------------------------------------------
2+
set hlsearch " Highlight searches
3+
set incsearch " Highlight search results instantly
4+
set ignorecase " Ignore case
5+
set smartcase " Override 'ignorecase' option if the search contains upper case characters.
6+
7+
" Indentation ------------------------------------------------------------------
8+
set shiftwidth=2 " Number of spaces to use in each autoindent step
9+
set tabstop=2 " Two tab spaces
10+
set softtabstop=2 " Number of spaces to skip or insert when <BS>ing or <Tab>ing
11+
set expandtab " Spaces instead of tabs for better cross-editor compatibility
12+
set autoindent " Keep the indent when creating a new line
13+
set smarttab " Use shiftwidth and softtabstop to insert or delete (on <BS>) blanks
14+
set cindent " Recommended seting for automatic C-style indentation
15+
set autoindent " Automatic indentation in non-C files
16+
17+
function! SetupEnvironment()
18+
let l:path = expand('%:p')
19+
if l:path =~ '/Users/artega/dev/reinteractive/amaysim'
20+
if &filetype == 'javascript'
21+
setlocal tabstop=4 shiftwidth=4 softtabstop=4
22+
" else
23+
" setlocal tabstop=4 shiftwidth=4
24+
endif
25+
if &filetype == 'eruby'
26+
setlocal tabstop=4 shiftwidth=4 softtabstop=4
27+
endif
28+
endif
29+
endfunction
30+
autocmd! BufReadPost,BufNewFile * call SetupEnvironment()
31+
32+
" Reselect visual block after indent
33+
vnoremap < <gv
34+
vnoremap > >gv

config/filetypes.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
" mobile.erb support
2+
autocmd BufNewFile,BufRead *.mobile.erb let b:eruby_subtype='html'
3+
autocmd BufNewFile,BufRead *.mobile.erb set filetype=eruby

config/functions.vim

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2+
" Test-running stuff
3+
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4+
function! RunCurrentTest()
5+
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
6+
if in_test_file
7+
call SetTestFile()
8+
9+
if match(expand('%'), '\.feature$') != -1
10+
call SetTestRunner("!bundle exec cucumber")
11+
exec g:bjo_test_runner g:bjo_test_file
12+
elseif match(expand('%'), '_spec\.rb$') != -1
13+
call SetTestRunner("!bundle exec rspec")
14+
exec g:bjo_test_runner g:bjo_test_file
15+
else
16+
call SetTestRunner("!ruby -Itest")
17+
exec g:bjo_test_runner g:bjo_test_file
18+
endif
19+
else
20+
exec g:bjo_test_runner g:bjo_test_file
21+
endif
22+
endfunction
23+
24+
function! SetTestRunner(runner)
25+
let g:bjo_test_runner=a:runner
26+
endfunction
27+
28+
function! RunCurrentLineInTest()
29+
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
30+
if in_test_file
31+
call SetTestFileWithLine()
32+
end
33+
34+
exec "!bundle exec rspec" g:bjo_test_file . ":" . g:bjo_test_file_line
35+
endfunction
36+
37+
function! RunPreviousTest()
38+
exec "!bundle exec rspec" g:bjo_test_file . ":" . g:bjo_test_file_line
39+
endfunction
40+
41+
function! SetTestFile()
42+
let g:bjo_test_file=@%
43+
endfunction
44+
45+
function! SetTestFileWithLine()
46+
let g:bjo_test_file=@%
47+
let g:bjo_test_file_line=line(".")
48+
endfunction
49+
50+
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

config/keybinds.vim

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
" CtrlP search
2+
call unite#filters#matcher_default#use(['matcher_fuzzy'])
3+
nnoremap <C-p> :Unite -start-insert -winheight=10 file_rec/async<cr>
4+
nnoremap <C-m> :Unite -start-insert -winheight=10 file_mru<cr>
5+
6+
" Buffer nav
7+
nnoremap <Leader>b :Unite -start-insert -winheight=10 buffer<cr>
8+
9+
" Unite on the bottom
10+
let g:unite_split_rule = 'botright'
11+
12+
" Grep
13+
nnoremap <Leader>f :Unite grep:.<cr>
14+
15+
" Yank history
16+
let g:unite_source_history_yank_enable = 1
17+
nnoremap <Leader>y :Unite history/yank<cr>
18+
19+
" Bookmark a file for Unite
20+
noremap <Leader>bb :UniteBookmarkAdd<cr>
21+
noremap <C-b> :Unite -start-insert -winheight=10 bookmark<cr>
22+
23+
" Nerdtree
24+
noremap <Leader>n :NERDTreeToggle<cr>
25+
26+
" paste toggle
27+
noremap <F2> :set paste!<cr>
28+
29+
" change pwd
30+
noremap <Leader>cd :lcd %:p:h<cr>:pwd<CR>
31+
32+
33+
34+
" Window Navigation ------------------------------------------------------------
35+
" Use ctrl+(h|j|k|j) to move through open windows.
36+
map <C-h> <C-w>h
37+
map <C-j> <C-w>j
38+
map <C-k> <C-w>k
39+
map <C-l> <C-w>l
40+
41+
" Remote search highlighting
42+
map <silent><Leader>/ :nohls<CR> " Clear search
43+
44+
" Disable cursor keys
45+
inoremap <Up> <Nop>
46+
inoremap <Down> <Nop>
47+
inoremap <Left> <Nop>
48+
inoremap <Right> <Nop>
49+
inoremap <Up> <Nop>
50+
inoremap <M-Down> <Nop>
51+
inoremap <M-Left> <Nop>
52+
inoremap <M-Right> <Nop>
53+
noremap <Up> <Esc>
54+
noremap <Down> <Esc>
55+
noremap <Left> <Esc>
56+
noremap <Right> <Esc>
57+
vmap <Up> <Esc><Esc>gv
58+
vmap <Down> <Esc><Esc>gv
59+
vmap <Left> <Esc><Esc>gv
60+
vmap <Right> <Esc><Esc>gv
61+
62+
" Use <leader>tw to toggle wrapping
63+
nmap <silent> <leader>tw :set invwrap<CR>:set wrap?<CR>
64+
65+
" testing
66+
map <Leader>r :call RunCurrentTest()<CR>
67+
map <Leader>R :call RunCurrentLineInTest()<CR>
68+
map <Leader>p :call RunCurrentLineInTest()<CR>

config/misc.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
" Misc -------------------------------------------------------------------------
2+
set nowrap " I don't always wrap lines...
3+
set linebreak " ...but when I do, I wrap whole words.
4+
set t_Co=256 " Support for xterm with 256 colors (gets overriden in .gvimrc)
5+
set number " Show line numbers
6+
set ruler " Show ruler
7+
set listchars=trail:.,tab:>-,eol " Change the invisible characters
8+
set noswapfile " Don't create annoying *.swp files
9+
set scrolloff=5 " Start scrolling the file 5 lines before the end of the window
10+
set spelllang=en_au " Set default spelling language to English (Australia)
11+
set hidden " Allow hiding buffers with unsaved changes
12+
set wildmenu " Make tab completion act more like bash
13+
set wildmode=list:longest " Tab complete to longest common string, like bash
14+
set showcmd " Display an incomplete command in the lower right corner
15+
set showmode " Show current mode down the bottom
16+
set laststatus=2 " Always show the status line
17+
set ignorecase " searches are case insensitive...
18+
set smartcase " ... unless they contain at least one capital letter
19+
set backspace=2 " because backspace should work properly
20+

config/neobundle.vim

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
if has('vim_starting')
2+
set runtimepath+=~/.vim/bundle/neobundle.vim/
3+
endif
4+
5+
call neobundle#rc(expand('~/.vim/bundle/'))
6+
7+
" Let NeoBundle manage NeoBundle
8+
NeoBundleFetch 'Shougo/neobundle.vim'
9+
10+
" I like my searches to be faster
11+
NeoBundle 'Shougo/vimproc'
12+
13+
" Now for some bundles
14+
NeoBundle 'tpope/vim-fugitive'
15+
NeoBundle 'Shougo/unite.vim'
16+
17+
" Visual
18+
NeoBundle 'Lokaltog/vim-powerline'
19+
20+
" Editing
21+
NeoBundle 'tomtom/tcomment_vim'
22+
NeoBundle 'bronson/vim-trailing-whitespace'
23+
NeoBundle 'Shougo/neocomplete.vim'
24+
25+
" Navigation
26+
NeoBundle 'scrooloose/nerdtree'
27+
28+
" Language
29+
NeoBundle 'tpope/vim-rails'
30+
NeoBundle 'haml.zip'
31+
NeoBundle 'cakebaker/scss-syntax.vim'
32+
NeoBundle 'kchmck/vim-coffee-script'
33+
NeoBundle 'yaymukund/vim-rabl'
34+
NeoBundle 'plasticboy/vim-markdown'
35+
NeoBundle 'evanmiller/nginx-vim-syntax'
36+
NeoBundle "pangloss/vim-javascript"
37+
38+
" Colours
39+
NeoBundle 'twe4ked/vim-colorscheme-switcher'
40+
NeoBundle 'altercation/vim-colors-solarized'
41+
NeoBundle 'nanotech/jellybeans.vim'
42+
43+
filetype plugin indent on " Required!
44+
"
45+
" Brief help
46+
" :NeoBundleList - list configured bundles
47+
" :NeoBundleInstall(!) - install(update) bundles
48+
" :NeoBundleClean(!) - confirm(or auto-approve) removal of unused bundles
49+
50+
" Installation check.
51+
NeoBundleCheck

config/pluginconfig.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
" tcomment
2+
let g:tcommentMapLeaderOp1 = '<Leader>c'
3+
4+
" NERDTree
5+
let g:loaded_netrw = 1 " Disable netrw
6+
let g:loaded_netrwPlugin = 1 " Disable netrw
7+
let g:NERDTreeHijackNetrw = 0 " Hijack netrw
8+
let g:NERDTreeShowLineNumbers = 0 " Disable line numbers
9+
let g:NERDTreeMinimalUI = 1 " Disable help message
10+
let g:NERDTreeDirArrows = 1 " Enable directory arrows
11+
12+
" neocomplete
13+
let g:neocomplete#enable_at_startup = 1
14+
15+
" tab complete
16+
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"

vimrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let $CONFIG = "$HOME/.vim/config"
2+
3+
" this is VIM
4+
set nocompatible
5+
6+
" Set leader
7+
let mapleader = "\\"
8+
9+
source $CONFIG/misc.vim
10+
source $CONFIG/neobundle.vim
11+
source $CONFIG/editing.vim
12+
source $CONFIG/colors.vim
13+
source $CONFIG/pluginconfig.vim
14+
source $CONFIG/filetypes.vim
15+
source $CONFIG/functions.vim
16+
17+
source $CONFIG/keybinds.vim

0 commit comments

Comments
 (0)