-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
306 lines (263 loc) · 10.1 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
306
""""""""""""""""""""""""""""""""""""""""""""""""""
" I don't really know what i'm doing... "
""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " be iMproved, required!
filetype off " required!
" load plugins
if filereadable(expand('~/.vim/custom-plugins.vim'))
source $HOME/.vim/custom-plugins.vim
endif
""""""""""""""""""""""""""""""""""""""""""""""""""
" Sourcing Vim Scripts and Functions "
""""""""""""""""""""""""""""""""""""""""""""""""""
source $HOME/.vim/functions.vim
""""""""""""""""""""""""""""""""""""""""""""""""""
" Basic Settings "
""""""""""""""""""""""""""""""""""""""""""""""""""
set t_Co=256
set autoread
set shiftwidth=2
set softtabstop=2
set expandtab
set smarttab
set tabstop=2
set shortmess=I
set hlsearch
set showmatch
set incsearch
set number
" A nice status line that looks like this:
" ~/www/.vimrc[+][47][unix][vim][34%][0016,0001]
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
" keeps a permanent blank line for commands and
" keeps the status bar always visible
set laststatus=2
set showtabline=2
set encoding=utf-8
set termencoding=utf-8
set ruler
set et
set textwidth=120
set backspace=indent,eol,start " better backspace support
set clipboard+=unnamed
set autoread
set clipboard=unnamedplus
set lazyredraw
set completeopt=menuone,longest,preview
set hidden
set guicursor=
" plugins and syntax
filetype plugin indent on
syntax on
if has('nvim')
set termguicolors
endif
" let g:deoplete#enable_at_startup = 1
" let g:solarized_termcolors=256
let g:solarized_termtrans = 1
" let g:solarized_visibility = "high"
" let g:solarized_contrast = "normal"
set background=dark
" set background=light
colorscheme solarized
" colorscheme kalisi
" set no error bells
set noerrorbells visualbell t_vb=
""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom Mappings "
""""""""""""""""""""""""""""""""""""""""""""""""""
" Toggle line numbers and fold column for easy copying:
nnoremap <F2> :set nonumber!<CR>:set foldcolumn=0<CR>
" Execute file being edited with <Shift> + e:
" map <buffer> <S-e> :w<CR>:!/usr/bin/env python % <CR>
" Shorter commands to toggle Taglist display
" nnoremap TT :TlistToggle<CR>
" map <F4> :TlistToggle<CR>
nmap <F4> :TagbarToggle<CR>
map <F5> :NERDTreeToggle<CR>
map <F6> :w <CR>
set pastetoggle=<F8>
" arduino binds
map <silent> <LocalLeader>am :!make<CR>
map <silent> <LocalLeader>ac :!make clean<CR>
map <silent> <LocalLeader>au :!make upload<CR>
map <silent> <LocalLeader>aa :!make && make upload<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom Commands "
""""""""""""""""""""""""""""""""""""""""""""""""""
command! Pylint cexpr system('/usr/bin/env pylint --output-format=parseable --include-ids=y ' . expand('%'))
""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto Commands "
""""""""""""""""""""""""""""""""""""""""""""""""""
" If your file's extention is .sh .pl. or .py
" automatically set the executable bit.
" au BufWritePost *.sh !chmod +x %
" au BufWritePost *.pl !chmod +x %
" au BufWritePost *.py !chmod +x %
" Bash style guide recommends you don't name your
" scripts .sh, so this will make your file executable
" as long as you have your shabang line as the first line.
" au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "bash" | silent !chmod +x <afile> | endif | endif
au BufRead,BufNewFile *.go set shiftwidth=4 softtabstop=4 noexpandtab
autocmd FileType html setlocal shiftwidth=2 tabstop=2 expandtab
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 expandtab
autocmd FileType groovy setlocal shiftwidth=4 tabstop=4 expandtab
autocmd FileType java setlocal shiftwidth=4 tabstop=4 expandtab
" au FileType python call FT_Python()
" au FileType python set omnifunc=pythoncomplete#Complete
autocmd! BufNewFile,BufRead *.pde setlocal ft=arduino
autocmd! BufNewFile,BufRead *.ino setlocal ft=arduino
" disable visual bells
autocmd GUIEnter * set visualbell t_vb=
""""""""""""""""""""""""""""""""""""""""""""""""""
" Nvim vs Vim specific configurations "
""""""""""""""""""""""""""""""""""""""""""""""""""
if !has('nvim')
set term=xterm-256color
endif
if has('nvim')
autocmd BufEnter * if &buftype == "terminal" | startinsert | endif
tnoremap <Esc> <C-\><C-n>
command Tsplit split term://$SHELL
command Tvsplit vsplit term://$SHELL
command Ttabedit tabedit term://$SHELL
let g:python_host_prog = expand('~/.pyenv/versions/neovim/bin/python')
let g:python3_host_prog = expand('~/.pyenv/versions/neovim3/bin/python')
endif
""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto Load File Templates "
""""""""""""""""""""""""""""""""""""""""""""""""""
au BufNewFile *.py r $HOME/.vim/templates/skeleton.py
""""""""""""""""""""""""""""""""""""""""""""""""""
" Python FileType Settings "
""""""""""""""""""""""""""""""""""""""""""""""""""
function! FT_Python()
" Indent Python in the Google way.
setlocal indentexpr=GetGooglePythonIndent(v:lnum)
let s:maxoff = 50 " maximum number of lines to look backwards.
let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"
map <buffer> <Leader>p8 :call Pep8()<CR>
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""
" JSON FileType Settings "
""""""""""""""""""""""""""""""""""""""""""""""""""
au! BufRead,BufNewFile *.json set filetype=json
" autocmd BufNewFile,BufRead *.json set ft=javascript
"let g:vim_json_syntax_conceal = 0
" Use tern_for_vim.
let g:tern#command = [system(expand('~/.nodenv/bin/nodenv which tern'))]
""""""""""""""""""""""""""""""""""""""""""""""""""
" Powershell FileType Settings "
""""""""""""""""""""""""""""""""""""""""""""""""""
au BufNewFile,BufRead *.ps1xml set ft=ps1xml
au BufNewFile,BufRead *.ps1 set ft=ps1
au BufNewFile,BufRead *.psd1 set ft=ps1
au BufNewFile,BufRead *.psm1 set ft=ps1
""""""""""""""""""""""""""""""""""""""""""""""""""
" GoLang FileType Settings "
""""""""""""""""""""""""""""""""""""""""""""""""""
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <Leader>gb <Plug>(go-doc-browser)
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
let g:go_fmt_command = "goimports"
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_term_enabled = 1
let g:go_list_type = "quickfix"
let g:go_addtags_transform = "camelcase"
" let g:go_fmt_fail_silently = 1
" let g:go_fmt_autosave = 0
" let g:go_play_open_browser = 0
""""""""""""""""""""""""""""""""""""""""""""""""""
" JavaScript FileType Settings "
""""""""""""""""""""""""""""""""""""""""""""""""""
au BufRead,BufNewFile *.js set filetype=javascript
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ },
\}
""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC Stuff "
""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_save = 1
" Put plugins and dictionaries in this dir
let vimDir = '$HOME/.vim'
let &runtimepath.=','.vimDir
" Keep undo history across sessions by storing it in a file
if has('persistent_undo')
let myUndoDir = expand(vimDir . '/undodir')
" Create dirs
call system('mkdir -p ' . myUndoDir)
let &undodir = myUndoDir
set undofile
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""
"" PromptLine Config "
"""""""""""""""""""""""""""""""""""""""""""""""""""
let g:promptline_preset = {
\'a' : [ promptline#slices#user(), promptline#slices#host({ 'only_if_ssh': 1 }) ],
\'b' : [ promptline#slices#cwd() ],
\'c' : [ promptline#slices#vcs_branch(), '$(git rev-parse --short HEAD 2>/dev/null)' ],
\'x' : [ promptline#slices#git_status() ],
\'y' : [ promptline#slices#jobs() ],
\'z' : [ '%D{%A %Y-%m-%d} %T' ],
\'warn' : [ promptline#slices#last_exit_code() ],
\'options': {
\'left_sections' : [ 'a', 'b', 'c', 'x', 'warn' ],
\'right_sections' : [ 'y', 'z' ]}}
let g:tmuxline_preset = {
\ 'a': '#S',
\ 'b': '#H',
\ 'win': ['#I', '#W'],
\ 'cwin': ['#I', '#W'],
\ 'x': "#(uptime |awk '{ print $10, $11, $12 }'|tr -d ',')",
\ 'y': ['%A', '%Y-%m-%d'],
\ 'z': '%H:%M'}
let g:airline#extensions#tmuxline#enabled = 0
let g:tmuxline_theme = 'airline_insert'
let g:airline_powerline_fonts = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""
"" Ultisnips "
"""""""""""""""""""""""""""""""""""""""""""""""""""
"" make YCM and MacVim less shitty
"if has("unix")
" let s:uname = system("uname -s")
" if s:uname == "Darwin"
" " let g:ycm_path_to_python_interpreter = '/usr/bin/python2'
" " let g:ycm_path_to_python_interpreter = '/usr/bin/env python'
" let g:ycm_path_to_python_interpreter = '/usr/bin/python'
" " let g:ycm_path_to_python_interpreter = '/Users/jay/.pyenv/shims/python'
" elseif s:uname == "Linux"
" let g:ycm_path_to_python_interpreter = '/usr/bin/env python'
" endif
"endif
"" make YCM compatible with UltiSnips (using supertab)
"let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
"let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
"let g:SuperTabDefaultCompletionType = '<C-n>'
"let g:EclimCompletionMethod = 'omnifunc'
"
"" better key bindings for UltiSnipsExpandTrigger
"let g:UltiSnipsExpandTrigger = "<tab>"
"let g:UltiSnipsJumpForwardTrigger = "<tab>"
"let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
"" If you want :UltiSnipsEdit to split your window.
"" let g:UltiSnipsEditSplit="vertical"
" load CoC Config
if filereadable(expand('~/.vim/coc-vim-config.vim'))
source $HOME/.vim/coc-vim-config.vim
endif