-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathvimrc
399 lines (298 loc) · 10.5 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'easymotion/vim-easymotion.git'
"Plugin 'ivanov/vim-ipython'
Plugin 'scrooloose/nerdtree'
"Plugin 'christoomey/vim-tmux-navigator'
Plugin 'djoshea/vim-autoread'
Plugin 'lumiliet/vim-twig'
Plugin 'vim-scripts/Txtfmt-The-Vim-Highlighter'
Plugin 'vimwiki/vimwiki'
Plugin '907th/vim-auto-save'
Plugin 'scrooloose/nerdcommenter'
Plugin 'vim-syntastic/syntastic'
Plugin 'rking/ag.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'junegunn/vim-easy-align'
Plugin 'Shougo/vimproc.vim'
Plugin 'Shougo/unite.vim'
"Plugin 'godlygeek/tabular'
"Plugin 'plasticboy/vim-markdown'
"Plugin 'rhysd/vim-grammarous'
"Plugin 'w0rp/ale'
Plugin 'dhruvasagar/vim-table-mode'
"Plugin 'vim-scripts/DrawIt'
"Plugin 'lervag/vimtex'
Plugin 'szw/vim-tags'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
"Plugin 'ludovicchabant/vim-gutentags'
Plugin 'Shougo/deoplete.nvim'
Plugin 'morhetz/gruvbox'
"Plugin 'tbabej/taskwiki'
"Plugin 'farseer90718/vim-taskwarrior'
Plugin 'powerman/vim-plugin-AnsiEsc'
Plugin 'dpelle/vim-LanguageTool'
"Plugin 'SirVer/ultisnips'
Plugin 'meain/vim-printer'
Plugin 'tpope/vim-surround'
Plugin 'airblade/vim-rooter'
"Plugin 'codota/tabnine-vim'
"Plugin 'ycm-core/YouCompleteMe'
"Plugin 'altercation/vim-colors-solarized'
Plugin 'github/copilot.vim'
"Plugin 'Lucklyric/copilot.vim'
Plugin 'psf/black'
"Plugin 'google/vim-codefmt'
"Plugin 'davidhalter/jedi-vim'
Plugin 'file:///home/tom/git/vim_codex'
"Plugin 'file:///home/tom/git/vim-openai'
"Plugin 'tom-doerr/vim_codex'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
set clipboard=unnamedplus
set tabstop=8
set expandtab
set shiftwidth=4
set softtabstop=4
filetype indent on
" post by cdated https://stackoverflow.com/questions/2561418/how-to-comment-out-a-block-of-python-code-in-vim
vnoremap <silent> # :s/^/#/<cr>:noh<cr>
vnoremap <silent> -# :s/^#//<cr>:noh<cr>
let g:EasyMotion_do_mapping = 1 " Disable/Enable default mappings
map <Space> H<Plug>(easymotion-w)
" autosave (post by Sameer https://stackoverflow.com/questions/6991638/how-to-auto-save-a-file-every-1-second-in-vim)
" autocmd TextChanged,TextChangedI <buffer> silent write
"let g:gruvbox_italic=1
" post by ying17zi https://stackoverflow.com/questions/6778961/alt-key-shortcuts-not-working-on-gnome-terminal-with-vim
" Alt-j/k to add a blank line
if has('gui_running')
" the following two lines do not work in vim, but work in Gvim
nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>
else
" these two work in vim
" shrtcut with alt key: press Ctrl-v then Alt-k
" ATTENTION: the following two lines should not be
" edited under other editors like gedit. ^[k and ^[j will be broken!
nnoremap k :set paste<CR>m`O<Esc>``:set nopaste<CR>
nnoremap j :set paste<CR>m`o<Esc>``:set nopaste<CR>
endif
" Alt-j/k for eight bit terminal like xterm
nnoremap <m-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>
nnoremap <m-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
map <C-n> :NERDTreeToggle<CR>
set noswapfile
" Highlight search matches
set hls
" Spell checking
map <F7> :setlocal spell spelllang=en <return>
map <F8> :setlocal spell spelllang=de <return>
" Insert date with F3
" https://stackoverflow.com/questions/56052/best-way-to-insert-timestamp-in-vim
nmap <F3> i<C-R>=strftime("%Y-%m-%d %a %I:%M %p ")<CR><Esc>
imap <F3> <C-R>=strftime("%Y-%m-%d %a %I:%M %p ")<CR>
" Increase history size
set history=1000
"" Scroll with space
"map <Space>
"map <S-Space>
let g:auto_save = 1 " enable AutoSave on Vim startup
let g:auto_save_silent = 1 " do not display the auto-save notification
" Use Alt + l/h to move between tabs
nnoremap <m-l> gt
nnoremap <m-h> gT
inoremap <m-l> <C-O>gt
inoremap <è> <C-O>gt
inoremap <m-h> <C-O>gT
inoremap <ì> <C-O>gT
" Add shortcut to open file and close NERDTree
" https://vi.stackexchange.com/questions/3489/nerdtree-how-to-open-a-file-and-automatically-close-the-explorer-buffer
" autocmd BufEnter NERD_tree_* nmap d<CR> <CR> :NERDTreeToggle <CR>
" autocmd BufLeave NERD_tree_* unmap d<CR>
" Tab-bar design
hi TabLine ctermfg=Black ctermbg=White
hi TabLineSel ctermfg=White ctermbg=Black
"nnoremap == mtgg=G't
" Automatically relaod vimrc
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
" Syntastic settings
set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <Leader>e :SyntasticCheck<CR>
nnoremap <m-e> :SyntasticCheck<CR>
nnoremap å :SyntasticCheck<CR>
" Searching
nnoremap <Leader>s :Ag
nnoremap <m-a> :Ag
nmap <Leader>8 :Ag <c-r>=expand("<cword>")<cr><cr>
nmap <m-8> :Ag <c-r>=expand("<cword>")<cr><cr>
nmap ¸ :Ag <c-r>=expand("<cword>")<cr><cr>
" Searching for files
let g:unite_source_history_yank_enable = 1
try
"let g:unite_source_rec_async_command='ag --nocolor --nogroup -g ""'
"call unite#filters#matcher_default#use(['matcher_fuzzy'])
catch
endtry
" search a file in the filetree
nnoremap <m-f> :split<cr> :<C-u>Unite -start-insert file_rec/async<cr>
nnoremap æ :split<cr> :<C-u>Unite -start-insert file_rec/async<cr>
" Aligning
vnoremap <silent> <Enter> :EasyAlign<cr>
" Save and close
nnoremap <m-c> ZZ
nnoremap <m-d> ZZ
nnoremap ã ZZ
" Disable automatic folding in markdown files
let g:vim_markdown_folding_disabled = 1
" Stop autoindenting bullet points
" https://stackoverflow.com/questions/46876387/vim-with-markdown-how-to-remove-blankspace-after-bullet-point
let g:vim_markdown_new_list_item_indent = 0
setlocal formatoptions=tqlnrc
set comments=b:>
let g:grammarous#use_location_list = 1
set ignorecase
set smartcase
" ALE linting
"let g:ale_enabled = 0
nmap <silent> [W <Plug>(ale_first)
nmap <silent> [w <Plug>(ale_previous)
nmap <silent> ]w <Plug>(ale_next)
nmap <silent> ]W <Plug>(ale_last)
set virtualedit=all
" Indent Python in the Google way.
setlocal indentexpr=GetGooglePythonIndent(v:lnum)
let s:maxoff = 50 " maximum number of lines to look backwards.
function GetGooglePythonIndent(lnum)
" Indent inside parens.
" Align with the open paren unless it is at the end of the line.
" E.g.
" open_paren_not_at_EOL(100,
" (200,
" 300),
" 400)
" open_paren_at_EOL(
" 100, 200, 300, 400)
call cursor(a:lnum, 1)
let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
\ . " =~ '\\(Comment\\|String\\)$'")
if par_line > 0
call cursor(par_line, 1)
if par_col != col("$") - 1
return par_col
endif
endif
" Delegate the rest to the original function.
return GetPythonIndent(a:lnum)
endfunction
let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"
nnoremap <Leader>gc :Git commit -v -q %:p<CR>i
nnoremap <Leader>gp :Git push<CR>
nnoremap <Leader>gl :Gpull<CR>
set conceallevel=2
"nnoremap <Leader>b bi*<Esc>ea*<Esc>
"nmap <Leader>b ysiw*
set modelines=0
set nomodeline
" FZF mappings
imap <c-x><c-p> <plug>(fzf-complete-path)
nnoremap <Leader>f :Rg<CR>
nnoremap <C-f> :Rg<CR>
map <M-;> :Lines<CR>
map <C-s> :History<CR>
" Jedi
let g:jedi#completions_enabled = 0
autocmd FileType python setlocal completeopt-=preview
autocmd FileType markdown TableModeEnable
" Statusline
set statusline+=%f
" Latex insert todo
"map <M-t><C-o> o%todo:
map <Leader>t <C-o> o%todo:
map <M-r><C-o> o%todo: add reference<CR>
map <Leader>r <C-o> o%todo: add reference<CR>
map <Leader>to o. -- Tom}<C-o>I\todo[inline]{TODO:
map <Leader>ts o. -- Tom}<C-o>I\todo[inline]{@Tom: TODO:
"
" Taskwiki
map <Leader>s :TaskWikiMod +next_twt<CR>:!task rc.context=none +ACTIVE done; task rc.context=none +next_twt +PENDING start &>> /var/log/taskwiki_custom<CR><CR>:e<CR>
map <Leader>c :TaskWikiDone<CR>
"map <Leader>d :!source ~/.zshrc && td<CR><CR>:e<CR>
map <Leader>D :TaskWikiDelete<CR>
map <Leader>S :TaskWikiStop<CR>:TaskWikiMod -next_twt<CR>
map <M-t> <M-j>jVs* [ ]
autocmd BufRead * let g:auto_save = 1
"autocmd BufRead *.wiki let g:auto_save = 0
let g:languagetool_jar='/opt/languagetool/LanguageTool-4.9.1/languagetool-commandline.jar'
map <M-w> :w<CR>
map <M-e> :e<CR>
" vim-taskwarrior
let g:task_rc_override = 'rc._forcecolor=off'
imap <M-k> <C-k>
let g:vim_markdown_math = 1
" Ultisnips
"let g:UltiSnipsExpandTrigger="<tab>"
" vimwiki
map <Leader>1 I =<C-o>0=
map <Leader>2 I ==<C-o>0==
map <Leader>3 I ===<C-o>0===
map <Leader>4 I ====<C-o>0====
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
let g:vim_printer_print_below_keybinding = '<M-p>'
let g:vim_printer_print_above_keybinding = '<M-P>'
set viminfo='1000
let g:vimwiki_global_ext = 0
let g:tex_flavor='latex'
nnoremap <Leader>sd :setlocal spell spelllang=de<CR>
nnoremap <Leader>se :setlocal spell spelllang=en<CR>
set autochdir
colorscheme gruvbox
"set background =dark
"colorscheme solarized
autocmd vimenter * hi Normal guibg=NONE ctermbg=NONE
map <C-p> <plug>NERDCommenterToggle
nnoremap <C-x> :CreateCompletion<CR>
inoremap <C-x> <Esc>li<C-g>u<Esc>l:CreateCompletion<CR>
let g:black_skip_string_normalization = 1
nnoremap <Leader>b :Black <CR>
set inccommand=nosplit
let g:copilot_filetypes = {
\ 'xml': v:false,
\ 'fish': v:true,
\ }
imap <silent><script><expr> <C-J> copilot#Accept("")
let g:python3_host_prog = '/usr/bin/python3'
let g:loaded_python3_provider = 1
"let g:deoplete#enable_at_startup = 1
"let g:jedi#goto_command = "<leader>d"
map <Leader>d :jedi-goto-definition<CR>
let g:ale_python_pylint_options = '--disable=E1101,C0114,C0114,C0114'
nnoremap <M-y> ggVGy " Alt+y
nnoremap <M-p> ggVGp " Alt+p
nmap <leader>y ggVGy
nmap <leader>p ggVGp
imap <silent><script><expr> <Tab> copilot#Accept("\<CR>")