forked from braintreeps/vim_dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
248 lines (190 loc) · 7.32 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
" ========= Setup ========
set rtp+=/usr/local/lib/python2.6/dist-packages/powerline/bindings/vim
set rtp+=/opt/homebrew/opt/fzf
set nocompatible
if &shell == "/usr/bin/sudosh"
set shell=/bin/bash
endif
filetype off
call pathogen#infect()
filetype plugin indent on
runtime macros/matchit.vim
" ========= Options ========
compiler ruby
syntax on
set hlsearch
set number
set showmatch
set incsearch
set background=dark
set hidden
set backspace=indent,eol,start
set textwidth=0 nosmartindent tabstop=2 shiftwidth=2 softtabstop=2 expandtab
set ruler
set wrap
set dir=/tmp//
set scrolloff=5
set ignorecase
set smartcase
set wildignore+=*.pyc,*.o,*.class,*.lo,.git,*/vendor/*,*/node_modules/*,*/build/*
if version >= 703
set undodir=~/.vim/undodir
set undofile
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
endif
set undolevels=1000 "maximum number of changes that can be undone
" Color
colorscheme vibrantink
au FileType diff colorscheme desert
au FileType git colorscheme desert
au BufWinLeave * colorscheme vibrantink
" Cursor
highlight Cursor guifg=white guibg=black
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
" File Types
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 omnifunc=jedi#completions
autocmd FileType tex setlocal textwidth=78
autocmd FileType ruby runtime ruby_mappings.vim
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd BufNewFile,BufRead *.txt setlocal textwidth=78
autocmd BufNewFile,BufRead *.tsx set filetype=typescript
if version >= 700
autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en_us
autocmd FileType tex setlocal spell spelllang=en_us
endif
" Highlight trailing whitespace
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd BufRead,InsertLeave * match ExtraWhitespace /\s\+$/
" Autoremove trailing spaces when saving the buffer
autocmd FileType ruby,c,cpp,java,php,html,py autocmd BufWritePre <buffer> :%s/\s\+$//e
" Highlight too-long lines
autocmd BufRead,InsertEnter,InsertLeave * 2match LineLengthError /\%126v.*/
highlight LineLengthError ctermbg=black guibg=black
autocmd ColorScheme * highlight LineLengthError ctermbg=black guibg=black
" Set up highlight group & retain through colorscheme changes
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
" Status
set laststatus=2
set statusline=
set statusline+=%<\ " cut at start
set statusline+=%2*[%n%H%M%R%W]%*\ " buffer number, and flags
set statusline+=%-40f\ " relative path
set statusline+=%= " seperate between right- and left-aligned
set statusline+=%1*%y%*%*\ " file type
set statusline+=%10(L(%l/%L)%)\ " line
set statusline+=%2(C(%v/125)%)\ " column
set statusline+=%P " percentage of file
" ========= Plugin Options ========
let g:AckAllFiles = 0
let g:AckCmd = 'ack --type-add ruby=.feature --ignore-dir=tmp 2> /dev/null'
let html_use_css=1
let html_number_lines=0
let html_no_pre=1
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:rubycomplete_buffer_loading = 1
let g:no_html_toolbar = 'yes'
let coffee_no_trailing_space_error = 1
let NERDTreeIgnore=['\.pyc', '\.o', '\.class', '\.lo']
let g:VimuxUseNearestPane = 1
let $FZF_DEFAULT_COMMAND = 'find . -name "*" -type f 2>/dev/null
\ | grep -v -E "tmp\/|.gitmodules|.git\/|deps\/|_build\/|node_modules\/|vendor\/"
\ | sed "s|^\./||"'
let $FZF_DEFAULT_OPTS = '--reverse'
let g:fzf_tags_command = 'ctags -R --exclude=".git\|.svn\|log\|tmp\|db\|pkg" --extra=+f --langmap=Lisp:+.clj'
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
let g:fzf_layout = { 'up': '~20%' }
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#popup_on_dot = 0
let g:jedi#smart_auto_mappings = 0
let g:syntastic_check_on_open = 1
let g:syntastic_python_checkers = ['python', 'pyflakes']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_typescript_checkers = ['eslint']
let g:jsx_ext_required = 0
" ========= Shortcuts ========
" NERDTree
map <silent> <LocalLeader>nt :NERDTreeToggle<CR>
map <silent> <LocalLeader>nr :NERDTree<CR>
map <silent> <LocalLeader>nf :NERDTreeFind<CR>
" FZF
function! SmartFuzzy()
let root = split(system('git rev-parse --show-toplevel'), '\n')
if len(root) == 0 || v:shell_error
Files
else
GFiles -co --exclude-standard -- . ':!:vendor/*'
endif
endfunction
command! -nargs=* SmartFuzzy :call SmartFuzzy()
map <silent> <leader>ff :SmartFuzzy<CR>
map <silent> <leader>fg :GFiles<CR>
map <silent> <leader>fb :Buffers<CR>
map <silent> <leader>ft :Tags<CR>
" Ack
map <LocalLeader>aw :Ack '<C-R><C-W>'
" TComment
map <silent> <LocalLeader>cc :TComment<CR>
map <silent> <LocalLeader>uc :TComment<CR>
" Vimux
map <silent> <LocalLeader>rl :wa<CR> :VimuxRunLastCommand<CR>
map <silent> <LocalLeader>vi :wa<CR> :VimuxInspectRunner<CR>
map <silent> <LocalLeader>vk :wa<CR> :VimuxInterruptRunner<CR>
map <silent> <LocalLeader>vx :wa<CR> :VimuxClosePanes<CR>
map <silent> <LocalLeader>vp :VimuxPromptCommand<CR>
vmap <silent> <LocalLeader>vs "vy :call VimuxRunCommand(@v)<CR>
nmap <silent> <LocalLeader>vs vip<LocalLeader>vs<CR>
map <silent> <LocalLeader>rt :!ctags -R --exclude=".git\|.svn\|log\|tmp\|db\|pkg" --extra=+f --langmap=Lisp:+.clj<CR>
map <silent> <LocalLeader>gd :e product_diff.diff<CR>:%!git diff<CR>:setlocal buftype=nowrite<CR>
map <silent> <LocalLeader>pd :e product_diff.diff<CR>:%!svn diff<CR>:setlocal buftype=nowrite<CR>
map <silent> <LocalLeader>nh :nohls<CR>
map <silent> <LocalLeader>bd :bufdo :bd<CR>
cnoremap <Tab> <C-L><C-D>
nnoremap <silent> k gk
nnoremap <silent> j gj
nnoremap <silent> Y y$
map <silent> <LocalLeader>ws :highlight clear ExtraWhitespace<CR>
" Vimux Nose Test
autocmd FileType python map <silent> <LocalLeader>rf :wa<CR> :RunFocusedNoseTests<CR>
autocmd FileType python map <silent> <LocalLeader>rb :wa<CR> :RunAllNoseTests<CR>
" Vimux Jest Test
autocmd FileType javascript,typescript map <silent> <LocalLeader>rf :wa<CR> :RunJestFocused<CR>
autocmd FileType javascript,typescript map <silent> <LocalLeader>rb :wa<CR> :RunJestOnBuffer<CR>
" Prettier
autocmd FileType javascript map <silent> <leader>pt :Prettier<CR>
autocmd FileType python map <silent> <leader>pt :Black<CR>
" Tsuquyomi
let g:tsuquyomi_disable_quickfix = 1
autocmd FileType javascript,typescript map <silent> <LocalLeader>g :TsuDefinition<CR>
" ========= Insert Shortcuts ========
imap <C-L> <SPACE>=><SPACE>
imap <C-D> import ipdb; ipdb.sset_trace()
" Remapping of autocomplete trigger
imap <C-SPACE> <C-N>
imap <C-@> <C-Space>
" ========= Functions ========
command SudoW w !sudo tee %
" http://techspeak.plainlystated.com/2009/08/vim-tohtml-customization.html
function! DivHtml(line1, line2)
exec a:line1.','.a:line2.'TOhtml'
%g/<style/normal $dgg
%s/<\/style>\n<\/head>\n//
%s/body {/.vim_block {/
%s/<body\(.*\)>\n/<div class="vim_block"\1>/
%s/<\/body>\n<\/html>/<\/div>
"%s/\n/<br \/>\r/g
set nonu
endfunction
command -range=% DivHtml :call DivHtml(<line1>,<line2>)
nnoremap <silent> <Leader>gw :Ggrep! "\<<cword>\>"<CR>:cwin<CR>
function! Trim()
%s/\s*$//
endfunction
command! -nargs=0 Trim :call Trim()
nnoremap <silent> <Leader>cw :Trim<CR>