-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
227 lines (189 loc) · 4.88 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
" basic settings {{{
set nocompatible
set backspace=2
set hidden
set showmatch
set nobackup
set noswapfile
set visualbell
set noerrorbells
set mouse-=a
set encoding=utf-8
" pastetoggle
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
" use 4 spaces for indentation
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set autoindent
set smartindent
set ruler
set shortmess+=I
set autoread
set relativenumber
set number
" yanktoggle
nnoremap + :set number! relativenumber!<CR>:GitGutterToggle<CR>
" Get rid of those enticing arrow keys
vnoremap <right> <nop>
vnoremap <left> <nop>
vnoremap <up> <nop>
vnoremap <down> <nop>
inoremap <right> <nop>
inoremap <left> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
nnoremap <right> <nop>
nnoremap <left> <nop>
nnoremap <up> <nop>
nnoremap <down> <nop>
" some nice keybindings
nnoremap <space> <nop>
let mapleader=" "
nnoremap ; :
inoremap jk <Esc>
" search easier
set gdefault
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set hlsearch
" copy paste easier
vnoremap <leader>d "+d
vnoremap <leader>y "+y
vnoremap <leader>p "+p
vnoremap <leader>P "+P
nnoremap <leader>d "+d
nnoremap <leader>y "+y
nnoremap <leader>p "+p
nnoremap <leader>P "+P
" splits
set splitright
set splitbelow
nnoremap <leader>h <C-W><C-H>
nnoremap <leader>j <C-W><C-J>
nnoremap <leader>k <C-W><C-K>
nnoremap <leader>l <C-W><C-L>
" remove whitespace
nnoremap <leader>w :%s/\s\+$//<cr>:let @/=''<CR>
" crlf to lf
nnoremap <leader>f :e ++ff=dos<CR>
" enable folding
set foldmethod=manual
autocmd BufRead * setlocal foldmethod=marker
autocmd BufRead * normal zM
" It's useful to show the buffer number in the status line.
set laststatus=2 statusline=%02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" PEP8 indentation
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix |
" flag bad whitespace
highlight BadWhitespace ctermbg=red guibg=darkred
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
" macros
" error-chain rust crate
let @c = "o.chain_err(|| \"jkA?;jkb"
" unwraps for rust
let @u = "o.unwrap();jk"
" creates test module in rust
let @t =
\ "o#[cfg(testjkomod tests {use super::*;#[testjkofn test() {assert!(falsejkA;jk"
" }}}
" Plugins {{{
" pathogen
execute pathogen#infect()
execute pathogen#helptags()
" Enable filetype plugins
filetype plugin indent on
syntax on
" fugitive
nnoremap <leader>A :Git add %:p<CR><CR>
nnoremap <leader>. :Git a<CR><CR>
nnoremap <leader>S :Gstatus<CR>
nnoremap <leader>CM :Git cm<CR>
nnoremap <leader>D :Gdiff<CR>
nnoremap <leader>E :Gedit<CR>
nnoremap <leader>R :Gread<CR>
nnoremap <leader>W :Gwrite<CR><CR>
nnoremap <leader>F :Ggrep<Space>
nnoremap <leader>MV :Gmove<Space>
" gruvbox
syntax enable
set background=dark
colorscheme gruvbox
" fzf
nnoremap <c-p> :Files<CR>
set rtp+=/usr/local/opt/fzf
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" vim-go golang
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_disable_autoinstall = 0
let g:go_fmt_command = "goimports"
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
let g:go_list_type = "quickfix"
let g:go_metalinter_enabled = 1
au FileType go nmap <leader>gr <Plug>(go-run)
au FileType go nmap <leader>gi <Plug>(go-install)
au FileType go nmap <leader>gb <Plug>(go-build)
au FileType go nmap <leader>gt <Plug>(go-test)
au FileType go nmap <leader>gc <Plug>(go-coverage)
au FileType go nmap <leader>gd <Plug>(go-doc)
au FileType go nmap <leader>gv <Plug>(go-doc-vertical)
" neocomplete
let g:neocomplete#enable_at_startup = 1
" syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" airline
set laststatus=2
let g:airline_theme='gruvbox'
" vim-ansible-yaml
let g:ansible_options = {'ignore_blank_lines': 0}
let g:ansible_options = {'documentation_mapping': '<C-K>'}
" NERD Commenter
nnoremap <leader>cB <plug>NERDCommenterAlignBoth
" vim-rust
nnoremap <leader>cb :CargoBuild<CR>
nnoremap <leader>cr :CargoRun<CR>
nnoremap <leader>ct :CargoTest<CR>
let g:rustfmt_autosave = 0
" vim-racer
set hidden
let g:racer_cmd = "~/.cargo/bin/racer"
let $RUST_SRC_PATH="~/muhdotfiles/deps/rust/src/"
let g:racer_experimental_completer = 1
" deoplete
let g:deoplete#enable_at_startup = 1
" }}}