-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
193 lines (156 loc) · 4.71 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
set nocompatible
filetype on
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" Github theme
Plugin 'croaky/vim-colors-github'
" Railcasts theme
Plugin 'jpo/vim-railscasts-theme'
" Create missing directories when editing files
Plugin 'pbrisbin/vim-mkdir'
" Finder
Plugin 'ctrlpvim/ctrlp.vim'
" Syntax checking
Plugin 'scrooloose/syntastic'
" Navigate code
Plugin 'vim-scripts/ctags.vim'
" Quoting and parenthesizing support
Plugin 'tpope/vim-surround'
" Support for bundler
Plugin 'tpope/vim-bundler'
" Closes code structures automatically
Plugin 'tpope/vim-endwise'
" Navigate in rails projects
Plugin 'tpope/vim-rails'
" Support for ruby code
Plugin 'vim-ruby/vim-ruby'
" Git support
Plugin 'tpope/vim-fugitive'
" Run specs form vim
Plugin 'thoughtbot/vim-rspec'
" Creates text objects
Plugin 'kana/vim-textobj-user'
" Navigate ruby blocks
Plugin 'nelstrom/vim-textobj-rubyblock'
" Navigate tags in open file
Plugin 'majutsushi/tagbar'
" Go language support
Plugin 'fatih/vim-go'
call vundle#end()
filetype plugin indent on
set number
set relativenumber
set numberwidth=5
set ruler
set showcmd
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
set noswapfile
set history=50
set backspace=2
set autoindent
set expandtab
set smarttab
set nowrap
set laststatus=2
set nobackup
set nowritebackup
set incsearch
set hlsearch
set relativenumber
set splitbelow
set splitright
set textwidth=120
set colorcolumn=+1
colorscheme railscasts
let mapleader = " "
" Display extra whitespace
" set list listchars=tab:.>>,trail:·,nbsp:·
" Exclude files and directories from search path
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
set wildignore+=*/git/*
let g:ctrlp_max_files = 0
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:25,results:25'
" RSpec.vim mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Tab movement
map <Leader><left> gT
map <Leader><right> gt
" Method movement
map <Leader><up> [m
map <Leader><down> ]m
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile Appraisals set filetype=ruby
autocmd BufRead,BufNewFile *.md set filetype=markdown
" Enable spellchecking for Markdown
autocmd FileType markdown setlocal spell
" Automatically wrap at 80 characters for Markdown
autocmd BufRead,BufNewFile *.md setlocal textwidth=80
" Automatically wrap at 72 characters and spell check git commit messages
autocmd FileType gitcommit setlocal textwidth=72
autocmd FileType gitcommit setlocal spell
" Allow stylesheets to autocomplete hyphenated words
autocmd FileType css,scss,sass setlocal iskeyword+=-
augroup END
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
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>
inoremap <S-Tab> <c-n>
" Always use vertical diffs
set diffopt+=vertical
" Exclude Javascript files in :Rtags via rails.vim due to warnings when parsing
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
" Index ctags from any project, including those outside Rails
map <Leader>ct :!ctags .<CR>
" Switch between the last two files
nnoremap <leader><leader> <c-^>
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
" configure syntastic syntax checking to check on open as well as save
let g:syntastic_check_on_open=1
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
" Enables % command to jump between kwywords module, def, do and
" corresponding end.
runtime macros/matchit.vim
let g:rspec_command = "!bundle exec rspec --format documentation {spec}"
syntax on