forked from holman/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc.symlink
256 lines (218 loc) · 8.42 KB
/
vimrc.symlink
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
set nocompatible
let $FZF_DEFAULT_COMMAND = 'fd --type f --hidden --follow --exclude .git --exclude native/target --exclude librubyfmt/ruby_checkout'
" All of your Plugins must be added before the following line
call plug#begin('~/.vim/plugged')
Plug 'git://github.com/gkz/vim-ls.git'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'haya14busa/vim-stacktrace', { 'do': 'make' }
Plug 'https://github.com/godlygeek/tabular'
Plug 'mileszs/ack.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-surround'
Plug 'https://github.com/justinj/vim-pico8-syntax'
Plug 'https://github.com/rust-lang/rust.vim'
Plug 'https://github.com/scrooloose/syntastic'
Plug 'tpope/vim-endwise'
Plug 'https://github.com/thoughtbot/vim-rspec'
Plug 'https://github.com/fatih/vim-go'
call plug#end()
filetype plugin indent on " required
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
set noswapfile
syntax on
filetype plugin indent on
set nocp
filetype plugin on
let g:ctrlp_clear_cache_on_exit=0
set ruler
set relativenumber
set showmatch
set showcmd
set ignorecase
set ttyfast
set lazyredraw
set tabstop=4
set shiftwidth=4
set expandtab
set nowrap
set hlsearch
let g:ausession=".vimsession"
"mother fucking makefiles
autocmd FileType make setlocal noexpandtab
autocmd FileType go setlocal noexpandtab
autocmd BufNewFile,BufRead *.rbi set ft=ruby
autocmd BufRead,BufNewFile *.rbi set syntax=ruby
function! TwoSpace()
setlocal ts=2
setlocal sw=2
endfunction
function! OpenSpec()
let repl = substitute(substitute(expand('%'), '\.rb', '', ''), "lib/", "spec/", "")
let path = repl . '_spec.rb'
exec('tabe ' . path)
endfunction
function! RunLastFailure()
exec('!bundle exec rspec --next-failure')
endfunction
function! VsplitSpec()
let repl = substitute(substitute(substitute(expand('%'), '\.rb', '', ''), "lib/", "spec/", ""), "app/", "spec/", "")
let path = repl . '_spec.rb'
let folder = fnamemodify(path, ":p:h")
echom folder
silent exec('!mkdir -p ' . folder)
exec('vsplit ' . path)
endfunction
au FileType ruby call TwoSpace()
au FileType coffee call TwoSpace()
au FileType vim call TwoSpace()
au FileType typescript call TwoSpace()
au FileType javascript call TwoSpace()
au FileType proto set noexpandtab
au BufNewFile,BufRead *.erb call TwoSpace()
au BufRead,BufNewFile *.go set filetype=go
set list
set listchars=tab:→\ ,trail:☃
let g:rspec_command = "!bundle exec rspec {spec}"
map <leader>srb :!clear && bundle exec srb tc 2>&1 \| head -n 40<CR>
map <leader>jca :!bundle exec cucumber --no-color<CR>
map <leader>jsrb :!bundle exec srb tc<CR>
map <leader>jra :call RunAllSpecs()<CR>
map <leader>jrf :call RunCurrentSpecFile()<CR>
map <leader>jrn :call RunNearestSpec()<CR>
map <leader>jrl :call RunLastSpec()<CR>
map <leader>jr! :call RunLastFailure()<CR>
map <leader>efz :s/\([A-Z]\)/_\1/g<CR>\ f(r.lxx$xguu
map <leader>jna :!nose2 <CR>
map <leader>jnf :!nose2 %<CR>
map <leader>jma :!ruby test/test_helper.rb <CR>
map <leader>jmf :!bundle exec ruby % <CR>
map <leader>jta :!./script/test<CR>
map <leader>rpf :!python3 % <CR>
map <leader>rrf :!bundle exec ruby %<CR>
map <leader>rf :!./% <CR>
map <leader>rb :!bash <CR>
map <leader>rv :so ~/.vimrc <CR>
map <leader>rm :!touch % && make <CR>
map <leader>rc :!ctags --exclude=build/ -R<CR>
map <leader>cr :!cargo run<CR>
map <leader>cb :!bash -c 'cargo build 2>&1 \| head -n 15'<CR>
map <leader>ct :!cargo test<CR>
map <leader>eir o<ESC>ogem "rspec-core", :github => "rspec/rspec-core"<CR>gem "rspec-expectations", :github => "rspec/rspec-expectations"<CR>gem "rspec-mocks", :github => "rspec/rspec-mocks"<CR>gem "rspec-support", :github => "rspec/rspec-support"<CR><ESC>
map <leader>eipr o<ESC>ogem "rspec-core", :path => "/Users/sam/dev/rspec/rspec-dev/repos/rspec-core"<CR>gem "rspec-expectations", :path => "/Users/sam/dev/rspec/rspec-dev/repos/rspec-expectations"<CR>gem "rspec-mocks", :path => "/Users/sam/dev/rspec/rspec-dev/repos/rspec-mocks"<CR>gem "rspec-support", :path => "/Users/sam/dev/rspec/rspec-dev/repos/rspec-support"<CR><ESC>
map <leader>eid orequire 'pry'; binding.pry<ESC>
map <leader>li gg/def.*init<CR>
map <leader>lcd gg/class.*<CR>
map <leader>lrp /^ *p <CR>
map <leader>arp :Ack "^ *p " <CR>
map <leader>apr :Ack "binding.pry " <CR>
map <leader>eal :Align & <CR>
map <leader>eap :Align => <CR>
map <leader>edc mzO<ESC>j:s/,/,\r/g<CR>(%i<CR><ESC>%a<CR><ESC>(%=%:%s/ *$//g<CR>:noh<CR>'zkdd
map <leader>ecl :silent! %s/\[x\]/\[ \]/g<CR>gg
map <leader>eae :Align =<CR>
map <leader>ea{ :Align {<CR>
map <leader>erf i.fetchlr{r(f]r)
map <leader>erh xea:llxxx
map <leader>epl :PromoteToLet<cr>
map <leader>etw mp:%s/ *$//g<CR>:noh<CR>'p
map <leader>ert :%s/\t/ /g<CR>
map <leader>orf :call OpenSpec()<CR>
map <leader>orv :call VsplitSpec()<CR>
map <leader>onrv :call VsplitSpec()<CR>irequire "spec_helper"<CR><ESC>
map <leader>ors :tabe .rspec<CR>
map <leader>ogf :vsp Gemfile<CR>
map <leader>ovr :tabe ~/.vimrc<CR>/map.*leader<CR>:noh<CR>
map <leader>bi :!bundle install<CR>
map <leader>ft zfat
map <leader>uft zR
map <leader>gt :!go test -tags=integration -ldflags -s ./...<CR>
map <leader>gb :GoBuild<CR>
map <leader>snp :set nopaste<CR>
map <leader>sp :set paste<CR>
map <leader>fr :!clear && make build/rubyfmt.rb && bundle exec ruby build/rubyfmt.rb %<CR>
map <leader><space> :noh<CR>
nnoremap <leader>h <Esc>:call ToggleHardMode()<CR>
set incsearch
set vb
map <C-s> <esc>:w<CR>
imap <C-s> <esc>:w<CR>
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
command! Q q " Bind :Q to :q
command! W w " Bind :W to :w
command! Wq wq " Bind :Wq to :wq
command! WQ wq " Bind :WQ to :wq
set backspace=indent,eol,start
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RENAME CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
vmap <C-c><C-c> <Plug>SendSelectionToTmux
nmap <C-c><C-c> <Plug>NormalModeSendToTmux
nmap <C-c>r <Plug>SetTmuxVars
set background=dark
map j gj
map k gk
autocmd FileType markdown set textwidth=80
autocmd FileType markdown set spell
autocmd FileType markdown set tabstop=2
map <leader>y "*y
" Use the old vim regex engine (version 1, as opposed to version 2, which was
" introduced in Vim 7.3.969). The Ruby syntax highlighting is significantly
" slower with the new regex engine.
set re=1
let g:syntastic_mode_map = {
\'mode': 'active',
\'passive_filetypes': ['python', 'css', 'scss', 'sass', 'haml','rust']
\}
let g:ctrlp_max_files=0
let g:go_fmt_command = "goimports"
let g:ackprg = 'rg --vimgrep --no-heading --ignore-file "$HOME/.rgignore"'
let g:ctrlp_custom_ignore = 'node_modules\|venv\|git\\|deps\/\|priv\/\|_build\/\|target|tmp\/rspec-core'
let g:ctrlp_dotfiles = 1
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
set completeopt-=preview
let g:rustfmt_autosave=0
let g:syntastic_sh_checkers = ['shellcheck']
let g:syntastic_bash_checkers = ['shellcheck']
let g:syntastic_check_on_open = 0
let g:syntastic_c_include_dirs=["./ruby_checkout/include", "./ruby_checkout/.ext/include/x86_64-darwin19/", "./ruby_checkout"]
hi CocErrorSign ctermfg=black
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
autocmd BufEnter * redraw!
nmap <C-p> :Files<cr>
nmap <leader>rn <Plug>(coc-rename)
" source ~/dev/rubyfmt/rubyfmt.vim
let g:fzf_layout = { 'down': '~60%' }