1
2
3
4
5
6 "Software"
7
8
9
10
11
12
13
14
15 "AS IS"
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 set nocompatible
41
42
43
44
45 let mapleader = '\'
46 let maplocalleader = '\'
47
+ - 48 +-- 39 lines: System Dependencies:
48
| 49 let g:jm_vimrc = {}
| 50
| 51
| 52
| 53 let g:jm_vimrc.docs = {}
| 54
| 55
| 56
| 57 let g:jm_vimrc.docs.commands = {}
| 58
| 59
| 60
| 61 let g:jm_vimrc.docs.mappings = {}
| 62
| 63
| 64 let g:jm_vimrc.deps = #{
| 65 \ jshell: 'jshell',
| 66 \ curl: 'curl',
| 67 \ blaze: 'blaze',
| 68 \ javap: 'javap',
| 69 \ ag: 'ag',
| 70 \ fish: 'fish',
| 71 \ python: 'python3',
| 72 \ }
| 73
| 74
| 75 let g:jm_vimrc.is_mac = system('uname -s') =~# 'Darwin'
| 76
| 77
| 78 let g:jm_vimrc.has_python = has('python3')
| 79
| 80
| 81 let g:jm_vimrc.deps.JavaClassnameList = {-> systemlist('fish -c "classpath list-all-classes"')}
| 82 let g:jm_vimrc.deps.ClasspathJarList = {-> systemlist('fish -c classpath')}
| 83
| 84 let g:jm_vimrc.deps.google_java_executable = 'google-java-format'
| 85 let g:jm_vimrc.deps.buildozer = 'fish -c buildozer'
| 86
87
+ - 88 +-- 28 lines: Playground:
88
| 89 let s:pg_items = (g:jm_vimrc.is_mac)
| 90 \ ? #{
| 91 \ co: 'Files ~/Playground',
| 92 \ cj: 'Files ~/Playground/jdk/src/java.base/share/classes',
| 93 \ pg: 'Files ~/Playground',
| 94 \ n: 'Files ~/Playground/jmendio/n',
| 95 \ v: 'edit ~/.vimrc',
| 96 \ }
| 97 \ : #{
| 98 \ a: 'Files ~/code/abseil-cpp/absl',
| 99 \ co: 'Files ~/code',
| 100 \ cg: 'Files ~/code/guava/guava/src',
| 101 \ cj: 'Files ~/code/jdk/src/java.base/share/classes',
| 102 \ cv: 'Files ~/code/opencv/modules/core',
| 103 \ cp: 'Files ~/code/pandas',
| 104 \ cd: 'Files ~/code/dagger',
| 105 \ cb: 'Files ~/code/basis',
| 106 \ cO: 'Files /usr/lib/ocaml',
| 107 \ j: 'Files ~/junk',
| 108 \ n: 'Files ~/jmendio/n',
| 109 \ v: 'edit ~/.vimrc',
| 110 \ }
| 111 for [key, path] in items(s:pg_items)
| 112 execute printf('nnoremap <leader>e%s :%s<cr>', key, path)
| 113 let g:jm_vimrc.docs.mappings['\e' .. key] = 'Run :' .. path
| 114 endfor
| 115
116
+ - 117 +-- 86 lines: Plugins (vim-plug):
117
| 118 call plug#begin('~/.vim/bundle')
| 119
| 120
| 121 Plug 'morhetz/gruvbox'
| 122 Plug 'tpope/vim-surround'
| 123 Plug 'scrooloose/nerdtree'
| 124 Plug 'godlygeek/tabular'
| 125 if g:jm_vimrc.has_python
| 126 Plug 'SirVer/ultisnips'
| 127 Plug 'Valloric/YouCompleteMe'
| 128 endif
| 129 Plug 'honza/vim-snippets'
| 130 Plug 'junegunn/fzf', {'do': {-> fzf#install()}}
| 131 Plug 'junegunn/fzf.vim'
| 132 Plug 'junegunn/vim-easy-align'
| 133 Plug 'tpope/vim-fugitive'
| 134 Plug 'moll/vim-bbye'
| 135 Plug 'scrooloose/nerdcommenter'
| 136 Plug 'jiangmiao/auto-pairs'
| 137 Plug 'tpope/vim-repeat'
| 138 Plug 'triglav/vim-visual-increment'
| 139 Plug 'tmhedberg/SimpylFold'
| 140 Plug 'majutsushi/tagbar'
| 141 Plug 'pangloss/vim-javascript'
| 142 Plug 'nelstrom/vim-markdown-folding'
| 143 Plug 'justinmk/vim-syntax-extra'
| 144 Plug 'jpalardy/vim-slime'
| 145 Plug 'itchyny/lightline.vim'
| 146 Plug 'ap/vim-buftabline'
| 147 Plug 'airblade/vim-gitgutter'
| 148 Plug 'google/vim-maktaba'
| 149 Plug 'google/vim-codefmt'
| 150 Plug 'google/vim-glaive'
| 151 Plug 'frazrepo/vim-rainbow'
| 152 Plug 'AndrewRadev/splitjoin.vim'
| 153 Plug 'AndrewRadev/linediff.vim'
| 154 Plug 'shiracamus/vim-syntax-x86-objdump-d'
| 155 Plug 'romainl/vim-devdocs'
| 156 if isdirectory('$OCAML_OCP_INDENT')
| 157 Plug $OCAML_OCP_INDENT
| 158 endif
| 159 if exists("$BASIS")
| 160 Plug $BASIS, { 'rtp': 'vim' }
| 161 else
| 162 Plug 'jmend736/basis', { 'rtp': 'vim' }
| 163 endif
| 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 call plug#end()
| 189
| 190 if !exists('g:loaded_plug')
| 191 echoerr "ERROR: vim-plug is REQUIRED https://github.com/junegunn/vim-plug"
| 192 finish
| 193 endif
| 194
| 195
| 196 call glaive#Install()
| 197
| 198 Glaive codefmt
| 199 \ google_java_executable=`g:jm_vimrc.deps.google_java_executable`
| 200 \ clang_format_style='Google'
| 201
| 202
203
+ - 204 +-- 99 lines: General Options:
204
| 205 filetype plugin indent on
| 206
| 207 set t_Co=256
| 208 set t_ut=
| 209
| 210 set scrolloff=0
| 211
| 212 set shell=/bin/bash
| 213
| 214 set hidden
| 215
| 216 set tabstop=2
| 217 set softtabstop=2
| 218 set shiftwidth=2
| 219 set expandtab
| 220 set smarttab
| 221
| 222 set autoindent
| 223 set smartindent
| 224
| 225
| 226 set backspace=indent,eol,start
| 227
| 228 set list
| 229 set listchars=tab:\>\ ,trail:·,extends:→,precedes:←
| 230
| 231 set number
| 232 set numberwidth=4
| 233 set relativenumber
| 234 set noruler
| 235 set showcmd
| 236
| 237 set statusline=%f\ %=L:%l/%L\ %c\ (%p%%)
| 238
| 239 set wildmenu
| 240 set wildmode=longest,list,full
| 241
| 242 set hlsearch
| 243 set incsearch
| 244 set foldopen-=search
| 245
| 246
| 247
| 248 set ignorecase
| 249 set smartcase
| 250
| 251
| 252 set fileencodings=utf-8
| 253 set tags=tags
| 254 set tags+=/usr/include/**/tags
| 255 set printoptions=number:y,duplex:long,paper:letter
| 256 if g:jm_vimrc.is_mac
| 257 set clipboard=unnamed
| 258 else
| 259 set clipboard=unnamedplus
| 260 endif
| 261 set errorbells
| 262 set laststatus=2
| 263 set cursorline
| 264 set sessionoptions=
| 265 \blank,
| 266 \curdir,
| 267 \folds,
| 268 \help,
| 269 \localoptions,
| 270 \options,
| 271 \tabpages,
| 272 \winsize,
| 273 \terminal
| 274
| 275 set directory=~/.swaps//
| 276
| 277
| 278 digraphs el 8712
| 279 digraphs in 8712
| 280 digraphs ni 8713
| 281 digraphs es 8709
| 282 digraphs ss 8834
| 283 digraphs se 8838
| 284 digraphs ns 8836
| 285 digraphs nS 8840
| 286 digraphs nn 8745 " Intersection
| 287 digraphs uu 8746
| 288 digraphs un 8746
| 289 digraphs co 8728
| 290 digraphs \|> 8614
| 291 digraphs tl 8598
| 292 digraphs tr 8599
| 293 digraphs br 8600
| 294 digraphs bl 8601
| 295 digraphs -u 8593
| 296 digraphs -d 8595
| 297
| 298
| 299 colorscheme gruvbox
| 300 syntax enable
| 301 set bg=dark
| 302
303
+ - 304 +-- 67 lines: Plugin Settings:
304
| 305
| 306 let g:lightline = {
| 307 \ 'active': {
| 308 \ 'left': [['mode', 'paste'], ['filename', 'modified']],
| 309 \ 'right': [['winlayout', 'winid_bufnr', 'lineinfo'], ['percent', 'foldlevel'], ['readonly']]
| 310 \ },
| 311 \ 'inactive': {
| 312 \ 'left': [['filename', 'modified']],
| 313 \ 'right': [['winlayout', 'winid_bufnr', 'lineinfo'], ['readonly']]
| 314 \ },
| 315 \ 'component_type': {
| 316 \ 'readonly': 'error',
| 317 \ },
| 318 \ 'component': {
| 319 \ 'winid_bufnr': '[%{winnr()}/%{win_getid()}(%{Layout()[win_getid()]})]{%{bufnr()}}',
| 320 \ 'foldlevel': '%{(&foldenable) ? &foldlevel : "-"}f',
| 321 \ },
| 322 \ }
| 323
| 324 let $FZF_DEFAULT_COMMAND = 'ag -l'
| 325
| 326
| 327
| 328
| 329
| 330 let g:ycm_auto_trigger = 1
| 331 let g:ycm_disable_signature_help = 1
| 332 let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
| 333 let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
| 334
| 335 let g:slime_target = "tmux"
| 336
| 337
| 338 let g:bss_markdown_fix = 1
| 339
| 340 let g:bss_java_fix = 1
| 341
| 342 let g:vim_markdown_new_list_item_indent = 0
| 343 let g:vim_markdown_folding_disabled = 1
| 344 let g:markdown_fold_style = 'nested'
| 345
| 346 let g:NERDCompactSexyComs = v:true
| 347 let g:NERDCommentEmptyLines = v:true
| 348 let g:NERDDefaultAlign = 'left'
| 349
| 350 let g:tagbar_sort = v:false
| 351
| 352
| 353 let g:buftabline_numbers = 2
| 354 let g:buftabline_indicators = v:true
| 355 let g:buftabline_separators = v:false
| 356
| 357 let g:netre_liststyle=3
| 358
| 359 let g:tex_flavor='latex'
| 360
| 361 let g:UltiSnipsExpandTrigger="<tab>"
| 362 let g:UltiSnipsJumpForwardTrigger="<c-j>"
| 363 let g:UltiSnipsJumpBackwardTrigger="<c-z>"
| 364 let g:UltiSnipsEditSplit="vertical"
| 365
| 366 let g:gitgutter_sign_added = '··'
| 367 let g:gitgutter_sign_modified = '··'
| 368 let g:gitgutter_sign_removed = '·'
| 369 let g:gitgutter_sign_modified_removed = '·'
| 370
371
+ - 372 +--141 lines: Keymappings:
372
| 373
| 374
| 375
| 376
| 377
| 378
| 379
| 380
| 381
| 382
| 383 let g:jm_vimrc.docs.mappings['<C-[hjkl]>'] =
| 384 \ 'Move between windows by holding CTRL'
| 385 noremap <C-j> <C-W>j
| 386 noremap <C-k> <C-W>k
| 387 noremap <C-h> <C-W>h
| 388 noremap <C-l> <C-W>l
| 389
| 390 let g:jm_vimrc.docs.mappings['<C-[←↑↓→]>'] =
| 391 \ 'Move visual selection'
| 392 vnoremap <C-Up> koko
| 393 vnoremap <C-Down> jojo
| 394 vnoremap <C-Left> hoho
| 395 vnoremap <C-Right> lolo
| 396
| 397 let g:jm_vimrc.docs.mappings['[['] =
| 398 \ 'Enable [[,][,]],[] to operate on non-col-1-{}'
| 399
| 400 nnoremap [[ ?{<CR>w99[{
| 401 nnoremap ][ /}<CR>b99]}
| 402 nnoremap ]] j0[[%/{<CR>
| 403 nnoremap [] k$][%?}<CR>
| 404
| 405 let g:jm_vimrc.docs.mappings['\q'] =
| 406 \ 'Delete current buffer without changing window layout'
| 407 nnoremap <leader>q :Bdelete<cr>
| 408
| 409 let g:jm_vimrc.docs.mappings["\\'"] =
| 410 \ 'Open NERDTree (file explorer)'
| 411 nnoremap <leader>' :NERDTreeToggle<cr>
| 412
| 413 let g:jm_vimrc.docs.mappings['\"'] =
| 414 \ 'Open NERDTree (file explorer) to current file'
| 415 nnoremap <leader>" :NERDTreeFind<cr>
| 416
| 417 let g:jm_vimrc.docs.mappings['\<Tab>'] =
| 418 \ 'Open Tagbar'
| 419 nnoremap <leader><tab> :TagbarToggle<cr>
| 420
| 421 let g:jm_vimrc.docs.mappings['<F10>'] =
| 422 \ 'Toggle paste'
| 423 set pastetoggle=<F10>
| 424
| 425 let g:jm_vimrc.docs.mappings['<F9>'] =
| 426 \ 'Toggle virtualedit=all'
| 427 nnoremap <F9> :let &ve = <C-r>=empty(&ve) ? '"all"' : '""'<cr><cr>
| 428
| 429 let g:jm_vimrc.docs.mappings['<C-r><C-f>'] =
| 430 \ '[modes:ic] Insert file name root'
| 431 inoremap <C-r><C-f> <C-r>=expand('%:p:t:r')<cr>
| 432 cnoremap <C-r><C-f> <C-r>=expand('%:p:t:r')<cr>
| 433
| 434 let g:jm_vimrc.docs.mappings['<C-r><C-t>'] =
| 435 \ '[modes:ic] Insert file name root'
| 436 inoremap <C-r><C-t> <C-r>=bss#blaze#BlazeTarget()<cr>
| 437 cnoremap <C-r><C-t> <C-r>=bss#blaze#BlazeTarget()<cr>
| 438
| 439 let g:jm_vimrc.docs.mappings['<C-p>'] =
| 440 \ 'Fuzzy-search PWD'
| 441 nnoremap <C-p> :Files<cr>
| 442
| 443 let g:jm_vimrc.docs.mappings['\w'] =
| 444 \ 'Clear search highlights (:nohlsearch)'
| 445 nnoremap <silent> <leader>w :nohlsearch<Bar>:echo<cr>
| 446
| 447 let g:jm_vimrc.docs.mappings['<F11>'] =
| 448 \ 'Ensure non-syntax toplevel text is spell-checked'
| 449 noremap <F11> :syntax spell toplevel<cr>
| 450 let g:jm_vimrc.docs.mappings['<F12>'] =
| 451 \ 'Toggle spell checking'
| 452 noremap <F12> :setlocal spell! spelllang=en_us<cr>
| 453
| 454 let g:jm_vimrc.docs.mappings['<Space>l'] =
| 455 \ 'Open Git ("Change [L]ist")'
| 456 nnoremap <leader>l :Git<cr>
| 457
| 458 let g:jm_vimrc.docs.mappings['<C-w><C-z>'] =
| 459 \ 'Set window height to 10 and fix the height'
| 460 nnoremap <C-w><C-z> :FixHeight 10<cr>
| 461 nnoremap <C-w>z :FixHeight 10<cr>
| 462
| 463 let g:jm_vimrc.docs.mappings['K'] =
| 464 \ 'Do grep for word under cursor'
| 465 nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
| 466
| 467 let g:jm_vimrc.docs.mappings['\\'] =
| 468 \ 'Show :tags'
| 469 nnoremap <leader><leader> :tags<cr>
| 470
| 471 let g:jm_vimrc.docs.mappings['\s'] =
| 472 \ 'Refresh UltSnips snippets'
| 473 nnoremap <leader>s :call UltiSnips#RefreshSnippets()<cr>
| 474
| 475 let g:jm_vimrc.docs.mappings['\<Space>'] =
| 476 \ 'Toggle foldcolumn'
| 477 nnoremap <leader><space> :let &l:foldcolumn = (&l:foldcolumn) ? 0 : 3<cr>
| 478
| 479 let g:jm_vimrc.docs.mappings['\a'] =
| 480 \ 'Trigger EasyAlign (See :Wtf ea)'
| 481 xmap <leader>a <Plug>(EasyAlign)
| 482 nmap <leader>a <Plug>(EasyAlign)
| 483
| 484 let g:jm_vimrc.docs.mappings["C-W !"] =
| 485 \ 'Toggle buflisted'
| 486 nnoremap <C-W>l :set buflisted!<cr>
| 487
| 488 nnoremap <space>c :YcmCompleter GetType<cr>
| 489 nnoremap <space>cq :YcmCompleter GoToDocumentOutline<cr>
| 490 nnoremap <space>cc :YcmCompleter GoToCallers<cr>
| 491 nnoremap <space>cC :YcmCompleter GoToDefinition<cr>
| 492 nnoremap <space>cf :YcmCompleter FixIt<cr>
| 493 nnoremap <space>cd :YcmCompleter GetDoc<cr>
| 494 nnoremap <space>ct :YcmCompleter GetType<cr>
| 495
| 496 let g:jm_vimrc.docs.mappings['\a[:(]'] =
| 497 \ 'Extra/overriden EasyAlign items'
| 498 let g:easy_align_delimiters = bss#extra#EasyAlignDelimiters()
| 499
| 500 let g:jm_vimrc.docs.mappings['\[0-9]'] =
| 501 \ 'Switch to buffer (from buftabline)'
| 502 nmap <leader>1 <Plug>BufTabLine.Go(1)
| 503 nmap <leader>2 <Plug>BufTabLine.Go(2)
| 504 nmap <leader>3 <Plug>BufTabLine.Go(3)
| 505 nmap <leader>4 <Plug>BufTabLine.Go(4)
| 506 nmap <leader>5 <Plug>BufTabLine.Go(5)
| 507 nmap <leader>6 <Plug>BufTabLine.Go(6)
| 508 nmap <leader>7 <Plug>BufTabLine.Go(7)
| 509 nmap <leader>8 <Plug>BufTabLine.Go(8)
| 510 nmap <leader>9 <Plug>BufTabLine.Go(9)
| 511 nmap <leader>0 <Plug>BufTabLine.Go(10)
| 512
513
+ - 514 +--214 lines: Commands:
514
| 515
| 516
| 517
| 518
| 519
| 520
| 521
| 522
| 523
| 524 if !exists('g:jm_term')
| 525 let g:jm_term = bss#view#TermView()
| 526 endif
| 527 let g:jm_vimrc.docs.commands['Term'] =
| 528 \ 'Run a terminal command in a reused window'
| 529 command! -nargs=* -complete=shellcmd Term
| 530 \ eval g:jm_term.Run(<q-args>)
| 531
| 532 let g:jm_vimrc.docs.commands['ReplaceR'] =
| 533 \ 'Locally set \r to run :Term with the specified command'
| 534 command! -nargs=+ ReplaceR
| 535 \ nnoremap <buffer> <localleader>r :Term <args><cr>
| 536
| 537 let g:jm_vimrc.docs.commands['ReplaceRTarget'] =
| 538 \ 'Set \r to bazel target of the current file'
| 539 command! -bar ReplaceRTarget
| 540 \ execute 'ReplaceR' BlazeGuessCommand()
| 541
| 542 let g:jm_vimrc.docs.commands['StopAllJobs'] =
| 543 \ 'Stop all running jobs'
| 544 command! -bar StopAllJobs eval job_info()->map('job_stop(v:val)')
| 545
| 546 let g:jm_vimrc.docs.commands['ListAllJobs'] =
| 547 \ 'List all running jobs'
| 548 command! -bar -bang ListAllJobs
| 549 \ call bss#PP(job_info()->filter('<bang>0 || (job_status(v:val) == "run")'))
| 550
| 551 let g:jm_vimrc.docs.commands['DumpAllJobs'] =
| 552 \ 'List job_infos for all running jobs'
| 553 command! -bar -bang DumpAllJobs
| 554 \ call bss#PP(job_info()->filter('<bang>0 || (job_status(v:val) == "run")')->map('job_info(v:val)'))
| 555
| 556 let g:jm_vimrc.docs.commands['SetupClasspath'] =
| 557 \ 'Set classpath to jm_vimrc.deps.ClasspathJarList()'
| 558 command! -bar SetupClasspath
| 559 \ let $CLASSPATH = join(g:jm_vimrc.deps.ClasspathJarList(), ':')
| 560
| 561 let g:jm_vimrc.docs.commands['SetupTargetClasspath'] =
| 562 \ 'Set classpath to blaze target included jars'
| 563 command! -bar SetupTargetClasspath
| 564 \ let $CLASSPATH = s:TargetClasspath()
| 565
| 566 let g:jm_vimrc.docs.commands['SetupCV'] =
| 567 \ 'Setup $LDFLAGS, $CFLAGS and &path for OpenCV development'
| 568 command! -bar SetupCV
| 569 \ let $LDFLAGS = '-lopencv_core -lopencv_imgcodecs -lopencv_imgproc' |
| 570 \ let $CFLAGS = '-I/usr/include/opencv4' |
| 571 \ let &path ..= ',/usr/include/opencv4,/usr/include/c++/10/'
| 572
| 573 let g:jm_vimrc.docs.commands['FixHeight'] =
| 574 \ 'Resize window and fix its height'
| 575 command! -nargs=1 FixHeight
| 576 \ resize <args> | set winfixheight
| 577
| 578 let g:jm_vimrc.docs.commands['SetupTermRainbow'] =
| 579 \ 'Add Rainbow-coloring to terminals'
| 580 command! -bar SetupTermRainbow
| 581 \ autocmd TerminalOpen * RainbowLoad
| 582
| 583 let g:jm_vimrc.docs.commands['SetupAutoread'] =
| 584 \ 'Enable autoread and add checktime autocmd'
| 585 command! -bar SetupAutoread
| 586 \ set autoread | autocmd FocusGained,BufEnter * checktime
| 587
| 588 let g:jm_vimrc.docs.commands['RemoveTrailingWhitespace'] =
| 589 \ 'Removes all trailing whitespace from the selected lines'
| 590 command! -range=% RemoveTrailingWhitespace
| 591 \ <line1>,<line2>s/\s\+$//
| 592
| 593 let g:jm_vimrc.docs.commands['SetupMatchHex'] =
| 594 \ 'Match hex numbers'
| 595 command! -bar SetupMatchHex
| 596 \ match GruvboxAqua /\<0x0*\zs[1-9a-f]\x*\>/
| 597
| 598 let g:jm_vimrc.docs.commands['SetupMatchNum'] =
| 599 \ 'Match decimal numbers'
| 600 command! -bar SetupMatchNum
| 601 \ match GruvboxAqua /\<\(0x\)\?0*\zs[1-9a-f]\x*\>/
| 602
| 603 let g:jm_vimrc.docs.commands['RefreshSnippets'] =
| 604 \ 'Refresh ultisnips'
| 605 command! -bar RefreshSnippets
| 606 \ call UltiSnips#RefreshSnippets()
| 607
| 608 let g:jm_vimrc.docs.commands['Dis'] =
| 609 \ 'Setup terminal for viewing objdump output ($ objdump -d ... | vim +Dis -)'
| 610 command! -bar Dis
| 611 \ setlocal ft=dis buftype=nofile
| 612
| 613 let g:jm_vimrc.docs.commands['Center'] =
| 614 \ 'Block alignment-preserving :center'
| 615 call bss#draw#block#RegisterCommands()
| 616
| 617 let g:jm_vimrc.docs.commands['ToggleFoldOpenSearch'] =
| 618 \ 'Toggle search on foldopen option'
| 619 command! ToggleFoldOpenSearch
| 620 \ if stridx(&foldopen, "search") == -1 |
| 621 \ set foldopen+=search |
| 622 \ echo "ENABLED foldopen search" |
| 623 \ else |
| 624 \ set foldopen-=search |
| 625 \ echo "DISABLED foldopen search" |
| 626 \ endif
| 627
| 628 let g:jm_vimrc.docs.commands['SetupMath'] =
| 629 \ 'Set up abbreviations for math symbols'
| 630 command! SetupMath
| 631 \ execute 'iabbrev <buffer> nn ∩' |
| 632 \ execute 'iabbrev <buffer> uu ∪' |
| 633 \ execute 'iabbrev <buffer> in ∈' |
| 634 \ execute 'iabbrev <buffer> ni ∉' |
| 635 \ execute 'iabbrev <buffer> ss ⊂' |
| 636 \ execute 'iabbrev <buffer> se ⊆' |
| 637 \ execute 'iabbrev <buffer> ns ⊄' |
| 638 \ execute 'iabbrev <buffer> AN ∧' |
| 639 \ execute 'iabbrev <buffer> OR ∨' |
| 640 \ execute 'iabbrev <buffer> es ∅' |
| 641 \ execute 'iabbrev <buffer> => ⇒' |
| 642 \ execute 'iabbrev <buffer> == ⇔' |
| 643 \ execute 'iabbrev <buffer> != ≠' |
| 644 \ execute 'iabbrev <buffer> co ∘' |
| 645 \ execute 'iabbrev <buffer> FA ∀' |
| 646 \ execute 'iabbrev <buffer> TE ∃' |
| 647 \ execute 'iabbrev <buffer> \|> ↦'
| 648
| 649 let g:jm_vimrc.docs.commands['PyHelp'] =
| 650 \ 'Look-up help for python expression (: PyHelp <pkg> <cls>)'
| 651 command! -nargs=+ -bang PyHelp
| 652 \ call py3eval((<bang>0) ? printf('help(%s)', <q-args>) : printf('help(__import__("%s").%s)', <f-args>))
| 653
| 654 let g:jm_vimrc.docs.commands['MakeOrSetup'] =
| 655 \ 'Run blaze, make, or create a Makefile with included commands (using ; as separator)'
| 656 command! -nargs=+ MakeOrSetup call s:MakeOrSetup(<q-args>)
| 657 function! s:MakeOrSetup(cmds) abort
| 658 if filereadable('WORKSPACE')
| 659 execute 'Term blaze build' BlazeTarget()
| 660 elseif filereadable('Makefile')
| 661 Term make
| 662 else
| 663 let l:cmds = substitute(a:cmds, '%', expand('%'), 'g')
| 664 let l:lines = split(l:cmds, ';')->map('trim(v:val)')
| 665 let l:cursor = bss#cursor#SaveWithBuf()
| 666 try
| 667 redir > Makefile
| 668 silent echo '.PHONY: all'
| 669 silent echo 'all:'
| 670 for l:cmd in l:lines
| 671 silent echo ' ' .. l:cmd
| 672 endfor
| 673 redir END
| 674 silent edit Makefile
| 675 Term make
| 676 finally
| 677 call l:cursor.Restore()
| 678 endtry
| 679 endif
| 680 endfunction
| 681
| 682 let g:jm_vimrc.docs.commands['SetupYcmClasspath'] =
| 683 \ 'Create .ycm_extra_conf.py with CLASSPATH'
| 684 command! -bang SetupYcmClasspath
| 685 \ call s:SetupYcmClasspath($CLASSPATH)
| 686 function! s:SetupYcmClasspath(classpath) abort
| 687 let l:classpath = split(a:classpath, ':')
| 688 let l:lines = s:GenerateYcm(l:classpath)
| 689 if filereadable('.ycm_extra_conf.py')
| 690 throw 'ERROR(FileExists): .ycm_extra_conf.py already exists!'
| 691 else
| 692 call writefile(l:lines, '.ycm_extra_conf.py')
| 693 YcmRestartServer
| 694 endif
| 695 endfunction
| 696 function! s:GenerateYcm(classpath) abort
| 697 let l:path = a:classpath
| 698 \->map('string(v:val)')
| 699 \->join(", ")
| 700 let l:lines =<< eval trim END
| 701 def Settings(**kwargs):
| 702 if kwargs["language"] == "java":
| 703 return {{
| 704 "ls": {{
| 705 "java.project.referencedLibraries": [{l:path}]
| 706 }}
| 707 }}
| 708 END
| 709 return l:lines
| 710 endfunction
| 711
| 712 let g:jm_vimrc.docs.commands['SetupOcamlformat'] =
| 713 \ 'Create a basic .ocamlformat'
| 714 command! SetupOcamlformat call s:SetupOcamlformat()
| 715 function! s:SetupOcamlformat() abort
| 716 if !filereadable('.ocamlformat')
| 717 call writefile(['profile = default'], '.ocamlformat')
| 718 endif
| 719 endfunction
| 720
| 721
| 722 if executable('ag')
| 723
| 724 set grepprg=ag\ --nogroup\ --nocolor\ --ignore=tags\ --vimgrep
| 725 set grepformat^=%f:%l:%c:%m
| 726 endif
| 727
728
+ - 729 +--255 lines: FT-Specific Settings:
729
| 730
| 731
| 732
| 733
| 734
| 735
| 736
| 737
| 738
| 739
| 740
| 741
| 742
| 743
| 744
| 745
| 746
| 747 augroup ft_latex
| 748 autocmd!
| 749 autocmd FileType tex setlocal nocursorline
| 750 autocmd FileType tex setlocal tabstop=4 shiftwidth=4
| 751 autocmd FileType tex nnoremap <buffer> <localleader>r
| 752 \ :execute 'Term fish -c "mkt ' .. expand('%') .. '"'<cr>
| 753 augroup END
| 754
| 755 augroup ft_dot
| 756 autocmd!
| 757 autocmd FileType dot setlocal tabstop=2 shiftwidth=2
| 758 autocmd FileType dot nnoremap <buffer> <localleader>r
| 759 \ :execute 'Term dot -T svg -O' expand('%') <cr>
| 760 augroup END
| 761
| 762 augroup ft_c
| 763 autocmd!
| 764 autocmd FileType c setlocal tabstop=2 shiftwidth=2
| 765 autocmd FileType c setlocal foldmethod=syntax
| 766 autocmd FileType c nnoremap <buffer> <localleader>r
| 767 \ :Term make<CR>
| 768 autocmd FileType c nnoremap <buffer> <localleader>R
| 769 \ :MakeOrSetup gcc -Wall -O3 -o a.out %; ./a.out; rm a.out<cr>
| 770 augroup END
| 771
| 772
| 773 augroup ft_cc
| 774 autocmd!
| 775 autocmd FileType cpp setlocal tabstop=2 shiftwidth=2
| 776 autocmd FileType cpp setlocal foldmethod=syntax
| 777 autocmd FileType cpp nnoremap <buffer> <localleader>t
| 778 \ :term <C-r>=BlazeGuessCommand()<CR>
| 779 autocmd FileType cpp nnoremap <buffer> <localleader>r
| 780 \ :MakeOrSetup
| 781 \ clang++-12 -std=c++17 $(CFLAGS) -o build % $(LDFLAGS);
| 782 \ ./build<CR>
| 783 autocmd FileType cpp nnoremap <buffer> <space>f
| 784 \ :FormatCode<CR>
| 785 autocmd FileType cpp
| 786 \ if exists('g:jm_setup_cpp_cv') |
| 787 \ SetupCV |
| 788 \ endif
| 789 autocmd FileType cpp
| 790 \ if expand('%:p') =~ '/home/jmend/pg' |
| 791 \ silent ReplaceRTarget |
| 792 \ endif
| 793 augroup END
| 794
| 795 augroup ft_gdb
| 796 autocmd!
| 797 autocmd FileType gdb nnoremap <buffer> <localleader>r
| 798 \ :execute 'Term gdb -q -x' expand('%')<cr>
| 799 augroup END
| 800
| 801 augroup ft_python
| 802 autocmd!
| 803 autocmd FileType python command! RunPython
| 804 \ execute "Term" g:jm_vimrc.deps.python expand('%')
| 805 autocmd FileType python command! RunPythonTests
| 806 \ execute "Term" g:jm_vimrc.deps.python "-m pytest" expand('%')
| 807 autocmd FileType python command! RunPythonTypechecks
| 808 \ execute "Term" g:jm_vimrc.deps.python "-m mypy --ignore-missing-imports --follow-imports=skip " expand("%")
| 809 autocmd FileType python command! RunPythonMPL
| 810 \ StopAllJobs | eval timer_start(0, {-> execute('RunPython')})
| 811 autocmd FileType python nnoremap <buffer> <localleader>r
| 812 \ :RunPython<cr>
| 813 autocmd FileType python nnoremap <buffer> <localleader>R
| 814 \ :RunPythonTests<cr>
| 815 autocmd FileType python nnoremap <buffer> <localleader>t
| 816 \ :RunPythonTypechecks<cr>
| 817 autocmd FileType python nnoremap <buffer> <space>f
| 818 \ :FormatCode<CR>
| 819
| 820 autocmd BufNewFile .ycm_extra_conf.py call setline('.', [
| 821 \ 'def Settings(**kwargs):',
| 822 \ ' if kwargs["language"] == "java":',
| 823 \ ' return {',
| 824 \ ' "ls": {',
| 825 \ ' "java.project.referencedLibraries": ["~/.jars/*.jar"]',
| 826 \ ' }',
| 827 \ ' }',
| 828 \ ])
| 829
| 830
| 831 augroup END
| 832
| 833 augroup ft_scheme
| 834 autocmd!
| 835 autocmd FileType scheme setlocal colorcolumn=79
| 836 autocmd FileType scheme let g:lisp_rainbow = v:true
| 837 autocmd FileType scheme nnoremap <buffer> <localleader>r
| 838 \ :w<CR> :Term mit-scheme --load % <CR>
| 839 augroup END
| 840
| 841 augroup ft_java
| 842 autocmd!
| 843 autocmd FileType java
| 844 \ setlocal tabstop=2 softtabstop=2 tabstop=2 shiftwidth=2 smarttab
| 845 autocmd FileType java
| 846 \ setlocal foldmethod=marker foldmarker={,}
| 847 autocmd FileType java nnoremap <space>f :FormatCode<cr>
| 848 autocmd FileType java nnoremap <space>F :set bt=nowrite <bar> FormatCode<cr>
| 849 autocmd FileType java vnoremap <space>f :FormatLines<cr>
| 850 if filereadable('Makefile')
| 851 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 852 \ :Term make<cr>
| 853 elseif filereadable('WORKSPACE')
| 854 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 855 \ :execute "Term blaze run " .. join(<SID>BlazeTargets(expand("%")), " ")<cr>
| 856 elseif filereadable('gradlew')
| 857 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 858 \ :Term ./gradlew test --rerun<cr>
| 859 else
| 860 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 861 \ :MakeOrSetup java %<cr>
| 862 endif
| 863 autocmd FileType java nnoremap <silent> <buffer> <localleader>R
| 864 \ :Term ./gradlew run<cr>
| 865 autocmd FileType java let b:surround_99 = "{@code \r}"
| 866 augroup END
| 867
| 868 augroup ft_jar
| 869 autocmd!
| 870 autocmd FileType jar
| 871 \ call zip#Browse(expand("<amatch>"))
| 872 autocmd FileType jar
| 873 \ setlocal buflisted
| 874 augroup END
| 875
| 876 augroup ft_class
| 877 autocmd!
| 878 autocmd BufReadCmd *.class
| 879 \ call bss#java#javap#Browse(expand("<amatch>"))
| 880 augroup END
| 881
| 882 augroup ft_javascript
| 883 autocmd!
| 884 autocmd FileType javascript
| 885 \ setlocal tabstop=2 softtabstop=2 tabstop=2 smarttab
| 886 autocmd FileType javascript nnoremap <buffer> <localleader>r
| 887 \ :execute "Term node " .. expand('%')<cr>
| 888 autocmd FileType javascript nnoremap <buffer> <localleader>R
| 889 \ :Term webpack<CR>
| 890 autocmd FileType javascript nnoremap <buffer> <space>f
| 891 \ :FormatCode<CR>
| 892 augroup END
| 893
| 894 augroup ft_markdown
| 895 autocmd!
| 896 autocmd FileType markdown set textwidth=72 smartindent autoindent
| 897 autocmd FileType markdown set cinwords+=:
| 898
| 899 autocmd FileType markdown nnoremap <buffer> ]h :<c-u>call search('\v^#+ ', 'Wz')<cr>
| 900 autocmd FileType markdown nnoremap <buffer> [h :<c-u>call search('\v^#+ ', 'bWz')<cr>
| 901
| 902
| 903
| 904 autocmd FileType markdown command! SetupR nnoremap <buffer> <localleader>r
| 905 \ :call execute(printf(
| 906 \ "Term pandoc %s -s --highlight-style kate --pdf-engine=xelatex -o %s.pdf",
| 907 \ expand('%:p'),
| 908 \ expand('%:t:r'),
| 909 \ ))<cr>
| 910
| 911 autocmd FileType markdown command! JmMdQuotesAsComments match GruvboxFg3 /^\s*>.*/
| 912
| 913 if !exists('g:bss_markdown_fix') || !g:bss_markdown_fix
| 914
| 915
| 916 autocmd FileType markdown syntax clear markdownCodeBlock
| 917 autocmd FileType markdown syntax region markdownCodeBlock matchgroup=markdownCodeDelimiter start="^\s*\z(`\{3,\}\).*$" end="^\s*\z1\ze\s*$" keepend
| 918 autocmd FileType markdown syntax region markdownCodeBlock matchgroup=markdownCodeDelimiter start="^\s*\z(\~\{3,\}\).*$" end="^\s*\z1\ze\s*$" keepend
| 919
| 920
| 921 autocmd FileType markdown highlight link markdownH1 GruvboxRedBold
| 922 autocmd FileType markdown highlight link markdownH2 GruvboxBlueBold
| 923 autocmd FileType markdown highlight link markdownH3 GruvboxGreenBold
| 924 autocmd FileType markdown highlight link markdownH4 GruvboxPurpleBold
| 925
| 926
| 927 autocmd FileType markdown highlight link markdownBold GruvboxFg4
| 928 autocmd FileType markdown highlight link markdownBoldDelimiter GruvboxFg4
| 929 autocmd FileType markdown highlight link markdownItalic GruvboxFg2
| 930 autocmd FileType markdown highlight link markdownItalicDelimiter GruvboxFg2
| 931 endif
| 932 augroup END
| 933
| 934 augroup ft_vim
| 935 autocmd!
| 936 autocmd FileType vim setlocal foldmethod=marker shiftwidth=2
| 937 autocmd FileType vim nnoremap <buffer> <localleader>r
| 938 \ :source %<cr>
| 939 autocmd FileType vim nnoremap K :help <C-r><C-w><CR>
| 940 augroup END
| 941
| 942 augroup ft_fish
| 943 autocmd!
| 944 autocmd FileType fish setlocal tabstop=4 shiftwidth=4 smartindent
| 945 autocmd FileType fish nnoremap <buffer> <space>f
| 946 \ :0,$!fish_indent<cr>
| 947 autocmd FileType fish setlocal omnifunc=bss#fish#Complete
| 948 augroup END
| 949
| 950 augroup ft_make
| 951 autocmd!
| 952 autocmd FileType make nnoremap <buffer> <localleader>r
| 953 \ :Term make<cr>
| 954 augroup END
| 955
| 956 augroup ft_ocaml
| 957 autocmd!
| 958 autocmd FileType ocaml
| 959 \ setlocal tabstop=2 softtabstop=2 tabstop=2 smarttab
| 960 autocmd FileType ocaml nnoremap <space>f :FormatCode<cr>
| 961 autocmd FileType ocaml vnoremap <space>f :FormatLines<cr>
| 962 if filereadable('Makefile')
| 963 autocmd FileType ocaml nnoremap <silent> <buffer> <localleader>r
| 964 \ :Term make<cr>
| 965 elseif filereadable('dune-project')
| 966 autocmd FileType ocaml nnoremap <silent> <buffer> <localleader>r
| 967 \ :Term dune build<cr>
| 968 else
| 969 autocmd FileType ocaml nnoremap <silent> <buffer> <localleader>r
| 970 \ :execute 'Term ocaml' expand("%")<cr>
| 971 endif
| 972 if isdirectory('/usr/bin/ocaml')
| 973 autocmd FileType ocaml set path+=/usr/lib/ocaml
| 974 endif
| 975 augroup END
| 976
| 977
| 978 augroup cfg_quickfix_fix
| 979 autocmd QuickFixCmdPost [^l]* nested cwindow
| 980 autocmd QuickFixCmdPost l* nested lwindow
| 981 augroup end
| 982
| 983
984
+ - 985 +--525 lines: Misc:
985
| 986
| 987
| 988
| 989
| 990
| 991
| 992
| 993
|+ |- 994 +--- 94 lines:
994
|| 995 let g:jm_vimrc.docs.commands['FindImport'] =
|| 996 \ 'Given a name, find the corresponding import and add an import statment'
|| 997 nnoremap <space>t :call <SID>FindImport(expand('<cword>'))<CR>
|| 998 command -nargs=1 FindImport call <SID>FindImport(<q-args>)
|| 999 function! s:FindImport(word) abort
|| 1000
|| 1001 if &filetype ==# 'cpp'
|| 1002 let l:res = g:jm_vimrc.cc_import_cache
|| 1003 \->copy()
|| 1004 \->filter({incl, names -> index(names, a:word) != -1})
|| 1005 \->keys()
|| 1006 \->map({k, incl -> printf("#include %s", incl)})
|| 1007 if len(l:res) == 0
|| 1008 echo "FindImport: `" .. a:word .. "` not found!"
|| 1009 elseif len(l:res) > 1
|| 1010 call maktaba#ui#selector#Create(l:res)
|| 1011 \.WithMappings({'<cr>': [function("s:AddImportCpp")->get("name"), 'Close', 'Add import']})
|| 1012 \.Show()
|| 1013 else
|| 1014 call s:AddImportCpp(l:res[0])
|| 1015 endif
|| 1016 return
|| 1017 endif
|| 1018
|| 1019 if &filetype !=# 'java'
|| 1020 throw 'ERROR(InvalidFiletype)'
|| 1021 return
|| 1022 endif
|| 1023
|| 1024
|| 1025 if (has_key(g:jm_vimrc.java_import_cache, a:word))
|| 1026 call s:AddOrSelectImport(get(g:jm_vimrc.java_import_cache, a:word)->mapnew({_, w -> printf('import %s;', w)}))
|| 1027 return
|| 1028 endif
|| 1029
|| 1030
|| 1031 let l:results = printf(
|| 1032 \ '%s --nofilename --nobreak %s',
|| 1033 \ g:jm_vimrc.deps.ag,
|| 1034 \ shellescape(printf('import .+\b%s\b;', a:word)))
|| 1035 \->systemlist()
|| 1036 \->sort()
|| 1037 \->uniq()
|| 1038
|| 1039
|| 1040 if empty(l:results)
|| 1041 let l:results = g:jm_vimrc.deps.JavaClassnameList()
|| 1042 \->filter('v:val =~# a:word')
|| 1043 \->map('"import " .. v:val .. ";"')
|| 1044 endif
|| 1045
|| 1046 call s:AddOrSelectImport(l:results)
|| 1047 endfunction
|| 1048
|| 1049 function! s:AddOrSelectImport(options) abort
|| 1050 if len(a:options) == 1
|| 1051 call s:AddImport(a:options[0])
|| 1052 elseif len(a:options) > 1
|| 1053 call maktaba#ui#selector#Create(a:options)
|| 1054 \.WithMappings({'<cr>': [function("s:AddImport")->get("name"), 'Close', 'Add import']})
|| 1055 \.Show()
|| 1056 endif
|| 1057 endfunction
|| 1058
|| 1059 function! s:AddImport(import) abort
|| 1060 let l:result = search(a:import, 'nw')
|| 1061 if l:result == 0
|| 1062 let l:start = search('^import', 'nw')
|| 1063 if l:start == 0
|| 1064 let l:start = search('^package', 'nw')
|| 1065 call append(l:start, [""])
|| 1066 let l:start += 1
|| 1067 endif
|| 1068 call append(l:start, [a:import])
|| 1069
|| 1070 echom "Adding: " .. a:import
|| 1071 else
|| 1072 echom "Already Present: " .. a:import
|| 1073 endif
|| 1074 endfunction
|| 1075
|| 1076 function! s:AddImportCpp(import) abort
|| 1077 let l:result = search(a:import, 'nw')
|| 1078 if l:result == 0
|| 1079 let l:start = search('^#include', 'nw')
|| 1080 call append(l:start, [a:import])
|| 1081
|| 1082 echom "Adding: " .. a:import
|| 1083 else
|| 1084 echom "Already Present: " .. a:import
|| 1085 endif
|| 1086 endfunction
|| 1087
| 1088
| 1089
| 1090
|+ |- 1091 +--- 40 lines:
1091
|| 1092 let g:jm_vimrc.docs.commands['Javap'] =
|| 1093 \ 'Execute Javap and show output with highlighting'
|| 1094 command! -nargs=? -complete=customlist,<SID>JavapComplete -bang
|| 1095 \ Javap call <SID>Javap(<q-args>, "<bang>" ==# '!')
|| 1096 function! s:Javap(arg, search) abort
|| 1097 if empty($CLASSPATH)
|| 1098 SetupClasspath
|| 1099 endif
|| 1100
|| 1101
|| 1102 let l:cls = empty(a:arg) ? @" : a:arg
|| 1103 let l:cls = substitute(l:cls, '\(;\|<.\+>\)', '', 'ga')
|| 1104
|| 1105 if a:search
|| 1106 let l:results = s:JavapComplete(l:cls, v:none, v:none)
|| 1107 if len(l:results) == 1
|| 1108 let l:cls = l:results[0]
|| 1109 else
|| 1110 call maktaba#ui#selector#Create(l:results)
|| 1111 \.WithMappings({'<cr>': [function("s:JavapOpen")->get("name"), 'Close', 'Open window']})
|| 1112 \.Show()
|| 1113 return
|| 1114 endif
|| 1115 endif
|| 1116
|| 1117 eval g:jm_term
|| 1118 \.Run(join([g:jm_vimrc.deps.javap, l:cls], ' '))
|| 1119 \.Exec('set ft=java')
|| 1120 endfunction
|| 1121
|| 1122 function! s:JavapComplete(arg_lead, cmd_line, cursor_pos) abort
|| 1123 return g:jm_vimrc.deps.JavaClassnameList()
|| 1124 \->filter('v:val =~# a:arg_lead')
|| 1125 endfunction
|| 1126
|| 1127 function! s:JavapOpen(cls) abort
|| 1128 execute 'Javap ' .. a:cls
|| 1129 endfunction
|| 1130
| 1131
| 1132
| 1133
| 1134
|+ |- 1135 +--- 62 lines:
1135
|| 1136 let g:jm_vimrc.docs.commands['MavenSearch'] =
|| 1137 \ 'Search maven, then either add a dependecy or download the jar'
|| 1138 command! -nargs=1 MavenSearch call <SID>MavenSearch(<q-args>)
|| 1139 command! -nargs=1 M MavenSearch <args>
|| 1140 function! s:MavenSearch(query) abort
|| 1141 const l:query_url = printf(
|| 1142 \ 'https://search.maven.org/solrsearch/select?q=%s&rows=20&wt=json',
|| 1143 \ a:query)
|| 1144
|| 1145 const l:query_cmd = join([
|| 1146 \ g:jm_vimrc.deps.curl,
|| 1147 \ '-s',
|| 1148 \ printf('"%s"', l:query_url),
|| 1149 \ ])
|| 1150
|| 1151 let l:msg = system(l:query_cmd)
|| 1152 let l:resp = json_decode(l:msg).response
|| 1153
|| 1154 if l:resp.numFound == 0
|| 1155 echom "None found!"
|| 1156 return
|| 1157 endif
|| 1158 let l:docs = l:resp.docs
|| 1159 const l:mappings = {
|| 1160 \ '<cr>': [function("s:MInsert")->get("name"), 'Close', 'Insert below'],
|| 1161 \ 'D': [function("s:MDownload")->get("name"), 'Close', 'Insert below'],
|| 1162 \ }
|| 1163 call maktaba#ui#selector#Create(map(l:docs, 'v:val.id .. ":" .. v:val.latestVersion'))
|| 1164 \.WithMappings(l:mappings)
|| 1165 \.Show()
|| 1166 endfunction
|| 1167
|| 1168 function! s:MInsert(msg) abort
|| 1169 let l:spaces = getline('.')->matchstr('^\s*')
|| 1170 call append(line('.'), printf("%simplementation '%s'", l:spaces, a:msg))
|| 1171 endfunction
|| 1172
|| 1173 function! s:MDownload(msg) abort
|| 1174 let [l:package, l:name, l:version] = split(a:msg, ':')
|| 1175 let l:url_package = substitute(l:package, '\.', '/', 'g')
|| 1176 let l:url = printf('https://repo1.maven.org/maven2/%s/%s/%s/',
|| 1177 \ l:url_package,
|| 1178 \ l:name,
|| 1179 \ l:version)
|| 1180 let l:file = printf('%s-%s.jar', l:name, l:version)
|| 1181 let l:file_url = l:url .. l:file
|| 1182 echom l:url .. l:file
|| 1183
|| 1184 const l:cmd = join([
|| 1185 \ g:jm_vimrc.deps.curl,
|| 1186 \ '-o',
|| 1187 \ shellescape(l:file),
|| 1188 \ '-s',
|| 1189 \ shellescape(l:file_url),
|| 1190 \ ])
|| 1191 silent call system(l:cmd)
|| 1192 if v:shell_error
|| 1193 echom 'ERROR: Could not download! ' .. l:file_url
|| 1194 endif
|| 1195 endfunction
|| 1196
| 1197
| 1198
| 1199
| 1200
| 1201
| 1202
| 1203
| 1204
| 1205
| 1206
| 1207
| 1208
| 1209
| 1210
| 1211
| 1212
|+ |- 1213 +--- 69 lines:
1213
|| 1214 function! s:BlazeTargets(fname) abort
|| 1215 let l:query = printf(
|| 1216 \ 'same_pkg_direct_rdeps(%s)',
|| 1217 \ fnamemodify(a:fname, ":p:."),
|| 1218 \ )
|| 1219
|| 1220 let l:command = printf(
|| 1221 \ "%s query '%s'",
|| 1222 \ g:jm_vimrc.deps.blaze,
|| 1223 \ l:query,
|| 1224 \ )
|| 1225 return filter(systemlist(l:command), 'v:val =~# "^//"')
|| 1226 endfunction
|| 1227
|| 1228 function! BlazeGuessCommand(show = v:false) abort
|| 1229 let l:fname = expand('%:p')
|| 1230
|| 1231 let l:target = BlazeTarget()
|| 1232 if l:target ==# "???"
|| 1233 echom "Can't find blaze target!"
|| 1234 return "false"
|| 1235 endif
|| 1236
|| 1237 let l:action = 'build'
|| 1238 if l:fname =~# '\v(_test.cc|Test.java)$' || l:target =~# '\v(_test|Test)$'
|| 1239 let l:action = 'test'
|| 1240 elseif l:fname =~# '\v(main.cc|_bin.cc|Bin.java)$' || l:target =~# '\v(_bin|Bin|main|Main)$'
|| 1241 let l:action = 'run'
|| 1242 elseif l:fname =~# '\v(_bench.cc)$' || l:target =~# '\v(_bench)$'
|| 1243 let l:action = 'run -c opt'
|| 1244 endif
|| 1245
|| 1246 let l:command = printf(
|| 1247 \ "%s %s %s",
|| 1248 \ g:jm_vimrc.deps.blaze,
|| 1249 \ l:action,
|| 1250 \ l:target,
|| 1251 \ )
|| 1252 if a:show
|| 1253 echom 'Using:' l:command
|| 1254 endif
|| 1255 return l:command
|| 1256 endfunction
|| 1257
|| 1258 function! BlazeTarget() abort
|| 1259 return get(s:BlazeTargets(expand('%:p')), 0, "???")
|| 1260 endfunction
|| 1261
|| 1262 function! s:TargetClasspath() abort
|| 1263 let l:target = BlazeTarget()
|| 1264 if l:target ==# "???"
|| 1265 echom "Can't find blaze target!"
|| 1266 return ""
|| 1267 endif
|| 1268
|| 1269 let l:lines = systemlist(printf('blaze print_action "%s"', l:target))
|| 1270 let l:jars = filter(l:lines, {_, v -> v =~# '^\s\+\(outputjar\|classpath\): "[^"]*"'})
|| 1271 \->map({_, v -> matchlist(v, '"\([^"]*\)"')[1]})
|| 1272 return join(l:jars, ':')
|| 1273 endfunction
|| 1274
|| 1275 function! s:CompleteTargets(arg_lead, cmd_line, cursor_pos) abort
|| 1276 if a:arg_lead =~ '^//.*'
|| 1277 return systemlist(printf('%s query ... 2>&1', g:jm_vimrc.deps.blaze))
|| 1278 \->filter('v:val =~# "' .. a:arg_lead .. '"')
|| 1279 endif
|| 1280 endfunction
|| 1281
| 1282
| 1283
| 1284
|+ |- 1285 +--- 16 lines:
1285
|| 1286 let g:jm_vimrc.docs.commands['Touch'] =
|| 1287 \ 'Create files and directories'
|| 1288 command! -nargs=* Touch call s:Touch([<f-args>])
|| 1289 function! s:Touch(paths) abort
|| 1290 for l:path in a:paths
|| 1291 let l:dir = fnamemodify(l:path, ':h')
|| 1292 if l:dir !=# '.' && !isdirectory(l:dir)
|| 1293 call system('mkdir -p ' .. shellescape(l:dir))
|| 1294 endif
|| 1295 if !filereadable(l:path)
|| 1296 call system('touch ' .. shellescape(l:path))
|| 1297 endif
|| 1298 endfor
|| 1299 endfunction
|| 1300
| 1301
| 1302
| 1303
|+ |- 1304 +--- 8 lines:
1304
|| 1305 let g:jm_vimrc.docs.commands['CurrentHLGroup'] =
|| 1306 \ 'Echo name of the highlight group under the cursor'
|| 1307 command! CurrentHLGroup echo s:SyntaxItem()
|| 1308 function! s:SyntaxItem()
|| 1309 return synIDattr(synID(line("."), col("."), 1), "name")
|| 1310 endfunction
|| 1311
| 1312
| 1313
| 1314
| 1315
| 1316
| 1317
|+ |- 1318 +--- 9 lines:
1318
|| 1319 function! s:Async(Fn)
|| 1320 eval timer_start(0, a:Fn)
|| 1321 endfunction
|| 1322
|| 1323 function! s:AsyncExec(...)
|| 1324 eval s:Async({-> execute(join(map(a:000, function('string'))))})
|| 1325 endfunction
|| 1326
| 1327
| 1328
| 1329
|+ |- 1330 +--- 17 lines:
1330
|| 1331 let g:jm_vimrc.docs.commands['ConcealK'] =
|| 1332 \ 'Define conceal rules: eg. ConcealK lambda:λ'
|| 1333 command! -complete=expression -nargs=1 ConcealK call <SID>ConcealK(<q-args>)
|| 1334 function! s:ConcealK(repl_str) abort
|| 1335 let l:repl = {}
|| 1336 let l:i = 0
|| 1337 for [l:keyword, l:replacement] in split(a:repl_str, ' ')->map('v:val->split(":")')
|| 1338 let l:i += 1
|| 1339 execute 'syntax keyword'
|| 1340 \ printf('ConcealK%03d', l:i) l:keyword
|| 1341 \ 'conceal' printf('cchar=%s', l:replacement)
|| 1342 endfor
|| 1343 setlocal conceallevel=1
|| 1344 setlocal concealcursor=ni
|| 1345 endfunction
|| 1346
| 1347
| 1348
| 1349
|+ |- 1350 +--- 5 lines:
1350
|| 1351 let g:jm_vimrc.docs.commands['ReadExecute'] =
|| 1352 \ 'Execute then read the output of that vim command'
|| 1353 command! -nargs=* -complete=command ExecuteRead eval append(line('.'), execute(<q-args>)->split("\n"))
|| 1354
| 1355
| 1356
| 1357
|+ |- 1358 +--- 9 lines:
1358
|| 1359 let g:jm_vimrc.docs.commands['Bdz'] =
|| 1360 \ 'Run buildozer on current target (or :__pkg__ if none exists)'
|| 1361 command! -nargs=* Bdz echom
|| 1362 \ system(printf("fish -c \"buildozer '%s' %s\"",
|| 1363 \ join([<f-args>], ' '),
|| 1364 \ BlazeTarget() != '???' ? BlazeTarget() : ':__pkg__'
|| 1365 \ ))
|| 1366
| 1367
| 1368
| 1369 "format:`cmd`""format: END"
|+ |- 1370 +--- 38 lines:
1370
|| 1371 let g:jm_vimrc.docs.commands['JemFormat'] =
|| 1372 \ 'Format lines between "format:`cmd`" to "format: END"'
|| 1373 command! -nargs=* -complete=customlist,<SID>JemFormatComplete JemFormat eval s:JemFormat[<q-args>]()
|| 1374 let s:JemFormat = {
|| 1375 \ '' : {-> s:JemFormat.format()},
|| 1376 \ 'help' : {-> bss#PP(s:JemFormat, v:true)},
|| 1377 \ }
|| 1378 function! s:JemFormatComplete(arglead, cmdline, curpos) abort
|| 1379 return keys(s:JemFormat)->filter({k, v -> !stridx(v, a:arglead)})
|| 1380 endfunction
|| 1381
|| 1382 function! s:JemFormat.format() abort dict
|| 1383 let command = self.find()
|| 1384 if !empty(command)
|| 1385 silent execute command
|| 1386 endif
|| 1387 endfunction
|| 1388
|| 1389 function! s:JemFormat.find() abort dict
|| 1390 let [_, num, col; _] = getcurpos()
|| 1391 let start_pat = '\v.*for' .. 'mat: `([^`]+)`.*'
|| 1392 let end_pat = '\v.*for' .. 'mat: END.*'
|| 1393 let start_lines = matchbufline(bufnr(), start_pat, 1, num)
|| 1394 let start_line = bss#Last(start_lines)
|| 1395 let end_line = start_line
|| 1396 \->bss#Get('lnum')
|| 1397 \->bss#Apply({l -> matchbufline(bufnr(), end_pat, l, '$')})
|| 1398 \->bss#Apply('bss#Last')
|| 1399 \->bss#Or('$')
|| 1400 if start_line is v:none
|| 1401 return ''
|| 1402 endif
|| 1403 let range = [start_line.lnum + 1, end_line.lnum - 1]->join(',')
|| 1404 let command = substitute(start_line.text, start_pat, '\1', '')
|| 1405 return join([range, command], ' ')
|| 1406 endfunction
|| 1407
| 1408
| 1409
| 1410
| 1411
| 1412
| 1413
| 1414
| 1415
|+ |- 1416 +--- 50 lines:
1416
|| 1417 command! -nargs=1 -complete=file SetupAppendMarkdownBlock
|| 1418 \ nnoremap <buffer> \r :AppendMarkdownBlock <args><cr>
|| 1419 command! -nargs=1 -complete=file -range=% AppendMarkdownBlock
|| 1420 \ eval AppendMarkdownBlock(<q-args>, <line1>, <line2>)
|| 1421 command! -nargs=1 -complete=file AppendMarkdownBlockDebug
|| 1422 \ eval AppendMarkdownBlock(<q-args>, 0, '$', v:true)
|| 1423
|| 1424 function! AppendMarkdownBlock(fname, begin=0, end='$', debug=v:false) abort
|| 1425 let lines = getline(a:begin, a:end)->s:Markdown_lines2codeblock()
|| 1426 if !a:debug
|| 1427 call s:AppendMarkdownBlock_write(a:fname, lines)
|| 1428 else
|| 1429 call s:AppendMarkdownBlock_dump(a:fname, lines)
|| 1430 endif
|| 1431 endfunction
|| 1432
|| 1433
|| 1434
|| 1435
|| 1436 function! s:Markdown_lines2codeblock(lines) abort
|| 1437 let prefix = '```'
|| 1438 let suffix = prefix
|| 1439 return [prefix] + a:lines + [suffix]
|| 1440 endfunction
|| 1441
|| 1442
|| 1443
|| 1444
|| 1445
|| 1446 function! s:AppendMarkdownBlock_write(fname, lines) abort
|| 1447 let prefix = (readfile(a:fname)->bss#Last()->empty())
|| 1448 \ ? [] : [""]
|| 1449 call writefile(prefix + a:lines, a:fname, 'a')
|| 1450 echom "Wrote file" a:fname
|| 1451 endfunction
|| 1452
|| 1453
|| 1454
|| 1455
|| 1456 function! s:AppendMarkdownBlock_dump(fname, lines) abort
|| 1457
|| 1458 echo 'fname:' a:fname
|| 1459 echo 'lines:'
|| 1460 echo
|| 1461 for l in a:lines
|| 1462 echo ' ' .. l
|| 1463 endfor
|| 1464 endfunction
|| 1465
| 1466
| 1467
| 1468
|+ |- 1469 +--- 17 lines:
1469
|| 1470 command! -nargs=? -complete=customlist,s:SetupSlimeTarget_Complete SetupSlimeTarget call s:SetupSlimeTarget(<q-args>)
|| 1471 let s:SlimeTargets = [
|| 1472 \ 'tmux',
|| 1473 \ 'vimterminal',
|| 1474 \ ]
|| 1475 function! s:SetupSlimeTarget(arg) abort
|| 1476 if empty(a:arg)
|| 1477 echom printf('Current slime target: %s', g:slime_target)
|| 1478 else
|| 1479 let g:slime_target = a:arg
|| 1480 endif
|| 1481 endfunction
|| 1482 function! s:SetupSlimeTarget_Complete(arg, ...) abort
|| 1483 return s:SlimeTargets->filter('stridx(v:val, a:arg) == 0')
|| 1484 endfunction
|| 1485
| 1486
| 1487 function! Layout() abort
| 1488 let layout = winlayout()
| 1489 return s:InvertLayout(layout)
| 1490 endfunction
| 1491 function! s:InvertLayout(l, path=[]) abort
| 1492 if len(a:l) != 2
| 1493 throw "ERROR(InvalidArguments): s:InvertLayout expects only 2-element lists"
| 1494 endif
| 1495 let [kind, val] = a:l
| 1496 if kind ==# 'leaf'
| 1497 return {val: join(a:path, '')}
| 1498 elseif kind ==# 'col'
| 1499 return val
| 1500 \->map('s:InvertLayout(v:val, a:path + ["|"])')
| 1501 \->reduce({a, b -> extend(a, b)})
| 1502 elseif kind ==# 'row'
| 1503 return val
| 1504 \->map('s:InvertLayout(v:val, a:path + ["-"])')
| 1505 \->reduce({a, b -> extend(a, b)})
| 1506 endif
| 1507 endfunction
| 1508
| 1509
1510
+ - 1511 +-- 5 lines: Notes
1511
| 1512 let s:Wtf = bss#wtf#Initialize()
| 1513 call bss#wtf#AddDict(['mappings', 'm'], g:jm_vimrc.docs.mappings)
| 1514 call bss#wtf#AddDict(['commands', 'c'], g:jm_vimrc.docs.commands)
| 1515
1516
1517
1518
1519
1520 TODO
+ - 1521 +--243 lines: Java Import Cache:
1521
| 1522 let g:jm_vimrc.java_import_list =<< JAVA_IMPORT_LIST_END
| 1523 com.google.auto.common.AnnotationMirrors
| 1524 com.google.auto.common.AnnotationValues
| 1525 com.google.auto.common.BasicAnnotationProcessor
| 1526 com.google.auto.common.MoreElements
| 1527 com.google.auto.common.MoreTypes
| 1528 com.google.common.base.Stopwatch
| 1529 com.google.common.collect.ImmutableList
| 1530 com.google.common.collect.ImmutableMap
| 1531 com.google.common.collect.ImmutableSet
| 1532 com.google.common.collect.ImmutableTable
| 1533 com.google.common.collect.Lists
| 1534 com.google.common.collect.Streams
| 1535 com.google.common.collect.Table
| 1536 com.google.common.collect.Tables
| 1537 com.google.common.math.Stats
| 1538 com.google.common.math.StatsAccumulator
| 1539 com.google.common.util.concurrent.Futures
| 1540 com.google.common.util.concurrent.ListenableFuture
| 1541 com.google.common.util.concurrent.MoreExecutors
| 1542 com.google.common.util.concurrent.SettableFuture
| 1543 com.squareup.javapoet.ClassName
| 1544 com.squareup.javapoet.CodeBlock
| 1545 com.squareup.javapoet.FieldSpec
| 1546 com.squareup.javapoet.JavaFile
| 1547 com.squareup.javapoet.MethodSpec
| 1548 com.squareup.javapoet.ParameterSpec
| 1549 com.squareup.javapoet.ParameterizedTypeName
| 1550 com.squareup.javapoet.TypeName
| 1551 com.squareup.javapoet.TypeSpec
| 1552 dagger.Binds
| 1553 dagger.BindsInstance
| 1554 dagger.Component
| 1555 dagger.MapKey
| 1556 dagger.Module
| 1557 dagger.Provides
| 1558 dagger.multibindings.ClassKey
| 1559 dagger.multibindings.ElementsIntoSet
| 1560 dagger.multibindings.IntKey
| 1561 dagger.multibindings.IntoMap
| 1562 dagger.multibindings.IntoSet
| 1563 dagger.multibindings.LongKey
| 1564 dagger.multibindings.Multibinds
| 1565 dagger.multibindings.StringKey
| 1566 dagger.producers.Produced
| 1567 dagger.producers.Producer
| 1568 dagger.producers.ProducerModule
| 1569 dagger.producers.Producers
| 1570 dagger.producers.Produces
| 1571 dagger.producers.Production
| 1572 dagger.producers.ProductionComponent
| 1573 dagger.producers.ProductionScope
| 1574 dagger.producers.ProductionSubcomponent
| 1575 dagger.producers.monitoring.ProducerMonitor
| 1576 dagger.producers.monitoring.ProducerToken
| 1577 dagger.producers.monitoring.ProductionComponentMonitor
| 1578 java.io.IOException
| 1579 java.lang.reflect.AnnotatedElement
| 1580 java.lang.reflect.Executable
| 1581 java.lang.reflect.Field
| 1582 java.lang.reflect.GenericDeclaration
| 1583 java.lang.reflect.Method
| 1584 java.lang.reflect.Modifier
| 1585 java.lang.reflect.Type
| 1586 java.nio.file.Files
| 1587 java.nio.file.Path
| 1588 java.util.ArrayList
| 1589 java.util.Arrays
| 1590 java.util.Collection
| 1591 java.util.HashMap
| 1592 java.util.HashSet
| 1593 java.util.Iterator
| 1594 java.util.LinkedList
| 1595 java.util.List
| 1596 java.util.Map
| 1597 java.util.NavigableMap
| 1598 java.util.Optional
| 1599 java.util.OrderedMap
| 1600 java.util.Set
| 1601 java.util.TreeMap
| 1602 java.util.TreeSet
| 1603 java.util.concurrent.ConcurrentHashMap
| 1604 java.util.concurrent.CopyOnWriteArrayList
| 1605 java.util.concurrent.ExecutionException
| 1606 java.util.concurrent.Executor
| 1607 java.util.concurrent.ExecutorService
| 1608 java.util.concurrent.Executors
| 1609 java.util.concurrent.Future
| 1610 java.util.concurrent.ThreadPoolExecutor
| 1611 java.util.concurrent.TimeUnit
| 1612 java.util.concurrent.atomic.AtomicInteger
| 1613 java.util.concurrent.atomic.AtomicLong
| 1614 java.util.concurrent.atomic.LongAdder
| 1615 java.util.function.Consumer
| 1616 java.util.function.Function
| 1617 java.util.function.Predicate
| 1618 java.util.function.Supplier
| 1619 java.util.stream.Collector
| 1620 java.util.stream.Collectors
| 1621 java.util.stream.Stream
| 1622 javax.annotation.processing.AbstractProcessor
| 1623 javax.annotation.processing.Completion
| 1624 javax.annotation.processing.Completions
| 1625 javax.annotation.processing.Filer
| 1626 javax.annotation.processing.FilerException
| 1627 javax.annotation.processing.Generated
| 1628 javax.annotation.processing.Messager
| 1629 javax.annotation.processing.ProcessingEnvironment
| 1630 javax.annotation.processing.Processor
| 1631 javax.annotation.processing.RoundEnvironment
| 1632 javax.annotation.processing.SupportedAnnotationTypes
| 1633 javax.annotation.processing.SupportedOptions
| 1634 javax.annotation.processing.SupportedSourceVersion
| 1635 javax.inject.Inject
| 1636 javax.inject.Named
| 1637 javax.inject.Provider
| 1638 javax.inject.Qualifier
| 1639 javax.inject.Singleton
| 1640 javax.lang.model.element.Element
| 1641 javax.lang.model.element.ElementVisitor
| 1642 javax.lang.model.element.ExecutableElement
| 1643 javax.lang.model.element.Modifier
| 1644 javax.lang.model.element.TypeElement
| 1645 javax.lang.model.type.TypeMirror
| 1646 org.apache.commons.lang3.builder.ReflectionToStringBuilder
| 1647 org.apache.commons.lang3.builder.ToStringStyle
| 1648 org.objectweb.asm.ClassReader
| 1649 org.objectweb.asm.ClassVisitor
| 1650 org.objectweb.asm.ClassWriter
| 1651 org.objectweb.asm.FieldVisitor
| 1652 org.objectweb.asm.MethodVisitor
| 1653 org.objectweb.asm.Opcodes
| 1654 org.objectweb.asm.TypePath
| 1655 org.openjdk.jmh.annotations.AuxCounters
| 1656 org.openjdk.jmh.annotations.Benchmark
| 1657 org.openjdk.jmh.annotations.BenchmarkMode
| 1658 org.openjdk.jmh.annotations.CompilerControl
| 1659 org.openjdk.jmh.annotations.Fork
| 1660 org.openjdk.jmh.annotations.Group
| 1661 org.openjdk.jmh.annotations.GroupThreads
| 1662 org.openjdk.jmh.annotations.Level
| 1663 org.openjdk.jmh.annotations.Measurement
| 1664 org.openjdk.jmh.annotations.Mode
| 1665 org.openjdk.jmh.annotations.OperationsPerInvocation
| 1666 org.openjdk.jmh.annotations.OutputTimeUnit
| 1667 org.openjdk.jmh.annotations.Param
| 1668 org.openjdk.jmh.annotations.Scope
| 1669 org.openjdk.jmh.annotations.Setup
| 1670 org.openjdk.jmh.annotations.State
| 1671 org.openjdk.jmh.annotations.TearDown
| 1672 org.openjdk.jmh.annotations.Threads
| 1673 org.openjdk.jmh.annotations.Timeout
| 1674 org.openjdk.jmh.annotations.Warmup
| 1675 org.openjdk.jmh.infra.BenchmarkParams
| 1676 org.openjdk.jmh.infra.Blackhole
| 1677 org.openjdk.jmh.infra.Control
| 1678 org.openjdk.jmh.infra.IterationParams
| 1679 org.openjdk.jmh.infra.ThreadParams
| 1680 org.openjdk.jmh.results.RunResult
| 1681 org.openjdk.jmh.results.format.ResultFormatType
| 1682 org.openjdk.jmh.runner.Runner
| 1683 org.openjdk.jmh.runner.RunnerException
| 1684 org.openjdk.jmh.runner.options.CommandLineOptionException
| 1685 org.openjdk.jmh.runner.options.CommandLineOptions
| 1686 org.openjdk.jmh.runner.options.Options
| 1687 org.openjdk.jmh.runner.options.OptionsBuilder
| 1688 static com.google.common.collect.ImmutableList.toImmutableList
| 1689 static com.google.common.collect.ImmutableSet.toImmutableSet
| 1690 static com.google.common.truth.Truth.assertThat
| 1691 static com.google.common.truth.Truth.assertWithMessage
| 1692 static com.google.common.util.concurrent.MoreExecutors.directExecutor
| 1693 static java.util.concurrent.TimeUnit.DAYS
| 1694 static java.util.concurrent.TimeUnit.HOURS
| 1695 static java.util.concurrent.TimeUnit.MICROSECONDS
| 1696 static java.util.concurrent.TimeUnit.MILLISECONDS
| 1697 static java.util.concurrent.TimeUnit.MINUTES
| 1698 static java.util.concurrent.TimeUnit.NANOSECONDS
| 1699 static java.util.concurrent.TimeUnit.SECONDS
| 1700 static java.util.stream.Collectors.averagingDouble
| 1701 static java.util.stream.Collectors.averagingInt
| 1702 static java.util.stream.Collectors.averagingLong
| 1703 static java.util.stream.Collectors.collectingAndThen
| 1704 static java.util.stream.Collectors.counting
| 1705 static java.util.stream.Collectors.filtering
| 1706 static java.util.stream.Collectors.flatMapping
| 1707 static java.util.stream.Collectors.groupingBy
| 1708 static java.util.stream.Collectors.joining
| 1709 static java.util.stream.Collectors.mapping
| 1710 static java.util.stream.Collectors.maxBy
| 1711 static java.util.stream.Collectors.minBy
| 1712 static java.util.stream.Collectors.partitioningBy
| 1713 static java.util.stream.Collectors.reducing
| 1714 static java.util.stream.Collectors.summarizingDouble
| 1715 static java.util.stream.Collectors.summarizingInt
| 1716 static java.util.stream.Collectors.summarizingLong
| 1717 static java.util.stream.Collectors.summingDouble
| 1718 static java.util.stream.Collectors.summingInt
| 1719 static java.util.stream.Collectors.summingLong
| 1720 static java.util.stream.Collectors.toCollection
| 1721 static java.util.stream.Collectors.toConcurrentMap
| 1722 static java.util.stream.Collectors.toList
| 1723 static java.util.stream.Collectors.toMap
| 1724 static java.util.stream.Collectors.toSet
| 1725 static java.util.stream.Collectors.toUnmodifiableList
| 1726 static java.util.stream.Collectors.toUnmodifiableMap
| 1727 static java.util.stream.Collectors.toUnmodifiableSet
| 1728 JAVA_IMPORT_LIST_END
| 1729
| 1730 command! AddJavaImport call AddJavaImport(getline('.'))
| 1731 function! AddJavaImport(content) abort
| 1732 let content = a:content
| 1733 \->substitute('^import ', '', '')
| 1734 \->substitute(';$', '', '')
| 1735 if index(g:jm_vimrc.java_import_list, content)
| 1736 echom "Already present:" content
| 1737 return
| 1738 endif
| 1739 let lines = readfile($MYVIMRC)
| 1740 let index = match(lines, '^JAVA_IMPORT_LIST_END$')
| 1741 call insert(lines, content, index)
| 1742 call writefile(lines, $MYVIMRC)
| 1743 execute 'source' $MYVIMRC
| 1744 echom "Added:" content
| 1745 endfunction
| 1746
| 1747 function! s:ProcessJavaImportList(import_list) abort
| 1748 let cache = {}
| 1749 for elem in a:import_list
| 1750 let name = slice(elem, strridx(elem, '.') + 1)
| 1751 if has_key(cache, name)
| 1752 call add(cache[name], elem)
| 1753 else
| 1754 let cache[name] = [elem]
| 1755 endif
| 1756 endfor
| 1757 return cache
| 1758 endfunction
| 1759
| 1760 let g:jm_vimrc.java_import_cache =
| 1761 \ s:ProcessJavaImportList(g:jm_vimrc.java_import_list)
| 1762
| 1763
1764
1765
+ - 1766 +--193 lines: C++ Import Cache:
1766
| 1767 let g:jm_vimrc.cc_import_cache = {
| 1768 \ '"absl/flags/flag.h"': ['ABSL_FLAG', 'GetFlag'],
| 1769 \ '"absl/flags/declare.h"': ['ABSL_DECLARE_FLAG'],
| 1770 \ '"absl/flags/parse.h"': ['ParseCommandLine'],
| 1771 \ '"absl/flags/usage.h"': ['ProgramUsageMessage', 'SetProgramUsageMessage'],
| 1772 \ '"absl/strings/str_join.h"': ['StrJoin'],
| 1773 \ '"absl/strings/str_cat.h"': ['StrCat'],
| 1774 \ '"absl/strings/str_replace.h"': ['StrReplaceAll'],
| 1775 \ '"absl/strings/str_split.h"': ['StrSplit'],
| 1776 \ '"absl/status/status.h"': ['Status'],
| 1777 \ '"absl/status/statusor.h"': ['StatusOr'],
| 1778 \ '<opencv2/core.hpp>': [
| 1779 \ 'Mat',
| 1780 \ 'Mat_',
| 1781 \ 'Mat1b', 'Mat2b', 'Mat3b', 'Mat4b',
| 1782 \ 'Mat1i', 'Mat2i', 'Mat3i', 'Mat4i',
| 1783 \ 'Mat1f', 'Mat2f', 'Mat3f', 'Mat4f',
| 1784 \ 'Mat1d', 'Mat2d', 'Mat3d', 'Mat4d',
| 1785 \ 'Matx',
| 1786 \ 'Matx22f', 'Matx33f', 'Matx44f',
| 1787 \ 'Matx21f', 'Matx31f', 'Matx41f',
| 1788 \ 'Matx22d', 'Matx33d', 'Matx44d',
| 1789 \ 'Matx21d', 'Matx31d', 'Matx41d',
| 1790 \ 'Vec',
| 1791 \ 'Vec1b', 'Vec2b', 'Vec3b', 'Vec4b', 'Vec6b',
| 1792 \ 'Vec1i', 'Vec2i', 'Vec3i', 'Vec4i', 'Vec6i',
| 1793 \ 'Vec1f', 'Vec2f', 'Vec3f', 'Vec4f', 'Vec6f',
| 1794 \ 'Vec1d', 'Vec2d', 'Vec3d', 'Vec4d', 'Vec6d',
| 1795 \ 'Scalar_', 'Scalar',
| 1796 \ 'Point_', 'Point2i', 'Point2l', 'Point2f', 'Point2d',
| 1797 \ 'Point3_', 'Point3i', 'Point3l', 'Point3f', 'Point3d',
| 1798 \ 'abs',
| 1799 \ 'exp', 'log',
| 1800 \ 'pow', 'sqrt',
| 1801 \ ],
| 1802 \ '<opencv2/imgcodecs.hpp>': ['imread', 'imwrite'],
| 1803 \ '<opencv2/imgproc.hpp>': ['circle'],
| 1804 \ '<utility>': [
| 1805 \ 'forward', 'declval',
| 1806 \ 'move', 'swap', 'exchange',
| 1807 \ 'integer_sequence', 'make_integer_sequence',
| 1808 \ 'index_sequence', 'make_index_sequence',
| 1809 \ 'pair', 'make_pair',
| 1810 \ ],
| 1811 \ '<memory>': ['unique_ptr', 'make_unique'],
| 1812 \ '<vector>': ['vector'],
| 1813 \ '<tuple>': [
| 1814 \ 'tuple',
| 1815 \ 'tuple_size',
| 1816 \ 'tuple_element',
| 1817 \ 'get',
| 1818 \ ],
| 1819 \ '<type_traits>': [
| 1820 \ 'enable_if', 'conditional',
| 1821 \ 'enable_if_t', 'conditional_t',
| 1822 \ 'integral_constant', 'bool_constant',
| 1823 \ 'true_type', 'false_type',
| 1824 \ 'conjunction', 'disjunction', 'negation',
| 1825 \ 'conjunction_v', 'disjunction_v', 'negation_v',
| 1826 \ 'is_same', 'is_base_of', 'is_convertible',
| 1827 \ 'is_same_v', 'is_base_of_v', 'is_convertible_v',
| 1828 \ ],
| 1829 \ '<array>': ['array'],
| 1830 \ '<valarray>': ['valarray'],
| 1831 \ '<cstddef>': [
| 1832 \ 'size_t', 'ptrdiff_t', 'nullptr_t',
| 1833 \ ],
| 1834 \ '<future>': [
| 1835 \ 'future', 'promise', 'async', 'launch',
| 1836 \ ],
| 1837 \ '<thread>': [
| 1838 \ 'thread', 'this_thread', 'yield', 'get_id', 'sleep_for',
| 1839 \ ],
| 1840 \ '<cstdint>': [
| 1841 \ 'int8_t', 'int16_t', 'int32_t', 'int64_t',
| 1842 \ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
| 1843 \ ],
| 1844 \ '<cmath>': [
| 1845 \ 'abs',
| 1846 \ 'exp', 'log', 'log2', 'log10',
| 1847 \ 'pow', 'sqrt', 'hypot',
| 1848 \ 'sin', 'cos', 'tan',
| 1849 \ 'asin', 'acos', 'atan',
| 1850 \ 'sinh', 'cosh', 'tanh',
| 1851 \ 'asinh', 'acosh', 'atanh',
| 1852 \ 'ceil', 'floor', 'trunc', 'round',
| 1853 \ ],
| 1854 \ '<string>': [
| 1855 \ 'string',
| 1856 \ 'to_string',
| 1857 \ 'stoi', 'stol', 'stoul', 'stoll', 'stoull',
| 1858 \ 'stof', 'stod', 'stold',
| 1859 \ ],
| 1860 \ '<map>': ['map'],
| 1861 \ '<unordered_map>': ['unordered_map'],
| 1862 \ '<set>': ['set'],
| 1863 \ '<iostream>': [
| 1864 \ 'cout', 'cin', 'cerr',
| 1865 \ 'endl',
| 1866 \ ],
| 1867 \ '<ios>': [
| 1868 \ 'internal', 'left', 'right',
| 1869 \ 'boolalpha', 'showbase', 'showpos',
| 1870 \ 'dec', 'hex', 'oct',
| 1871 \ 'fixed', 'scientific', 'default',
| 1872 \ ],
| 1873 \ '<format>': ['format'],
| 1874 \ '<iomanip>': [
| 1875 \ 'setw',
| 1876 \ 'quoted',
| 1877 \ ],
| 1878 \ '<unordered_set>': ['unordered_set'],
| 1879 \ '<optional>': ['optional'],
| 1880 \ '<complex>': ['complex'],
| 1881 \ '<initializer_list>': ['initializer_list'],
| 1882 \ '<numeric>': [
| 1883 \ 'iota',
| 1884 \ 'accumulate',
| 1885 \ 'reduce',
| 1886 \ 'inner_product',
| 1887 \ 'adjacent_difference',
| 1888 \ 'partial_sum',
| 1889 \ ],
| 1890 \ '<cstdlib>': [
| 1891 \ 'system',
| 1892 \ 'exit',
| 1893 \ 'getenv',
| 1894 \ 'malloc',
| 1895 \ 'free',
| 1896 \ 'aligned_malloc',
| 1897 \ ],
| 1898 \ '<random>': [
| 1899 \ 'random_device',
| 1900 \ 'mt19937',
| 1901 \ 'mt19937_64',
| 1902 \ 'uniform_real_distribution',
| 1903 \ 'uniform_int_distribution',
| 1904 \ 'normal_distribution',
| 1905 \ ],
| 1906 \ '<functional>': [
| 1907 \ 'function',
| 1908 \ 'plus', 'minus', 'multiplies', 'divides',
| 1909 \ 'equal_to', 'not_equal_to',
| 1910 \ 'greater', 'less', 'greater_equal', 'less_equal',
| 1911 \ 'logical_and', 'logical_or', 'logical_not',
| 1912 \ 'bit_end', 'bit_or', 'bit_xor', 'bit_not',
| 1913 \ ],
| 1914 \ '<algorithm>': [
| 1915 \
| 1916 \ 'all_of', 'any_of', 'none_of',
| 1917 \ 'for_each', 'for_each_n',
| 1918 \ 'count', 'count_if',
| 1919 \ 'mismatch',
| 1920 \ 'find', 'find_if', 'find_if_not',
| 1921 \ 'find_end', 'find_first_of', 'adjacent_find',
| 1922 \ 'search', 'search_n',
| 1923 \
| 1924 \ 'copy', 'copy_backward', 'move', 'move_backward', 'copy_n',
| 1925 \ 'fill', 'fill_n', 'transform', 'generate', 'generate_n',
| 1926 \ 'remove', 'remove_if', 'remove_copy', 'remove_copy_if',
| 1927 \ 'replace', 'replace_if', 'replace_copy', 'replace_copy_if',
| 1928 \ 'swap', 'swap_ranges', 'swap_iter',
| 1929 \ 'reverse', 'reverse_copy', 'rotate',
| 1930 \ 'rotate_copy',
| 1931 \ 'shuffle',
| 1932 \ 'max', 'min', 'max_element', 'min_element', 'minmax',
| 1933 \ ],
| 1934 \ '"absl/algorithm/container.h"': [
| 1935 \
| 1936 \ 'c_all_of', 'c_any_of', 'c_none_of',
| 1937 \ 'c_for_each', 'c_for_each_n',
| 1938 \ 'c_count', 'c_count_if',
| 1939 \ 'c_mismatch',
| 1940 \ 'c_find', 'c_find_if', 'c_find_if_not',
| 1941 \ 'c_find_end', 'c_find_first_of', 'c_adjacent_find',
| 1942 \ 'c_search', 'c_search_n',
| 1943 \
| 1944 \ 'c_copy', 'c_copy_backward', 'c_move', 'c_move_backward', 'c_copy_n',
| 1945 \ 'c_fill', 'c_fill_n', 'c_transform', 'c_generate', 'c_generate_n',
| 1946 \ 'c_remove', 'c_remove_if', 'c_remove_copy', 'c_remove_copy_if',
| 1947 \ 'c_replace', 'c_replace_if', 'c_replace_copy', 'c_replace_copy_if',
| 1948 \ 'c_swap', 'c_swap_ranges', 'c_swap_iter',
| 1949 \ 'c_reverse', 'c_reverse_copy', 'c_rotate',
| 1950 \ 'c_rotate_copy',
| 1951 \ 'c_shuffle',
| 1952 \ ],
| 1953 \ '<iterator>': [
| 1954 \ 'istream_iterator',
| 1955 \ 'ostream_iterator',
| 1956 \ ],
| 1957 \ }
| 1958