-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
291 lines (223 loc) · 6.36 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
286
287
288
289
290
291
" Use Vim settings, rather than Vi settings
set nocompatible
" Set mapleader
let mapleader=" "
" Navigation by visual line rather than \n line
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" Allow changing buffers w/o saving
set hidden
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Set backup directory
set backupdir=~/tmp,/var/tmp,/tmp
" keep 50 lines of command line history
set history=1000
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
" do incremental searching
set incsearch
" show line numbers
set number
"Use jj as escape in insert mode and command line mode
inoremap jj <C-c>
cnoremap jj <C-c>
"Use semi-colon to clear highlighted search results
nmap <silent> <Leader>; :noh<CR>
" enables more % matching
runtime macros/matchit.vim
" fixes complete problems
set wildmenu
set wildmode=list:longest
" searches treat undercase and lowercase similarly
set ignorecase
set smartcase
" Title
set title
" Syntax highlighting
syntax on
" Allow vim to recognize filetype
filetype off
" Filetype specific settings
filetype plugin off
filetype indent off
" Tabs are two spaces
set tabstop=4
set shiftwidth=4
set expandtab
" Leave space below cursor when strolling
set scrolloff=3
" Highligh search terms
set hlsearch
" Highlight search terms as they are typed
set incsearch
" View tabs and trailing useful (quite useful!)
set listchars=tab:>-,trail:·,eol:$
nmap <silent> <leader>w :set nolist!<CR>
" Disable annoying beeps
set visualbell
" View buffers
noremap <silent> <Leader>b :CtrlPBuffer<CR>
" Tab changes buffer
nnoremap <Tab> :bn<CR>
map <Esc>[Z <S-Tab>
nnoremap <S-Tab> :bp<CR>
" delete buffers without closing window
" (just switch to next buffer in window)
nnoremap <Leader>d :bn<CR>:bd#<CR>
" Split creation
noremap <silent> <Leader>v <C-w>v
noremap <silent> <Leader>s <C-w>s
noremap <silent> <Leader>c <C-w>c
" Split navigation
noremap <silent> <Leader>l <C-w>l
noremap <silent> <Leader>h <C-w>h
noremap <silent> <Leader>k <C-w>k
noremap <silent> <Leader>j <C-w>j
" Close brackets, parenthesis, and quotation marks
inoremap " ""<left>
inoremap ' ''<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
" http://stackoverflow.com/questions/677986/vim-copy-selection-to-os-x-clipboard
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
" Split resizing
" set winheight=30
" set winminheight=5
" Vundle
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" golang support
Plugin 'fatih/vim-go'
" coffee support
Plugin 'kchmck/vim-coffee-script'
" python autocompletion
"Plugin 'davidhalter/jedi-vim'
" javascript support
Plugin 'pangloss/vim-javascript'
" fuzzy file search
Plugin 'ctrlpvim/ctrlp.vim'
" Syntax errors
"Plugin 'scrooloose/syntastic.git'
" vim status line
"Plugin 'bling/vim-airline'
" elixir support
Plugin 'elixir-lang/vim-elixir'
" typescript support
Plugin 'leafgarland/typescript-vim'
" js/ts formatting
Plugin 'prettier/vim-prettier'
" kotlin
Plugin 'udalov/kotlin-vim'
" linting
Plugin 'w0rp/ale'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just
" :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to
" auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" Faster scrolling
if !exists("*MultiScroll")
function MultiScroll(OnOff)
if a:OnOff == 1
noremap j 5j
noremap k 5k
else
noremap j j
noremap k k
endif
endfunction
endif
map <silent> <Leader>aj :call MultiScroll(1)<CR>
map <silent> <Leader>ak :call MultiScroll(0)<CR>
" Run Gnu Make
noremap <Leader>m :make<CR>
" Automatically jump to last known cursor position
if has("autocmd")
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
" Set path to current directory
set path+=**
" Yapf
if !exists("*Yapf")
function Yapf()
if &ft != 'python'
return
end
kb
let current_line = line('.')
silent execute "0,$!yapf"
silent! bdelete 'error_msg'
if v:shell_error != 0 && v:shell_error != 2
" Shell command failed, so open a new buffer with error text
execute 'normal! gg"ayG'
silent undo
execute 'normal! ' . current_line . 'G'
silent new
setlocal buftype=nofile
setlocal bufhidden=delete
setlocal noswapfile
silent file 'error_msg'
silent put a
end
silent! 'b
endfunction
endif
nnoremap <silent> <leader>y :call Yapf()<Cr>:w<Cr>
" autocmd BufWritePre * call Yapf()
" format with goimports instead of gofmt
let g:go_fmt_command = "goimports"
let g:go_autodetect_gopath = 0
" Syntastic bullshit
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
let g:syntastic_loc_list_height = 5
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_disabled_filetypes=['ts']
let g:syntastic_html_checkers=['']
" SQL spacing
autocmd Filetype sql setlocal ts=2 sts=2 sw=2
" Yaml spacing
autocmd Filetype yaml setlocal ts=2 sts=2 sw=2
" Lua spacing
autocmd Filetype lua setlocal ts=2 sts=2 sw=2
" Javascript spacing
autocmd Filetype js setlocal ts=2 sts=2 sw=2
" Typescript spacing
autocmd Filetype typescript setlocal ts=2 sts=2 sw=2
" Elixir spacing
autocmd Filetype elixir setlocal ts=2 sts=2 sw=2
" Run prettier on save
"let g:prettier#autoformat = 0
"autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md PrettierAsync
let g:ale_linters = {
\ 'go': [],
\}