-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
207 lines (164 loc) · 5.14 KB
/
Copy pathvimrc
File metadata and controls
207 lines (164 loc) · 5.14 KB
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
call plug#begin('~/.vim/plugged')
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
Plug 'easymotion/vim-easymotion'
Plug 'w0rp/ale'
Plug 'posva/vim-vue'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-commentary'
Plug 'mattn/emmet-vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'hashivim/vim-terraform'
Plug 'rust-lang/rust'
Plug 'leafgarland/typescript-vim'
Plug 'lepture/vim-jinja'
Plug 'wesgibbs/vim-irblack'
" Initialize plugin system
call plug#end()
syntax on
let g:ale_set_highlights = 0
colorscheme ir_black
filetype plugin indent on
set number
set tabstop=2
set shiftwidth=2
set expandtab
set backspace=indent,eol,start
set signcolumn=yes
"scrolling maxes out all cores at the mo without this
"https://github.com/vim/vim/issues/2584
set nocursorline
"statusline setup
set statusline =%#identifier#
set statusline+=[%f] "tail of the filename
set statusline+=%*
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
set statusline+=%h "help file flag
set statusline+=%y "filetype
"read only flag
set statusline+=%#identifier#
set statusline+=%r
set statusline+=%*
"modified flag
set statusline+=%#warningmsg#
set statusline+=%m
set statusline+=%*
set statusline+=%{fugitive#statusline()}
"display a warning if &paste is set
set statusline+=%#error#
set statusline+=%{&paste?'[paste]':''}
set statusline+=%*
set statusline+=%= "left/right separator
set statusline+=%c, "cursor column
set statusline+=%l/%L "cursor line/total lines
set statusline+=\ %P "percent through file
set laststatus=2
"recalculate the trailing whitespace warning when idle, and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
"return '[\s]' if trailing white space is detected
"return '' otherwise
function! StatuslineTrailingSpaceWarning()
if !exists("b:statusline_trailing_space_warning")
if !&modifiable
let b:statusline_trailing_space_warning = ''
return b:statusline_trailing_space_warning
endif
if search('\s\+$', 'nw') != 0
let b:statusline_trailing_space_warning = '[\s]'
else
let b:statusline_trailing_space_warning = ''
endif
endif
return b:statusline_trailing_space_warning
endfunction
"find the median of the given array of numbers
function! s:Median(nums)
let nums = sort(a:nums)
let l = len(nums)
if l % 2 == 1
let i = (l-1) / 2
return nums[i]
else
return (nums[l/2] + nums[(l/2)-1]) / 2
endif
endfunction
" We have to have a winheight bigger than we want to set winminheight. But if
" we set winheight to be huge before winminheight, the winminheight set will
" fail.
set winwidth=84
set winheight=5
set winminheight=5
set winheight=999
set wildmenu
set wildmode=list:longest
" taken from: http://stackoverflow.com/questions/356126/how-can-you-automatically-remove-trailing-whitespace-in-vim/1618401#1618401
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" auto-strip trailing white space for ruby files
" autocmd BufWritePre *.rb :call <SID>StripTrailingWhitespaces()
autocmd FileType c,cpp,java,php,ruby,python,haml,html,javascript,scss,sass,feature,yaml,typescript,vue,erb,tf autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
nnoremap <leader><leader> <c-^>
map <Leader>m :RTmodel
map <Leader>c :RTcontroller
map <Leader>v :RTview
command! Rroutes :tabe config/routes.rb
" open routes and gemfile in their own split
map <leader>gr :topleft :split config/routes.rb<cr>
map <leader>gg :topleft 100 :split Gemfile<cr>
" open files in the current directory
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
" close a buffer in a split without closing the split
command! BD bn\|bd \# <cr>
" write with sudo
cmap w!! w !sudo tee % > /dev/null
" Rspec.vim mappings
let g:rspec_runner = "os_x_iterm2"
" let g:rspec_command = "Dispatch bundle exec ./bin/rspec {spec} --color"
let g:rspec_command = "Dispatch bundle exec rspec {spec} --color"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" fix pre ruby 1.9 hash syntax
command! Fh :%s/:\([^ ]*\)\(\s*\)=>/\1:/gc
" stop those pesky swp warnings
:set noswapfile
:set nobackup
:set nowritebackup
" Gif config
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
map [b :bp<cr>
map ]b :bn<cr>
nnoremap <C-t> :GFiles<Cr>
nnoremap <C-g> :Ag<Cr>
map <Leader>f :ALEFix<Cr>
" don't hide quotes in json
let g:vim_json_syntax_conceal = 0
set shell=/usr/local/bin/zsh
hi EasyMotionMoveHLDefault cterm=bold ctermfg=242 ctermbg=10 gui=bold guifg=#CCCCCC guibg=#7fbf00
let g:ale_fixers = {
\ 'javascript': ['eslint'],
\ 'ruby': ['rubocop'],
\}
let g:user_emmet_leader_key=','