-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
306 lines (261 loc) · 7.66 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
set nocompatible
set encoding=utf-8
set ts=4
set sw=4
set ruler
set laststatus=2 "always show status
set number
set nowrap
set tw=72
set autoindent
set backspace=eol,start,indent
"copy and paste to system clipboard
if has('win32')
set clipboard=unnamed
else
set clipboard=unnamedplus
endif
set visualbell " don't beep - our clicky keyboard is annoying enough for the neighbors
" don't polute the world with temp files
set nobackup
set directory=~/.vim/swap
" turn on syntax folding (toggle folds with za)
let g:xml_syntax_folding=1
set foldmethod=syntax
set foldlevelstart=3
syntax on;
" turn on code completion
filetype plugin on
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
" disable syntax for large files to prevent slowdown
autocmd BufReadPre * if getfsize(expand("%")) > 10000000 | syntax off | endif
" ----------------------------------------------------
" tag stuff
" ----------------------------------------------------
"
" search for tags in current dir then parent and so on
set tags=./tags;/
" open taglist with T
nnoremap <silent> T :TlistToggle<CR>
" give the taglist focus when it's opened
let Tlist_GainFocus_On_ToggleOpen = 1
" ----------------------------------------------------
" package management
" ----------------------------------------------------
"
" stuff required to get vundle to work
filetype off
set shellslash
set rtp+=~/vimfiles/bundle/Vundle.vim/
call vundle#begin('~/vimfiles/bundle')
Plugin 'VundleVim/Vundle.vim'
" list of installed packages
Plugin 'thinca/vim-fontzoom'
Plugin 'gmarik/vundle'
Plugin 'vcscommand.vim'
Plugin 'surround.vim'
Plugin 'tpope/vim-repeat'
Plugin 'visSum.vim'
"Plugin 'taglist.vim'
Plugin 'will133/vim-dirdiff'
Plugin 'TaskList.vim'
Plugin 'xmledit'
Plugin 'xml.vim'
Plugin 'dbext.vim'
Plugin 'highlight.vim'
Plugin 'vim-scripts/CycleColor'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'easymotion/vim-easymotion'
Plugin 'jeffkreeftmeijer/vim-numbertoggle'
Plugin 'scrooloose/nerdtree'
Plugin 'chrisbra/csv.vim'
Plugin 'sbdchd/neoformat'
"Plugin 'tpope/vim-fugitive'
" js / react stuff
Plugin 'pangloss/vim-javascript'
Plugin 'MaxMEllon/vim-jsx-pretty'
" colorschemes
Plugin 'flazz/vim-colorschemes'
Plugin 'Heorhiy/VisualStudioDark.vim'
Plugin 'felixhummel/setcolors.vim'
Plugin 'ajmwagar/vim-deus'
Plugin 'neomake/neomake'
Plugin 'Rigellute/shades-of-purple.vim'
call vundle#end()
filetype plugin indent on
" neomake config
let g:neomake_open_list = 2
call neomake#configure#automake('nw', 750)
" ----------------------------------------------------
" color scheme
" ----------------------------------------------------
"
" set font for neovim qt
set guifont=Consolas:h10
if has("gui_running")
" set font in gvim
" gui colors
" favorites: zenburn anderson deus wombat VisualStudioDark gruvbox
" pencil shades_of_purple
if (has("termguicolors"))
set termguicolors
endif
"""" enable the theme
colorscheme shades_of_purple
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_win32")
set guifont=Consolas:h10:cANSI
endif
else
" terminal colors
if (has("termguicolors"))
set termguicolors
colorscheme shades_of_purple
else
colorscheme 0x7A69_dark
endif
endif
" add command to format xml
" if on windows run choco install xsltproc to get xmllint
if executable("xmllint")
function! DoFormatXml()
% !xmllint.exe % --format
endfunction
command FormatXml call DoFormatXml()
endif
if executable("python")
function! DoFormatJson()
:%!python -m json.tool
set syntax=json
endfunction
command FormatJson call DoFormatJson()
elseif executable("py")
function! DoFormatJson()
:%!py -m json.tool
set syntax=json
endfunction
command FormatJson call DoFormatJson()
endif
if executable("sqlformat")
function! DoFormatSql()
:%!sqlformat --indent " " -U
set syntax=sql
endfunction
command FormatSql call DoFormatSql()
endif
function! DoRemoveCr()
silent execute "%s/\r//g"
endfunction
command RemoveCr call DoRemoveCr()
function! DoQuoteParens()
silent execute "%s/{/'{/g"
silent execute "%s/}/}'/g"
endfunction
command QuoteParens call DoQuoteParens()
function! DoFormatQueryResultAsCsv()
silent execute "g/|----/d"
silent execute "%s/||/|/g"
silent execute "%s/^| *//g"
silent execute "%s/ *|$//g"
silent execute "%s/ *| */,/g"
endfunction
command FormatQueryResultAsCsv call DoFormatQueryResultAsCsv()
" hide unused stuff in gvim
set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions+=c
" settings for git commit messages
function! GitCommitSettings()
setlocal spell
set ts=4
endfunction
au BufNewFile,BufRead COMMIT_EDITMSG call GitCommitSettings()
" prevent editor config from loading for vim commit message
let g:EditorConfig_exclude_patterns = ['COMMIT_EDITMSG']
" settings for editing trello card text
function! TrelloSettings()
set tw=58
set syntax=markdown
endfunction
au BufNewFile,BufRead vimperator-trello.* call TrelloSettings()
function! s:SqlQueryDart(env, client, loc, busDate, sqlFile, outFile, bufOpenCmd)
set syntax=sql
let cmd = "RosTools QueryDataSets -eod -e " . a:env . " -c " . a:client . " -l " . a:loc . " -b \"" . a:busDate . "\" -i \"" . a:sqlFile . "\" -o " . a:outFile
silent execute "!" . cmd
if (bufnr(a:outFile) < 0)
execute a:bufOpenCmd a:outFile
:setl autoread
endif
endfunction
function! s:SqlQueryRos(env, db, sqlFile, outFile, bufOpenCmd, diff)
set syntax=sql
let cmd = "RosTools query --timeout 120 -e " . a:env . " -db " . a:db . " -i \"" . a:sqlFile . "\" -o " . a:outFile
silent execute "!" . cmd
if (bufnr(a:outFile) < 0)
execute a:bufOpenCmd a:outFile
if (a:diff == 1)
:diffthis
endif
:setl autoread
endif
endfunction
function! s:SqlQuery(server, db, sqlFile, outFile, bufOpenCmd, diff)
set syntax=sql
let cmd = "RosTools query --timeout 120 -s " . a:server . " -db " . a:db . " -i \"" . a:sqlFile . "\" -o " . a:outFile
silent execute "!" . cmd
if (bufnr(a:outFile) < 0)
execute a:bufOpenCmd a:outFile
if (a:diff == 1)
:diffthis
endif
:setl autoread
endif
endfunction
function! s:Query(server, db)
let sqlFile = tempname()
let lines = getline(1,'$')
let test = writefile(lines, sqlFile)
call s:SqlQuery(a:server, a:db, sqlFile, tempname(), "new", 0)
endfunction
function! s:QueryDiff(serverA, dbA, serverB, dbB)
let sqlFile = tempname()
let lines = getline(1,'$')
let test = writefile(lines, sqlFile)
let a = tempname()
let b = tempname()
call s:SqlQuery(a:serverB, a:dbB, sqlFile, b, "new", 1)
call s:SqlQuery(a:serverA, a:dbA, sqlFile, a, "vnew", 1)
:redraw
endfunction
function! s:QueryRos(env, db)
let sqlFile = tempname()
let lines = getline(1,'$')
let test = writefile(lines, sqlFile)
call s:SqlQueryRos(a:env, a:db, sqlFile, tempname(), "new", 0)
endfunction
function! s:QueryRosDiff(envA, dbA, envB, dbB)
let sqlFile = tempname()
let lines = getline(1,'$')
let test = writefile(lines, sqlFile)
let a = tempname()
let b = tempname()
call s:SqlQueryRos(a:envB, a:dbB, sqlFile, b, "new", 1)
call s:SqlQueryRos(a:envA, a:dbA, sqlFile, a, "vnew", 1)
:redraw
endfunction
function! s:QueryDart(env, client, loc, busDate)
let sqlFile = tempname()
let lines = getline(1,'$')
let test = writefile(lines, sqlFile)
call s:SqlQueryDart(a:env, a:client, a:loc, a:busDate, sqlFile, tempname(), "new")
endfunction
command! -nargs=+ Query call s:Query(<f-args>)
command! -nargs=+ QueryDiff call s:QueryDiff(<f-args>)
command! -nargs=+ QueryRos call s:QueryRos(<f-args>)
command! -nargs=+ QueryRosDiff call s:QueryRosDiff(<f-args>)
command! -nargs=+ QueryDart call s:QueryDart(<f-args>)