-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
executable file
·285 lines (241 loc) · 8.79 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
" Of course
set nocompatible
" Make 'Y' yank from the cursor to the end of the line. As the help file says
" 'which is more logical, but not Vi-compatible'
:map Y y$
" Required Vundle setup
filetype off
set runtimepath+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rails'
Plugin 'vim-ruby/vim-ruby'
Plugin 'jparise/vim-graphql'
Plugin 'mileszs/ack.vim'
Plugin 'junegunn/fzf.vim'
Plugin 'majutsushi/tagbar'
Plugin 'rodjek/vim-puppet'
Plugin 'rust-lang/rust.vim'
Plugin 'elixir-lang/vim-elixir'
Plugin 'fatih/vim-go'
Plugin 'airblade/vim-gitgutter'
Plugin 'scrooloose/syntastic'
Plugin 'Align'
Plugin 'AndrewRadev/sideways.vim'
Plugin 'l9' " required by something!
" colourschemes
Plugin 'twerth/ir_black'
" All of your Plugins must be added before the following line
call vundle#end() " required
" Enable filetype detection and filetype specific plugins and indentation
filetype plugin indent on " required
" Add fzf binary to runtime path
set rtp+=/usr/local/opt/fzf
" Enable the backspace key in insert mode
" See http://vim.wikia.com/wiki/Backspace_and_delete_problems
set backspace=indent,eol,start
" Watch .vimrc for changes and automatically reload config.
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYVIMRC | endif
augroup END
" Syntax higlighting on
syntax on
" Recognise Guardfiles as ruby
au BufNewFile,BufRead Guardfile.* set filetype=ruby
au BufNewFile,BufRead *.md setlocal spell
" Use the vividchalk colourscheme. Looks much like TextMate on the Mac.
" colorscheme solarized
" colorscheme vividchalk
colorscheme grb256
set background=dark
" Tabs are 2 characters, replace tabs with spaces.
set shiftwidth=2
set expandtab
" Strip trailing whitespace on save - for all file types.
" See http://vim.wikia.com/wiki/Remove_unwanted_spaces
autocmd BufWritePre * :%s/\s\+$//e
" Automatic wrapping of comments at 80 characters
set formatoptions+=c
set textwidth=80
" Allow switching between buffers even if the current buffer has unsaved
" changes
set hidden
" Automatically load changed files.
set autoread
" Autosave.
" autowriteall (see vim help) saves on various motions around buffers.
" Also save whenever leaving vim.
set autowriteall
:au FocusLost * :wa
" Test output from xunit tests
set wildignore=TEST-*.xml
" ag, not ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Remap leader from \ to , which is easier to hit, and a common remapping.
let mapleader = ","
" *** Searching ***
" Ignore case unless there is some uppercase in the string
set ignorecase
set smartcase
" Always match all occurrences on a line. When do you ever want something else?
set gdefault
" Make searching (using /) incremental (turn this off with "set incsearch!")
set incsearch
" Highlight search results
set showmatch
set hlsearch
" Clear search highlighting
nnoremap <leader><space> :noh<cr>
" Automatically open, but do not go to (if there are errors) the quickfix
" window, or close it when is has become empty.
"
" Note: Must allow nesting of autocmds to enable any customizations for quickfix
" buffers.
" Note: Normally, :cwindow jumps to the quickfix window if the command opens it
" (but not if it's already open). However, as part of the autocmd, this doesn't
" seem to happen.
autocmd QuickFixCmdPost [^l]* nested cwindow
" Leave insert mode. Two semicolons are easy to type.
imap ;; <Esc>
" Jump to matching bracket on tab.
nnoremap <tab> %
vnoremap <tab> %
" Training mode
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" Shortcuts for Sideways.vim
nnoremap <c-h> :SidewaysLeft<cr>
nnoremap <c-l> :SidewaysRight<cr>
omap aa <Plug>SidewaysArgumentTextobjA
xmap aa <Plug>SidewaysArgumentTextobjA
omap ia <Plug>SidewaysArgumentTextobjI
xmap ia <Plug>SidewaysArgumentTextobjI
" F7 and F8 to move to next/previous buffer
nmap <F7> :bp<CR>
nmap <F8> :bn<CR>
" F2 to save whilst in insert mode (remain in insert mode)
imap <F2> <C-o>:w<CR>
" Ctrl+ up/down to scroll
nmap <C-Down> <C-e>
nmap <C-Up> <C-y>
" Alt+Shift+ up/down to move through grep matches
nmap <M-S-Down> :cn<CR>
nmap <M-S-Up> :cp<CR>
" Alt+Shift+ j/k to move through grep matches when in a strict mood
nmap <M-S-j> :cn<CR>
nmap <M-S-k> :cp<CR>
nmap <leader>b :Buffers<CR>
nmap <C-P> :Files<CR>
" Give FZF a history directory, so that Ctrl+P will repeat the last file search
" (And Ctrl+N the next file search if you go too far back.)
let g:fzf_history_dir = '~/.fzf_history'
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Grep for the word under the cursor.
nmap <leader>g :grep '\b<cword>\b' .<CR>
nnoremap <leader>a :Ack '\b<cword>\b' .<CR>
" Useful defaults for grepping a Rails app.
set grepprg=grep\ -InR\ --include=*.erb\ --include=*.rb\ --include=*.rake\ $*
" vim-gitgutter - set background colour to the same as the line number column.
highlight clear SignColumn
if has('statusline')
" Set a statusline - but don't attempt to run this when launching vim in vi
" mode on Linux (by typing 'vi <file>').
hi User1 guifg=#eea040 guibg=#222222
hi User2 guifg=#dd3333 guibg=#222222
hi User3 guifg=#ff66ff guibg=#222222
hi User4 guifg=#a0ee40 guibg=#222222
hi User5 guifg=#eeee40 guibg=#222222
set statusline=
set statusline +=%1*\ %n\ %* "buffer number
set statusline +=%5*%{&ff}%* "file format
set statusline +=%3*%y%* "file type
set statusline +=%4*\ %<%F%* "full path
set statusline +=%2*%m%* "modified flag
set statusline +=%1*%=%5l%* "current line
set statusline +=%2*/%L%* "total lines
set statusline +=%1*%4v\ %* "virtual column number
set statusline +=%2*0x%04B\ %* "character under cursor
set laststatus=2
endif
" NERDTree configuration
" Config lines cribbed from https://github.com/scrooloose/nerdtree
"
" Open NERDTree automatically when Vim starts up
" autocmd vimenter * NERDTree
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Show tags in current file in left sidebar
" :h tagbar
let g:tagbar_left = 1
nnoremap <silent> <Leader>tb :TagbarToggle<CR>
" Make the unnamed register the same as the clipboard register. The unnamed
" register is where text is stored when you yank it. By making it the same
" as the clipboard, yanking and pasting in Vim affects the Windows clipboard.
" http://vim.wikia.com/wiki/VimTip21
" set clipboard=unnamed
nmap <F1> :set paste<CR>:r !pbpaste<CR>:set nopaste<CR>
imap <F1> <Esc>:set paste<CR>:r !pbpaste<CR>:set nopaste<CR>
nmap <F2> :.w !pbcopy<CR><CR>
vmap <F2> :w !pbcopy<CR><CR>
" Shift+CR adds an 'end' to a Ruby block and puts the cursor back on the
" previous line.
imap <S-CR> <CR><CR>end<Esc>-cc
" Reselect the text just pasted so I can perform commands (like indentation) on
" it. http://stevelosh.com/blog/2010/09/coming-home-to-vim
nnoremap <leader>v V`]
" Tag ruby
nnoremap <leader>t :!ctags -R --languages=ruby<CR>
" Golang settings
" Format with goimports instead of gofmt
let g:go_fmt_command = 'goimports'
" if has('gui_running')
" " Settings for GUI mode - i.e. running under Windows
"
" " Change the font and font size.
" set guifont=Consolas:h10:cANSI
"
" " Maximise the window (on Windows)
" " http://vim.wikia.com/wiki/Maximize_or_set_initial_window_size
" au GUIEnter * simalt ~x
"
" " Remove the toolbar. Vim experts don't use toolbar buttons!
" set guioptions-=T
"
" " Highlight text that goes over the 80 column limit. This is Windows only
" " because Vim on Linux is often used for log files, where this setting is a
" " nuisance!
" " See http://stackoverflow.com/questions/235439/vim-80-column-layout-concerns
" set colorcolumn=81
"
" Put temporary files in the temp directory, rather than the current
" directory (so they don't turn up in svn/git status).
" http://stackoverflow.com/questions/4824188/git-ignore-vim-temporary-files
set backupdir=$TEMP//,/tmp//
set directory=$TEMP//,/tmp//
"
" " Force vim to use Slick grep on Windows (rather than 'findstr'), and tell it
" " how to interpret the results that it gets (filename + space + line number +
" " space + column number + colon + the match string)
" set grepprg=grep
" set grepformat=%f\ %l\ %c:%m
" endif